Compare commits
5 Commits
6169b90c0d
...
852ad87465
Author | SHA1 | Date | |
---|---|---|---|
![]() |
852ad87465 | ||
![]() |
1cbfd0ae03 | ||
![]() |
1efa9308f2 | ||
![]() |
be06835a6d | ||
![]() |
3c35089f07 |
10
App.vue
10
App.vue
@ -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添加最低价格字段
|
||||||
|
@ -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)
|
||||||
|
@ -48,9 +48,6 @@
|
|||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.$store.dispatch('fetchOrderList')
|
this.$store.dispatch('fetchOrderList')
|
||||||
setTimeout(()=> {
|
|
||||||
console.log(this.orderList)
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -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) => {
|
||||||
|
if(res.status===1){
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '支付成功',
|
title: '支付成功',
|
||||||
icon: 'success'
|
icon: 'success'
|
||||||
});
|
})
|
||||||
// 可以在这里处理支付成功后的逻辑
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '支付失败',
|
title: '支付失败',
|
||||||
icon: 'none'
|
icon: 'error'
|
||||||
});
|
});
|
||||||
console.error(err);
|
console.error(err)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
@ -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('有订单更新')
|
||||||
|
}) //更新订单
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user