瀏覽代碼

用户体系优化V1.0.0

zhengjinyi 5 年之前
父節點
當前提交
43dd5c392c
共有 5 個文件被更改,包括 94 次插入113 次删除
  1. 0 4
      api/use.js
  2. 2 2
      common/config/config.js
  3. 10 7
      common/css/common.scss
  4. 40 36
      pages/user-module/bindwechat.vue
  5. 42 64
      pages/user-module/login.vue

+ 0 - 4
api/use.js

@@ -221,10 +221,6 @@ export function bindingWechat(params) {
  */
  */
 export function invitationCodeLogin(params) {
 export function invitationCodeLogin(params) {
 	return new Promise(function(resolve,reject) {
 	return new Promise(function(resolve,reject) {
-		if( params.invitationCode == ''){
-			uni.showToast({title: '请输入邀请码',duration: 2000,mask:true, icon:'none'})
-			return
-		}
 		request.post('/club/invitationCode',params,true, res => {
 		request.post('/club/invitationCode',params,true, res => {
 			if(res.code == '0'){
 			if(res.code == '0'){
 				resolve(res)
 				resolve(res)

+ 2 - 2
common/config/config.js

@@ -1,9 +1,9 @@
 let URL_CONFIG = ""
 let URL_CONFIG = ""
 if(process.env.NODE_ENV === 'development'){
 if(process.env.NODE_ENV === 'development'){
     // 开发环境
     // 开发环境
-	URL_CONFIG = 'http://192.168.1.22:8008'//本地联调地址
+	// URL_CONFIG = 'http://192.168.1.22:8008'//本地联调地址
 	// URL_CONFIG = 'http://192.168.1.24:8107'//俊俊联调地址
 	// URL_CONFIG = 'http://192.168.1.24:8107'//俊俊联调地址
-    // URL_CONFIG = 'https://spi-b.caimei365.com'//测试地址
+    URL_CONFIG = 'https://spi-b.caimei365.com'//测试地址
 }else{
 }else{
     // 生产环境
     // 生产环境
     URL_CONFIG = 'https://spi.caimei365.com'
     URL_CONFIG = 'https://spi.caimei365.com'

+ 10 - 7
common/css/common.scss

@@ -127,7 +127,7 @@ button::after{
 	}
 	}
 	.model-alert{
 	.model-alert{
 		width: 518rpx;
 		width: 518rpx;
-		height: 316rpx;
+		height: 280rpx;
 		position: absolute;
 		position: absolute;
 		background: $bg-color;
 		background: $bg-color;
 		left: 0;
 		left: 0;
@@ -135,10 +135,11 @@ button::after{
 		bottom: 0;
 		bottom: 0;
 		top: 0;
 		top: 0;
 		margin: auto;
 		margin: auto;
+		border-radius: 20rpx;
 		.alert-content{
 		.alert-content{
 			width: 466rpx;
 			width: 466rpx;
-			height: 152rpx;
-			padding: 40rpx 26rpx;					
+			height: 100rpx;
+			padding: 40rpx 26rpx;
 			.t-h1,.t-p{
 			.t-h1,.t-p{
 				font-size: $font-size-28;
 				font-size: $font-size-28;
 				line-height: 40rpx;
 				line-height: 40rpx;
@@ -169,17 +170,19 @@ button::after{
 			}
 			}
 		}
 		}
 		.alert-btn{
 		.alert-btn{
-			width: 100%;
-			height: 88rpx;
+			width: 80%;
+			height: 70rpx;
 			display: flex;
 			display: flex;
+			margin: 0 auto;
 			.btn{
 			.btn{
 				flex: 1;
 				flex: 1;
-				line-height: 88rpx;
+				line-height: 70rpx;
 				font-size: $font-size-28;
 				font-size: $font-size-28;
 				text-align: center;
 				text-align: center;
 				color: #FFFFFF;
 				color: #FFFFFF;
-				border-radius: 14rpx;
+				border-radius: 10rpx;
 				padding: 0;
 				padding: 0;
+				margin: 0 15rpx;
 				&.btn-cancel{
 				&.btn-cancel{
 					background: $btn-cancel;
 					background: $btn-cancel;
 				}
 				}

+ 40 - 36
pages/user-module/bindwechat.vue

@@ -62,7 +62,7 @@
 			<view class="login-btn"  @click="bindWechatInfo">绑定</view>
 			<view class="login-btn"  @click="bindWechatInfo">绑定</view>
 		</view>
 		</view>
 		<!-- 授权按钮 -->
 		<!-- 授权按钮 -->
-		<view class="model-warp" :class="[isUserInfo===false ? 'none':'show']">
+		<view class="model-warp" :class="[isUserInfo ? 'show':'none']">
 			<view class="model-alert">
 			<view class="model-alert">
 				<view class="alert-content">
 				<view class="alert-content">
 					<view class="t-p">采美采购商城需要获取您的微信授权才能正常提供服务</view>
 					<view class="t-p">采美采购商城需要获取您的微信授权才能正常提供服务</view>
@@ -81,7 +81,6 @@
 	import authorize from '@/common/config/authorize.js' 
 	import authorize from '@/common/config/authorize.js' 
 	import { bindingWechat } from "@/api/use.js"
 	import { bindingWechat } from "@/api/use.js"
 	import { getImageCode, getbindWechatCode } from "@/api/utils.js"
 	import { getImageCode, getbindWechatCode } from "@/api/utils.js"
-	var self;
 	export default{
 	export default{
 		data() {
 		data() {
 			return{
 			return{
@@ -94,7 +93,7 @@
 				imageCodeUrl:'',		//图形验证码地址
 				imageCodeUrl:'',		//图形验证码地址
 				imageCodetoken:'',		//图形校验token
 				imageCodetoken:'',		//图形校验token
 				isMobileDisabled:false, //获取手机短信按钮
 				isMobileDisabled:false, //获取手机短信按钮
-				isUserInfo:false,	//控制显示授权弹窗
+				isUserInfo:false,		//控制显示授权弹窗
 				count: '',				//倒计时
 				count: '',				//倒计时
 				mobileCodeText: '获取验证码',
 				mobileCodeText: '获取验证码',
 				codeTime: null,
 				codeTime: null,
@@ -123,23 +122,23 @@
 			...mapMutations(['login']),
 			...mapMutations(['login']),
 			bindWechatInfo(){
 			bindWechatInfo(){
 				if( this.bindLinkName == ''){
 				if( this.bindLinkName == ''){
-					uni.showToast({title: '请输入姓名',duration: 2000,mask:true, icon:'none'})
+					this.$util.msg('请输入姓名',2000)
 					return
 					return
 				}
 				}
 				if( this.bindLinkPhone == ''){
 				if( this.bindLinkPhone == ''){
-					uni.showToast({title: '请输入手机号',duration: 2000,mask:true,icon:'none'})
+					this.$util.msg('请输入手机号',2000)
 					return
 					return
 				}
 				}
-				if(this.$reg.isMobile(this.bindLinkPhone)){
-					uni.showToast({title: '请输入正确的手机号',duration: 2000,mask:true,icon:'none'})
+				if(!this.$reg.isMobile(this.bindLinkPhone)){
+					this.$util.msg('请输入正确的手机号',2000)
 					return
 					return
 				}
 				}
 				if( this.mobildeCode == ''){
 				if( this.mobildeCode == ''){
-					uni.showToast({title: '请输入手机验证码',duration: 2000,mask:true,icon:'none'})
+					this.$util.msg('请输入手机验证码',2000)
 					return
 					return
 				}
 				}
-				if(this.$reg.isMobileCode(this.mobildeCode)){
-					uni.showToast({title: '验证码格式不正确',duration: 2000,mask:true,icon:'none'})
+				if(!this.$reg.isMobileCode(this.mobildeCode)){
+					this.$util.msg('验证码格式不正确',2000)
 					return
 					return
 				}
 				}
 				//查看此微信用户是否已经授权过
 				//查看此微信用户是否已经授权过
@@ -189,31 +188,9 @@
 					this.$util.msg(res.msg,2000)
 					this.$util.msg(res.msg,2000)
 				})
 				})
 			},
 			},
-			goUserLogininit(){
-				let url;
-				if(this.loginType) {
-					if(this.loginType=='detilType'){
-						this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
-					}else if(this.loginType=='search'){
-						this.$api.redirectTo('/pages/search/search');
-					}else if(this.loginType == 1){
-						url ='/pages/tabBar/cart/cart'
-					}else if(this.loginType == 4){
-						url ='/pages/tabBar/user/user'
-					}else {
-						url ='/pages/tabBar/home/home'
-					}
-					uni.switchTab({
-						url
-					})
-				} else if(this.listType) {
-					this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
-				}
-			},
-			//授权登录
-			getuserinfo: function (e) {
+			getuserinfo: function (e) {//微信授权登录
 			    if (e.detail.userInfo) {
 			    if (e.detail.userInfo) {
-					self.wxGetUserInfo()
+					this.wxGetUserInfo()
 			    }else{
 			    }else{
 					//用户按了拒绝按钮
 					//用户按了拒绝按钮
 					uni.showModal({
 					uni.showModal({
@@ -236,10 +213,11 @@
 			    }
 			    }
 			 },
 			 },
 			wxGetUserInfo(){
 			wxGetUserInfo(){
+				let self = this
 				authorize.getCode('weixin').then(wechatcode =>{
 				authorize.getCode('weixin').then(wechatcode =>{
 					wx.getUserInfo({
 					wx.getUserInfo({
 						success: res => {
 						success: res => {
-							// console.log('useInfo:',res.userInfo)
+							console.log('useInfo:',res.userInfo)
 							self.userInfo = res.userInfo;
 							self.userInfo = res.userInfo;
 							let params ={
 							let params ={
 									userID:this.userID,
 									userID:this.userID,
@@ -247,9 +225,10 @@
 									linkName:this.bindLinkName,
 									linkName:this.bindLinkName,
 									verificationCode:this.mobildeCode,
 									verificationCode:this.mobildeCode,
 									nickName:res.userInfo.nickName,
 									nickName:res.userInfo.nickName,
-									headimgurl:res.userInfo.headimgurl,
+									headimgurl:res.userInfo.avatarUrl,
 							}
 							}
 							bindingWechat(params).then(res =>{
 							bindingWechat(params).then(res =>{
+								this.isUserInfo = false;
 								this.goUserLogininit()
 								this.goUserLogininit()
 							}).catch(res =>{
 							}).catch(res =>{
 								this.$util.msg(res.msg,2000)
 								this.$util.msg(res.msg,2000)
@@ -257,6 +236,31 @@
 						}
 						}
 					});	
 					});	
 				})
 				})
+			},
+			goUserLogininit(){
+				let url;
+				if(this.loginType) {
+					if(this.loginType=='detilType'){
+						this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
+					}else if(this.loginType=='search'){
+						this.$api.redirectTo('/pages/search/search');
+					}else if(this.loginType == 1){
+						url ='/pages/tabBar/cart/cart'
+					}else if(this.loginType == 4){
+						url ='/pages/tabBar/user/user'
+					}else {
+						url ='/pages/tabBar/home/home'
+					}
+					uni.switchTab({
+						url
+					})
+				} else if(this.listType) {
+					this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
+				}
+			},
+			//关闭未授权用户授权提示弹窗
+			hideModel(){
+				this.isUserInfo = false;
 			}
 			}
 		},
 		},
 		onShow() {
 		onShow() {

+ 42 - 64
pages/user-module/login.vue

@@ -76,34 +76,20 @@
 		methods:{
 		methods:{
 			...mapMutations(['login']),
 			...mapMutations(['login']),
 			goLogin() {
 			goLogin() {
-				invitationCodeLogin({invitationCode:this.invitationCode}).then(response =>{
-					//查看此微信用户是否已经授权过
-					authorize.getSetting().then(res =>{
-						// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
-						if(res == 2){
-							this.isUserInfo = true
-						}else{
-							this.isUserInfo = false
-							this.wxGetUserInfo()
-						}
-					})
-				}).catch(response =>{
-					if(res.code =='-2'){
-						this.toestText ='邀请码已失效';
-						this.alertText ='新邀请码';
-						this.telPhone = res.msg;
-						this.isToast = true;
-					}else if(res.code =='-3'){
-						this.toestText ='邀请码已被使用';
-						this.alertText ='新邀请码';
-						this.telPhone = res.msg;
-						this.isToast = true;
+				if( this.invitationCode == ''){
+					this.$util.msg('请输入邀请码',2000)
+					return
+				}
+				//查看此微信用户是否已经授权过
+				authorize.getSetting().then(res =>{
+					// console.log('是否已授权',res);//0:为取消授权 1:为已授权 2:为未操作
+					if(res == 2){
+						this.isUserInfo = true
 					}else{
 					}else{
-						this.$util.msg(response.msg,2000)
 						this.isUserInfo = false
 						this.isUserInfo = false
+						this.wxGetUserInfo()
 					}
 					}
-				})
-				
+				})				
 			},
 			},
 			//授权登录 
 			//授权登录 
 			getuserinfo: function (e) {
 			getuserinfo: function (e) {
@@ -137,51 +123,43 @@
 							// console.log('useInfo:',res.userInfo)
 							// console.log('useInfo:',res.userInfo)
 							self.userInfo = res.userInfo;
 							self.userInfo = res.userInfo;
 							let params ={
 							let params ={
-									code:wechatcode,
+									userID:this.userID,
+									invitationCode:this.invitationCode,
 									nickName:res.userInfo.nickName,
 									nickName:res.userInfo.nickName,
-									invitationCode:self.invitationCode,
-									userOrganizeID:self.userOrganizeID,
-								}
-							self.goUserLogininit(params);
+									headimgurl:res.userInfo.avatarUrl,
+							}							
+							invitationCodeLogin(params).then(response =>{
+								self.isUserInfo = false
+								this.goUserLogininit()
+							}).catch(response =>{
+								this.$util.msg(response.msg,2000)
+								this.isUserInfo = false
+							})
+							
 						}
 						}
 					});	
 					});	
 				})
 				})
 			},
 			},
-			goUserLogininit(params){
-				self.$api.lodingGet('/login/register',params, response => {
-					// console.log(response)
-					if (response.code == "1") {
-						self.isUserInfo = false;
-						self.login(self.userInfo);
-						let user_key = {code:response.code,openid:response.data.openid,userID:response.data.userID}
-						uni.setStorageSync('cookieKey','JSESSIONID='+response.data.sessionId);
-						this.$store.commit('updateStatus',user_key)
-						let url;
-						uni.switchTab({
-							url:'/pages/tabBar/user/user'
-						})
-						// if(self.loginType) {
-						// 	if(self.loginType=='detilType'){
-						// 		self.$api.redirectTo(`/pages/goods/product?id=${self.id}&page=2`);
-						// 	}else if(self.loginType=='search'){
-						// 		self.$api.redirectTo('/pages/search/search');
-						// 	}else if(self.loginType == 1){
-						// 		url ='/pages/tabBar/cart/cart'
-						// 	}else if(self.loginType == 2){
-						// 		url ='/pages/tabBar/user/user'
-						// 	}else {
-						// 		url ='/pages/tabBar/home/home'
-						// 	}
-						// 	uni.switchTab({
-						// 		url
-						// 	})
-						// } else if(self.listType) {
-						// 	self.$api.navToListPage({type:self.listType,value:self.listVal,lType:'4'});
-						// }
-					} else {
-						this.$util.msg(response.msg,3000);
+			goUserLogininit(){
+				let url;
+				if(this.loginType) {
+					if(this.loginType=='detilType'){
+						this.$api.redirectTo(`/pages/goods/product?id=${this.id}&page=2`);
+					}else if(this.loginType=='search'){
+						this.$api.redirectTo('/pages/search/search');
+					}else if(this.loginType == 1){
+						url ='/pages/tabBar/cart/cart'
+					}else if(this.loginType == 4){
+						url ='/pages/tabBar/user/user'
+					}else {
+						url ='/pages/tabBar/home/home'
 					}
 					}
-				})
+					uni.switchTab({
+						url
+					})
+				} else if(this.listType) {
+					this.$api.navToListPage({type:this.listType,value:this.listVal,lType:'4'});
+				}
 			},
 			},
 			//关闭未填邀请码弹窗
 			//关闭未填邀请码弹窗
 			hideToast(){
 			hideToast(){