From 852ad874654d1f75c8d4d2576b8c41ac085efe74 Mon Sep 17 00:00:00 2001 From: tk Date: Wed, 12 Jun 2024 18:47:15 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=09=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E4=B8=BB=09=E9=A2=98=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E9=A6=96=E6=AC=A1=E8=BF=9B=E5=85=A5=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E6=97=B6=20=E5=8D=B3=E9=A6=96=E6=AC=A1=E8=A7=81=E6=AD=A4?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=97=B6=20=E8=8E=B7=E5=8F=96=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=EF=BC=8C=E8=AE=A2?= =?UTF-8?q?=E9=98=85=E8=AE=A2=E8=AE=A2=E5=8D=95=E6=9C=89=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=97=B6=20=E5=88=B7=E6=96=B0=E8=AE=A2=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=20=E3=80=90=E6=8F=8F=09=E8=BF=B0=E3=80=91=EF=BC=9A=20?= =?UTF-8?q?=09[=E5=8E=9F=E5=9B=A0]=EF=BC=9A=E5=AE=9E=E7=8E=B0=E5=AE=9E?= =?UTF-8?q?=E6=97=B6=E6=98=BE=E7=A4=BA=E8=AE=A2=E5=8D=95=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=20=09[=E8=BF=87=E7=A8=8B]=EF=BC=9A=20=09[=E5=BD=B1=E5=93=8D]?= =?UTF-8?q?=EF=BC=9A=20=E3=80=90=E7=BB=93=09=E6=9D=9F=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动 --- pages/main/order.vue | 3 --- store/index.js | 2 +- utils/index.js | 10 ++++++++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pages/main/order.vue b/pages/main/order.vue index 5ad2fc3..74d6f1d 100644 --- a/pages/main/order.vue +++ b/pages/main/order.vue @@ -48,9 +48,6 @@ }, onLoad() { this.$store.dispatch('fetchOrderList') - setTimeout(()=> { - console.log(this.orderList) - }, 2000); } } diff --git a/store/index.js b/store/index.js index 54c41fe..bff4b27 100644 --- a/store/index.js +++ b/store/index.js @@ -153,7 +153,7 @@ const store = new Vuex.Store({ }) } }, - //异步修改 + //异步请求 actions: { //获取订单列表 async fetchOrderList({ diff --git a/utils/index.js b/utils/index.js index e6b9d3a..d368ab0 100644 --- a/utils/index.js +++ b/utils/index.js @@ -157,6 +157,8 @@ export function checkUserInfo() { initMqtt() //连接mqtt 并订阅 和执行回调逻辑 store.commit('setMqttState', true) //标记订阅 } + //登录成功后更新一次订单列表 + store.dispatch('fetchOrderList') } }) }, @@ -225,6 +227,8 @@ export function wxLogin() { success: () => { //登录成功后 把用户信息提取到内存 store.commit('setUserInfo', res.data.userInfo) + //登录成功后更新一次订单列表 + store.dispatch('fetchOrderList') } }) } @@ -250,10 +254,12 @@ function initMqtt() { /* mqtt */ mqtt.mqttConf() // 连接mqtt // 订阅游客下单频道 - const topic = `refreshQuestList/${store.state.userInfo.topic_prefix}` + const topic = `refreshOrderList/${store.state.userInfo.topic_prefix}` mqtt.doSubscribe(topic, (res) => { if (res.topic.indexOf(topic) > -1) { - console.log('新订单') + store.dispatch('fetchOrderList').then(()=>{ + console.log('有订单更新') + }) //更新订单 } }) } \ No newline at end of file