浏览代码

保存token

李天标 5 年之前
父节点
当前提交
6a3cc3673c

+ 2 - 1
pages/Charts/equipmentStatistics.vue

@@ -299,7 +299,8 @@
 			if (globalUser.id == '1') {
 				this.show = true
 			}
-			if (globalUser.id!=null) {
+			var token = uni.getStorageSync("token");
+			if (token.length>1) {
 				this.init();
 			}else{
 				uni.reLaunch({

+ 2 - 2
pages/Charts/mainStatistics.vue

@@ -250,8 +250,8 @@
 			this.day();
 		},
 		mounted() {
-			var globalUser = uni.getStorageSync("globalUser");
-			if (globalUser.toString().length > 1) {
+			var token = uni.getStorageSync("token");
+			if (token.toString().length > 1) {
 				this.init();
 			}else{
 				uni.reLaunch({

+ 1 - 0
pages/Login/loginWeixin.vue

@@ -74,6 +74,7 @@
 						var result = data.message;
 						var weixinInfo = data.data;
 						var code = data.code;
+						uni.setStorageSync("token", data.token);
 						uni.setStorageSync("globalUser", weixinInfo);
 						if (code == true) {
 							uni.reLaunch({

+ 23 - 5
pages/User/equipmentStatusList.vue

@@ -114,7 +114,7 @@
 						<view class="line1"></view>
 						<!-- 远程开门 -->
 						<view class="opendoor"><span>{{$t('equipmentStatusList.door')}}:</span>
-							<view class="button">
+							<view class="">
 								<button type="primary" @click="openDoor(equipment.id)" class="button">
 									<p class="p">{{$t('equipmentStatusList.open')}}</p>
 								</button>
@@ -202,7 +202,8 @@
 				index: 3,
 				text: this.$t('tabs.tab4')
 			});
-			if (this.globalUser.id!=null) {
+			var token = uni.getStorageSync("token");
+			if (token.length>1) {
 				this.getEquipmentListData();
 			}else{
 				uni.reLaunch({
@@ -464,20 +465,37 @@
 	}
 
 	.opendoor {
+		/* #ifdef H5 */
+		
+		/* #endif */
 		padding-top: 10upx;
 		padding-bottom: 10upx;
-		text-align: center;
+		/* text-align: center; */
 		display: flex;
 		flex-direction: row;
 	}
 
 	.button {
+		/* #ifdef H5 */
+		text-align: center;
+		height: 50upx;
+		weight:20upx ;
+		/* #endif */
 		padding-left: 15upx;
-		padding-top: 2upx;
+		/* padding-top: 2upx; */
 	}
 
 	.p {
-		padding-left: 10upx;
+		/* #ifdef H5 */
+		font-size: 28upx;
+		height: 50upx;
+		weight:20upx ;
+		transform: translateY(-14upx);
+		/* text-align: center; */
+		/* #endif */
+		/* padding-bottom: 50upx; */
+		text-align: center;
+		padding-left: 13upx;
 	}
 
 	.img {

+ 2 - 2
pages/User/merchantList.vue

@@ -63,8 +63,8 @@
 			uni.setTabBarItem({ index: 1,text: this.$t('tabs.tab2')});
 			this.globalUser = uni.getStorageSync("globalUser");
 			this.id = this.globalUser.id;
-			
-			if (this.id!=null) {
+			var token = uni.getStorageSync("token");
+			if (token.length>1) {
 				this.getEquipmentListData();
 			}else{
 				uni.reLaunch({

+ 2 - 1
pages/User/user.vue

@@ -96,7 +96,8 @@
 			if (ifForeign == 0) {
 				this.ifForeign = true;
 			}
-			if (gid != null) {
+			var token = uni.getStorageSync("token");
+			if (token.length>1) {
 				var name = uni.getStorageSync("name");
 				this.name = name;
 				var listName = uni.getStorageSync("listName");

+ 4 - 0
store/index.js

@@ -42,6 +42,9 @@ const store = new Vuex.Store({
 					uni.setStorageSync("name", res.data.name);
 					const userObj = res.data;
 					uni.setStorageSync("globalUser", res.data);
+					uni.setStorageSync("token", res.token);
+					// uni.setCookie(res.token);
+					// uni.setToken(res.token);
 					commit('setLoading', false);
 					commit('setLoginUser', userObj);
 					// commit('setToken', token);
@@ -72,6 +75,7 @@ const store = new Vuex.Store({
 				.then(res => {
 					//用户名缓存
 					uni.setStorageSync("name", res.data.name);
+					uni.setStorageSync("token", res.token);
 					const userObj = res.data;
 					commit('setLoading', false);
 					commit('setLoginUser', userObj);