386 lines
7.5 KiB
Vue
Raw Normal View History

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>
<!-- 学生信息卡片 -->
<view class="info-card">
<view class="card-title">报名信息</view>
<view class="divider"></view>
<view class="student-info">
<view class="student-avatar">
<image
src="/static/images/student-avatar.jpg"
mode="aspectFill"
></image>
</view>
<view class="student-details">
<view class="student-name">
2025-05-30 17:22:30 +08:00
{{ student.xm }}
2025-05-07 09:44:23 +08:00
</view>
2025-05-30 17:22:30 +08:00
<view class="student-class"
>{{ student.njmc }}{{ student.bjmc }}</view
>
2025-05-07 09:44:23 +08:00
</view>
</view>
</view>
<!-- 课程信息卡片 -->
<view class="info-card">
<view class="card-title">课程信息</view>
<view class="divider"></view>
<view class="course-info">
<image
class="course-image"
2025-05-30 17:22:30 +08:00
:src="imagUrl(course.xkkcImg)"
2025-05-07 09:44:23 +08:00
mode="aspectFill"
></image>
<view class="course-details">
2025-05-30 17:22:30 +08:00
<view class="course-name">{{ course.kcmc }}</view>
<view class="course-teacher">开课老师{{ course.jsName }}</view>
<view class="course-location">上课地点{{ course.kcdd }}</view>
2025-05-07 09:44:23 +08:00
<view class="course-price"
2025-05-30 17:22:30 +08:00
>金额<text class="price-value">¥{{ course.kcje }}</text></view
2025-05-07 09:44:23 +08:00
>
</view>
</view>
</view>
<!-- 底部支付区域 -->
<view class="payment-footer">
<view class="total-amount">
<text>总金额</text>
2025-05-30 17:22:30 +08:00
<text class="amount-value">¥{{ course.kcje }}</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-05-30 17:22:30 +08:00
import { xkqddeleteApi } from "@/api/base/server";
import { useDataStore } from "@/store/modules/data";
import { imagUrl } from "@/utils";
2025-05-07 09:44:23 +08:00
import { ref, onMounted, onUnmounted } from "vue";
2025-05-30 17:22:30 +08:00
const useData = useDataStore();
const { getData } = storeToRefs(useData);
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 student = ref(getData.value.studentInfo);
2025-05-07 09:44:23 +08:00
// 课程信息
2025-05-30 17:22:30 +08:00
const course = ref(getData.value.enrolledCourse);
console.log(course.value);
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 = () => {
uni.navigateBack();
};
// 取消报名
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-05-30 17:22:30 +08:00
await xkqddeleteApi({
id: course.value.id,
});
2025-05-07 09:44:23 +08:00
uni.showToast({
title: "已取消报名",
icon: "success",
});
setTimeout(() => {
goBack();
}, 1500);
}
},
});
};
// 立即支付
const payNow = () => {
uni.showLoading({
title: "支付中...",
});
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;
}
}
}
.info-card {
margin: 15px;
background-color: #fff;
border-radius: 8px;
padding: 15px;
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
.card-title {
font-size: 16px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
}
.divider {
height: 1px;
background-color: #eee;
margin-bottom: 15px;
}
}
.student-info {
display: flex;
align-items: center;
.student-avatar {
width: 60px;
height: 60px;
margin-right: 15px;
border-radius: 50%;
overflow: hidden;
image {
width: 100%;
height: 100%;
}
}
.student-details {
.student-name {
font-size: 18px;
font-weight: 500;
color: #333;
display: flex;
align-items: center;
margin-bottom: 5px;
.gender-icon {
margin-left: 5px;
}
}
.student-class {
font-size: 14px;
color: #666;
}
}
}
.course-info {
display: flex;
.course-image {
width: 120px;
height: 120px;
border-radius: 8px;
margin-right: 15px;
}
.course-details {
flex: 1;
.course-name {
font-size: 18px;
font-weight: 500;
color: #333;
margin-bottom: 10px;
}
.course-teacher,
.course-location {
font-size: 14px;
color: #666;
margin-bottom: 8px;
}
.course-price {
font-size: 14px;
color: #666;
.price-value {
color: #ff6b00;
font-weight: bold;
}
}
}
}
.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>