小程序提交
This commit is contained in:
@ -1,15 +1,15 @@
|
||||
import { baseUrl } from "../../../request";
|
||||
import { baseUrl, globalImgUrl } from "../../../request";
|
||||
import { decodeBase64 } from "../../../utils/decodebase64";
|
||||
|
||||
// pages/course/courseDetail/courseDetail.js
|
||||
Page({
|
||||
data: {
|
||||
chapterList: [null, null, null,null, null, null], // 章节目录
|
||||
activeTab: 'intro', // 默认选中“课程简介”
|
||||
activeIndex: null, // 默认没有任何标题被选中
|
||||
cid: 0, // 课程ID
|
||||
courseObj: '', // 课程对象
|
||||
richText: '', // 课程概述富文本
|
||||
globalImgUrl,
|
||||
},
|
||||
|
||||
// 获取课程详情
|
||||
@ -29,7 +29,6 @@ Page({
|
||||
if (res.data.code === 1) {
|
||||
this.setData({
|
||||
courseObj: res.data.data,
|
||||
chapterList: res.data.data.courseChapters,
|
||||
richText: decodeBase64(res.data.data.detail)
|
||||
})
|
||||
}
|
||||
@ -59,6 +58,7 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
// 好像不要了
|
||||
// 跳转申请推广页面
|
||||
gotoApplyPromotion(e) {
|
||||
const courseId = e.currentTarget.dataset.id;
|
||||
|
@ -1,79 +1,36 @@
|
||||
<view class="flex-col page">
|
||||
<view class="flex-col">
|
||||
<!-- 背景图 -->
|
||||
<view class="flex-col section">
|
||||
<image class="background-image" src="https://img.picui.cn/free/2025/06/26/685cc80000461.png" />
|
||||
</view>
|
||||
|
||||
<!-- 选项卡 -->
|
||||
<view class="flex-col section_3">
|
||||
<view class="flex-row justify-center group_2">
|
||||
<text bindtap="selectTab" data-tab="intro" class="text-tab {{activeTab==='intro'?'tab-active':'tab-inactive'}}">课程简介</text>
|
||||
<text bindtap="selectTab" data-tab="catalog" class="text-tab {{activeTab==='catalog'?'tab-active':'tab-inactive'}}">课程目录</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 标题+价格 -->
|
||||
<view class="flex-col section_4">
|
||||
<view class="flex-row items-center group_4">
|
||||
<view class="shrink-0 group_5">
|
||||
<text class="text_6">{{ courseObj.originPrice }}</text>
|
||||
<text class="font_3 text_7">元券后价</text>
|
||||
</view>
|
||||
<view class="ml-4 flex-col justify-start items-start shrink-0 relative group_6">
|
||||
<text class="font_2 text text_8">{{ courseObj.discountPrice }}元</text>
|
||||
<view class="divider pos"></view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="group_4 text_9 mt-9">{{ courseObj.name }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 课程概述(仅当 activeTab==='intro') -->
|
||||
<view wx:if="{{activeTab==='intro'}}" class="flex-col section_5">
|
||||
<view class="flex-row items-center group_7">
|
||||
<image class="image" src="./image/cal.png" />
|
||||
<text class="ml-6 font_2 text_10">课程概述</text>
|
||||
</view>
|
||||
<rich-text class="section_6" nodes="{{richText}}"></rich-text>
|
||||
</view>
|
||||
|
||||
<!-- 课程目录(仅当 activeTab==='catalog') -->
|
||||
<view wx:if="{{activeTab==='catalog'}}" class="flex-col mt-35">
|
||||
<view class="flex-col section_7">
|
||||
<view class="flex-col list">
|
||||
<view class="flex-col list-item mt-15" wx:for="{{chapterList}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
||||
<!-- <view class="flex-col justify-start self-end text-wrapper_2">
|
||||
<text class="font_4 text_11">全集试看</text>
|
||||
</view> -->
|
||||
<view class="flex-row self-start group_8 mt-1">
|
||||
<text class="shrink-0 self-start font_5 text_12">{{ index + 1}}</text>
|
||||
<text class="ml-16 flex-1 font_2 {{activeIndex === index ? 'active-title' : ''}}" bindtap="selectCourse" data-index="{{index}}">
|
||||
{{ item.name }}
|
||||
</text>
|
||||
</view>
|
||||
<view class="flex-row justify-between self-stretch group_9 mt-1">
|
||||
<!-- <text class="self-start font_6 text_13" style="margin-top: 10rpx;">视频课·27分59秒</text> -->
|
||||
<!-- <image class="image_2" src="./image/lock.png" /> -->
|
||||
</view>
|
||||
<view class="flex-col">
|
||||
<image class="image" src="{{ globalImgUrl + courseObj.image }}" />
|
||||
<view class="flex-col section">
|
||||
<view class="flex-row items-center group">
|
||||
<view class="shrink-0 group_2">
|
||||
<text class="text">{{ courseObj.discountPrice }}</text>
|
||||
<text class="font text_2">元券后价</text>
|
||||
</view>
|
||||
<view class="ml-4 flex-col justify-start items-start shrink-0 relative group_3">
|
||||
<text class="font text_3">{{ courseObj.originPrice }}元</text>
|
||||
<view class="divider pos"></view>
|
||||
</view>
|
||||
</view>
|
||||
<text class="group text_4 mt-9">{{ courseObj.name }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="mt-26 flex-col section_2">
|
||||
<view class="flex-row items-center group_4">
|
||||
<image class="image_2" src="./image/cal.png" />
|
||||
<text class="ml-6 font text_5">课程概述</text>
|
||||
</view>
|
||||
<rich-text class="section_3" nodes="{{ richText }}"></rich-text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部固定按钮栏 -->
|
||||
<view class="flex-row items-center section_8 section_8_fixed">
|
||||
<view class="flex-col items-center shrink-0" style="margin-left: 30rpx;">
|
||||
<view class="flex-row justify-between items-center section_4 mt-37">
|
||||
<view class="flex-col items-center">
|
||||
<image class="image_3" src="./image/messge.png" />
|
||||
<text class="font_6 text_16 mt-1">咨询</text>
|
||||
<text class="text_7 mt-1">咨询</text>
|
||||
</view>
|
||||
<view class="ml-44 flex-row flex-1">
|
||||
<view class="flex-col justify-start items-center text-wrapper_3" bind:tap="gotoApplyPromotion" data-id="{{ '1' }}">
|
||||
<text class="font_7 text_14">申请推广</text>
|
||||
</view>
|
||||
<view class="flex-col justify-start items-center text-wrapper_4 ml-15" bind:tap="gotoCourseOrder" data-id="{{ '1' }}">
|
||||
<text class="font_7 text_15">立即购买</text>
|
||||
</view>
|
||||
<view class="flex-col justify-start items-center text-wrapper" bind:tap="gotoCourseOrder" data-id="{{ courseObj.id }}">
|
||||
<text class="text_6">立即购买</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -1,123 +1,43 @@
|
||||
/* pages/course/courseDetail/courseDetail.wxss */
|
||||
|
||||
/* 通用间距 */
|
||||
.mt-9 {
|
||||
margin-top: 16.88rpx;
|
||||
}
|
||||
/* .mt-35 {
|
||||
margin-top: 65.63rpx;
|
||||
} */
|
||||
.mt-15 {
|
||||
margin-top: 28.13rpx;
|
||||
}
|
||||
.mt-7 {
|
||||
margin-top: 13.13rpx;
|
||||
.mt-37 {
|
||||
margin-top: 69.38rpx;
|
||||
}
|
||||
.mt-1 {
|
||||
margin-top: 1.88rpx;
|
||||
}
|
||||
.ml-15 {
|
||||
margin-left: 28.13rpx;
|
||||
}
|
||||
|
||||
/* 背景图样式移至 WXML */
|
||||
.background-image {
|
||||
width: 100%;
|
||||
height: 300rpx; /* 给图片设置固定高度,或者你可以设置为100% */
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
/* 页面样式保持不变 */
|
||||
.page {
|
||||
background-color: #f6f7f9;
|
||||
padding-bottom: 100rpx;
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
height: 100%;
|
||||
padding-bottom: 100rpx; /* 为底部固定栏预留空间 */
|
||||
}
|
||||
|
||||
/* 背景图 */
|
||||
.image {
|
||||
width: 100vw;
|
||||
height: 54.75vw;
|
||||
}
|
||||
.section {
|
||||
background-size: 100% 100%;
|
||||
background-repeat: no-repeat;
|
||||
padding: 37.5rpx 11.25rpx 30rpx 18.75rpx;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
/* 顶部遮罩 */
|
||||
.section_2 {
|
||||
padding: 131.25rpx 176.25rpx 101.25rpx;
|
||||
background-color: #00000063;
|
||||
backdrop-filter: blur(9.38rpx);
|
||||
}
|
||||
|
||||
/* 宽度组 */
|
||||
.group {
|
||||
width: 344.34rpx;
|
||||
}
|
||||
|
||||
/* 白色文字 */
|
||||
.font {
|
||||
font-size: 26.25rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 31.88rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* 橙色按钮 */
|
||||
.text-wrapper {
|
||||
padding: 15rpx 0;
|
||||
background-color: #ff8d1a;
|
||||
border-radius: 187.5rpx;
|
||||
width: 208.13rpx;
|
||||
}
|
||||
|
||||
/* 橙色小字体 */
|
||||
.font_3 {
|
||||
font-size: 26.25rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 24.6rpx;
|
||||
color: #ff8d1a;
|
||||
}
|
||||
.text_3 {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
/* 选项卡容器 */
|
||||
.section_3 {
|
||||
padding: 0 135rpx 7.5rpx 142.5rpx;
|
||||
background-color: #ffffff;
|
||||
border-bottom: solid 1.88rpx #9c9c9c;
|
||||
}
|
||||
.group_2 {
|
||||
padding: 22.5rpx 0 11.25rpx;
|
||||
display: flex;
|
||||
justify-content: center; /* 增加选项卡间隔 */
|
||||
}
|
||||
|
||||
/* 标题+价格 */
|
||||
.section_4 {
|
||||
padding: 37.5rpx 7.5rpx 30rpx 22.5rpx;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.group_4 {
|
||||
padding: 0 3.75rpx;
|
||||
}
|
||||
.group_5 {
|
||||
.group_2 {
|
||||
line-height: 28.8rpx;
|
||||
height: 30.58rpx;
|
||||
}
|
||||
.text_6 {
|
||||
.text {
|
||||
color: #f84947;
|
||||
font-size: 37.5rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
font-weight: 700;
|
||||
line-height: 28.8rpx;
|
||||
}
|
||||
.text_7 {
|
||||
color: #f84947;
|
||||
line-height: 24.43rpx;
|
||||
}
|
||||
.group_6 {
|
||||
.group_3 {
|
||||
margin-right: 453.75rpx;
|
||||
width: 75.02rpx;
|
||||
}
|
||||
@ -133,212 +53,78 @@
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
.text_9 {
|
||||
.text_4 {
|
||||
color: #000000;
|
||||
font-size: 33.75rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 41.25rpx;
|
||||
}
|
||||
|
||||
/* 课程概述 */
|
||||
.section_5 {
|
||||
margin-top: 28.13rpx;
|
||||
.section_2 {
|
||||
padding: 0 30rpx 52.5rpx;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.group_7 {
|
||||
.group_4 {
|
||||
padding: 26.25rpx 0;
|
||||
}
|
||||
.image {
|
||||
.image_2 {
|
||||
width: 39.38rpx;
|
||||
height: 39.38rpx;
|
||||
}
|
||||
|
||||
/* 概述内容区 */
|
||||
.section_6 {
|
||||
background-color: #ffffff00;
|
||||
height: 791.25rpx;
|
||||
/* border-left: solid 1.88rpx #000000;
|
||||
border-right: solid 1.88rpx #000000;
|
||||
border-top: solid 1.88rpx #000000;
|
||||
border-bottom: solid 1.88rpx #000000; */
|
||||
}
|
||||
|
||||
/* 目录列表 */
|
||||
.section_7 {
|
||||
padding: 31.88rpx 0;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.list {
|
||||
margin: 0 22.5rpx;
|
||||
}
|
||||
.group_8 {
|
||||
width: 590.81rpx;
|
||||
display: flex;
|
||||
align-items: center; /* 序号垂直居中 */
|
||||
margin-top: 3rpx !important; /* 视频标题与上方内容的间距 */
|
||||
}
|
||||
.list-item {
|
||||
padding-left: 37.5rpx;
|
||||
padding-bottom: 25.75rpx;
|
||||
background-color: #f6f7f9;
|
||||
border-radius: 10.63rpx;
|
||||
}
|
||||
.list-item:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* 全局试看按钮 */
|
||||
.text-wrapper_2 {
|
||||
padding: 3.75rpx 0;
|
||||
background-color: #ff8d1a;
|
||||
border-radius: 0rpx 9.38rpx 0rpx 9.38rpx;
|
||||
}
|
||||
.font_4 {
|
||||
font-size: 24rpx; /* 放大字体 */
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 28rpx; /* 放大行高 */
|
||||
color: #ffffff;
|
||||
}
|
||||
.text_11 {
|
||||
margin: 0 7.5rpx;
|
||||
line-height: 28rpx; /* 放大行高 */
|
||||
}
|
||||
|
||||
/* 列表文本 */
|
||||
.font_5 {
|
||||
.font {
|
||||
font-size: 26.25rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 19.24rpx;
|
||||
color: #8f8f8f;
|
||||
line-height: 25.97rpx;
|
||||
}
|
||||
.text_12 {
|
||||
margin-top: 0; /* 垂直居中序号 */
|
||||
align-self: center !important;
|
||||
padding-top: 32rpx;
|
||||
}
|
||||
.font_2 {
|
||||
font-size: 26.25rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
.text_3 {
|
||||
width: 100rpx;
|
||||
color: #8c8c8c;
|
||||
line-height: 31.88rpx;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/* 其他文本 */
|
||||
.text {
|
||||
word-break: break-all;
|
||||
}
|
||||
.text_8 {
|
||||
color: #8c8c8c;
|
||||
width: 100rpx;
|
||||
}
|
||||
.text_2 {
|
||||
color: #ff8d1a;
|
||||
color: #f84947;
|
||||
line-height: 24.43rpx;
|
||||
}
|
||||
.group_9 {
|
||||
padding-left: 41.25rpx;
|
||||
padding-right: 20.63rpx;
|
||||
.text_5 {
|
||||
color: #000000;
|
||||
font-size: 28.13rpx;
|
||||
}
|
||||
.font_6 {
|
||||
font-size: 22.5rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 19.24rpx;
|
||||
color: #8f8f8f;
|
||||
.section_3 {
|
||||
height: 791.25rpx;
|
||||
/* 以下是新增 */
|
||||
white-space: normal; /* 允许换行 */
|
||||
word-break: break-all; /* 在任意字符处断行,数字也会换行 */
|
||||
}
|
||||
.text_13 {
|
||||
line-height: 20.79rpx;
|
||||
}
|
||||
.image_2 {
|
||||
width: 30rpx;
|
||||
height: 30rpx;
|
||||
}
|
||||
|
||||
/* 底部原有按钮组 */
|
||||
.section_8 {
|
||||
.section_4 {
|
||||
padding: 15rpx 26.25rpx;
|
||||
background-color: #ffffff;
|
||||
}
|
||||
.image_3 {
|
||||
width: 52.5rpx;
|
||||
height: 52.5rpx;
|
||||
}
|
||||
.text_16 {
|
||||
color: #000000;
|
||||
line-height: 20.94rpx;
|
||||
}
|
||||
.text-wrapper_3 {
|
||||
padding: 22.5rpx 0;
|
||||
flex: 1 1 268.13rpx;
|
||||
background-color: #a5d63f;
|
||||
border-radius: 75rpx;
|
||||
height: 71.25rpx;
|
||||
}
|
||||
.font_7 {
|
||||
font-size: 30rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 28.8rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
.text_14 {
|
||||
line-height: 28.29rpx;
|
||||
}
|
||||
.text-wrapper_4 {
|
||||
padding: 22.5rpx 0;
|
||||
flex: 1 1 268.13rpx;
|
||||
background-color: #ff8d1a;
|
||||
border-radius: 75rpx;
|
||||
height: 71.25rpx;
|
||||
}
|
||||
.text_15 {
|
||||
line-height: 28.11rpx;
|
||||
}
|
||||
|
||||
/* 新增:选项卡文字基础样式 */
|
||||
.text-tab {
|
||||
font-size: 32rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 38rpx;
|
||||
padding-bottom: 8rpx; /* 文字与下划线之间留白 */
|
||||
margin: 0 80rpx; /* 增大间距 */
|
||||
}
|
||||
|
||||
/* 新增:选中/未选中状态 */
|
||||
.tab-active {
|
||||
color: #ff8d1a;
|
||||
border-bottom: 2rpx solid #ff8d1a;
|
||||
}
|
||||
.tab-inactive {
|
||||
color: #000000;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* 覆盖:让 .group_2 居中其子元素,增强间距控制 */
|
||||
.group_2 {
|
||||
justify-content: center !important;
|
||||
}
|
||||
|
||||
/* 新增:底部固定按钮栏 */
|
||||
.section_8_fixed {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
background-color: #ffffff;
|
||||
z-index: 999; /* 确保它在最上层 */
|
||||
}
|
||||
/* 禁止容器内元素换行 */
|
||||
.no-wrap {
|
||||
flex-wrap: nowrap !important;
|
||||
|
||||
.image_3 {
|
||||
width: 52.5rpx;
|
||||
height: 52.5rpx;
|
||||
}
|
||||
/* 强制所有 text 不换行 */
|
||||
.no-wrap text {
|
||||
white-space: nowrap;
|
||||
.text_7 {
|
||||
color: #000000;
|
||||
font-size: 22.5rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 20.94rpx;
|
||||
}
|
||||
.mx-15 {
|
||||
margin-left: 15rpx;
|
||||
margin-right: 15rpx;
|
||||
}
|
||||
/* 课程目录的点击状态 */
|
||||
.active-title {
|
||||
color: #ff8d1a; /* 点击后的颜色:橙色 */
|
||||
.text-wrapper {
|
||||
padding: 22.5rpx 0 18.75rpx;
|
||||
background-color: #ff8d1a;
|
||||
border-radius: 75rpx;
|
||||
width: 268.13rpx;
|
||||
height: 71.25rpx;
|
||||
}
|
||||
.text_6 {
|
||||
color: #ffffff;
|
||||
font-size: 30rpx;
|
||||
font-family: SourceHanSansCN;
|
||||
line-height: 28.11rpx;
|
||||
}
|
@ -1,3 +1,5 @@
|
||||
import { baseUrl, globalImgUrl } from "../../../request";
|
||||
|
||||
// pages/course/courseList/courseList.js
|
||||
Page({
|
||||
|
||||
@ -5,8 +7,9 @@ Page({
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
items:[null,null,null,null,null,null,null,null,null],
|
||||
courseList:[], // 课程列表
|
||||
courseType: '', // 课程类别
|
||||
globalImgUrl,
|
||||
},
|
||||
|
||||
// 跳转课程详情页面
|
||||
@ -23,10 +26,45 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
// console.log('option--->',options);
|
||||
this.setData({
|
||||
courseType: options.type
|
||||
})
|
||||
// 接收路由参数 type 作为搜索关键字
|
||||
const courseType = options.type || '';
|
||||
this.setData({ courseType }, () => {
|
||||
this.fetchCourseList();
|
||||
});
|
||||
},
|
||||
|
||||
// 从后端拉取课程列表
|
||||
fetchCourseList() {
|
||||
wx.request({
|
||||
url: baseUrl + '/course/query/type',
|
||||
method: 'POST',
|
||||
header: {
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
data: {
|
||||
templateString: this.data.courseType
|
||||
},
|
||||
success: res => {
|
||||
console.log('课程列表',res.data.data);
|
||||
if (res.data.code === 1) {
|
||||
this.setData({
|
||||
courseList: res.data.data
|
||||
});
|
||||
} else {
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: res.data.message || '获取课程失败',
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
console.error('request failed', err);
|
||||
wx.showToast({
|
||||
icon: 'none',
|
||||
title: '网络请求失败',
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,35 +1,39 @@
|
||||
<!--pages/course/courseList/courseList.wxml-->
|
||||
<view class="flex-col page">
|
||||
<text class="self-center text">{{ courseType }}</text>
|
||||
<image
|
||||
class="shrink-0 self-start image image_2"
|
||||
src="./image/line.png"
|
||||
/>
|
||||
<image
|
||||
class="shrink-0 self-end image image_3"
|
||||
src="./image/line.png"
|
||||
/>
|
||||
<image class="shrink-0 self-start image image_2" src="./image/line.png" />
|
||||
<image class="shrink-0 self-end image image_3" src="./image/line.png" />
|
||||
|
||||
<view class="flex-col self-stretch list">
|
||||
<!-- 遍历接口返回的 items 数组 -->
|
||||
<view
|
||||
class="flex-col justify-start list-item"
|
||||
wx:for="{{items}}"
|
||||
class="flex-col list-item"
|
||||
wx:for="{{courseList}}"
|
||||
wx:for-item="item"
|
||||
wx:for-index="index"
|
||||
wx:key="index"
|
||||
wx:key="id"
|
||||
>
|
||||
<view class="flex-row items-center relative group" bind:tap="gotoCourseDetail" data-id="{{ '1' }}">
|
||||
<view
|
||||
class="flex-row items-center relative group"
|
||||
bindtap="gotoCourseDetail"
|
||||
data-id="{{item.id}}"
|
||||
>
|
||||
<!-- 课程封面 -->
|
||||
<image
|
||||
class="shrink-0 image_4"
|
||||
src="https://ide.code.fun/api/image?token=6858ee4b4ae84d0012334127&name=9c2a22f14e2bd768cbd40d939693e4a8.png"
|
||||
src="{{ globalImgUrl + item.image}}"
|
||||
mode="aspectFill"
|
||||
/>
|
||||
<view class="flex-col flex-1 ml-12">
|
||||
<text class="font">区块链和加密数字货币(随报随学认证班)</text>
|
||||
<!-- 课程名称 -->
|
||||
<text class="font">{{item.name}}</text>
|
||||
<view class="flex-row justify-between items-baseline mt-17">
|
||||
<text class="font_2">券后99元起</text>
|
||||
<text class="font_3">18523人学习</text>
|
||||
<!-- 卷后价格 -->
|
||||
<text class="font_2">券后{{item.discountPrice}}元起</text>
|
||||
<!-- 已有下单人数 -->
|
||||
<text class="font_3">{{item.orderCount}}人学习</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -1,88 +1,143 @@
|
||||
import { baseUrl } from "../../../request";
|
||||
|
||||
// pages/course/courseOrderList/courseOrderList.js
|
||||
Page({
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
items: [null, null, null],
|
||||
countDown: 30 * 60 , // 初始倒计时
|
||||
countDownStr: '' // 用于在视图中渲染的倒计时文本
|
||||
orderList: [], // 后端返回的订单列表
|
||||
hasModalShown: false, // 弹框只显示一次
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
this.startCountDown();
|
||||
this.fetchOrders();
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
clearInterval(this.intervalId);
|
||||
clearInterval(this._timer);
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
clearInterval(this.intervalId);
|
||||
clearInterval(this._timer);
|
||||
},
|
||||
onShow() {
|
||||
this.fetchOrders()
|
||||
},
|
||||
|
||||
/**
|
||||
* 启动倒计时
|
||||
*/
|
||||
startCountDown() {
|
||||
this.updateCountDownStr();
|
||||
this.intervalId = setInterval(() => {
|
||||
let cd = this.data.countDown;
|
||||
if (cd <= 1) {
|
||||
clearInterval(this.intervalId);
|
||||
this.setData({
|
||||
countDown: 0,
|
||||
countDownStr: '00分00秒'
|
||||
});
|
||||
} else {
|
||||
cd--;
|
||||
this.setData({ countDown: cd });
|
||||
this.updateCountDownStr();
|
||||
// 拉取后端接口
|
||||
fetchOrders() {
|
||||
wx.request({
|
||||
url: baseUrl + '/courseOrder/query/list', // 替换为真实接口
|
||||
method: 'POST',
|
||||
header: {
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
success: res => {
|
||||
console.log('课程订单列表---->',res.data.data);
|
||||
if (res.data.code === 1) {
|
||||
const now = Date.now();
|
||||
let list = res.data.data.map(item => {
|
||||
// 计算从 createTime 到 now 剩余秒数
|
||||
const createMs = new Date(item.createTime.replace(/-/g,'/')).getTime();
|
||||
let diff = Math.floor((createMs + 30*60*1000 - now) / 1000);
|
||||
|
||||
// 只有“待支付”才需要倒计时、过期置“交易取消”
|
||||
if (item.orderStatus === '待支付') {
|
||||
if (diff <= 0) {
|
||||
item.orderStatus = '交易取消';
|
||||
diff = 0;
|
||||
// 首次检测到过期就弹框
|
||||
if (!this.data.hasModalShown) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '订单超时未支付,已取消',
|
||||
showCancel: false
|
||||
});
|
||||
this.setData({ hasModalShown: true });
|
||||
}
|
||||
}
|
||||
item.countDown = diff;
|
||||
const m = Math.floor(diff / 60);
|
||||
const s = diff % 60;
|
||||
item.countDownStr = `${m}分${s < 10 ? '0'+s : s}秒`;
|
||||
} else {
|
||||
item.countDown = 0;
|
||||
item.countDownStr = '';
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
this.setData({ orderList: list }, () => {
|
||||
// 初始处理完后启动全局定时器
|
||||
this.startTimer();
|
||||
});
|
||||
|
||||
} else {
|
||||
wx.showToast({ title: res.data.message || '获取失败', icon: 'none' });
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({ title: '网络错误', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 每秒更新所有待支付订单的倒计时
|
||||
startTimer() {
|
||||
this._timer = setInterval(() => {
|
||||
const updated = this.data.orderList.map(item => {
|
||||
if (item.orderStatus === '待支付' && item.countDown > 0) {
|
||||
const cd = item.countDown - 1;
|
||||
item.countDown = cd;
|
||||
const m = Math.floor(cd / 60);
|
||||
const s = cd % 60;
|
||||
item.countDownStr = `${m}分${s < 10 ? '0'+s : s}秒`;
|
||||
|
||||
if (cd <= 0) {
|
||||
item.orderStatus = '交易取消';
|
||||
item.countDownStr = '';
|
||||
if (!this.data.hasModalShown) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '订单超时未支付,已取消',
|
||||
showCancel: false
|
||||
});
|
||||
this.setData({ hasModalShown: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
return item;
|
||||
});
|
||||
this.setData({ orderList: updated });
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
/**
|
||||
* 更新倒计时显示字符串
|
||||
*/
|
||||
updateCountDownStr() {
|
||||
const minutes = Math.floor(this.data.countDown / 60);
|
||||
const seconds = this.data.countDown % 60;
|
||||
const str = `${minutes}分${seconds < 10 ? '0' + seconds : seconds}秒`;
|
||||
this.setData({ countDownStr: str });
|
||||
// 跳转订单详情
|
||||
gotoOrderDetail(e) {
|
||||
const orderId = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/course/orderDetail/orderDetail?id=${orderId}`,
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {},
|
||||
// 取消订单
|
||||
cancelOrder() {
|
||||
wx.showModal({
|
||||
title: '取消订单',
|
||||
content: '是否要取消订单?',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
wx.request({
|
||||
url: baseUrl + "/courseOrder/cancel",
|
||||
method: 'POST',
|
||||
data: { courseId: this.data.orderId },
|
||||
header: { Authorization: wx.getStorageSync('token') },
|
||||
success: () => this.getOrderDetail()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {}
|
||||
// 支付订单
|
||||
payOrder() {
|
||||
// wx.navigateTo({ url: `/pages/pay/pay?orderId=${this.data.orderId}` });
|
||||
wx.showToast({ title: '支付功能稍后开放', icon: 'none' });
|
||||
},
|
||||
});
|
||||
|
@ -1,21 +1,36 @@
|
||||
<!-- pages/course/courseOrderList/courseOrderList.wxml -->
|
||||
<view class="flex-col justify-start page">
|
||||
<view class="flex-col group_1">
|
||||
<view class="flex-col list-item mt-17" wx:for="{{items}}" wx:for-item="item" wx:for-index="index" wx:key="index">
|
||||
<view
|
||||
class="flex-col list-item mt-17"
|
||||
wx:for="{{orderList}}"
|
||||
wx:for-item="item"
|
||||
wx:for-index="index"
|
||||
wx:key="item"
|
||||
bind:tap="gotoOrderDetail"
|
||||
data-id="{{ item.id }}"
|
||||
>
|
||||
<view class="flex-row self-stretch group">
|
||||
<text class="font text">订单号:202506191307440406460485418</text>
|
||||
<text class="font_2 ml-37">待支付</text>
|
||||
<text class="font text">订单号:{{item.orderNumber}}</text>
|
||||
<text class="font_2 ml-37">{{ item.orderStatus }}</text>
|
||||
</view>
|
||||
<text class="self-stretch font_3 text_2">区块链和加密数字货币(随报随学认证班)(随报随学认证班)</text>
|
||||
<text class="self-end font_4 text_3">¥999.00</text>
|
||||
<text class="self-end font_5 text_4">请在 {{countDownStr}} 内完成支付</text>
|
||||
|
||||
<text class="self-stretch font_3 text_2">{{ item.name }}</text>
|
||||
<text class="self-end font_4 text_3">¥{{ item.totalAmount }}</text>
|
||||
|
||||
<!-- 倒计时,只在“待支付”时显示 -->
|
||||
<text wx:if="{{ item.orderStatus === '待支付' }}" class="self-end font_5 text_4">
|
||||
请在 {{ item.countDownStr }} 内完成支付
|
||||
</text>
|
||||
|
||||
<view class="flex-row justify-between items-center self-stretch group_2">
|
||||
<text class="font_6 text_5">2025-06-17 13:00:33</text>
|
||||
<text class="font_6 text_5">{{ item.createTime }}</text>
|
||||
<view class="flex-row">
|
||||
<view class="flex-col justify-start items-center text-wrapper">
|
||||
<!-- 仅待支付时可操作 -->
|
||||
<view wx:if="{{ item.orderStatus === '待支付' }}" class="flex-col justify-start items-center text-wrapper" catch:tap="cancelOrder">
|
||||
<text class="font_7">取消订单</text>
|
||||
</view>
|
||||
<view class="flex-col justify-start items-center text-wrapper_2 ml-11">
|
||||
<view wx:if="{{ item.orderStatus === '待支付' }}" class="flex-col justify-start items-center text-wrapper_2 ml-11" catch:tap="payOrder">
|
||||
<text class="font_8">支付</text>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -4,13 +4,13 @@
|
||||
margin-top: 31.88rpx;
|
||||
}
|
||||
.ml-37 {
|
||||
margin-left: 69.38rpx;
|
||||
margin-left: 92.38rpx;
|
||||
}
|
||||
.ml-11 {
|
||||
margin-left: 20.63rpx;
|
||||
}
|
||||
.page {
|
||||
padding: 26.25rpx 0 350.63rpx;
|
||||
padding: 26.25rpx 0 50.63rpx;
|
||||
background-color: #f8f8f8;
|
||||
width: 100%;
|
||||
overflow-y: auto;
|
||||
@ -68,7 +68,7 @@
|
||||
.text_3 {
|
||||
margin-top: 58.09rpx;
|
||||
line-height: 22.76rpx;
|
||||
margin-right: 50rpx; /* 向左移动:增加右侧间距 */
|
||||
margin-right: 22rpx; /* 向左移动:增加右侧间距 */
|
||||
}
|
||||
.font_5 {
|
||||
font-size: 26.25rpx;
|
||||
@ -93,9 +93,9 @@
|
||||
line-height: 26.25rpx;
|
||||
color: #a1a1a1;
|
||||
}
|
||||
.text_5 {
|
||||
/* .text_5 {
|
||||
width: 206.25rpx;
|
||||
}
|
||||
} */
|
||||
.text-wrapper {
|
||||
padding: 10.8rpx 0 8.16rpx;
|
||||
background-color: #ffffff;
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { baseUrl, globalImgUrl } from "../../../request";
|
||||
// pages/course/createCourseOrder/createCourseOrder.js
|
||||
Page({
|
||||
|
||||
@ -6,13 +7,56 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
courseId: 0, // 课程id
|
||||
courseObj: '', // 课程对象
|
||||
globalImgUrl, // 全局图片
|
||||
},
|
||||
|
||||
// 创建订单方法
|
||||
createOrder(e) {
|
||||
const courseId = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/course/waitPayOrder/waitPayOrder?id=${courseId}`,
|
||||
createOrder() {
|
||||
const { courseId } = this.data;
|
||||
let orderId ;
|
||||
wx.request({
|
||||
url: baseUrl + '/courseOrder/add',
|
||||
method: 'POST',
|
||||
data: {
|
||||
courseId: courseId
|
||||
},
|
||||
header: {
|
||||
Authorization :wx.getStorageSync('token'),
|
||||
},
|
||||
success : res => {
|
||||
console.log(res);
|
||||
this.setData({
|
||||
orderId: res.data.data
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: `/pages/course/orderDetail/orderDetail?id=${this.data.orderId}`,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
// 获取课程详情
|
||||
getCourseDetail() {
|
||||
const cid = this.data.courseId;
|
||||
wx.request({
|
||||
url: baseUrl + '/course/detail/id',
|
||||
method: 'POST',
|
||||
data: {
|
||||
id: cid
|
||||
},
|
||||
header: {
|
||||
Authorization :wx.getStorageSync('token'),
|
||||
},
|
||||
success : res => {
|
||||
console.log(res);
|
||||
if (res.data.code === 1) {
|
||||
this.setData({
|
||||
courseObj: res.data.data,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@ -24,6 +68,7 @@ Page({
|
||||
this.setData({
|
||||
courseId: options.id,
|
||||
})
|
||||
this.getCourseDetail()
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -4,14 +4,14 @@
|
||||
<view class="flex-row items-center section">
|
||||
<image
|
||||
class="shrink-0 image"
|
||||
src="https://ide.code.fun/api/image?token=6859f7a14ae84d0012334fa9&name=9c2a22f14e2bd768cbd40d939693e4a8.png"
|
||||
src="{{ globalImgUrl + courseObj.image }}"
|
||||
/>
|
||||
<view class="flex-col flex-1 ml-11">
|
||||
<text class="self-start text">区块链和加密数字货币(随报随学认证班)(随报随学认证班)</text>
|
||||
<text class="self-start text">{{ courseObj.name }}</text>
|
||||
<view class="flex-row items-center self-stretch group mt-15">
|
||||
<text class="text_2">¥999</text>
|
||||
<text class="text_2">¥{{ courseObj.originPrice }}</text>
|
||||
<view class="flex-col justify-start relative ml-1">
|
||||
<text class="text_3">¥999</text>
|
||||
<text class="text_3">¥{{ courseObj.discountPrice }}</text>
|
||||
<view class="divider pos"></view>
|
||||
</view>
|
||||
</view>
|
||||
@ -19,7 +19,7 @@
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center section_2 mt-14">
|
||||
<text class="font">商品价格</text>
|
||||
<text class="font text_4">¥999</text>
|
||||
<text class="font text_4">¥{{ courseObj.discountPrice }}</text>
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center section_3 mt-14">
|
||||
<view class="flex-row items-center">
|
||||
@ -37,8 +37,8 @@
|
||||
<!-- 固定在底部的区域 -->
|
||||
<view class="footer">
|
||||
<view class="flex-row justify-between items-center section_4">
|
||||
<text class="font text_5">应付¥999</text>
|
||||
<view class="flex-col justify-center items-center text-wrapper" bind:tap="createOrder" data-id="{{ '1' }}">
|
||||
<text class="font text_5">应付¥{{ courseObj.discountPrice }}</text>
|
||||
<view class="flex-col justify-center items-center text-wrapper" bind:tap="createOrder">
|
||||
<text class="font text_6">立即支付</text>
|
||||
</view>
|
||||
</view>
|
||||
|
@ -6,7 +6,14 @@ Page({
|
||||
|
||||
data: {
|
||||
// 初始时置空,待接口返回后再渲染
|
||||
courseList: []
|
||||
banners: [
|
||||
'./image/banner.png',
|
||||
'./image/banner.png',
|
||||
'./image/banner.png',
|
||||
'./image/banner.png'
|
||||
],
|
||||
courseList: [],
|
||||
globalImgUrl
|
||||
},
|
||||
|
||||
// 跳转课程列表页
|
||||
|
@ -1,47 +1,35 @@
|
||||
<view class="flex-col page">
|
||||
<view class="flex-col self-stretch group">
|
||||
<view class="flex-row justify-center items-center section" bind:tap="gotoSearch">
|
||||
<image
|
||||
class="image"
|
||||
src="./image/sousuo.png"
|
||||
/>
|
||||
<image class="image" src="./image/sousuo.png" />
|
||||
<text class="text ml-3">搜索更多好课</text>
|
||||
</view>
|
||||
<swiper class="swiper" autoplay="true" circular="true"></swiper>
|
||||
<swiper class="swiper" autoplay="true" circular="true" interval="3000" circular="true">
|
||||
<block wx:for="{{banners}}" wx:for-item="img" wx:key="index">
|
||||
<swiper-item>
|
||||
<image src="{{img}}" class="swiper-image" mode="aspectFill" />
|
||||
</swiper-item>
|
||||
</block>
|
||||
</swiper>
|
||||
</view>
|
||||
<view class="flex-row equal-division">
|
||||
<view class="flex-col items-center group_2 group_1" bind:tap="gotoCourseList" data-type="{{ '考公考研' }}">
|
||||
<image
|
||||
class="image_3"
|
||||
src="./image/kgky.png"
|
||||
/>
|
||||
<text class="font text_1 mt-12">考公考研</text>
|
||||
<view class="flex-col items-center group_2 group_1" bind:tap="gotoCourseList" data-type="{{ '考研' }}">
|
||||
<image class="image_3" src="./image/kgky.png" />
|
||||
<text class="font text_1 mt-12">考研</text>
|
||||
</view>
|
||||
<view class="flex-col items-center group_2 group_3" bind:tap="gotoCourseList" data-type="{{ '自媒体' }}">
|
||||
<image
|
||||
class="image_3"
|
||||
src="./image/zmt.png"
|
||||
/>
|
||||
<text class="font text_3 mt-12">自媒体</text>
|
||||
<view class="flex-col items-center group_2 group_3" bind:tap="gotoCourseList" data-type="{{ '考公' }}">
|
||||
<image class="image_3" src="./image/zmt.png" />
|
||||
<text class="font text_3 mt-12">考公</text>
|
||||
</view>
|
||||
<view class="flex-col items-center group_2 group_4" bind:tap="gotoCourseList" data-type="{{ '财经' }}">
|
||||
<image
|
||||
class="image_3"
|
||||
src="./image/cj.png"
|
||||
/>
|
||||
<text class="font text_4 mt-12">财经</text>
|
||||
<view class="flex-col items-center group_2 group_4" bind:tap="gotoCourseList" data-type="{{ '考证' }}">
|
||||
<image class="image_3" src="./image/cj.png" />
|
||||
<text class="font text_4 mt-12">考证</text>
|
||||
</view>
|
||||
</view>
|
||||
<text class="self-start text_2">热门课程</text>
|
||||
<view class="flex-col self-stretch list">
|
||||
<!-- items 数组循环 -->
|
||||
<view
|
||||
class="flex-row relative group_5"
|
||||
wx:for="{{courseList}}"
|
||||
wx:for-item="item"
|
||||
wx:for-index="index"
|
||||
wx:key="item.id"
|
||||
>
|
||||
<view class="flex-row relative group_5" wx:for="{{courseList}}" wx:for-item="item" wx:for-index="index" wx:key="item.id">
|
||||
<view bind:tap="gotoCourseDetail" data-id="{{item.id}}">
|
||||
<view class="list-divider pos_3"></view>
|
||||
<!-- 绑定课程封面图 -->
|
||||
|
@ -134,4 +134,9 @@
|
||||
width: 691.88rpx;
|
||||
height: 324.38rpx;
|
||||
margin-top: 22.5rpx;
|
||||
}
|
||||
/* 轮播图图片 */
|
||||
.swiper-image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
BIN
pages/course/homepage/image/banner.png
Normal file
BIN
pages/course/homepage/image/banner.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 145 KiB |
139
pages/course/orderDetail/orderDetail.js
Normal file
139
pages/course/orderDetail/orderDetail.js
Normal file
@ -0,0 +1,139 @@
|
||||
import { baseUrl, globalImgUrl } from "../../../request";
|
||||
|
||||
Page({
|
||||
data: {
|
||||
countdown: '',
|
||||
orderId: 0,
|
||||
orderObj: {}, // 订单详情对象
|
||||
_secondsRemaining: 0, // 内部倒计时秒数
|
||||
_hasShownTimeout: false, // 是否已弹过“超时未支付”弹窗
|
||||
globalImgUrl,
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
console.log('options---->',options);
|
||||
this.setData({ orderId: options.id });
|
||||
this.getOrderDetail();
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
clearInterval(this._timer);
|
||||
},
|
||||
|
||||
// 拉取订单详情并初始化倒计时
|
||||
getOrderDetail() {
|
||||
wx.request({
|
||||
url: baseUrl + '/courseOrder/query/detail',
|
||||
method: 'POST',
|
||||
data: { id: this.data.orderId },
|
||||
header: { Authorization: wx.getStorageSync('token') },
|
||||
success: res => {
|
||||
console.log('订单详情--->',res.data.data);
|
||||
if (res.data.code !== 1) return wx.showToast({ title: res.data.message, icon: 'none' });
|
||||
|
||||
const order = res.data.data;
|
||||
this.setData({ orderObj: order });
|
||||
|
||||
// 仅“待支付”需要倒计时
|
||||
if (order.orderStatus === '待支付') {
|
||||
this._initFromCreateTime(order.createTime);
|
||||
}
|
||||
},
|
||||
fail: () => wx.showToast({ title: '网络错误', icon: 'none' })
|
||||
});
|
||||
},
|
||||
|
||||
// 计算剩余秒数并启动定时器
|
||||
_initFromCreateTime(createTime) {
|
||||
// 将 "2025-07-13 12:38:17" → 时间戳
|
||||
const createMs = new Date(createTime.replace(/-/g, '/')).getTime();
|
||||
const now = Date.now();
|
||||
let diff = Math.floor((createMs + 30 * 60 * 1000 - now) / 1000);
|
||||
|
||||
if (diff <= 0) {
|
||||
// 已超时
|
||||
this._handleTimeout();
|
||||
} else {
|
||||
// 未超时,初始化秒数并启动倒计时
|
||||
this.setData({
|
||||
_secondsRemaining: diff,
|
||||
countdown: this._format(diff)
|
||||
});
|
||||
this._startTimer();
|
||||
}
|
||||
},
|
||||
|
||||
// 每秒递减
|
||||
_startTimer() {
|
||||
this._timer = setInterval(() => {
|
||||
let sec = this.data._secondsRemaining - 1;
|
||||
if (sec <= 0) {
|
||||
clearInterval(this._timer);
|
||||
this._handleTimeout();
|
||||
} else {
|
||||
this.setData({
|
||||
_secondsRemaining: sec,
|
||||
countdown: this._format(sec)
|
||||
});
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// 超时处理:弹窗 + 改状态
|
||||
_handleTimeout() {
|
||||
if (!this.data._hasShownTimeout) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '订单超时未支付,已取消',
|
||||
showCancel: false
|
||||
});
|
||||
this.setData({ _hasShownTimeout: true });
|
||||
}
|
||||
// 更新状态并隐藏倒计时
|
||||
const o = this.data.orderObj;
|
||||
o.orderStatus = '交易取消';
|
||||
this.setData({
|
||||
orderObj: o,
|
||||
countdown: '00分00秒'
|
||||
});
|
||||
},
|
||||
|
||||
// 秒数 → "MM分SS秒"
|
||||
_format(sec) {
|
||||
const m = Math.floor(sec / 60);
|
||||
const s = sec % 60;
|
||||
const mm = m < 10 ? '0' + m : m;
|
||||
const ss = s < 10 ? '0' + s : s;
|
||||
return `${mm}分${ss}秒`;
|
||||
},
|
||||
|
||||
// 取消订单
|
||||
cancelOrder() {
|
||||
wx.showModal({
|
||||
title: '取消订单',
|
||||
content: '是否要取消订单?',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
wx.request({
|
||||
url: baseUrl + "/courseOrder/cancel",
|
||||
method: 'POST',
|
||||
data: { courseId: this.data.orderId },
|
||||
header: { Authorization: wx.getStorageSync('token') },
|
||||
success: () => this.getOrderDetail()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 去支付(示例跳转)
|
||||
goPay() {
|
||||
// wx.navigateTo({ url: `/pages/pay/pay?orderId=${this.data.orderId}` });
|
||||
wx.showToast({ title: '支付功能稍后开放', icon: 'none' });
|
||||
},
|
||||
|
||||
// 退款(示例弹窗)
|
||||
refundOrder() {
|
||||
wx.showToast({ title: '退款功能稍后开放', icon: 'none' });
|
||||
}
|
||||
});
|
87
pages/course/orderDetail/orderDetail.wxml
Normal file
87
pages/course/orderDetail/orderDetail.wxml
Normal file
@ -0,0 +1,87 @@
|
||||
<view class="flex-col page">
|
||||
<view class="flex-col group">
|
||||
<view class="flex-col section">
|
||||
<!-- 订单状态 + 倒计时 -->
|
||||
<view class="flex-row justify-between self-stretch group_2">
|
||||
<text class="font">订单状态</text>
|
||||
<view class="flex-row group_3">
|
||||
<text class="font_2 text" wx:if="{{ orderObj.orderStatus === '待支付' }}">请在{{countdown}}内完成支付</text>
|
||||
<text class="font_2 text_2 ml-37">{{ orderObj.orderStatus }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 课程信息 -->
|
||||
<view class="flex-row self-stretch group_4 mt-15">
|
||||
<image
|
||||
class="shrink-0 image"
|
||||
src="{{ globalImgUrl + orderObj.image }}"
|
||||
/>
|
||||
<text class="flex-1 self-start font_3 text_3 ml-7">
|
||||
{{ orderObj.name }}
|
||||
</text>
|
||||
</view>
|
||||
<!-- 课程价格 -->
|
||||
<text class="self-end font_3 text_4 mt-15">¥{{ orderObj.originPrice }}</text>
|
||||
</view>
|
||||
|
||||
<!-- 订单详情 -->
|
||||
<view class="mt-16 flex-col section_2">
|
||||
<view class="self-start group_5">
|
||||
<text class="font text_5">订单编号:</text>
|
||||
<text class="font_4">{{ orderObj.orderNumber }}</text>
|
||||
</view>
|
||||
<view class="flex-row items-baseline self-start group_6">
|
||||
<text class="shrink-0 font text_6">下单时间:</text>
|
||||
<text class="flex-1 font_5 ml-3">{{ orderObj.createTime }}</text>
|
||||
</view>
|
||||
<view class="flex-col justify-start self-stretch relative group_7">
|
||||
<view class="flex-col section_3">
|
||||
<view class="self-stretch divider"></view>
|
||||
<view class="flex-row self-stretch group_8 mt-17">
|
||||
<text class="font text_7">支付方式:</text>
|
||||
<text class="ml-8 font text_8">微信支付</text>
|
||||
</view>
|
||||
<view class="flex-row items-center self-stretch mt-17">
|
||||
<text class="font text_9">交易号:</text>
|
||||
<!-- TODO -->
|
||||
<text class="font_4 ml-23">4002506191307440406460485418</text>
|
||||
</view>
|
||||
<text class="self-start font text_10 mt-17" wx:if="{{ orderObj.orderStatus === '交易成功' }}">交付时间:</text>
|
||||
</view>
|
||||
<text class="font_5 text_11 pos" wx:if="{{ orderObj.orderStatus === '交易成功' }}">{{ orderObj.updateTime }}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 价格明细 -->
|
||||
<view class="mt-16 flex-col section_4">
|
||||
<view class="flex-row justify-between items-center">
|
||||
<text class="font text_12">课程价格</text>
|
||||
<text class="font_4">¥{{ orderObj.totalAmount }}</text>
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center mt-11">
|
||||
<text class="font text_13">价格折扣</text>
|
||||
<text class="font_4 text_14">-¥{{ orderObj.totalAmount - orderObj.originPrice }}</text>
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center group_9 mt-11">
|
||||
<text class="font_2 text_15">订单金额</text>
|
||||
<text class="font_4 text_16">¥{{ orderObj.originPrice }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮:待支付 -->
|
||||
<view class="flex-row bottom-buttons" wx:if="{{ orderObj.orderStatus === '待支付' }}">
|
||||
<view class="flex-col justify-start items-center text-wrapper" bindtap="cancelOrder">
|
||||
<text class="font_3 text_17">取消</text>
|
||||
</view>
|
||||
<view class="flex-col justify-start items-center text-wrapper_2" bindtap="goPay">
|
||||
<text class="font_3 text_18">立即支付</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮:已支付 -->
|
||||
<view class="flex-row bottom-buttons" wx:if="{{ orderObj.orderStatus === '已支付' }}">
|
||||
<view class="flex-col justify-start items-center text-wrapper_2" bindtap="refundOrder">
|
||||
<text class="font_3 text_18">退款</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -173,7 +173,7 @@
|
||||
line-height: 24.41rpx;
|
||||
}
|
||||
.text_14 {
|
||||
margin-right: 15rpx;
|
||||
/* margin-right: 15rpx; */
|
||||
}
|
||||
.group_9 {
|
||||
padding: 22.5rpx 0 18.75rpx;
|
||||
@ -206,3 +206,12 @@
|
||||
color: #ffffff;
|
||||
line-height: 27.81rpx;
|
||||
}
|
||||
.bottom-buttons {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
background-color: #ffffff; /* 可以根据需要设置背景色 */
|
||||
}
|
@ -1,38 +1,66 @@
|
||||
// pages/course/waitPayOrder/waitPayOrder.js
|
||||
Page({
|
||||
|
||||
data: {
|
||||
// 初始倒计时字符串
|
||||
countdown: '30分00秒'
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
// 启动倒计时(总秒数 = 29*60 + 17)
|
||||
this.initCountdown(30 * 60 );
|
||||
},
|
||||
|
||||
/**
|
||||
* 初始化倒计时
|
||||
* @param {number} totalSeconds 初始总秒数
|
||||
* 页面的初始数据
|
||||
*/
|
||||
initCountdown(totalSeconds) {
|
||||
this.countdownTimer = setInterval(() => {
|
||||
if (totalSeconds <= 0) {
|
||||
clearInterval(this.countdownTimer);
|
||||
this.setData({ countdown: '00分00秒' });
|
||||
return;
|
||||
}
|
||||
totalSeconds--;
|
||||
const m = Math.floor(totalSeconds / 60);
|
||||
const s = totalSeconds % 60;
|
||||
const mm = m < 10 ? '0' + m : '' + m;
|
||||
const ss = s < 10 ? '0' + s : '' + s;
|
||||
this.setData({ countdown: `${mm}分${ss}秒` });
|
||||
}, 1000);
|
||||
data: {
|
||||
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
// 页面卸载时清除定时器
|
||||
clearInterval(this.countdownTimer);
|
||||
}
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
@ -1,79 +1,2 @@
|
||||
<view class="flex-col page">
|
||||
<view class="flex-col group">
|
||||
<view class="flex-col section">
|
||||
<!-- 订单状态 + 倒计时 -->
|
||||
<view class="flex-row justify-between self-stretch group_2">
|
||||
<text class="font">订单状态</text>
|
||||
<view class="flex-row group_3">
|
||||
<text class="font_2 text">请在{{countdown}}内完成支付</text>
|
||||
<text class="font_2 text_2 ml-37">待支付</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 课程信息 -->
|
||||
<view class="flex-row self-stretch group_4 mt-15">
|
||||
<image
|
||||
class="shrink-0 image"
|
||||
src="https://ide.code.fun/api/image?token=6859f7a14ae84d0012334fa9&name=9c2a22f14e2bd768cbd40d939693e4a8.png"
|
||||
/>
|
||||
<text class="flex-1 self-start font_3 text_3 ml-7">
|
||||
区块链和加密数字货币(随报随学认证班)(随报随学认证班)
|
||||
</text>
|
||||
</view>
|
||||
<!-- 课程价格 -->
|
||||
<text class="self-end font_3 text_4 mt-15">¥999.00</text>
|
||||
</view>
|
||||
|
||||
<!-- 订单详情 -->
|
||||
<view class="mt-16 flex-col section_2">
|
||||
<view class="self-start group_5">
|
||||
<text class="font text_5">订单编号:</text>
|
||||
<text class="font_4">202506191307440406460485418</text>
|
||||
</view>
|
||||
<view class="flex-row items-baseline self-start group_6">
|
||||
<text class="shrink-0 font text_6">下单时间:</text>
|
||||
<text class="flex-1 font_5 ml-3">2025-06-19 16:08:15</text>
|
||||
</view>
|
||||
<view class="flex-col justify-start self-stretch relative group_7">
|
||||
<view class="flex-col section_3">
|
||||
<view class="self-stretch divider"></view>
|
||||
<view class="flex-row self-stretch group_8 mt-17">
|
||||
<text class="font text_7">支付方式:</text>
|
||||
<text class="ml-8 font text_8">微信支付</text>
|
||||
</view>
|
||||
<view class="flex-row items-center self-stretch mt-17">
|
||||
<text class="font text_9">交易号:</text>
|
||||
<text class="font_4 ml-23">4002506191307440406460485418</text>
|
||||
</view>
|
||||
<text class="self-start font text_10 mt-17">交付时间:</text>
|
||||
</view>
|
||||
<text class="font_5 text_11 pos">2025-06-19 08:48:35</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 价格明细 -->
|
||||
<view class="mt-16 flex-col section_4">
|
||||
<view class="flex-row justify-between items-center">
|
||||
<text class="font text_12">课程价格</text>
|
||||
<text class="font_4">¥1999.9</text>
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center mt-11">
|
||||
<text class="font text_13">价格折扣</text>
|
||||
<text class="font_4 text_14">-¥10</text>
|
||||
</view>
|
||||
<view class="flex-row justify-between items-center group_9 mt-11">
|
||||
<text class="font_2 text_15">订单金额</text>
|
||||
<text class="font_4 text_16">¥999</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 底部按钮 -->
|
||||
<view class="flex-row mt-389">
|
||||
<view class="flex-col justify-start items-center text-wrapper">
|
||||
<text class="font_3 text_17">取消</text>
|
||||
</view>
|
||||
<view class="flex-col justify-start items-center text-wrapper_2">
|
||||
<text class="font_3 text_18">立即支付</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!--pages/course/waitPayOrder/waitPayOrder.wxml-->
|
||||
<text>pages/course/waitPayOrder/waitPayOrder.wxml</text>
|
Reference in New Issue
Block a user