shish 5 лет назад
Родитель
Сommit
2cb30f563a

+ 1 - 1
ghsApp/src/admin/home/workbench.vue

@@ -310,7 +310,7 @@ export default {
 			if(!uni.getStorageSync('token')){
 				setTimeout(()=>{
 					this.init();
-				},200);
+				},100);
 			}else{
 				getUser().then(res => {
 					uni.setNavigationBarTitle({

+ 1 - 1
ghsApp/src/mixins/priceSocket.js

@@ -19,7 +19,7 @@ export default {
 			if(!uni.getStorageSync('token')){
 				setTimeout(()=>{
 					this.priceSocketFun();
-				},200);
+				},100);
 			}else{
 				this.priceSocket = new SocketUtil({
 					onOpen: () => {},

+ 34 - 25
hdApp/src/admin/home/workbench.vue

@@ -308,33 +308,42 @@ export default {
       this.$util.pageTo(item)
     },
     init () {
-      getUser().then(res => {
-        uni.setNavigationBarTitle({
-          title: res.name
+
+			/*延迟监听token*/
+			if(!uni.getStorageSync('token')){
+				setTimeout(()=>{
+					this.init();
+				},100);
+			}else{
+        getUser().then(res => {
+          uni.setNavigationBarTitle({
+            title: res.name
+          });
+
+          let nowTime = getDataTimestamp(new Date(), true);
+          if (nowTime > res.setDeadline) {
+            this.renewMask = true;
+          }
+        });
+        consoleIndex().then(res => {
+          this.data = res.data;
+          const { asset, todayData } = res.data;
+          if (!this.$util.isEmpty(asset)) {
+            // 订单总览
+            this.orderData[0].value = asset.unSendOrder;
+            this.orderData[1].value = asset.sendingOrder;
+            this.orderData[2].value = todayData.order;
+            // 总览数据
+            this.totalData[0].value = asset.totalUser;
+            this.totalData[1].value = asset.totalMember;
+            this.totalData[2].value = asset.totalVisit;
+            this.totalData[3].value = asset.totalIncome;
+            this.totalData[4].value = asset.totalExpend;
+            this.totalData[5].value = asset.remainSmsNum;
+          }
         });
+      }
 
-        let nowTime = getDataTimestamp(new Date(), true);
-        if (nowTime > res.setDeadline) {
-          this.renewMask = true;
-        }
-      });
-      consoleIndex().then(res => {
-        this.data = res.data;
-        const { asset, todayData } = res.data;
-        if (!this.$util.isEmpty(asset)) {
-          // 订单总览
-          this.orderData[0].value = asset.unSendOrder;
-          this.orderData[1].value = asset.sendingOrder;
-          this.orderData[2].value = todayData.order;
-          // 总览数据
-          this.totalData[0].value = asset.totalUser;
-          this.totalData[1].value = asset.totalMember;
-          this.totalData[2].value = asset.totalVisit;
-          this.totalData[3].value = asset.totalIncome;
-          this.totalData[4].value = asset.totalExpend;
-          this.totalData[5].value = asset.remainSmsNum;
-        }
-      });
     },
     // 跳转
     pageToFn (page) {

+ 34 - 21
hdApp/src/mixins/priceSocket.js

@@ -10,28 +10,41 @@ export default {
 		};
 	},
 	onLaunch() {
-		this.priceSocket = new SocketUtil({
-			onOpen: () => {},
-			onMessage: data => {
-				let type = data.type || "";
-				switch (type) {
-					case "init":
-						let clientId = data.client_id;
+		this.priceSocketFun();
 
-						initSocket(clientId);
-						break;
-					case "money":
-						//到账消息    data:  {type: "money", msg: "微信到账1.2", money: 1.2}
-						console.log(data);
+	},
+	methods:{
+		/*延迟监听token*/
+		priceSocketFun(){
+			if(!uni.getStorageSync('token')){
+				setTimeout(()=>{
+					this.priceSocketFun();
+				},100);
+			}else{
+				this.priceSocket = new SocketUtil({
+					onOpen: () => {},
+					onMessage: data => {
+						let type = data.type || "";
+						switch (type) {
+							case "init":
+								let clientId = data.client_id;
+
+								initSocket(clientId);
+								break;
+							case "money":
+								//到账消息    data:  {type: "money", msg: "微信到账1.2", money: 1.2}
+								console.log(data);
 
-						this.playPriceAudio(data.money);
-						break;
-					default:
-						console.log("default");
-				}
-			},
-			onClose: () => {},
-			onError: () => {}
-		});
+								this.playPriceAudio(data.money);
+								break;
+							default:
+								console.log("default");
+						}
+					},
+					onClose: () => {},
+					onError: () => {}
+				});
+			}
+		},
 	}
 };