2024-10-18 14:49:08 +00:00
|
|
|
<template>
|
2024-11-06 12:43:48 +00:00
|
|
|
<view class="container">
|
|
|
|
<view class="order-tabs">
|
|
|
|
<view
|
|
|
|
class="tab-item"
|
|
|
|
:class="{ active: orderStatus === '全部', selected: isSelected('全部') }"
|
|
|
|
@click="changeTab('全部')"
|
|
|
|
>
|
|
|
|
全部
|
|
|
|
</view>
|
|
|
|
<view
|
|
|
|
class="tab-item"
|
|
|
|
:class="{ active: orderStatus === '待支付', selected: isSelected('待支付') }"
|
|
|
|
@click="changeTab('待支付')"
|
|
|
|
>
|
|
|
|
待支付
|
|
|
|
</view>
|
|
|
|
<view
|
|
|
|
class="tab-item"
|
|
|
|
:class="{ active: orderStatus === '待发货', selected: isSelected('待发货') }"
|
|
|
|
@click="changeTab('待发货')"
|
|
|
|
>
|
|
|
|
待发货
|
|
|
|
</view>
|
|
|
|
<view
|
|
|
|
class="tab-item"
|
|
|
|
:class="{ active: orderStatus === '已发货', selected: isSelected('已发货') }"
|
|
|
|
@click="changeTab('已发货')"
|
|
|
|
>
|
|
|
|
已发货
|
|
|
|
</view>
|
|
|
|
<view
|
|
|
|
class="tab-item"
|
|
|
|
:class="{ active: orderStatus === '售后', selected: isSelected('售后') }"
|
|
|
|
@click="changeTab('售后')"
|
|
|
|
>
|
|
|
|
售后
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="order-list">
|
|
|
|
<view v-for="order in Status.displayedOrders" :key="order.id" class="order-item">
|
|
|
|
{{order.orderStatus}}
|
|
|
|
<view v-for="item in order.orderItemList" :key="item.id">
|
|
|
|
<image :src="item.goodSnapshot.goodImg" style="height: 50px;width: 50px;"></image>
|
|
|
|
</view>
|
|
|
|
<view v-for="item in order.orderItemList" :key="item.id">
|
|
|
|
{{ item.goodSnapshot.name }}
|
|
|
|
</view>
|
|
|
|
<view v-for="item in order.orderItemList" :key="item.id">
|
|
|
|
{{ item.goodSnapshot.type }}
|
|
|
|
</view>
|
|
|
|
<view v-for="item in order.orderItemList" :key="item.id">
|
|
|
|
{{ item.goodSnapshot.price }}
|
|
|
|
</view>
|
|
|
|
<view v-if="order.orderStatus==='待支付'" >去支付</view>
|
|
|
|
<view v-if="order.orderStatus==='待发货'" >取消订单</view>
|
|
|
|
<view v-if="order.orderStatus==='已发货'" >确认收货</view>
|
|
|
|
<view v-if="order.orderStatus==='售后'" >售后详情</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
2024-10-18 14:49:08 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
2024-11-06 12:43:48 +00:00
|
|
|
import { ref, onMounted, toRaw } from 'vue';
|
|
|
|
import { baseUrl, testUrl, suiUrl } from '@/api/request';
|
2024-11-05 12:08:32 +00:00
|
|
|
const currentColor = ref(0);
|
2024-11-06 12:43:48 +00:00
|
|
|
onMounted(async () => {
|
|
|
|
await Getorder();
|
2024-11-06 00:30:21 +00:00
|
|
|
Status.displayedOrders = Status.orders;
|
2024-11-05 12:08:32 +00:00
|
|
|
});
|
2024-11-06 12:43:48 +00:00
|
|
|
const userInfo = ref({
|
|
|
|
userInfo: uni.getStorageSync('userInfo'),
|
|
|
|
});
|
2024-11-06 00:30:21 +00:00
|
|
|
const Getorder = async () => {
|
|
|
|
const res = await uni.request({
|
|
|
|
url: baseUrl + '/order/list',
|
|
|
|
method: 'POST',
|
|
|
|
data: {
|
2024-11-06 12:43:48 +00:00
|
|
|
// id:userInfo.value.userInfo.id,
|
|
|
|
id: 215,
|
|
|
|
},
|
|
|
|
});
|
2024-11-06 00:30:21 +00:00
|
|
|
if (res.data.code === 1) {
|
2024-11-06 12:43:48 +00:00
|
|
|
Status.value.orders = res.data.data;
|
|
|
|
} else {
|
|
|
|
console.log('没拿到用户数据');
|
2024-11-06 00:30:21 +00:00
|
|
|
}
|
|
|
|
};
|
2024-11-06 12:43:48 +00:00
|
|
|
const Status = ref({
|
|
|
|
orderStatus: '全部',
|
|
|
|
orders: [],
|
|
|
|
displayedOrders: [],
|
|
|
|
});
|
2024-11-06 00:30:21 +00:00
|
|
|
const changeTab = (tab) => {
|
|
|
|
if (tab === '全部') {
|
|
|
|
Status.value.displayedOrders = Status.value.orders;
|
2024-11-06 12:43:48 +00:00
|
|
|
Status.value.orderStatus = '全部';
|
2024-11-06 00:30:21 +00:00
|
|
|
} else {
|
2024-11-06 12:43:48 +00:00
|
|
|
Status.value.displayedOrders = Status.value.orders.filter((order) => {
|
2024-11-06 00:30:21 +00:00
|
|
|
switch (tab) {
|
|
|
|
case '待支付':
|
2024-11-06 12:43:48 +00:00
|
|
|
return order.orderStatus === '待支付';
|
|
|
|
case '待发货':
|
|
|
|
return order.orderStatus === '待发货';
|
2024-11-06 00:30:21 +00:00
|
|
|
case '已发货':
|
|
|
|
return order.orderStatus === '已发货';
|
|
|
|
case '售后':
|
|
|
|
return order.orderStatus === '售后';
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
2024-11-06 12:43:48 +00:00
|
|
|
Status.value.orderStatus = tab;
|
2024-11-06 00:30:21 +00:00
|
|
|
}
|
2024-11-06 12:43:48 +00:00
|
|
|
};
|
|
|
|
const isSelected = (tab) => Status.value.orderStatus === tab;
|
2024-10-18 14:49:08 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2024-11-06 00:30:21 +00:00
|
|
|
.container {
|
2024-11-06 12:43:48 +00:00
|
|
|
padding-bottom: 20px;
|
2024-10-18 14:49:08 +00:00
|
|
|
}
|
2024-11-06 00:30:21 +00:00
|
|
|
|
|
|
|
.order-tabs {
|
2024-11-05 12:08:32 +00:00
|
|
|
display: flex;
|
2024-11-06 00:30:21 +00:00
|
|
|
justify-content: space-around;
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
padding: 10px 0;
|
2024-10-18 14:49:08 +00:00
|
|
|
}
|
2024-11-05 12:08:32 +00:00
|
|
|
|
2024-11-06 00:30:21 +00:00
|
|
|
.tab-item {
|
|
|
|
cursor: pointer;
|
|
|
|
padding: 5px 10px;
|
2024-10-18 14:49:08 +00:00
|
|
|
}
|
2024-11-06 00:30:21 +00:00
|
|
|
|
|
|
|
.tab-item.active {
|
|
|
|
color: blue;
|
2024-10-18 14:49:08 +00:00
|
|
|
}
|
2024-11-06 12:43:48 +00:00
|
|
|
|
|
|
|
.tab-item.selected {
|
|
|
|
background-color: brown;
|
|
|
|
color: white;
|
2024-10-18 14:49:08 +00:00
|
|
|
}
|
2024-11-06 00:30:21 +00:00
|
|
|
|
|
|
|
.order-list {
|
2024-11-06 12:43:48 +00:00
|
|
|
margin: 10px 10px 0 10px;
|
2024-10-18 14:49:08 +00:00
|
|
|
}
|
2024-11-06 00:30:21 +00:00
|
|
|
|
|
|
|
.order-item {
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
padding: 10px;
|
|
|
|
margin-bottom: 10px;
|
2024-10-18 14:49:08 +00:00
|
|
|
}
|
|
|
|
@import url(../../../common/css/global.css);
|
2024-11-05 12:08:32 +00:00
|
|
|
</style>
|