Browse Source

登录调试

lilei 4 years ago
parent
commit
40156b8c06
3 changed files with 28 additions and 22 deletions
  1. 1 1
      App.vue
  2. 1 1
      components/uni-popup/image-txt-popup.vue
  3. 26 20
      pages/login/phoneLogin.vue

+ 1 - 1
App.vue

@@ -1,6 +1,6 @@
 <script>
 	// const uat_URL = 'https://carwash.test.zyucgj.com/gc-shop/' // 预发布
-	const uat_URL = 'http://192.168.16.155:8302/gc-shop/' // 本地
+	const uat_URL = 'http://192.168.16.105:8302/gc-shop/' // 本地
 	const pro_URL = 'https://carwash.zyucgj.com/gc-shop/'  // 生产
 	const buildType = 0 // 打包环境对应类型,1 生产 0 预发布
 	const buildURL = buildType ? pro_URL : uat_URL // 打包后实际对应的url

+ 1 - 1
components/uni-popup/image-txt-popup.vue

@@ -38,7 +38,7 @@
 			}
 		},
 		created() {
-			// this.getCode()
+			this.getCode()
 		},
 		methods: {
 			//  获取验证码

+ 26 - 20
pages/login/phoneLogin.vue

@@ -17,7 +17,7 @@
 		</form>
 		<!-- 图文验证码 -->
 		<uni-popup ref="imageTxtPopup" type="center">
-			<popup-con title="图文验证码" :popBtn="popBtn" :changeImg="changeImg" @captchaImg="captchaImg"></popup-con>
+			<popup-con title="图文验证码" :popBtn="popBtn" :changeImg="changeImg" @captchaImg="captchaVerify"></popup-con>
 		</uni-popup>
 	</view>
 </template>
@@ -34,7 +34,6 @@
 		},
 		data(){
 			return{
-				state: 0,  //  忘记密码当前状态
 				form: {
 					phone: '',
 					verifyCode: '',
@@ -48,12 +47,10 @@
 				popBtn: [],  //  name为操作按钮名称,color为操作按钮颜色值
 				changeImg: false,  //  是否重新更换图形验证码
 				randomCode: '',  //  图片验证码随机码
+				wxcode: ''
 			}
 		},
 		onLoad(opts) {
-			if(opts.username){
-				this.form.phone = opts.username
-			}
 		},
 		methods: {
 			//   登录
@@ -74,15 +71,29 @@
 				}
 				// 校验短信验证码是否正确
 				const obj = {}
-				obj.phone = _this.form.phone,
-				obj.random = _this.randomCode,  // 当前随机码
-				obj.code = _this.form.verifyCode
-				loginPhone(obj).then(res => {
-				  if(res.status == 200){
-				    _this.state = 1
-				  }else{
-					  uni.showToast({icon: 'none',title: res.message})
-				  }
+				obj.phone = _this.form.phone
+				obj.random = _this.randomCode  // 当前随机码
+				obj.verifiCode = _this.form.verifyCode
+				
+				uni.login({
+					provider: 'weixin',
+					success(res) {
+						console.log(res)
+						_this.wxcode = res.code
+						obj.code = res.code
+						loginPhone(obj).then(res => {
+						  if(res.status == 200){
+							console.log(res,'login success')
+							getApp().globalData.token = res.data
+							_this.$u.vuex('vuex_token',res.data)
+						    uni.navigateBack({
+						    	delta: 2
+						    })
+						  }else{
+							  uni.showToast({icon: 'none',title: res.message})
+						  }
+						})
+					}
 				})
 			},
 			//  获取验证码
@@ -94,7 +105,6 @@
 					}else{
 						//  图文验证码
 						this.$refs.imageTxtPopup.open()
-						this.changeImg = true
 					}
 				}else{
 					uni.showToast({icon: 'none',title: '请先输入手机号'})
@@ -119,17 +129,13 @@
 				  }, 1000)
 				}
 			},
-			//  图文验证码
-			captchaImg(code, nowRandomCode){
-				this.captchaVerify(code, nowRandomCode)
-			},
 			//  验证图片验证码
 			captchaVerify(code, nowRandomCode){
 				const _this = this
 				let obj = {}
 				obj.phone = this.form.phone
 				obj.random = nowRandomCode
-				obj.verifiCode = code
+				obj.code = code
 				//  短信验证码
 				sendVerifyCode(obj).then(res => {
 					console.log(JSON.stringify(res))