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