Browse Source

commit -m 授权登录

zhengjinyi 4 năm trước cách đây
mục cha
commit
963bf078ab
2 tập tin đã thay đổi với 21 bổ sung5 xóa
  1. 12 5
      pages/index/index.vue
  2. 9 0
      services/user.service.js

+ 12 - 5
pages/index/index.vue

@@ -128,6 +128,17 @@ export default {
 			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
+				})
+				this.logout()
+			})
+		},
+		getUserInfoPersonal(organizeId){//初始化个人中心数据
+			this.UserService.userInfoPersonal({organizeId:organizeId}).then(response=>{
 				this.organizeName = response.data.organizeName
 				this.paymentCount = this.showBadge(response.data.paymentCount) //待付款
 				this.waitShipmentsCount = this.showBadge(response.data.waitShipmentsCount) //待收货
@@ -135,11 +146,7 @@ export default {
 				this.salesReturnCount = this.showBadge(response.data.salesReturnCount) //退货/款
 				this.isRequest = true
 			}).catch(error =>{
-				uni.setStorage({//缓存游客用户openid
-				    key: 'openid',
-				    data: error.data.openid
-				})
-				this.logout()
+				this.$util.msg(error.msg, 2000)
 			})
 		},
 		// 客服

+ 9 - 0
services/user.service.js

@@ -17,6 +17,15 @@ export default class UserService {
 			isStatus: false
 		})
 	}
+	/* 初始化个人中心数据 */
+	userInfoPersonal(data = {}) {
+		return this.AjaxService.post({
+			url: '/buyer/personal',
+			data,
+			isLoading: false,
+			isStatus: false
+		})
+	}
 	/*维沙邀请码绑定*/
 	userInvitation(data = {}) {
 		return this.AjaxService.post({