【类 型】:feat

【主	题】:订单相关
【描	述】:
	[原因]:
	[过程]:订单页面  vux订单值,设置值方法 ,异步接口获取订单列表
	[影响]:
【结	束】

# 类型 包含:
# feat:新功能(feature)
# fix:修补bug
# docs:文档(documentation)
# style: 格式(不影响代码运行的变动)
# refactor:重构(即不是新增功能,也不是修改bug的代码变动)
# test:增加测试
# chore:构建过程或辅助工具的变动
This commit is contained in:
szdot 2024-06-06 01:44:07 +08:00
parent b409210546
commit 6169b90c0d
4 changed files with 74 additions and 16 deletions

View File

@ -13,10 +13,12 @@
</navigator>
<u-icon name="arrow-right"></u-icon>
</view>
<view class="flex column mc mac m-r-24 w-80rpx h-80rpx">
<u-icon size="48rpx" name="order"></u-icon>
<view class="fz24">订单</view>
</view>
<navigator url="/pages/main/order">
<view class="flex column mc mac m-r-24 w-80rpx h-80rpx">
<u-icon size="48rpx" name="order"></u-icon>
<view class="fz24">订单</view>
</view>
</navigator>
</view>
<!-- 主按钮 -->
<view class="flex mse" style="height: 222rpx;margin-top: 30rpx;">

View File

@ -6,6 +6,25 @@
<u-icon name="arrow-left" color="#fff" size="19"></u-icon>
</view>
</u-navbar>
<!-- tabs -->
<u-subsection :list="list" :current="curNow" @change="sectionChange"></u-subsection>
<!-- tabBoxs -->
<!-- 未付款 -->
<view v-if="curNow===0">
<view v-for="item in orderList" :key="item.id" v-if="item.status === 'unpaid' && item.back === 'normal'">
订单号: {{item.order_sn}}
</view>
</view>
<view v-if="curNow===1">
<view v-for="item in orderList" :key="item.id" v-if="item.status !== 'unpaid' && item.back === 'normal'">
订单号: {{item.order_sn}}
</view>
</view>
<view v-if="curNow===2">
<view v-for="item in orderList" :key="item.id" v-if="item.back !== 'normal'">
订单号: {{item.order_sn}}
</view>
</view>
</view>
</template>
@ -13,11 +32,25 @@
export default {
data() {
return {
list: ['未付款', '已付款', '申请售后'],
curNow: 0
}
},
computed: {
orderList() {
return this.$store.state.orderList
}
},
methods: {
sectionChange(index) {
this.curNow = index;
}
},
onLoad() {
this.$store.dispatch('fetchOrderList')
setTimeout(()=> {
console.log(this.orderList)
}, 2000);
}
}
</script>

View File

@ -30,6 +30,7 @@ const store = new Vuex.Store({
topic_prefix: null
}, //用户信息
orderList: [], //订单列表
siteList: [], //站点列表
menuList: [], //分类列表
spuList: [], //spu列表
@ -44,16 +45,16 @@ const store = new Vuex.Store({
//修改状态
mutations: {
//设置 列表页 购物车折叠显隐
setCartShow(state,val){
Vue.set(state,'cartShow', val)
setCartShow(state, val) {
Vue.set(state, 'cartShow', val)
},
//设置 标记用户登录状态
setMqttState(state,val){
Vue.set(state,'mqttState', val)
setMqttState(state, val) {
Vue.set(state, 'mqttState', val)
},
//设置tabbar当前激活像
setTabbarCurrent(state,val){
Vue.set(state,'tabbarCurrent', val)
setTabbarCurrent(state, val) {
Vue.set(state, 'tabbarCurrent', val)
},
//把用户信息 从本地缓存 提取到内存当中
setUserInfo(state, obj) {
@ -73,6 +74,10 @@ const store = new Vuex.Store({
Vue.set(state.userInfo, 'token', null)
Vue.set(state.userInfo, 'topic_prefix', null)
},
//设置订单列表
setOrderList(state, list) {
state.orderList = list
},
//设置站点列表
setSiteList(state, list) {
state.siteList = list
@ -94,8 +99,8 @@ const store = new Vuex.Store({
state.shopCon = obj
},
//清空购物车
clearCartList(state){
Vue.set(state,'cartList', [])
clearCartList(state) {
Vue.set(state, 'cartList', [])
},
// 设置购物车列表
setCartList(state, obj) {
@ -150,6 +155,24 @@ const store = new Vuex.Store({
},
//异步修改
actions: {
//获取订单列表
fetchOrderList({
state,
commit
}) {
uni.$u.http.get('/Api/Check/getOrderList', {
header:{
'Token': state.userInfo.token,
}
}).then(res => {
if (res.data.status === 1) {
//更新数据
commit('setOrderList', res.data.orderList)
} else {
commit('setSiteList', [])
}
})
},
//获取站点列表
fetchSiteList({
state,

View File

@ -135,7 +135,7 @@ export function totalPrice(cartList) {
* 检查用户信息登录 信息
*/
export function checkUserInfo() {
//检查是否已经标记登录了
//刚打开app token未赋值到内存时
if (store.state.userInfo.token === null) {
//先从storage里调取token
uni.getStorage({
@ -165,7 +165,7 @@ export function checkUserInfo() {
wxLogin()
}
})
} else {
} else { //内存中已经赋值了token时
//验证token
isTokenValid().then((isValid) => {
if (isValid.data.status === -1) { //token验证失败或过期