Compare commits

...

5 Commits

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

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-06-12 18:47:15 +08:00
tk
1cbfd0ae03 【类 型】:feat
【主	题】:主页显示 已付款订单信息 实时显示
【描	述】:
	[原因]:
	[过程]:
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-06-12 18:43:35 +08:00
tk
1efa9308f2 【类 型】:style
【主	题】:取消多余判断
【描	述】:
	[原因]:入口时直接请求接口 获取数据 不用判断有没有
	[过程]:
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-06-12 18:42:20 +08:00
tk
be06835a6d 【类 型】:refactor
【主	题】:actions 函数 加上async await关键字
【描	述】:
	[原因]:之前并没有做异步请求的处理
	[过程]:
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-06-12 17:36:24 +08:00
tk
3c35089f07 【类 型】:feat
【主	题】:支付失败 弹出提示框 打印失败原因
【描	述】:
	[原因]:
	[过程]:
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
2024-06-12 14:43:07 +08:00
6 changed files with 50 additions and 37 deletions

20
App.vue
View File

@ -3,27 +3,17 @@
// //
onLaunch: function() { onLaunch: function() {
// //
if (Object.keys(this.$store.state.shopCon).length === 0) { this.$store.dispatch('fetchShopCon')
this.$store.dispatch('fetchShopCon')
}
// //
if (this.$store.state.siteList.length === 0) { this.$store.dispatch('fetchSiteList')
this.$store.dispatch('fetchSiteList')
}
// //
if (this.$store.state.menuList.length === 0) { this.$store.dispatch('fetchMenuList')
this.$store.dispatch('fetchMenuList')
}
// Promise // Promise
const promises = []; const promises = [];
//spu //spu
if (this.$store.state.spuList.length === 0) { promises.push(this.$store.dispatch('fetchSpuList'))
promises.push(this.$store.dispatch('fetchSpuList'))
}
//sku //sku
if (this.$store.state.skuList.length === 0) { promises.push(this.$store.dispatch('fetchSkuList'))
promises.push(this.$store.dispatch('fetchSkuList'))
}
//sku spu //sku spu
Promise.all(promises).then(() => { Promise.all(promises).then(() => {
this.$store.commit('addMinPriceToSpuList') //spu this.$store.commit('addMinPriceToSpuList') //spu

View File

@ -20,6 +20,14 @@
</view> </view>
</navigator> </navigator>
</view> </view>
<!-- 新订单 提示框 -->
<!-- 新订单提示框 -->
<view v-for="(item, index) in orderList" :key="index">
订单{{ item.order_sn }}
<text v-if="item.status === 'pending'">状态已付款</text>
<text v-else-if="item.status === 'processing'">状态备货中</text>
<text v-else-if="item.status === 'shipped'">状态已发货</text>
</view>
<!-- 主按钮 --> <!-- 主按钮 -->
<view class="flex mse" style="height: 222rpx;margin-top: 30rpx;"> <view class="flex mse" style="height: 222rpx;margin-top: 30rpx;">
<navigator url="/pages/shop/list"> <navigator url="/pages/shop/list">
@ -57,6 +65,11 @@
computed: { computed: {
userInfo() { userInfo() {
return this.$store.state.userInfo return this.$store.state.userInfo
},
//
orderList() {
const validStatuses = ['pending', 'processing', 'shipped'];
return this.$store.state.orderList.filter(item => validStatuses.includes(item.status));
} }
}, },
onReady() { onReady() {
@ -67,9 +80,9 @@
this.checkUserInfo() this.checkUserInfo()
// tabber // tabber
this.$store.commit('setTabbarCurrent', 0) this.$store.commit('setTabbarCurrent', 0)
console.log(this.orderList)
}, },
methods: { methods: {
// //
checkUserInfo() { checkUserInfo() {
return checkUserInfo(this.$store) return checkUserInfo(this.$store)

View File

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

View File

@ -34,6 +34,12 @@
if (res.data.status === 1) { if (res.data.status === 1) {
// //
this.requestPayment(res.data.payMsg); this.requestPayment(res.data.payMsg);
}else{
uni.showToast({
title: '支付失败',
icon: 'error'
});
console.error(res.data.msg)
} }
}) })
}, },
@ -46,18 +52,19 @@
signType: payMsg.signType, signType: payMsg.signType,
paySign: payMsg.paySign, paySign: payMsg.paySign,
success: (res) => { success: (res) => {
uni.showToast({ if(res.status===1){
title: '支付成功', uni.showToast({
icon: 'success' title: '支付成功',
}); icon: 'success'
// })
}
}, },
fail: (err) => { fail: (err) => {
uni.showToast({ uni.showToast({
title: '支付失败', title: '支付失败',
icon: 'none' icon: 'error'
}); });
console.error(err); console.error(err)
} }
}); });
}, },

View File

@ -153,14 +153,14 @@ const store = new Vuex.Store({
}) })
} }
}, },
//异步修改 //异步请求
actions: { actions: {
//获取订单列表 //获取订单列表
fetchOrderList({ async fetchOrderList({
state, state,
commit commit
}) { }) {
uni.$u.http.get('/Api/Check/getOrderList', { await uni.$u.http.get('/Api/Check/getOrderList', {
header:{ header:{
'Token': state.userInfo.token, 'Token': state.userInfo.token,
} }
@ -174,11 +174,11 @@ const store = new Vuex.Store({
}) })
}, },
//获取站点列表 //获取站点列表
fetchSiteList({ async fetchSiteList({
state, state,
commit commit
}) { }) {
uni.$u.http.get('/Api/Normal/getSiteList', { await uni.$u.http.get('/Api/Normal/getSiteList', {
params: { params: {
shop_id: state.shop_id shop_id: state.shop_id
} }
@ -199,11 +199,11 @@ const store = new Vuex.Store({
}) })
}, },
//获取分类列表 //获取分类列表
fetchMenuList({ async fetchMenuList({
state, state,
commit commit
}) { }) {
uni.$u.http.get('/Api/Normal/getCategoryList', { await uni.$u.http.get('/Api/Normal/getCategoryList', {
params: { params: {
shop_id: state.shop_id shop_id: state.shop_id
} }
@ -294,11 +294,11 @@ const store = new Vuex.Store({
}) })
}, },
//获取商品信息 //获取商品信息
fetchShopCon({ async fetchShopCon({
state, state,
commit commit
}) { }) {
uni.$u.http.get('/Api/Normal/getShopCon', { await uni.$u.http.get('/Api/Normal/getShopCon', {
params: { params: {
shop_id: state.shop_id shop_id: state.shop_id
} }

View File

@ -157,6 +157,8 @@ export function checkUserInfo() {
initMqtt() //连接mqtt 并订阅 和执行回调逻辑 initMqtt() //连接mqtt 并订阅 和执行回调逻辑
store.commit('setMqttState', true) //标记订阅 store.commit('setMqttState', true) //标记订阅
} }
//登录成功后更新一次订单列表
store.dispatch('fetchOrderList')
} }
}) })
}, },
@ -225,6 +227,8 @@ export function wxLogin() {
success: () => { success: () => {
//登录成功后 把用户信息提取到内存 //登录成功后 把用户信息提取到内存
store.commit('setUserInfo', res.data.userInfo) store.commit('setUserInfo', res.data.userInfo)
//登录成功后更新一次订单列表
store.dispatch('fetchOrderList')
} }
}) })
} }
@ -250,10 +254,12 @@ function initMqtt() {
/* mqtt */ /* mqtt */
mqtt.mqttConf() // 连接mqtt mqtt.mqttConf() // 连接mqtt
// 订阅游客下单频道 // 订阅游客下单频道
const topic = `refreshQuestList/${store.state.userInfo.topic_prefix}` const topic = `refreshOrderList/${store.state.userInfo.topic_prefix}`
mqtt.doSubscribe(topic, (res) => { mqtt.doSubscribe(topic, (res) => {
if (res.topic.indexOf(topic) > -1) { if (res.topic.indexOf(topic) > -1) {
console.log('新订单') store.dispatch('fetchOrderList').then(()=>{
console.log('有订单更新')
}) //更新订单
} }
}) })
} }