Browse Source

切换账号

twt 10 months ago
parent
commit
b56807163e
3 changed files with 159 additions and 18 deletions
  1. 94 14
      pages/index/index.vue
  2. 55 4
      pages/user/user.vue
  3. 10 0
      store/index.js

+ 94 - 14
pages/index/index.vue

@@ -308,6 +308,7 @@
 				qrimg:'',
 				qrSHow:false,
 				customerInfo:'',
+				exitNum:'',
 			}
 		},
 		onLoad(opt) {
@@ -352,8 +353,8 @@
 				this.queryHomeCardList()
 				this.queryManagerInfo()
 			}else{
-				console.log("uniLogin")
-				this.uniLogin()
+					this.uniLogin()
+				
 			}
 			//版本更新
 		    this.UpdateManager();
@@ -369,18 +370,24 @@
 				this.themeColor=themeColor
 			}
 			this.getwxLoing=true;
-			if(indexaddcar==1){
-				uni.removeStorageSync('indexaddcar');
-				this.getCarList();
+			this.exitNum=this.$store.state.exitNum;
+			if(this.exitNum==1){
+				this.carInfo=''
 			}else{
-				this.carInfo=this.$store.state.carInfo;
-				console.log("车辆信息")
-				console.log(this.carInfo)
-				if(!this.carInfo){
+				if(indexaddcar==1){
+					uni.removeStorageSync('indexaddcar');
 					this.getCarList();
+				}else{
+					this.carInfo=this.$store.state.carInfo;
+					console.log("车辆信息")
+					console.log(this.carInfo)
+					if(!this.carInfo){
+						this.getCarList();
+					}
+					this.jsTime()
 				}
-				this.jsTime()
 			}
+			
 		    
 			
 			
@@ -457,7 +464,22 @@
 			},
 			addCar(){
 				if(!this.userInfo){
-					this.authorizShow=true;
+						if(this.exitNum!=1){
+							this.authorizShow=true;
+						}else{
+							this.$common.automaticlogin().then(val => {
+								this.userInfo=this.$store.state.userInfo;
+								this.wxOpenData=this.$store.state.wxOpenData;
+								/* uni.navigateTo({
+									url:'../user/addCar/addCar?type=1'
+								}) */
+								this.getCarList();
+								uni.navigateTo({
+									url:'../user/addCar/cailist'
+								}) 
+							})
+						}
+					
 				}else{
 					uni.navigateTo({
 						url:'../user/addCar/addCar?type=1'
@@ -519,27 +541,85 @@
 			},
 			goGoods(item){
 				if(!this.userInfo){
-					this.authorizShow=true;
+					if(this.exitNum!=1){
+						this.authorizShow=true;
+					}else{
+						this.$common.automaticlogin().then(val => {
+							this.userInfo=this.$store.state.userInfo;
+							this.wxOpenData=this.$store.state.wxOpenData;
+							this.exitNum=''
+							this.$store.commit('mutationsexitNum', '')
+							uni.navigateTo({
+								url:'../shop/goodsDetail?id='+item.id
+							})
+						})
+					}
 				}else{
 					uni.navigateTo({
 						url:'../shop/goodsDetail?id='+item.id
 					})
 				}
+				/* if(!this.userInfo){
+					this.authorizShow=true;
+				}else{
+					uni.navigateTo({
+						url:'../shop/goodsDetail?id='+item.id
+					})
+				} */
 			},
 			goJk(item){
-				if(!this.userInfo){
+				/* if(!this.userInfo){
 					this.authorizShow=true;
 				}else{
 					uni.navigateTo({
 						url:'../activity/jkDetail?id='+item.id
 					})
+				} */
+				if(!this.userInfo){
+					if(this.exitNum!=1){
+						this.authorizShow=true;
+					}else{
+						this.$common.automaticlogin().then(val => {
+							this.userInfo=this.$store.state.userInfo;
+							this.wxOpenData=this.$store.state.wxOpenData;
+							this.exitNum=''
+							this.$store.commit('mutationsexitNum', '')
+							uni.navigateTo({
+								url:'../activity/jkDetail?id='+item.id
+							})
+						})
+					}
+				}else{
+					uni.navigateTo({
+						url:'../activity/jkDetail?id='+item.id
+					})
 				}
 				
 			},
 			goRoter(item){
+				if(!this.userInfo){
+					if(this.exitNum!=1){
+						this.authorizShow=true;
+					}else{
+						this.$common.automaticlogin().then(val => {
+							this.userInfo=this.$store.state.userInfo;
+							this.wxOpenData=this.$store.state.wxOpenData;
+							this.exitNum=''
+							this.$store.commit('mutationsexitNum', '')
+							this.goRoter2(item)
+						})
+					}
+				}else{
+					this.goRoter2(item)
+				}
+				
+			},
+			goRoter2(item){
 				console.log(item)
+				
 				if(!this.userInfo){
-					this.authorizShow=true;
+					//this.authorizShow=true;
+					
 				}else{
 					if(item.bizType==0){
 						if(item.name=='新车'){ //

+ 55 - 4
pages/user/user.vue

@@ -360,7 +360,8 @@
 
 		</view>
 		<view class="rowBoxBg">
-			<view class="exit" @click="exit">退出登录</view>
+			<view class="exit2" @click="exit">切换账号</view>
+			<view class="exit" @click="exit2">退出登录</view>
 		</view>
 		
 		<view class="releaseVersion">版本号:{{release_version}}</view>
@@ -424,6 +425,7 @@
 				interval:3000,
 				showSetting:'',
 				f2csystemlist:'',
+				exitNum:'',
 			}
 		},
 		onLoad(opt) {
@@ -474,7 +476,24 @@
 				this.queryMyDetail();
 			} else {
 				//console.log("授权")
-				this.authorizShow = true;
+				this.exitNum=this.$store.state.exitNum;
+				if(this.exitNum!=1){
+					this.authorizShow = true;
+				}else{
+					this.$common.automaticlogin().then(val => {
+						this.userInfo=this.$store.state.userInfo;
+						this.wxOpenData=this.$store.state.wxOpenData;
+						this.exitNum=''
+						this.$store.commit('mutationsexitNum', '')
+						if (this.userInfo) {
+							this.queryMyDetail();
+						}
+						if(!this.userInfo){
+							this.authorizShow=true
+						}
+					})
+				}
+				
 			}
 			if (wxOpenData) {
 
@@ -489,7 +508,7 @@
 				var that=this;
 				uni.showModal({
 				  title: '提示',
-				  content: '是否退出登录',
+				  content: '是否切换账号',
 				  success(res) {
 				    if (res.confirm) {
 						uni.clearStorageSync()
@@ -508,6 +527,27 @@
 				});
 				
 			},
+			exit2(){
+				var that=this;
+				uni.showModal({
+				  title: '提示',
+				  content: '是否退出登录',
+				  success(res) {
+				    if (res.confirm) {
+						uni.clearStorageSync()
+						that.$store.commit('mutationsuserInfo', '')
+						that.$store.commit('mutationscarInfo', '')
+						that.$store.commit('mutationsexitNum', '1')
+						/* uni.reLaunch({
+							 url: '../index/index'
+						}); */
+						  uni.switchTab({
+							 url: '../index/index'
+						 }) 
+				    }
+				  }
+				});
+			},
 			makePhoneCall(tel){
 				uni.makePhoneCall({
 				  phoneNumber: tel,
@@ -783,13 +823,24 @@
 .exit{
 	background: #FFFFFF;
 	line-height: 100rpx;
-	margin-top: 20rpx;
+	
 	font-size: 28rpx;
 	font-family: PingFang;
 	font-weight: 500;
 	color: #ED2323;
 	text-align: center;
 }
+.exit2{
+	background: #FFFFFF;
+	line-height: 100rpx;
+	font-size: 28rpx;
+	font-family: PingFang;
+	font-weight: 500;
+	color: #3C3C3C;
+	text-align: center;
+	border-bottom: 1px solid #eaeaea;
+	margin-top: 20rpx;
+}
 .cardNameIcon{
 	width: 30rpx;height: 30rpx;
 }

+ 10 - 0
store/index.js

@@ -9,6 +9,7 @@ const store = new Vuex.Store({
 		ckshopInfo:'',
 		userInfo:'',
 		wxOpenData:'',
+		exitNum:'',
 	},
 	getters:{
 		getyuyueData(state){
@@ -25,6 +26,9 @@ const store = new Vuex.Store({
 		},
 		getwxOpenData(state){
 			return state.wxOpenData
+		},
+		getexitNum(state){
+			return state.exitNum
 		}
     },
     mutations: {
@@ -43,6 +47,9 @@ const store = new Vuex.Store({
 		mutationswxOpenData(state,data){
 			state.wxOpenData=data
 		},
+		mutationsexitNum(state,data){
+			state.exitNum=data
+		},
 	},
     actions: {
 		actionsyuyueData(context,playload){
@@ -60,6 +67,9 @@ const store = new Vuex.Store({
 		actionswxOpenData(context,playload){
 			context.commit('mutationswxOpenData',playload)
 		},
+		actionsexitNum(context,playload){
+			context.commit('mutationsexitNum',playload)
+		},
 	}
 })
 export default store