Forráskód Böngészése

[Feat 0000]IP地址配置功能

bobo04052021@163.com 4 hete
szülő
commit
a0c95a651a
10 módosított fájl, 820 hozzáadás és 550 törlés
  1. 260 256
      App.vue
  2. 5 0
      api/api.js
  3. 7 0
      common/router/modules/routes.js
  4. 27 5
      common/service/config.service.js
  5. 86 81
      common/service/service.js
  6. 122 122
      manifest.json
  7. 4 0
      pages.json
  8. 137 0
      pages/ipConfig/ipConfig.vue
  9. 64 7
      pages/login/login.vue
  10. 108 79
      store/index.js

+ 260 - 256
App.vue

@@ -1,284 +1,288 @@
 <style lang="scss">
-	/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
-	@import "@/uni_modules/uview-ui/index.scss";
+/* 注意要写在第一行,同时给style标签加入lang="scss"属性 */
+@import "@/uni_modules/uview-ui/index.scss";
 </style>
 <script>
-	import Vue from 'vue'
-	import appUpdate from 'common/util/appUpdate.js'
-	export default {
-		onLaunch: function() {
-			uni.getSystemInfo({
-				success: function(e) {
-					
-					// #ifdef APP-PLUS
-					// 检测升级
-					appUpdate()
-					// #endif
-					// #ifndef MP
-					Vue.prototype.StatusBar = e.statusBarHeight;
-					if (e.platform == 'android') {
-						Vue.prototype.CustomBar = e.statusBarHeight + 50;
-					} else {
-						Vue.prototype.CustomBar = e.statusBarHeight + 45;
-					};
-					// #endif
+import Vue from "vue";
+import appUpdate from "common/util/appUpdate.js";
+export default {
+  onLaunch: function () {
+    const savedIP = uni.getStorageSync("selectedIP");
+    if (!savedIP) {
+      uni.reLaunch({ url: "/pages/ipConfig/ipConfig" });
+      return;
+    } else {
+      uni.getSystemInfo({
+        success: function (e) {
+          // #ifdef APP-PLUS
+          // 检测升级
+          appUpdate();
+          // #endif
+          // #ifndef MP
+          Vue.prototype.StatusBar = e.statusBarHeight;
+          if (e.platform == "android") {
+            Vue.prototype.CustomBar = e.statusBarHeight + 50;
+          } else {
+            Vue.prototype.CustomBar = e.statusBarHeight + 45;
+          }
+          // #endif
 
-					// #ifdef MP-WEIXIN
-					Vue.prototype.StatusBar = e.statusBarHeight;
-					let custom = wx.getMenuButtonBoundingClientRect();
-					Vue.prototype.Custom = custom;
-					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
-					// #endif		
+          // #ifdef MP-WEIXIN
+          Vue.prototype.StatusBar = e.statusBarHeight;
+          let custom = wx.getMenuButtonBoundingClientRect();
+          Vue.prototype.Custom = custom;
+          Vue.prototype.CustomBar =
+            custom.bottom + custom.top - e.statusBarHeight;
+          // #endif
 
-					// #ifdef MP-ALIPAY
-					Vue.prototype.StatusBar = e.statusBarHeight;
-					Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
-					// #endif
-					
-					// #ifdef APP-PLUS
-					//Vue.prototype.$api.listenTranMsg()
-			// 		var info = plus.push.getClientInfo();
-			
-			// 		/* 5+  push 消息推送 ps:使用:H5+的方式监听,实现推送*/
-			// 		plus.push.addEventListener("click", function(msg) {
-			// 			console.log("click:" + JSON.stringify(msg));
-			// 			console.log(msg.payload);
-			// 			console.log(JSON.stringify(msg));
-			// 			//这里可以写跳转业务代码
-			// 		}, false);
-			// 		// 监听在线消息事件    
-			// 		plus.push.addEventListener("receive", function(msg) {
-			// 			// plus.ui.alert(2);  
-			// 			//这里可以写跳转业务代码
-			// 			console.log("recevice:" + JSON.stringify(msg))
-			// 		}, false);
-					// #endif
-					
-					//Vue.prototype.$api.initLogin()
-					
-				}
-			})
-            Vue.prototype.NavBarColor='bg-gradual-blue'
-            Vue.prototype.Radio_Check_Size='scale(0.7)'
-			Vue.prototype.ColorList = [{
-					title: '嫣红',
-					name: 'red',
-					color: '#e54d42'
-				},
-				{
-					title: '桔橙',
-					name: 'orange',
-					color: '#f37b1d'
-				},
-				{
-					title: '明黄',
-					name: 'yellow',
-					color: '#fbbd08'
-				},
-				{
-					title: '橄榄',
-					name: 'olive',
-					color: '#8dc63f'
-				},
-				{
-					title: '森绿',
-					name: 'green',
-					color: '#39b54a'
-				},
-				{
-					title: '天青',
-					name: 'cyan',
-					color: '#1cbbb4'
-				},
-				{
-					title: '海蓝',
-					name: 'blue',
-					color: '#0081ff'
-				},
-				{
-					title: '姹紫',
-					name: 'purple',
-					color: '#6739b6'
-				},
-				{
-					title: '木槿',
-					name: 'mauve',
-					color: '#9c26b0'
-				},
-				{
-					title: '桃粉',
-					name: 'pink',
-					color: '#e03997'
-				},
-				{
-					title: '棕褐',
-					name: 'brown',
-					color: '#a5673f'
-				},
-				{
-					title: '玄灰',
-					name: 'grey',
-					color: '#8799a3'
-				},
-				{
-					title: '草灰',
-					name: 'gray',
-					color: '#aaaaaa'
-				},
-				{
-					title: '墨黑',
-					name: 'black',
-					color: '#333333'
-				},
-				{
-					title: '雅白',
-					name: 'white',
-					color: '#ffffff'
-				},
-			]
+          // #ifdef MP-ALIPAY
+          Vue.prototype.StatusBar = e.statusBarHeight;
+          Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
+          // #endif
 
-		},
-		onShow: function() {
-			console.log('App Show')
-		},
-		onHide: function() {
-			console.log('App Hide')
-			clearInterval(this.$store.state.timer); // 假设定时器存储在 Vuex 的状态管理中
-		},
+          // #ifdef APP-PLUS
+          //Vue.prototype.$api.listenTranMsg()
+          // 		var info = plus.push.getClientInfo();
 
-	}
+          // 		/* 5+  push 消息推送 ps:使用:H5+的方式监听,实现推送*/
+          // 		plus.push.addEventListener("click", function(msg) {
+          // 			console.log("click:" + JSON.stringify(msg));
+          // 			console.log(msg.payload);
+          // 			console.log(JSON.stringify(msg));
+          // 			//这里可以写跳转业务代码
+          // 		}, false);
+          // 		// 监听在线消息事件
+          // 		plus.push.addEventListener("receive", function(msg) {
+          // 			// plus.ui.alert(2);
+          // 			//这里可以写跳转业务代码
+          // 			console.log("recevice:" + JSON.stringify(msg))
+          // 		}, false);
+          // #endif
+
+          //Vue.prototype.$api.initLogin()
+        },
+      });
+      Vue.prototype.NavBarColor = "bg-gradual-blue";
+      Vue.prototype.Radio_Check_Size = "scale(0.7)";
+      Vue.prototype.ColorList = [
+        {
+          title: "嫣红",
+          name: "red",
+          color: "#e54d42",
+        },
+        {
+          title: "桔橙",
+          name: "orange",
+          color: "#f37b1d",
+        },
+        {
+          title: "明黄",
+          name: "yellow",
+          color: "#fbbd08",
+        },
+        {
+          title: "橄榄",
+          name: "olive",
+          color: "#8dc63f",
+        },
+        {
+          title: "森绿",
+          name: "green",
+          color: "#39b54a",
+        },
+        {
+          title: "天青",
+          name: "cyan",
+          color: "#1cbbb4",
+        },
+        {
+          title: "海蓝",
+          name: "blue",
+          color: "#0081ff",
+        },
+        {
+          title: "姹紫",
+          name: "purple",
+          color: "#6739b6",
+        },
+        {
+          title: "木槿",
+          name: "mauve",
+          color: "#9c26b0",
+        },
+        {
+          title: "桃粉",
+          name: "pink",
+          color: "#e03997",
+        },
+        {
+          title: "棕褐",
+          name: "brown",
+          color: "#a5673f",
+        },
+        {
+          title: "玄灰",
+          name: "grey",
+          color: "#8799a3",
+        },
+        {
+          title: "草灰",
+          name: "gray",
+          color: "#aaaaaa",
+        },
+        {
+          title: "墨黑",
+          name: "black",
+          color: "#333333",
+        },
+        {
+          title: "雅白",
+          name: "white",
+          color: "#ffffff",
+        },
+      ];
+    }
+  },
+  onShow: function () {
+    console.log("App Show");
+  },
+  onHide: function () {
+    console.log("App Hide");
+    clearInterval(this.$store.state.timer); // 假设定时器存储在 Vuex 的状态管理中
+  },
+};
 </script>
 
 <style>
-	@import "plugin/colorui/main.css";
-	@import "plugin/colorui/icon.css";
-    @import "plugin/colorui/animation.css";
-	.nav-list {
-		display: flex;
-		flex-wrap: wrap;
-		padding: 0px 40upx 0px;
-		justify-content: space-between;
-	}
+@import "plugin/colorui/main.css";
+@import "plugin/colorui/icon.css";
+@import "plugin/colorui/animation.css";
+.nav-list {
+  display: flex;
+  flex-wrap: wrap;
+  padding: 0px 40upx 0px;
+  justify-content: space-between;
+}
 
-	.nav-li {
-		padding: 30upx;
-		border-radius: 12upx;
-		width: 45%;
-		margin: 0 2.5% 40upx;
-		background-image: url(https://cdn.nlark.com/yuque/0/2019/png/280374/1552996358352-assets/web-upload/cc3b1807-c684-4b83-8f80-80e5b8a6b975.png);
-		background-size: cover;
-		background-position: center;
-		position: relative;
-		z-index: 1;
-	}
+.nav-li {
+  padding: 30upx;
+  border-radius: 12upx;
+  width: 45%;
+  margin: 0 2.5% 40upx;
+  background-image: url(https://cdn.nlark.com/yuque/0/2019/png/280374/1552996358352-assets/web-upload/cc3b1807-c684-4b83-8f80-80e5b8a6b975.png);
+  background-size: cover;
+  background-position: center;
+  position: relative;
+  z-index: 1;
+}
 
-	.nav-li::after {
-		content: "";
-		position: absolute;
-		z-index: -1;
-		background-color: inherit;
-		width: 100%;
-		height: 100%;
-		left: 0;
-		bottom: -10%;
-		border-radius: 10upx;
-		opacity: 0.2;
-		transform: scale(0.9, 0.9);
-	}
+.nav-li::after {
+  content: "";
+  position: absolute;
+  z-index: -1;
+  background-color: inherit;
+  width: 100%;
+  height: 100%;
+  left: 0;
+  bottom: -10%;
+  border-radius: 10upx;
+  opacity: 0.2;
+  transform: scale(0.9, 0.9);
+}
 
-	.nav-li.cur {
-		color: #fff;
-		background: rgb(94, 185, 94);
-		box-shadow: 4upx 4upx 6upx rgba(94, 185, 94, 0.4);
-	}
+.nav-li.cur {
+  color: #fff;
+  background: rgb(94, 185, 94);
+  box-shadow: 4upx 4upx 6upx rgba(94, 185, 94, 0.4);
+}
 
-	.nav-title {
-		font-size: 32upx;
-		font-weight: 300;
-	}
+.nav-title {
+  font-size: 32upx;
+  font-weight: 300;
+}
 
-	.nav-title::first-letter {
-		font-size: 40upx;
-		margin-right: 4upx;
-	}
+.nav-title::first-letter {
+  font-size: 40upx;
+  margin-right: 4upx;
+}
 
-	.nav-name {
-		font-size: 28upx;
-		text-transform: Capitalize;
-		margin-top: 20upx;
-		position: relative;
-	}
+.nav-name {
+  font-size: 28upx;
+  text-transform: Capitalize;
+  margin-top: 20upx;
+  position: relative;
+}
 
-	.nav-name::before {
-		content: "";
-		position: absolute;
-		display: block;
-		width: 40upx;
-		height: 6upx;
-		background: #fff;
-		bottom: 0;
-		right: 0;
-		opacity: 0.5;
-	}
+.nav-name::before {
+  content: "";
+  position: absolute;
+  display: block;
+  width: 40upx;
+  height: 6upx;
+  background: #fff;
+  bottom: 0;
+  right: 0;
+  opacity: 0.5;
+}
 
-	.nav-name::after {
-		content: "";
-		position: absolute;
-		display: block;
-		width: 100upx;
-		height: 1px;
-		background: #fff;
-		bottom: 0;
-		right: 40upx;
-		opacity: 0.3;
-	}
+.nav-name::after {
+  content: "";
+  position: absolute;
+  display: block;
+  width: 100upx;
+  height: 1px;
+  background: #fff;
+  bottom: 0;
+  right: 40upx;
+  opacity: 0.3;
+}
 
-	.nav-name::first-letter {
-		font-weight: bold;
-		font-size: 36upx;
-		margin-right: 1px;
-	}
+.nav-name::first-letter {
+  font-weight: bold;
+  font-size: 36upx;
+  margin-right: 1px;
+}
 
-	.nav-li text {
-		position: absolute;
-		right: 30upx;
-		top: 30upx;
-		font-size: 52upx;
-		width: 60upx;
-		height: 60upx;
-		text-align: center;
-		line-height: 60upx;
-	}
+.nav-li text {
+  position: absolute;
+  right: 30upx;
+  top: 30upx;
+  font-size: 52upx;
+  width: 60upx;
+  height: 60upx;
+  text-align: center;
+  line-height: 60upx;
+}
 
-	.text-light {
-		font-weight: 300;
-	}
+.text-light {
+  font-weight: 300;
+}
 
-	@keyframes show {
-		0% {
-			transform: translateY(-50px);
-		}
+@keyframes show {
+  0% {
+    transform: translateY(-50px);
+  }
 
-		60% {
-			transform: translateY(40upx);
-		}
+  60% {
+    transform: translateY(40upx);
+  }
 
-		100% {
-			transform: translateY(0px);
-		}
-	}
+  100% {
+    transform: translateY(0px);
+  }
+}
 
-	@-webkit-keyframes show {
-		0% {
-			transform: translateY(-50px);
-		}
+@-webkit-keyframes show {
+  0% {
+    transform: translateY(-50px);
+  }
 
-		60% {
-			transform: translateY(40upx);
-		}
+  60% {
+    transform: translateY(40upx);
+  }
 
-		100% {
-			transform: translateY(0px);
-		}
-	}
+  100% {
+    transform: translateY(0px);
+  }
+}
 </style>

+ 5 - 0
api/api.js

@@ -88,6 +88,11 @@ const apiService = {
   getDeviceMonitor(params) {
     return http.post("/monitor/device", params);
   },
+  //查询场景类型数据
+  getSysList(params) {
+    const url = buildURL("/safety/ventanalyManageSystem/list", params);
+    return http.get(url);
+  },
   //查询分页列表信息 通过分类查询 各类设备在app上是否展示的字段
   getShowColumList(params) {
     // const urlParams = new URLSearchParams(params);

+ 7 - 0
common/router/modules/routes.js

@@ -7,6 +7,13 @@ const routes = [
     },
   },
   {
+    path: "/pages/ipConfig/ipConfig",
+    name: "ipConfig",
+    meta: {
+      title: "IP配置",
+    },
+  },
+  {
     //注意:path必须跟pages.json中的地址对应,最前面别忘了加'/'哦
     path: "/pages/index/index",
     name: "index",

+ 27 - 5
common/service/config.service.js

@@ -1,13 +1,13 @@
 let BASE_URL = "";
 if (process.env.NODE_ENV == "development") {
-  BASE_URL = "http://182.92.126.35:9999"; // 开发环境
+  // BASE_URL = "http://182.92.126.35:9999"; // 开发环境
 } else {
   // BASE_URL = "http://182.92.126.35:9999"; // 开发环境
   // BASE_URL = "http://10.246.95.4:9999"; // 布尔台
   // BASE_URL = "http://10.248.135.10:9999"; // 大柳塔进
   // BASE_URL = "http://10.248.135.121:9999"; // 活鸡兔井
   // BASE_URL = "http://10.246.63.125:9999"; // 寸草塔二矿
-  BASE_URL = "http://10.246.183.35:9999"; // 乌兰木伦
+  // BASE_URL = "http://10.246.183.35:9999"; // 乌兰木伦
   // BASE_URL = "http://10.120.120.164:9999"; // 察哈素
   // BASE_URL = "http://182.92.126.35:9999"; // 生产环境
   // BASE_URL = "http://172.16.53.16:9999"; //
@@ -16,12 +16,34 @@ if (process.env.NODE_ENV == "development") {
   // BASE_URL = "http://10.246.167.205:9999"; //上湾
 }
 let staticDomainURL = BASE_URL + "/sys/common/static";
-
 const configService = {
-  apiUrl: BASE_URL,
-  apiUrlP: 'http://10.246.167.205:6006',
+  apiUrl: uni.getStorageSync("apiUrl"),
+  apiUrlP: "http://10.246.167.205:6006",
   // apiUrlP: 'http://182.92.126.35:6006',
   staticDomainURL: staticDomainURL,
 };
 
 export default configService;
+
+// let BASE_URL = "";
+
+// // 开发环境直接使用预设 IP
+// if (process.env.NODE_ENV === "development") {
+//   BASE_URL = "http://182.92.126.35:9999";
+// } else {
+//   // 生产环境优先读取本地存储
+//   BASE_URL = uni.getStorageSync("apiUrl") || "";
+// }
+
+// // 判断是否需要跳转 IP 设置页
+// if (process.env.NODE_ENV !== "development" && !BASE_URL) {
+//   uni.reLaunch({ url: "/pages/ipConfig/ipConfig" });
+// }
+
+// const staticDomainURL = BASE_URL + "/sys/common/static";
+// const configService = {
+//   apiUrl: BASE_URL,
+//   apiUrlP: "http://10.246.167.205:6006",
+//   staticDomainURL: staticDomainURL,
+// };
+// export default configService;

+ 86 - 81
common/service/service.js

@@ -1,32 +1,31 @@
-import Request from '@/common/luch-request/index.js'
-import { ACCESS_TOKEN } from '@/common/util/constants.js'
-import configService from './config.service.js'
-import tip from '@/common/util/tip.js';
-import store from '@/store/index.js';
+import Request from "@/common/luch-request/index.js";
+import { ACCESS_TOKEN } from "@/common/util/constants.js";
+import configService from "./config.service.js";
+import tip from "@/common/util/tip.js";
+import store from "@/store/index.js";
 
 let apiUrl = configService.apiUrl;
 
 const getTokenStorage = () => {
-  let token = ''
+  let token = "";
   try {
-    token = uni.getStorageSync(ACCESS_TOKEN)
+    token = uni.getStorageSync(ACCESS_TOKEN);
   } catch (e) {
     //TODO handle the exception
-    console.log("getTokenStorage", token)
+    console.log("getTokenStorage", token);
   }
-  return token
-}
+  return token;
+};
 
-
-
-const http = new Request()
-http.setConfig((config) => { /* 设置全局配置 */
-  config.baseUrl = apiUrl /* 根域名不同 */
+const http = new Request();
+http.setConfig((config) => {
+  /* 设置全局配置 */
+  config.baseUrl = apiUrl; /* 根域名不同 */
   config.header = {
-    ...config.header
-  }
-  return config
-})
+    ...config.header,
+  };
+  return config;
+});
 
 /**
  * 自定义验证器,如果返回true 则进入响应拦截器的响应成功函数(resolve),否则进入响应拦截器的响应错误函数(reject)
@@ -35,84 +34,90 @@ http.setConfig((config) => { /* 设置全局配置 */
  */
 // 有默认,非必写
 http.validateStatus = (statusCode) => {
-  return statusCode === 200
-}
+  return statusCode === 200;
+};
 
-http.interceptor.request((config, cancel) => { /* 请求之前拦截器 */
-  console.log(config, 'config---')
+http.interceptor.request((config, cancel) => {
+  /* 请求之前拦截器 */
+  console.log(config, "config---");
+  config.baseUrl = "";
+  config.url = uni.getStorageSync("apiUrl") + config.url;
+  console.log(config, "config11111111111");
   config.header = {
     ...config.header,
-    'X-Access-Token': getTokenStorage()
-  }
+    "X-Access-Token": getTokenStorage(),
+  };
 
   /*
   if (!token) { // 如果token不存在,调用cancel 会取消本次请求,但是该函数的catch() 仍会执行
     cancel('token 不存在') // 接收一个参数,会传给catch((err) => {}) err.errMsg === 'token 不存在'
   }
   */
-  return config
-})
+  return config;
+});
 
 // 必须使用异步函数,注意
-var that = this
-http.interceptor.response(async (response) => { /* 请求之后拦截器 */
-  // if (response.data.code !== 200) { // 服务端返回的状态码不等于200,则reject()
-  //   return Promise.reject(response)
-  // }
-  return response
-}, (response) => {
-  // 请求错误做点什么
-  console.log("请求错误做点什么", response);
-  if (response) {
-    let data = response.data
-    const token = uni.getStorageSync(ACCESS_TOKEN)
-    console.log("------异常响应------", token)
-    console.log("------异常响应------", data.code)
-    switch (data.code) {
-      case 403:
-        tip.error('拒绝访问');
-        break
-      case 500:
-        if (!token || data.message == "Token失效,请重新登录") {
-          let timeout = setTimeout(tip.alert('登录已过期'), 1000);
-          store.dispatch('Logout').then(() => {
-            clearTimeout(timeout)
-            window.location.reload()
-          })
-        }
-        break
-      case 404:
-        break
-      case 504:
-        break
-      case 401:
-        console.log("------异常响应-401-----", 401)
+var that = this;
+http.interceptor.response(
+  async (response) => {
+    /* 请求之后拦截器 */
+    // if (response.data.code !== 200) { // 服务端返回的状态码不等于200,则reject()
+    //   return Promise.reject(response)
+    // }
+    return response;
+  },
+  (response) => {
+    // 请求错误做点什么
+    console.log("请求错误做点什么", response);
+    if (response) {
+      let data = response.data;
+      const token = uni.getStorageSync(ACCESS_TOKEN);
+      console.log("------异常响应------", token);
+      console.log("------异常响应------", data.code);
+      switch (data.code) {
+        case 403:
+          tip.error("拒绝访问");
+          break;
+        case 500:
+          if (!token || data.message == "Token失效,请重新登录") {
+            let timeout = setTimeout(tip.alert("登录已过期"), 1000);
+            store.dispatch("Logout").then(() => {
+              clearTimeout(timeout);
+              window.location.reload();
+            });
+          }
+          break;
+        case 404:
+          break;
+        case 504:
+          break;
+        case 401:
+          console.log("------异常响应-401-----", 401);
 
-        console.log("------uni-----", uni)
-        uni.navigateTo({
-          url: '/pages/login/login'
-        });
-        return
-        if (token) {
-          /* store.dispatch('Logout').then(() => {
+          console.log("------uni-----", uni);
+          uni.navigateTo({
+            url: "/pages/login/login",
+          });
+          return;
+          if (token) {
+            /* store.dispatch('Logout').then(() => {
              setTimeout(() => {
                window.location.reload()
              }, 1500)
            }) */
-        }
-        break
-      default:
-        tip.error({
-          duration: 0,
-          forbidClick: true,
-          message: data.message
-        });
-        break
+          }
+          break;
+        default:
+          tip.error({
+            duration: 0,
+            forbidClick: true,
+            message: data.message,
+          });
+          break;
+      }
     }
+    return response;
   }
-  return response
-})
+);
 
-export {
-  http
-}
+export { http };

+ 122 - 122
manifest.json

@@ -1,130 +1,130 @@
 {
-  "name": "智能通风",
-  "appid": "__UNI__2000523",
-  "description": "",
-  "versionName": "2.2.22",
-  "versionCode": 1,
-  "transformPx": false,
-  "app-plus": {
-    "compatible": {
-      "ignoreVersion": true,
-      "runtimeVersion": "4.23,4.29",
-      "compilerVersion": "4.29"
-    },
-    "orientation": [
-      //竖屏正方向
-      "portrait-primary",
-      //竖屏反方向
-      "portrait-secondary",
-      //横屏正方向
-      "landscape-primary",
-      //横屏反方向
-      "landscape-secondary",
-      //自然方向
-      "default"
-    ],
-    /* 5+App特有相关 */
-    "modules": {
-      "VideoPlayer": {},
-      "Camera": {}
+    "name" : "智能通风",
+    "appid" : "__UNI__2000523",
+    "description" : "",
+    "versionName" : "2.2.22",
+    "versionCode" : 1,
+    "transformPx" : false,
+    "app-plus" : {
+        "compatible" : {
+            "ignoreVersion" : true,
+            "runtimeVersion" : "4.23,4.29",
+            "compilerVersion" : "4.29"
+        },
+        "orientation" : [
+            //竖屏正方向
+            "portrait-primary",
+            //竖屏反方向
+            "portrait-secondary",
+            //横屏正方向
+            "landscape-primary",
+            //横屏反方向
+            "landscape-secondary",
+            //自然方向
+            "default"
+        ],
+        /* 5+App特有相关 */
+        "modules" : {
+            "VideoPlayer" : {},
+            "Camera" : {}
+        },
+        /* 模块配置 */
+        "distribute" : {
+            /* 应用发布信息 */
+            "android" : {
+                /* android打包配置 */
+                "permissions" : [
+                    "<uses-feature android:name=\"android.hardware.camera\"/>",
+                    "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
+                    "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
+                    "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
+                    "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
+                    "<uses-permission android:name=\"android.permission.CAMERA\"/>",
+                    "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
+                    "<uses-permission android:name=\"android.permission.INTERNET\"/>",
+                    "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
+                    "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
+                    "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
+                    "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
+                    "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
+                    "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
+                    "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
+                    "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
+                    "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
+                    "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
+                    "<uses-permission android:name=\"android.permission.NFC\"/>",
+                    "<uses-sdk android:minSdkVersion=\"10\"/>",
+                    "<uses-feature android:name=\"android.hardware.nfc\" android:required=\"true\" />",
+                    "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>",
+                    "<uses-permission android:name=\"android.permission.READ_MEDIA_IMAGES\" />",
+                    "<uses-permission android:name=\"android.permission.READ_MEDIA_AUDIO\" />",
+                    "<uses-permission android:name=\"android.permission.READ_MEDIA_VIDEO\" />"
+                ]
+            },
+            "ios" : {
+                "dSYMs" : false
+            },
+            /* ios打包配置 */
+            "sdkConfigs" : {
+                "ad" : {},
+                "maps" : {
+                    "amap" : {
+                        "name" : "",
+                        "appkey_ios" : "87f4d2a4a0c42e0c86cf312c8b8154e8",
+                        "appkey_android" : "87f4d2a4a0c42e0c86cf312c8b8154e8"
+                    }
+                },
+                "push" : {}
+            },
+            "splashscreen" : {
+                "iosStyle" : "default"
+            },
+            "icons" : {
+                "android" : {
+                    "hdpi" : "static/desk-img/72 – 1.png",
+                    "xhdpi" : "static/desk-img/96.png",
+                    "xxhdpi" : "static/desk-img/144.png",
+                    "xxxhdpi" : "static/desk-img/192.png"
+                }
+            }
+        },
+        "nativePlugins" : {}
     },
-    /* 模块配置 */
-    "distribute": {
-      /* 应用发布信息 */
-      "android": {
-        /* android打包配置 */
-        "permissions": [
-          "<uses-feature android:name=\"android.hardware.camera\"/>",
-          "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
-          "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
-          "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
-          "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
-          "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
-          "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
-          "<uses-permission android:name=\"android.permission.CAMERA\"/>",
-          "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
-          "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
-          "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
-          "<uses-permission android:name=\"android.permission.INTERNET\"/>",
-          "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
-          "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
-          "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
-          "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
-          "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
-          "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
-          "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
-          "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
-          "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>",
-          "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>",
-          "<uses-permission android:name=\"android.permission.NFC\"/>",
-          "<uses-sdk android:minSdkVersion=\"10\"/>",
-          "<uses-feature android:name=\"android.hardware.nfc\" android:required=\"true\" />",
-          "<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>",
-          "<uses-permission android:name=\"android.permission.READ_MEDIA_IMAGES\" />",
-          "<uses-permission android:name=\"android.permission.READ_MEDIA_AUDIO\" />",
-          "<uses-permission android:name=\"android.permission.READ_MEDIA_VIDEO\" />"
-        ]
-      },
-      "ios": {
-        "dSYMs": false
-      },
-      /* ios打包配置 */
-      "sdkConfigs": {
-        "ad": {},
-        "maps": {
-          "amap": {
-            "name": "",
-            "appkey_ios": "87f4d2a4a0c42e0c86cf312c8b8154e8",
-            "appkey_android": "87f4d2a4a0c42e0c86cf312c8b8154e8"
-          }
+    /* SDK配置 */
+    "quickapp" : {},
+    /* 快应用特有相关 */
+    "mp-weixin" : {
+        "appid" : "wx2ba5c5690b35d173",
+        "setting" : {
+            "urlCheck" : false,
+            "es6" : true
         },
-        "push": {}
-      },
-      "splashscreen": {
-        "iosStyle": "default"
-      },
-      "icons": {
-        "android": {
-          "hdpi": "static/desk-img/72 – 1.png",
-          "xhdpi": "static/desk-img/96.png",
-          "xxhdpi": "static/desk-img/144.png",
-          "xxxhdpi": "static/desk-img/192.png"
+        "permission" : {
+            "scope.userLocation" : {
+                "desc" : "有定位功能需要导航定位"
+            }
         }
-      }
     },
-    "nativePlugins": {}
-  },
-  /* SDK配置 */
-  "quickapp": {},
-  /* 快应用特有相关 */
-  "mp-weixin": {
-    "appid": "wx2ba5c5690b35d173",
-    "setting": {
-      "urlCheck": false,
-      "es6": true
+    "h5" : {
+        "title" : "智能通风",
+        "domain" : "myhjdc.cn",
+        "router" : {
+            "mode" : "history"
+        }
     },
-    "permission": {
-      "scope.userLocation": {
-        "desc": "有定位功能需要导航定位"
-      }
-    }
-  },
-  "h5": {
-    "title": "智能通风",
-    "domain": "myhjdc.cn",
-    "router": {
-      "mode": "history"
-    }
-  },
-  "android": {
-    "theme": {
-      "primaryColor": "#000000",
-      "window": {
-        "fullscreen": true,
-        "navigationBarColor": "#000000"
-      }
+    "android" : {
+        "theme" : {
+            "primaryColor" : "#000000",
+            "window" : {
+                "fullscreen" : true,
+                "navigationBarColor" : "#000000"
+            }
+        },
+        "notch" : true
     },
-    "notch": true
-  },
-  "fallbackLocale": "zh-Hans"
+    "fallbackLocale" : "zh-Hans"
 }

+ 4 - 0
pages.json

@@ -205,6 +205,10 @@
       "style": {
         "navigationBarTitleText": ""
       }
+    },
+    {
+      "path": "pages/ipConfig/ipConfig",
+      "style": {}
     }
   ],
   "globalStyle": {

+ 137 - 0
pages/ipConfig/ipConfig.vue

@@ -0,0 +1,137 @@
+  <template>
+  <view class="zai-box">
+    <scroll-view scroll-y class="page">
+      <view class="IPSet">
+        <span class="text-style"
+          ><u-button
+            :plain="true"
+            color="#18a5ff"
+            size="small"
+            :text="IPSet ? IPSet : '选择IP地址'"
+            @tap="changeIP()"
+          ></u-button
+        ></span>
+        <u-picker
+          :show="ipShow"
+          :columns="IpConfig"
+          @cancel="ipShow = false"
+          @confirm="selectIpAddr"
+          keyName="label"
+        ></u-picker>
+      </view>
+    </scroll-view>
+  </view>
+</template>
+
+<script>
+import configService from "@/common/service/config.service.js";
+
+export default {
+  data() {
+    return {
+      ipShow: false,
+      IPSet: "",
+      IpConfig: [
+        [
+          { label: "布尔台", value: "http://10.246.95.4:9999" },
+          { label: "大柳塔井", value: "http://10.248.135.10:9999" },
+          { label: "活鸡兔井", value: "http://10.248.135.121:9999" },
+          { label: "寸草塔二矿", value: "http://10.246.63.125:9999" },
+          { label: "乌兰木伦", value: "http://10.246.183.35:9999" },
+          { label: "察哈素", value: "http://10.120.120.164:9999" },
+          { label: "上湾", value: "http://10.246.167.205:9999" },
+          { label: "元子沟", value: "http://172.30.157.9:9999" },
+          { label: "开发", value: "http://182.92.126.35:9999" },
+          { label: "测试", value: "http://192.168.183.151:9999" },
+        ],
+      ],
+      fromSetting: false, // 是否来自设置页
+      ip: "",
+    };
+  },
+  onLoad(options) {
+    this.fromSetting = options.from === "settings"; // 判断来源
+    this.ip = uni.getStorageSync("serverIP") || ""; // 读取已存IP
+  },
+  computed: {},
+  methods: {
+    selectIpAddr(e) {
+      this.ipShow = false;
+      this.ip = e.value[0].value;
+      const fullURL = e.value[0].value;
+      this.IPSet = e.value[0].label;
+      configService.apiUrl = fullURL;
+      uni.setStorageSync("selectedIP", true);
+      uni.setStorageSync("apiUrl", fullURL);
+      // uni.showModal({
+      //   title: "提示",
+      //   content: fullURL,
+      //   cancelText: "取消",
+      //   confirmText: "确认",
+      // });
+      uni.redirectTo({
+        url: "/pages/login/login?reload=" + 1,
+      });
+    },
+    changeIP() {
+      this.ipShow = true;
+    },
+  },
+  beforeDestroy() {},
+};
+</script>
+
+<style>
+.login-paddingtop {
+  padding-top: 300upx;
+}
+.zai-box {
+  height: 100vh;
+  background-image: url(/static/desk-img/loginBg.png);
+  background-size: cover;
+  padding: 0 20upx;
+  padding-top: 100upx;
+  position: relative;
+}
+
+.zai-logo {
+  width: 200upx;
+  height: 150px;
+}
+
+.zai-title {
+  margin-top: 20upx;
+  font-size: 58upx;
+  color: #000000;
+  text-align: center;
+}
+
+.input-placeholder,
+.zai-input {
+  color: #94afce;
+}
+
+.zai-btn {
+  background: #ff65a3;
+  color: #fff;
+  border: 0;
+  border-radius: 100upx;
+  font-size: 36upx;
+}
+
+.zai-btn:after {
+  border: 0;
+}
+
+/*按钮点击效果*/
+.zai-btn.button-hover {
+  transform: translate(1upx, 1upx);
+}
+.IPSet {
+  display: flex;
+  flex-direction: column;
+}
+.text-style {
+  margin: 20px;
+}
+</style>

+ 64 - 7
pages/login/login.vue

@@ -1,7 +1,7 @@
   <template>
     <view class="zai-box">
-      <!-- <u-icon name="setting-fill" color="#2979ff" size="28" @tap="setIp()"></u-icon> -->
-      <scroll-view scroll-y class="page">
+      <u-icon name="setting-fill" color="#2979ff" size="28" @click="setIp"></u-icon>
+      <scroll-view scroll-y class="page" v-if="!ipShow">
         <view class="text-center" :style="[{ animation: 'show ' + 0.4 + 's 1' }]">
           <image src="/static/desk-img/logo.png" mode='aspectFit' class="zai-logo "></image>
         </view>
@@ -45,7 +45,7 @@
         <view class="gray-text">登录中...</view>
       </view>
       <scroll-view scroll-y  class="page" v-if="ipShow">
-        <view class="IPSet">
+        <!-- <view class="IPSet">
             <span class="text-style">IP地址:  <u--input
               placeholder="请输入IP地址"
               border="surround"
@@ -57,7 +57,27 @@
               v-model="PortValue"
             ></u--input></span>
             <span class="text-style"><u-button :plain="true" color="#18a5ff" size="small" @tap="saveIP()">保存</u-button></span>
-        </view>
+        </view> -->
+        <!-- <scroll-view scroll-y class="page"> -->
+      <view class="IPSet">
+        <span class="text-style"
+          ><u-button
+            :plain="true"
+            color="#18a5ff"
+            size="small"
+            :text="IPSet ? IPSet : '选择IP地址'"
+            @tap="changeIP()"
+          ></u-button
+        ></span>
+        <u-picker
+          :show="ipShow1"
+          :columns="IpConfig"
+          @cancel="ipShow = false"
+          @confirm="selectIpAddr"
+          keyName="label"
+        ></u-picker>
+      </view>
+    <!-- </scroll-view> -->
       </scroll-view>
     </view>
 
@@ -73,6 +93,7 @@ export default {
   data() {
     return {
       ipShow: false,
+      ipShow1: false,
       shape: "", //round 圆形
       loading: false,
       userName: "",
@@ -93,6 +114,21 @@ export default {
       IPValue: "",
       PortValue: "",
       fullIPVal: "", //完整IP地址
+      IPSet: "",
+      IpConfig: [
+        [
+          { label: "布尔台", value: "http://10.246.95.4:9999" },
+          { label: "大柳塔井", value: "http://10.248.135.10:9999" },
+          { label: "活鸡兔井", value: "http://10.248.135.121:9999" },
+          { label: "寸草塔二矿", value: "http://10.246.63.125:9999" },
+          { label: "乌兰木伦", value: "http://10.246.183.35:9999" },
+          { label: "察哈素", value: "http://10.120.120.164:9999" },
+          { label: "上湾", value: "http://10.246.167.205:9999" },
+          { label: "元子沟", value: "http://172.30.157.9:9999" },
+          { label: "开发", value: "http://182.92.126.35:9999" },
+          { label: "测试", value: "http://192.168.183.151:9999" },
+        ],
+      ],
     };
   },
   onLoad: function (option) {
@@ -219,7 +255,7 @@ export default {
             than.getPermissionList();
           })
           .catch((error) => {
-            debugger;
+            // debugger;
             console.log("catch===>response", error);
             // uni.navigateTo({
             //   url: "/pages/home/home",
@@ -255,7 +291,7 @@ export default {
       });
     },
     saveClientId() {
-          this.getPermissionList();
+      this.getPermissionList();
       // var info = plus.push.getClientInfo();
       // var cid = info.clientid;
       // this.$http
@@ -367,6 +403,11 @@ export default {
         url: "/pages/webview/webview?url=" + encodeURIComponent(url),
       });
     },
+    // setIp() {
+    //   uni.navigateTo({
+    //     url: "/pages/ipConfig/ipConfig",
+    //   });
+    // },
     //正则判断ip地址
     validateIP(ip) {
       const regex =
@@ -386,9 +427,11 @@ export default {
       this.validateIP(this.IPValue);
       this.validatePort(this.PortValue);
       if (this.validateIP(this.IPValue) && this.validatePort(this.PortValue)) {
+        this.ipShow = false;
         this.fullIPVal = `http://${this.IPValue}:${this.PortValue}`;
         configService.apiUrl = this.fullIPVal;
-        localStorage.setItem("apiUrl", apiUrl);
+        uni.setStorageSync("apiUrl", configService.apiUrl);
+        // localStorage.setItem("apiUrl", apiUrl);
       } else if (!this.validateIP(this.IPValue)) {
         alert("请填写正确的IP地址");
       } else if (!this.validatePort(this.PortValue)) {
@@ -397,6 +440,20 @@ export default {
         alert("请检查输入的IP地址或端口号");
       }
     },
+    changeIP() {
+      this.ipShow1 = true;
+    },
+    selectIpAddr(e) {
+      this.ipShow1 = false;
+      const fullURL = e.value[0].value;
+      this.IPSet = e.value[0].label;
+      configService.apiUrl = fullURL;
+      uni.setStorageSync("apiUrl", configService.apiUrl);
+      setTimeout(() => {
+        uni.getStorageSync("apiUrl");
+      }, 100);
+      uni.reLaunch({ url: "/pages/login/login" });
+    },
   },
   beforeDestroy() {
     if (this.smsCountInterval) {

+ 108 - 79
store/index.js

@@ -1,112 +1,141 @@
-import Vue from 'vue'
-import Vuex from 'vuex'
-import api from "@/api/api"
-import MinCache from '@/common/util/MinCache.js'
-import { ACCESS_TOKEN, USER_NAME, USER_INFO } from "@/common/util/constants"
+import Vue from "vue";
+import Vuex from "vuex";
+import api from "@/api/api";
+import MinCache from "@/common/util/MinCache.js";
+import { ACCESS_TOKEN, USER_NAME, USER_INFO } from "@/common/util/constants";
 
-Vue.use(Vuex)
+Vue.use(Vuex);
 
 export default new Vuex.Store({
   state: {
-    token: '',
-    userid: '',
-    username: '',
-    realname: '',
-    welcome: '',
-    avatar: '',
-    dicts: '',
+    token: "",
+    userid: "",
+    username: "",
+    realname: "",
+    welcome: "",
+    avatar: "",
+    dicts: "",
     showColum: {},
-    nfcreadtxt:'',
+    nfcreadtxt: "",
   },
   mutations: {
-    setNfcReadTxt(state,nfcreadtxt){
-      state.nfcreadtxt = nfcreadtxt
-  },
+    setNfcReadTxt(state, nfcreadtxt) {
+      state.nfcreadtxt = nfcreadtxt;
+    },
     SET_TOKEN: (state, token) => {
-      state.token = token
+      state.token = token;
     },
     SET_NAME: (state, { username, realname, welcome }) => {
-      state.username = username
-      state.realname = realname
-      state.welcome = welcome
+      state.username = username;
+      state.realname = realname;
+      state.welcome = welcome;
     },
     SET_AVATAR: (state, avatar) => {
-      state.avatar = avatar
+      state.avatar = avatar;
     },
     SET_SHOWCOLUM: (state, showColum) => {
-      state.showColum = showColum
+      state.showColum = showColum;
     },
     SET_DICT: (state, dicts) => {
-      state.dicts = dicts
-    }
+      state.dicts = dicts;
+    },
   },
   actions: {
     // 登录
     mLogin({ commit }, userInfo) {
       return new Promise((resolve, reject) => {
-        api.login(userInfo).then(response => {
-          if (response.data.code == 200) {
-            const result = response.data.result
-            const userInfo = result.userInfo
-            uni.setStorageSync(ACCESS_TOKEN, result.token);
-            uni.setStorageSync(USER_INFO, userInfo);
-            commit('SET_TOKEN', result.token)
-            commit('SET_DICT', result.sysAllDictItems)
-            commit('SET_AVATAR', userInfo.avatar)
-            commit('SET_NAME', { username: userInfo.username, realname: userInfo.realname })
-            resolve(response)
-          } else {
-            resolve(response)
-          }
-        }).catch(error => {
-          console.log("catch===>response", response)
-          reject(error)
-        })
-      })
+        api
+          .login(userInfo)
+          .then((response) => {
+            if (response.data?.code == 200) {
+              const result = response.data.result;
+              const userInfo = result.userInfo;
+              uni.setStorageSync(ACCESS_TOKEN, result.token);
+              uni.setStorageSync(USER_INFO, userInfo);
+              commit("SET_TOKEN", result.token);
+              commit("SET_DICT", result.sysAllDictItems);
+              commit("SET_AVATAR", userInfo.avatar);
+              commit("SET_NAME", {
+                username: userInfo.username,
+                realname: userInfo.realname,
+              });
+              resolve(response);
+            } else {
+              resolve(response);
+            }
+          })
+          .catch((error) => {
+            console.log("catch===>response", response);
+            reject(error);
+          });
+      });
     },
     //手机号登录
     PhoneLogin({ commit }, userInfo) {
       return new Promise((resolve, reject) => {
-        api.phoneNoLogin(userInfo).then(response => {
-          if (response.data.code == 200) {
-            const result = response.data.result
-            const userInfo = result.userInfo
-            uni.setStorageSync(ACCESS_TOKEN, result.token);
-            uni.setStorageSync(USER_INFO, userInfo);
-            commit('SET_TOKEN', result.token)
-            commit('SET_NAME', { username: userInfo.username, realname: userInfo.realname })
-            commit('SET_AVATAR', userInfo.avatar)
-            resolve(response)
-          } else {
-            reject(response)
-          }
-        }).catch(error => {
-          reject(error)
-        })
-      })
+        api
+          .phoneNoLogin(userInfo)
+          .then((response) => {
+            if (response.data.code == 200) {
+              const result = response.data.result;
+              const userInfo = result.userInfo;
+              uni.setStorageSync(ACCESS_TOKEN, result.token);
+              uni.setStorageSync(USER_INFO, userInfo);
+              commit("SET_TOKEN", result.token);
+              commit("SET_NAME", {
+                username: userInfo.username,
+                realname: userInfo.realname,
+              });
+              commit("SET_AVATAR", userInfo.avatar);
+              resolve(response);
+            } else {
+              reject(response);
+            }
+          })
+          .catch((error) => {
+            reject(error);
+          });
+      });
     },
     // 登出
     Logout({ commit, state }) {
       return new Promise((resolve) => {
         let logoutToken = state.token;
-        commit('SET_TOKEN', '')
-        uni.removeStorageSync(ACCESS_TOKEN)
-        api.logout(logoutToken).then(() => {
-          resolve()
-        }).catch(() => {
-          resolve()
-        })
-      })
+        commit("SET_TOKEN", "");
+        uni.removeStorageSync(ACCESS_TOKEN);
+        api
+          .logout(logoutToken)
+          .then(() => {
+            resolve();
+          })
+          .catch(() => {
+            resolve();
+          });
+      });
     },
-
   },
   getters: {
-    token: state => state.token,
-    username: state => { state.userid = uni.getStorageSync(USER_INFO).username; return state.username },
-    nickname: state => { state.userid = uni.getStorageSync(USER_INFO).realname; return state.user.realname },
-    avatar: state => { state.userid = uni.getStorageSync(USER_INFO).avatar; return state.user.avatar },
-    userid: state => { state.userid = uni.getStorageSync(USER_INFO).id; return state.userid },
-    showColum: state => { state.userid = uni.getStorageSync(USER_INFO).showColum; return state.showColum },
-    nfcreadtxt: state => state.nfcreadtxt
-  }
-})
+    token: (state) => state.token,
+    username: (state) => {
+      state.userid = uni.getStorageSync(USER_INFO).username;
+      return state.username;
+    },
+    nickname: (state) => {
+      state.userid = uni.getStorageSync(USER_INFO).realname;
+      return state.user.realname;
+    },
+    avatar: (state) => {
+      state.userid = uni.getStorageSync(USER_INFO).avatar;
+      return state.user.avatar;
+    },
+    userid: (state) => {
+      state.userid = uni.getStorageSync(USER_INFO).id;
+      return state.userid;
+    },
+    showColum: (state) => {
+      state.userid = uni.getStorageSync(USER_INFO).showColum;
+      return state.showColum;
+    },
+    nfcreadtxt: (state) => state.nfcreadtxt,
+  },
+});