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-07-21 14:34:20 +08:00
|
|
|
|
<view class="countdown-timer">
|
2025-05-07 09:44:23 +08:00
|
|
|
|
<text>剩余:</text>
|
|
|
|
|
|
<text class="time-value">{{ countdownTime }}</text>
|
2025-07-21 14:34:20 +08:00
|
|
|
|
</view>
|
2025-05-07 09:44:23 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
|
2025-07-21 14:34:20 +08:00
|
|
|
|
<view class="scrollable-content">
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 学生信息卡片 -->
|
|
|
|
|
|
<XkPayXs />
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
2025-07-21 14:34:20 +08:00
|
|
|
|
<!-- 课程信息卡片 -->
|
|
|
|
|
|
<XkPayXkqd />
|
|
|
|
|
|
|
|
|
|
|
|
</view>
|
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-21 14:34:20 +08:00
|
|
|
|
import { jzGetQkExpiredTime, jzXkCancelApi, jzXkFqJfjApi } from "@/api/base/server";
|
2025-07-01 16:17:13 +08:00
|
|
|
|
import { useUserStore } from "@/store/modules/user";
|
|
|
|
|
|
import { useDataStore } from "@/store/modules/data";
|
|
|
|
|
|
const { getCurXs, getUser } = useUserStore();
|
2025-07-21 17:56:49 +08:00
|
|
|
|
const { getData, setData } = 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-07-21 14:34:20 +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-07-21 14:34:20 +08:00
|
|
|
|
const startCountdown = () => {
|
|
|
|
|
|
timer = setInterval(() => {
|
|
|
|
|
|
seconds--;
|
|
|
|
|
|
if (seconds <= 0) {
|
|
|
|
|
|
clearInterval(timer);
|
|
|
|
|
|
uni.showModal({
|
|
|
|
|
|
title: "支付超时",
|
|
|
|
|
|
content: "支付已超时,请重新选课",
|
|
|
|
|
|
showCancel: false,
|
|
|
|
|
|
success: () => {
|
|
|
|
|
|
cancelRegistration();
|
|
|
|
|
|
},
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2025-05-30 17:22:30 +08:00
|
|
|
|
|
2025-07-21 14:34:20 +08:00
|
|
|
|
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({
|
2025-08-05 20:31:37 +08:00
|
|
|
|
url: '/pages/base/home/index'
|
2025-07-02 23:25:47 +08:00
|
|
|
|
});
|
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-21 14:34:20 +08:00
|
|
|
|
try {
|
|
|
|
|
|
const res = await jzXkFqJfjApi({
|
|
|
|
|
|
xsId: getData.xsId,
|
|
|
|
|
|
xkId: getData.xkId,
|
|
|
|
|
|
jffs: "四川农信", // TODO: 目前只支持四川农信
|
|
|
|
|
|
jzId: getUser.jzId,
|
|
|
|
|
|
userId: getUser.userId,
|
|
|
|
|
|
openId: getUser.openId,
|
|
|
|
|
|
});
|
|
|
|
|
|
if (res.resultCode === 1 && res.result) {
|
2025-07-21 17:56:49 +08:00
|
|
|
|
setData({
|
|
|
|
|
|
...getData,
|
|
|
|
|
|
...res.result
|
|
|
|
|
|
});
|
2025-07-21 14:34:20 +08:00
|
|
|
|
uni.redirectTo({
|
2025-08-06 12:57:01 +08:00
|
|
|
|
url: `/pages/base/xk/pay/wait?payUrl=${encodeURIComponent(res.result.cashierPayHtml)}`
|
2025-07-21 14:34:20 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.log(error);
|
2025-07-21 15:44:03 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: "发起支付失败",
|
|
|
|
|
|
icon: "error",
|
2025-07-01 16:17:13 +08:00
|
|
|
|
});
|
2025-07-21 15:44:03 +08:00
|
|
|
|
// const url = "https://www.baidu.com";
|
|
|
|
|
|
// uni.redirectTo({
|
2025-08-06 12:57:01 +08:00
|
|
|
|
// url: `/pages/base/xk/pay/wait?payUrl=${encodeURIComponent(url)}`
|
2025-07-21 15:44:03 +08:00
|
|
|
|
// });
|
2025-07-01 16:17:13 +08:00
|
|
|
|
}
|
2025-05-07 09:44:23 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-07-21 14:34:20 +08:00
|
|
|
|
onMounted(async() => {
|
|
|
|
|
|
const res = await jzGetQkExpiredTime({ xsId: getCurXs.id} );
|
|
|
|
|
|
console.log('获取倒计时', res);
|
|
|
|
|
|
seconds = res.result;
|
|
|
|
|
|
startCountdown();
|
2025-05-07 09:44:23 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
2025-07-21 14:34:20 +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;
|
|
|
|
|
|
display: flex;
|
2025-07-21 14:34:20 +08:00
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
2025-05-07 09:44:23 +08:00
|
|
|
|
|
2025-07-21 14:34:20 +08:00
|
|
|
|
// 可滚动内容区域样式
|
|
|
|
|
|
.scrollable-content {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
-webkit-overflow-scrolling: touch; // 增强iOS滚动体验
|
2025-05-07 09:44:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.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 {
|
2025-07-21 14:34:20 +08:00
|
|
|
|
position: sticky;
|
|
|
|
|
|
bottom: 0;
|
2025-05-07 09:44:23 +08:00
|
|
|
|
left: 0;
|
|
|
|
|
|
right: 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>
|