2025-05-07 09:44:23 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<view class="payment-page">
|
|
|
|
|
|
<!-- 倒计时区域 -->
|
|
|
|
|
|
<view class="countdown-section">
|
|
|
|
|
|
<view class="countdown-icon">
|
|
|
|
|
|
<u-icon name="clock" size="22" color="#fff"></u-icon>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view class="countdown-text">待支付</view>
|
2025-05-30 17:22:30 +08:00
|
|
|
|
<!-- <view class="countdown-timer">
|
2025-05-07 09:44:23 +08:00
|
|
|
|
<text>剩余:</text>
|
|
|
|
|
|
<text class="time-value">{{ countdownTime }}</text>
|
2025-05-30 17:22:30 +08:00
|
|
|
|
</view> -->
|
2025-05-07 09:44:23 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 学生信息卡片 -->
|
2025-07-01 21:06:14 +08:00
|
|
|
|
<XkPayXs />
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 课程信息卡片 -->
|
2025-07-01 21:06:14 +08:00
|
|
|
|
<XkPayXkqd />
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 底部支付区域 -->
|
|
|
|
|
|
<view class="payment-footer">
|
|
|
|
|
|
<view class="total-amount">
|
|
|
|
|
|
<text>总金额:</text>
|
2025-07-01 16:17:13 +08:00
|
|
|
|
<text class="amount-value">¥{{ totalJe }}</text>
|
2025-05-07 09:44:23 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
|
|
|
|
|
<view class="action-buttons">
|
|
|
|
|
|
<view class="cancel-btn" @click="cancelRegistration">取消报名</view>
|
|
|
|
|
|
<view class="pay-btn" @click="payNow">立即支付</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
2025-07-01 21:06:14 +08:00
|
|
|
|
import XkPayXs from "@/pages/base/components/XkPayXs/index.vue"
|
|
|
|
|
|
import XkPayXkqd from "@/pages/base/components/XkPayXkqd/index.vue"
|
2025-07-01 16:17:13 +08:00
|
|
|
|
import { jzXkCancelApi, jzXkFqJfjApi } from "@/api/base/server";
|
|
|
|
|
|
import { useUserStore } from "@/store/modules/user";
|
|
|
|
|
|
import { useDataStore } from "@/store/modules/data";
|
|
|
|
|
|
const { getCurXs, getUser } = useUserStore();
|
2025-07-01 21:06:14 +08:00
|
|
|
|
const { getData } = useDataStore();
|
2025-07-01 16:17:13 +08:00
|
|
|
|
|
|
|
|
|
|
// 学生信息
|
|
|
|
|
|
const curXs = computed(() => getCurXs);
|
|
|
|
|
|
// 课程信息
|
|
|
|
|
|
const xkqdList = computed(() => getData.xkqdList);
|
|
|
|
|
|
// 总金额
|
|
|
|
|
|
const totalJe = computed(() => {
|
|
|
|
|
|
// 循环xkqdList.value 求和
|
|
|
|
|
|
if (!xkqdList.value || !xkqdList.value.length) {
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
let total = 0;
|
|
|
|
|
|
for (let i = 0; i < xkqdList.value.length; i++) {
|
2025-07-01 20:22:31 +08:00
|
|
|
|
total += xkqdList.value[i].jfje;
|
2025-07-01 16:17:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
return total;
|
|
|
|
|
|
});
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
|
|
|
|
|
// 倒计时
|
2025-05-30 17:22:30 +08:00
|
|
|
|
// const countdownTime = ref("1分20秒");
|
|
|
|
|
|
// let timer: any = null;
|
|
|
|
|
|
// let seconds = 1 * 60 + 20; // 1分20秒
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
|
|
|
|
|
// 开始倒计时
|
2025-05-30 17:22:30 +08:00
|
|
|
|
// const startCountdown = () => {
|
|
|
|
|
|
// timer = setInterval(() => {
|
|
|
|
|
|
// seconds--;
|
|
|
|
|
|
// if (seconds <= 0) {
|
|
|
|
|
|
// clearInterval(timer);
|
|
|
|
|
|
// uni.showModal({
|
|
|
|
|
|
// title: "支付超时",
|
|
|
|
|
|
// content: "支付已超时,请重新选课",
|
|
|
|
|
|
// showCancel: false,
|
|
|
|
|
|
// success: () => {
|
|
|
|
|
|
// goBack();
|
|
|
|
|
|
// },
|
|
|
|
|
|
// });
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// const minutes = Math.floor(seconds / 60);
|
|
|
|
|
|
// const remainSeconds = seconds % 60;
|
|
|
|
|
|
// countdownTime.value = `${minutes}分${remainSeconds}秒`;
|
|
|
|
|
|
// }, 1000);
|
|
|
|
|
|
// };
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
|
|
|
|
|
// 返回上一页
|
|
|
|
|
|
const goBack = () => {
|
2025-07-02 23:25:47 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: getData.backUrl
|
|
|
|
|
|
});
|
2025-05-07 09:44:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 取消报名
|
|
|
|
|
|
const cancelRegistration = () => {
|
|
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: "取消报名",
|
|
|
|
|
|
content: "确定要取消报名吗?",
|
2025-05-30 17:22:30 +08:00
|
|
|
|
success: async (res) => {
|
2025-05-07 09:44:23 +08:00
|
|
|
|
if (res.confirm) {
|
2025-07-01 16:17:13 +08:00
|
|
|
|
await jzXkCancelApi({
|
|
|
|
|
|
xsId: getData.xsId,
|
|
|
|
|
|
xkId: getData.xkId
|
2025-05-30 17:22:30 +08:00
|
|
|
|
});
|
2025-05-07 09:44:23 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: "已取消报名",
|
|
|
|
|
|
icon: "success",
|
|
|
|
|
|
});
|
2025-07-02 23:25:47 +08:00
|
|
|
|
goBack();
|
2025-05-07 09:44:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 立即支付
|
2025-07-01 16:17:13 +08:00
|
|
|
|
const payNow = async () => {
|
2025-07-01 20:22:31 +08:00
|
|
|
|
const res = await jzXkFqJfjApi({
|
|
|
|
|
|
xsId: getData.xsId,
|
|
|
|
|
|
xkId: getData.xkId,
|
|
|
|
|
|
jffs: "四川农信", // TODO: 目前只支持四川农信
|
|
|
|
|
|
jzId: getUser.jzId,
|
|
|
|
|
|
userId: getUser.userId,
|
|
|
|
|
|
openId: getUser.openId,
|
|
|
|
|
|
});
|
|
|
|
|
|
// const res = {
|
|
|
|
|
|
// resultCode: 1,
|
|
|
|
|
|
// result: "https://pay.weixin.qq.com/wxpay/pay.action?prepay_id=wx20191018103005f5c0c0f5c0c"
|
|
|
|
|
|
// }
|
2025-07-01 16:17:13 +08:00
|
|
|
|
if (res.resultCode === 1 && res.result) {
|
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
|
url: `/pages/base/course-selection/pay-wait?payUrl=${encodeURIComponent(res.result)}`
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// uni.showLoading({
|
|
|
|
|
|
// title: "支付中...",
|
|
|
|
|
|
// });
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
2025-05-30 17:22:30 +08:00
|
|
|
|
// // 模拟支付过程
|
|
|
|
|
|
// setTimeout(() => {
|
|
|
|
|
|
// uni.hideLoading();
|
|
|
|
|
|
|
|
|
|
|
|
// uni.redirectTo({
|
|
|
|
|
|
// url: "/pages/base/course-selection/payment-success",
|
|
|
|
|
|
// });
|
|
|
|
|
|
// // uni.redirectTo({
|
|
|
|
|
|
// // url: "/pages/base/course-selection/payment-fail",
|
|
|
|
|
|
// // });
|
|
|
|
|
|
// }, 2000);
|
2025-05-07 09:44:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
2025-05-30 17:22:30 +08:00
|
|
|
|
// startCountdown();
|
2025-05-07 09:44:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
2025-05-30 17:22:30 +08:00
|
|
|
|
// if (timer) {
|
|
|
|
|
|
// clearInterval(timer);
|
|
|
|
|
|
// }
|
2025-05-07 09:44:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.payment-page {
|
|
|
|
|
|
min-height: 100%;
|
|
|
|
|
|
background-color: #f5f7fa;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-bar {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
padding: 15px;
|
|
|
|
|
|
height: 44px;
|
|
|
|
|
|
background-color: #2879ff;
|
|
|
|
|
|
|
|
|
|
|
|
.nav-left {
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
height: 40px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-title {
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-right {
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.countdown-section {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
padding: 15px;
|
|
|
|
|
|
background-color: #2879ff;
|
|
|
|
|
|
|
|
|
|
|
|
.countdown-icon {
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.countdown-text {
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
margin-right: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.countdown-timer {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
|
|
|
|
|
|
.time-value {
|
|
|
|
|
|
color: #ff4d4f;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.payment-footer {
|
|
|
|
|
|
position: fixed;
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
padding: 15px;
|
|
|
|
|
|
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
|
|
|
|
|
|
|
|
|
|
|
|
.total-amount {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
margin-bottom: 15px;
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
|
|
|
|
|
|
.amount-value {
|
|
|
|
|
|
color: #ff6b00;
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.action-buttons {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
|
|
|
|
|
|
.cancel-btn,
|
|
|
|
|
|
.pay-btn {
|
|
|
|
|
|
width: 48%;
|
|
|
|
|
|
height: 44px;
|
|
|
|
|
|
line-height: 44px;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
border-radius: 22px;
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.cancel-btn {
|
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
border: 1px solid #ddd;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.pay-btn {
|
|
|
|
|
|
background-color: #ff8c00;
|
|
|
|
|
|
color: #fff;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|