【类 型】:feat

【主	题】:首次进入主页时 即首次见此登录时 获取一次订单列表,订阅订订单有更新时 刷新订单列表
【描	述】:
	[原因]:实现实时显示订单信息
	[过程]:
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
tk 2024-06-12 18:47:15 +08:00
parent 1cbfd0ae03
commit 852ad87465
3 changed files with 9 additions and 6 deletions

View File

@ -48,9 +48,6 @@
},
onLoad() {
this.$store.dispatch('fetchOrderList')
setTimeout(()=> {
console.log(this.orderList)
}, 2000);
}
}
</script>

View File

@ -153,7 +153,7 @@ const store = new Vuex.Store({
})
}
},
//异步修改
//异步请求
actions: {
//获取订单列表
async fetchOrderList({

View File

@ -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('有订单更新')
}) //更新订单
}
})
}