2025-05-28 15:00:31 +08:00
|
|
|
|
<script setup>
|
2025-07-01 00:25:17 +08:00
|
|
|
|
import { ref, onMounted } 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 SButton from "@/components/SButton.vue";
|
2025-07-12 17:12:24 +08:00
|
|
|
|
import { payOrderAPI, cancelOrderListAPI, getHomeData } from "@/apis";
|
2025-07-01 00:25:17 +08:00
|
|
|
|
import { orderStatusNames } from "@/constants";
|
2025-07-12 17:12:24 +08:00
|
|
|
|
import useStore from "@/store";
|
|
|
|
|
|
const store = useStore();
|
|
|
|
|
|
const { updateUser } = store;
|
2025-05-28 15:00:31 +08:00
|
|
|
|
|
2025-07-01 00:25:17 +08:00
|
|
|
|
const data = ref({});
|
2025-07-12 17:12:24 +08:00
|
|
|
|
const loading = ref(false);
|
2025-05-28 15:00:31 +08:00
|
|
|
|
|
2025-07-01 00:25:17 +08:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
const order = uni.getStorageSync("order");
|
|
|
|
|
|
data.value = order || {};
|
2025-05-28 15:00:31 +08:00
|
|
|
|
});
|
2025-07-01 00:25:17 +08:00
|
|
|
|
|
|
|
|
|
|
const goPay = async () => {
|
|
|
|
|
|
const result = await payOrderAPI(data.value.orderId);
|
2025-07-12 17:12:24 +08:00
|
|
|
|
const params = result.jsApi.params;
|
|
|
|
|
|
if (params) {
|
|
|
|
|
|
loading.value = true;
|
|
|
|
|
|
wx.requestPayment({
|
|
|
|
|
|
timeStamp: params.timeStamp, // 时间戳
|
|
|
|
|
|
nonceStr: params.nonceStr, // 随机字符串
|
|
|
|
|
|
package: params.package, // 统一下单接口返回的 prepay_id 参数值,格式:prepay_id=***
|
|
|
|
|
|
paySign: params.paySign, // 签名
|
|
|
|
|
|
signType: "RSA", // 签名类型,默认为RSA
|
|
|
|
|
|
async success(res) {
|
|
|
|
|
|
const result = await getHomeData();
|
|
|
|
|
|
if (result.user) updateUser(result.user);
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: "支付成功",
|
|
|
|
|
|
icon: "none",
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
fail(res) {
|
|
|
|
|
|
loading.value = false;
|
|
|
|
|
|
console.log("pay error", res);
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-07-01 00:25:17 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const cancelOrder = async () => {
|
|
|
|
|
|
const result = await cancelOrderListAPI(data.value.orderId);
|
|
|
|
|
|
data.value = result;
|
|
|
|
|
|
};
|
2025-05-28 15:00:31 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<Container title="订单详情">
|
|
|
|
|
|
<view class="container">
|
|
|
|
|
|
<view class="order">
|
2025-07-01 00:25:17 +08:00
|
|
|
|
<view>
|
|
|
|
|
|
<text>商品名:{{ data.vipName }}</text>
|
|
|
|
|
|
<text>订单号:{{ data.orderId }}</text>
|
|
|
|
|
|
<text>下单时间:{{ data.vipCreateAt }}</text>
|
2025-07-13 11:21:30 +08:00
|
|
|
|
<text
|
|
|
|
|
|
>支付时间:{{
|
|
|
|
|
|
data.orderStatus === 4 ? data.paymentTime : ""
|
|
|
|
|
|
}}</text
|
|
|
|
|
|
>
|
|
|
|
|
|
<text>金额:{{ data.total }} 元</text>
|
2025-07-01 00:25:17 +08:00
|
|
|
|
<text>支付方式:微信</text>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view v-if="data.orderStatus === 1">
|
|
|
|
|
|
<SButton :onClick="goPay">去支付</SButton>
|
2025-07-12 17:12:24 +08:00
|
|
|
|
<view :style="{ height: '10px' }" />
|
2025-07-01 00:25:17 +08:00
|
|
|
|
<SButton :onClick="cancelOrder">取消订单</SButton>
|
|
|
|
|
|
</view>
|
2025-05-28 15:00:31 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</Container>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.container {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
background-color: #e4e4e4;
|
|
|
|
|
|
padding-top: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.order {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
background-color: #fff;
|
2025-07-01 00:25:17 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
}
|
|
|
|
|
|
.order > view:first-child {
|
2025-05-28 15:00:31 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
padding: 15px;
|
|
|
|
|
|
}
|
2025-07-01 00:25:17 +08:00
|
|
|
|
.order > view:first-child > text:first-child {
|
2025-05-28 15:00:31 +08:00
|
|
|
|
color: #000;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
}
|
2025-07-01 00:25:17 +08:00
|
|
|
|
.order > view:first-child > text {
|
2025-05-28 15:00:31 +08:00
|
|
|
|
color: #666666;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
margin-top: 5px;
|
|
|
|
|
|
}
|
2025-07-01 00:25:17 +08:00
|
|
|
|
.order > view:last-child {
|
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
|
}
|
2025-05-28 15:00:31 +08:00
|
|
|
|
</style>
|