Jelajahi Sumber

接口调用

yuwenjun 4 tahun lalu
induk
melakukan
403ee735b9
1 mengubah file dengan 29 tambahan dan 17 penghapusan
  1. 29 17
      pages/index/index.vue

+ 29 - 17
pages/index/index.vue

@@ -63,7 +63,10 @@
 			</view>
 			<!-- 订单状态区域END -->
 			<!-- 帮机构下单 -->
-			<view class="place-order" @click="navigator(`/pages/user/club/club-list?id=${organizeId}`)">
+			<view
+				class="place-order"
+				@click="navigator(`/pages/user/club/club-list?id=${organizeId}`)"
+			>
 				<view class="place-left">
 					<text class="iconfont icon-bangjigouxiadan"></text>
 					<text class="title">帮机构下单</text>
@@ -109,14 +112,14 @@ export default {
 			waitShipmentsCount: 0, //待收货角标
 			shipmentsCount: 0, //已发货角标
 			salesReturnCount: '', //退货/款角标
-			organizeId:''
+			organizeId: ''
 		}
 	},
 	onLoad() {
 		authorize.getSetting().then(res => {
 			//0:为取消授权 1:为已授权 2:为未操作
 			if (res == 1) {
-				this.getWxAuthorize()
+				this.GetWxAuthorize()
 			}
 		})
 	},
@@ -125,11 +128,8 @@ export default {
 	},
 	methods: {
 		...mapMutations(['login', 'logout']),
-		// 获取用户信息
-		async getWxAuthorize() {
-			// const wechatCode = await
+		async GetWxAuthorize() {
 			const wechatCode = await authorize.getCode('weixin')
-			// 初始化用户状态
 			this.UserService.userInfoLogin({ code: wechatCode })
 				.then(response => {
 					// 保存登录信息
@@ -147,6 +147,19 @@ export default {
 					})
 					this.logout()
 				})
+			this.UserService.userInfoLogin({ code: wechatCode })
+				.then(response => {
+					this.login(response.data)
+					this.$store.commit('updateStatus', response.data)
+					this.GetUserInfoPersonal(response.data.organizeId)
+				})
+				.catch(error => {
+					uni.setStorage({
+						//缓存游客用户openid
+						key: 'openid',
+						data: error.data.openid
+					})
+				})
 		},
 		getUserInfoPersonal(organizeId) {
 			//初始化个人中心数据
@@ -163,7 +176,6 @@ export default {
 					this.$util.msg(error.msg, 2000)
 				})
 		},
-		// 客服
 		handleContact(e) {
 			console.log(e.detail.path)
 			console.log(e.detail.query)
@@ -204,15 +216,15 @@ export default {
 				num = n
 			}
 			return num
-		}
-	},
-	onPullDownRefresh() {
-		//下拉刷新
-		if (this.hasLogin) {
-			this.getWxAuthorize()
-			uni.stopPullDownRefresh()
-		} else {
-			uni.stopPullDownRefresh()
+		},
+		onPullDownRefresh() {
+			//下拉刷新
+			if (this.hasLogin) {
+				this.GetWxAuthorize()
+				uni.stopPullDownRefresh()
+			} else {
+				uni.stopPullDownRefresh()
+			}
 		}
 	}
 }