Browse Source

Signed-off-by: 1004749546@qq.com <1004749546@qq.com>
登录修改

1004749546@qq.com 5 years ago
parent
commit
755563290f
3 changed files with 54 additions and 36 deletions
  1. 46 34
      pages/login/login.vue
  2. 4 1
      pages/order/order.vue
  3. 4 1
      pages/store/storeList.vue

+ 46 - 34
pages/login/login.vue

@@ -22,7 +22,8 @@
 		data() {
 			return {
 				path: '/pages/index/index',
-				lanuch: true
+				lanuch: true,
+				code: ''
 			}
 		},
 		onShow() {
@@ -30,7 +31,8 @@
 		},
 		mounted() {},
 		onLoad(option) {
-			console.log(option)
+			// 为解决首次登录异常问题 进入页面先调微信登录获取code
+			this.wxLogin()
 			const {
 				path,
 				lanuch
@@ -39,7 +41,7 @@
 			if (path) {
 				this.path = decodeURIComponent(path);
 			}
-			console.log(this.path,this.lanuch,'111111111')
+			
 		},
 		methods: {
 			getPhoneNumber(e) {
@@ -48,41 +50,40 @@
 					mask: true,
 					title: '加载中'
 				});
+				if (!this.code) {
+					this.wxLogin()
+				} 
 				console.log(e.target.encryptedData,'eeeeeee')
 				if (e.target.errMsg === 'getPhoneNumber:ok') {
-					uni.login({
-						provider: 'weixin',
-						success(res) {
-							login({
-								code: res.code,
-								encryptedData: e.target.encryptedData,
-								iv: e.target.iv
-							}).then(res => {
-								uni.hideLoading();
-								console.log(res, 'login data')
-								if (res.status == '200') {
-									console.log(res.data, 'login data')
-									getApp().globalData.token = res.data
-									_this.$u.vuex('vuex_token',res.data)
-									if (_this.path === '/pages/index/index' || _this.lanuch) {
-										uni.reLaunch({
-											url: _this.path
-										});
-									} else {
-										uni.redirectTo({
-											url: _this.path
-										});
-									}
-								} else {
-									uni.showToast({
-										title: res.message,
-										icon: 'none',
-										duration: 2500
-									});
-								}
+					login({
+						code: _this.code,
+						encryptedData: e.target.encryptedData,
+						iv: e.target.iv
+					}).then(res => {
+						uni.hideLoading();
+						_this.code = ''
+						console.log(res, 'login data')
+						if (res.status == '200') {
+							getApp().globalData.token = res.data
+							_this.$u.vuex('vuex_token',res.data)
+							if (_this.path === '/pages/index/index' || _this.lanuch) {
+								uni.reLaunch({
+									url: _this.path
+								});
+							} else {
+								uni.redirectTo({
+									url: _this.path
+								});
+							}
+						} else {
+							uni.showToast({
+								title: res.message,
+								icon: 'none',
+								duration: 2500
 							});
 						}
-					})
+					});
+					
 				} else {
 					uni.showToast({
 						title: '授权失败',
@@ -91,6 +92,17 @@
 					});
 				}
 			},
+			// 调微信登录 获取code
+			wxLogin () {
+				let _this = this
+				uni.login({
+					provider: 'weixin',
+					success(res) {
+						_this.code = res.code
+					}
+				})
+				console.log(this.code,'1111111111')
+			},
 			gotoHome () {
 			  wx.reLaunch({
 			    url: '/pages/index/index'

+ 4 - 1
pages/order/order.vue

@@ -34,7 +34,7 @@
 		data() {
 			return {
 				noDataText: '暂无数据',
-				status: 'loadmore',
+				status: 'loading',
 				list:[],
 				pageNo:1,
 				pageSize:15,
@@ -158,6 +158,9 @@
 					}
 				}
 			}
+			.u-empty.data-v-6938e513{
+				height: 90%;
+			}
 		}
 	}
 </style>

+ 4 - 1
pages/store/storeList.vue

@@ -45,7 +45,7 @@
 		data() {
 			return {
 				noDataText: '暂无数据',
-				status: 'loadmore',
+				status: 'loading',
 				storeList: [],
 				// 用户拒绝授权位置信息时默认展示青海西宁位置地图
 				currentPosition: {
@@ -196,6 +196,9 @@
 					align-items: center;
 				}
 			}
+			.u-empty.data-v-6938e513{
+				height: 90%;
+			}
 		}
 	}
 </style>