Files
shoot-miniprograms/src/pages/orders.vue

103 lines
2.3 KiB
Vue
Raw Normal View History

2025-05-28 15:00:31 +08:00
<script setup>
2025-07-01 00:25:17 +08:00
import { ref } from "vue";
2025-05-28 15:00:31 +08:00
import Container from "@/components/Container.vue";
2025-07-01 00:25:17 +08:00
import ScrollList from "@/components/ScrollList.vue";
import { getOrderListAPI } from "@/apis";
import useStore from "@/store";
import { orderStatusNames } from "@/constants";
import { storeToRefs } from "pinia";
const store = useStore();
const { user, config } = storeToRefs(store);
2025-05-28 15:00:31 +08:00
const getStatusColor = (status) => {
switch (status) {
2025-07-12 17:12:24 +08:00
case 1:
2025-05-28 15:00:31 +08:00
return "#EF4848";
2025-07-12 17:12:24 +08:00
case 4:
return "#35CD67";
2025-05-28 15:00:31 +08:00
default:
return "#999999";
}
};
2025-07-01 00:25:17 +08:00
const toDetailPage = (detail) => {
uni.setStorageSync("order", detail);
2025-05-28 15:00:31 +08:00
uni.navigateTo({
2025-07-01 00:25:17 +08:00
url: `/pages/order-detail`,
2025-05-28 15:00:31 +08:00
});
};
2025-07-01 00:25:17 +08:00
const list = ref([]);
const onLoading = async (page) => {
const result = await getOrderListAPI(page);
if (page === 1) {
list.value = result;
} else {
list.value = list.value.concat(result);
}
return result.length;
};
2025-05-28 15:00:31 +08:00
</script>
<template>
<Container title="订单">
<view class="container">
2025-07-01 00:25:17 +08:00
<ScrollList :onLoading="onLoading">
<view
v-for="(item, index) in list"
:key="index"
class="order-item"
@click="() => toDetailPage(item)"
>
<view
:style="{ backgroundColor: getStatusColor(item.orderStatus) }"
>{{ orderStatusNames[item.orderStatus] }}</view
>
<text>{{ item.vipName }}</text>
<!-- <text>订单号{{ item.orderId }}</text> -->
<!-- <text>创建时间{{ item.vipCreateAt }}</text> -->
<text>支付时间2025-01-31 09:27:34</text>
<text>金额{{ item.vipPrice }} </text>
<text>支付方式微信</text>
</view>
</ScrollList>
2025-05-28 15:00:31 +08:00
</view>
</Container>
</template>
<style scoped>
.container {
width: 100%;
height: 100%;
background-color: #e4e4e4;
padding-top: 10px;
}
.order-item {
position: relative;
background-color: #fff;
margin-bottom: 10px;
display: flex;
flex-direction: column;
padding: 15px;
}
.order-item > view:first-child {
position: absolute;
top: 0;
right: 0;
width: 50px;
color: #fff;
text-align: center;
font-size: 11px;
}
.order-item > text:nth-child(2) {
color: #000;
font-size: 16px;
}
.order-item > text {
color: #666666;
font-size: 13px;
margin-top: 5px;
}
</style>