Browse Source

bug 修复

lilei 4 years ago
parent
commit
c01f851d9d
4 changed files with 18 additions and 3 deletions
  1. 15 2
      pages/index/index.vue
  2. 1 0
      pages/login/login.vue
  3. 1 0
      pages/login/phoneLogin.vue
  4. 1 1
      pages/userCenter/index.vue

+ 15 - 2
pages/index/index.vue

@@ -69,7 +69,7 @@
 	import {bannerList} from '@/api/banner.js'
 	import {getLookUpDatas,openDevice} from '@/api/data.js'
 	import {stationList} from '@/api/station.js'
-	import {checkLogin} from '@/api/login.js'
+	import {checkLogin,getUserInfo} from '@/api/login.js'
 	import {parseQueryString} from '@/libs/tools.js'
 	export default {
 		data() {
@@ -108,11 +108,24 @@
 			uni.$on("updateGoodsBuyQty",item=>{
 				this.updateGoodsBuyQty(item)
 			})
+			// 查询用户信息
+			uni.$on("getUserInfo",item=>{
+				this.getUserInfo(item)
+			})
 		},
 		onShow() {
 			
 		},
-		methods: { 
+		methods: {
+			// 获取用户信息
+			getUserInfo(){
+				console.log('getUserInfogetUserInfogetUserInfo')
+				getUserInfo().then(res => {
+					if(res.status == 200){
+						this.$u.vuex("vuex_userData",res.data)
+					}
+				})
+			},
 			// 获取数据字典
 			getCodeList(code,key) {
 				getLookUpDatas({

+ 1 - 0
pages/login/login.vue

@@ -81,6 +81,7 @@
 							if (res.status == '200') {
 								getApp().globalData.token = res.data
 								_this.$u.vuex('vuex_token',res.data)
+								uni.$emit("getUserInfo")
 								if (_this.path === '/pages/index/index' || _this.lanuch) {
 									uni.reLaunch({
 										url: _this.path

+ 1 - 0
pages/login/phoneLogin.vue

@@ -86,6 +86,7 @@
 							console.log(res,'login success')
 							getApp().globalData.token = res.data
 							_this.$u.vuex('vuex_token',res.data)
+							uni.$emit("getUserInfo")
 						    uni.navigateBack({
 						    	delta: 2
 						    })

+ 1 - 1
pages/userCenter/index.vue

@@ -51,7 +51,7 @@
 				console.log(res,'checkLogin')
 				this.hasLogin = res.status == 200
 				if(this.hasLogin){
-					this.getUserInfo()
+					// this.getUserInfo()
 				}
 			})
 		},