青橙1.1.2
This commit is contained in:
@ -91,7 +91,11 @@ Page({
|
||||
|
||||
onUnload() {},
|
||||
|
||||
onPullDownRefresh() {},
|
||||
onPullDownRefresh() {
|
||||
this.getCourseDetail()
|
||||
// 停止下拉刷新动画
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
onReachBottom() {},
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -74,7 +74,7 @@
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12rpx;
|
||||
margin-bottom: 12rpx;
|
||||
margin-bottom: 22rpx;
|
||||
}
|
||||
.head-icon { width: 34rpx; height: 34rpx; }
|
||||
.head-text { font-size: 28rpx; color: #111; font-weight: 600; }
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 753 B After Width: | Height: | Size: 4.2 KiB |
BIN
pages/course/courseDetail/image/cal1.png
Normal file
BIN
pages/course/courseDetail/image/cal1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 753 B |
@ -5,103 +5,134 @@ const { notLogin } = require('../../../utils/util')
|
||||
Page({
|
||||
data: {
|
||||
orderList: [], // 后端返回的订单列表
|
||||
hasModalShown: false, // 弹框只显示一次
|
||||
hasModalShown: false, // 本次停留页面只弹一次
|
||||
isMaskVisible: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
// —— 内部状态(不放 data,避免多余 setData)
|
||||
_timer: null,
|
||||
_isActive: false, // 页面是否处于“可见/激活”状态
|
||||
_justEnteredAt: 0, // 进入页面时刻(可按需使用)
|
||||
|
||||
onLoad() {
|
||||
this._isActive = true;
|
||||
this._justEnteredAt = Date.now();
|
||||
this.fetchOrders();
|
||||
},
|
||||
onShow() {
|
||||
this._isActive = true;
|
||||
this.fetchOrders(); // 如不想重复拉取可注释
|
||||
},
|
||||
onHide() {
|
||||
clearInterval(this._timer);
|
||||
this._isActive = false;
|
||||
this._clearTimer();
|
||||
},
|
||||
onUnload() {
|
||||
clearInterval(this._timer);
|
||||
},
|
||||
onShow() {
|
||||
this.fetchOrders()
|
||||
this._isActive = false;
|
||||
this._clearTimer();
|
||||
},
|
||||
|
||||
// 拉取后端接口
|
||||
onPullDownRefresh() {
|
||||
this.fetchOrders(); // stopPullDownRefresh 在 complete 里
|
||||
},
|
||||
|
||||
// ========= 工具函数 =========
|
||||
_clearTimer() {
|
||||
if (this._timer) {
|
||||
clearInterval(this._timer);
|
||||
this._timer = null;
|
||||
}
|
||||
},
|
||||
_pad2(n) {
|
||||
return String(n).padStart(2, '0');
|
||||
},
|
||||
_fmtCountDownStr(totalSec) {
|
||||
const sec = Math.max(0, totalSec | 0);
|
||||
const m = Math.floor(sec / 60);
|
||||
const s = sec % 60;
|
||||
return `${this._pad2(m)}分${this._pad2(s)}秒`;
|
||||
},
|
||||
|
||||
// ========= 拉单 =========
|
||||
fetchOrders() {
|
||||
wx.request({
|
||||
url: baseUrl + '/courseOrder/query/list', // 替换为真实接口
|
||||
url: baseUrl + '/courseOrder/query/list',
|
||||
method: 'POST',
|
||||
header: {
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
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 + 15*60*1000 - now) / 1000);
|
||||
const list = (res.data.data || []).map(it => {
|
||||
// 解析时间(iOS 兼容 + NaN 兜底)
|
||||
const ts = new Date(String(it.createTime).replace(/-/g, '/')).getTime();
|
||||
const createMs = Number.isFinite(ts) ? ts : now;
|
||||
|
||||
// 只有“待支付”才需要倒计时、过期置“交易取消”
|
||||
if (item.orderStatus === '待支付') {
|
||||
if (diff <= 0) {
|
||||
item.orderStatus = '交易取消';
|
||||
diff = 0;
|
||||
// 首次检测到过期就弹框
|
||||
if (!this.data.hasModalShown) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '订单超时未支付,已取消',
|
||||
showCancel: false
|
||||
});
|
||||
this.setData({ hasModalShown: true });
|
||||
// 统一按 15 分钟有效期(若后端返回 expireTime,建议直接用)
|
||||
const ttlMs = 15 * 60 * 1000;
|
||||
let diff = Math.floor((createMs + ttlMs - now) / 1000);
|
||||
diff = Math.max(0, diff);
|
||||
|
||||
if (it.orderStatus === '待支付') {
|
||||
it.countDown = diff;
|
||||
it.countDownStr = this._fmtCountDownStr(diff);
|
||||
it._expiredNotified = false; // 每单的本地防重复标记
|
||||
|
||||
// 初始化阶段:如果已经超时(diff=0),静默转关闭,不弹窗
|
||||
if (diff === 0) {
|
||||
it.orderStatus = '交易关闭';
|
||||
it.countDownStr = '';
|
||||
}
|
||||
}
|
||||
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 = '';
|
||||
it.countDown = 0;
|
||||
it.countDownStr = '';
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
this.setData({ orderList: list }, () => {
|
||||
// 初始处理完后启动全局定时器
|
||||
this.startTimer();
|
||||
return it;
|
||||
});
|
||||
|
||||
// 渲染 + 启动定时器
|
||||
this.setData({ orderList: list }, () => this._startTimer());
|
||||
} else {
|
||||
notLogin(res.data.message)
|
||||
notLogin(res.data.message);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.showToast({ title: '网络错误', icon: 'none' });
|
||||
},
|
||||
complete: () => {
|
||||
wx.stopPullDownRefresh();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
// 每秒更新所有待支付订单的倒计时
|
||||
startTimer() {
|
||||
// ← 新增:如果已有定时器,先清掉它
|
||||
if (this._timer) {
|
||||
clearInterval(this._timer);
|
||||
}
|
||||
// ========= 定时器刷新 =========
|
||||
_startTimer() {
|
||||
this._clearTimer();
|
||||
// 如果已经没有“待支付”的订单,就不启动定时器
|
||||
const hasPending = this.data.orderList.some(o => o.orderStatus === '待支付' && o.countDown > 0);
|
||||
if (!hasPending) return;
|
||||
|
||||
this._timer = setInterval(() => {
|
||||
// 不在激活页时不做任何 UI 相关动作(同时兜底不弹窗)
|
||||
if (!this._isActive) return;
|
||||
|
||||
let needRerender = false;
|
||||
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}秒`;
|
||||
const next = item.countDown - 1;
|
||||
item.countDown = next;
|
||||
item.countDownStr = this._fmtCountDownStr(next);
|
||||
needRerender = true;
|
||||
|
||||
if (cd <= 0) {
|
||||
item.orderStatus = '交易取消';
|
||||
if (next <= 0) {
|
||||
item.orderStatus = '交易关闭';
|
||||
item.countDownStr = '';
|
||||
if (!this.data.hasModalShown) {
|
||||
|
||||
// —— 仅在“当前页面可见”时弹一次,并且每单只弹一次;本页全局也只弹一次
|
||||
if (this._isActive && !item._expiredNotified && !this.data.hasModalShown) {
|
||||
item._expiredNotified = true;
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '订单超时未支付,已取消',
|
||||
content: '订单超时未支付,已关闭',
|
||||
showCancel: false
|
||||
});
|
||||
this.setData({ hasModalShown: true });
|
||||
@ -110,17 +141,28 @@ Page({
|
||||
}
|
||||
return item;
|
||||
});
|
||||
this.setData({ orderList: updated });
|
||||
|
||||
if (needRerender) {
|
||||
this.setData({ orderList: updated }, () => {
|
||||
// 如果已经没有可继续倒计时的订单,关掉定时器
|
||||
const stillPending = this.data.orderList.some(o => o.orderStatus === '待支付' && o.countDown > 0);
|
||||
if (!stillPending) this._clearTimer();
|
||||
});
|
||||
} else {
|
||||
// 没有需要更新的也关掉
|
||||
this._clearTimer();
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// ========= 支付相关 =========
|
||||
showIsPayModal(e) {
|
||||
const orderId = e.currentTarget.dataset.orderId;
|
||||
wx.showModal({
|
||||
title: '下单成功',
|
||||
content: '您确定要支付吗?',
|
||||
title: '确认支付',
|
||||
content: '是否立即支付该订单?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
confirmText: '去支付',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.payOrder(orderId);
|
||||
@ -130,30 +172,25 @@ Page({
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: '网络错误,下单失败',
|
||||
icon: 'none'
|
||||
});
|
||||
wx.showToast({ title: '网络错误', icon: 'none' });
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
payOrder(orderId) {
|
||||
// 同样先显示遮罩
|
||||
this.setData({ isMaskVisible: true });
|
||||
wx.showLoading({ title: '支付中...'});
|
||||
wx.showLoading({ title: '支付中...' });
|
||||
wx.request({
|
||||
url: baseUrl + '/courseOrder/payment',
|
||||
method: 'POST',
|
||||
header: { Authorization: wx.getStorageSync('token') },
|
||||
data: { id: orderId},
|
||||
data: { id: orderId }, // 与后端约定:支付接口传 id;若传 orderId 则改键名
|
||||
success: res => {
|
||||
wx.hideLoading();
|
||||
if (res.data.code === 1) {
|
||||
// 支付成功,跳转详情页
|
||||
wx.redirectTo({
|
||||
url: `/pages/course/orderDetail/orderDetail?id=${orderId}`,
|
||||
success: res => {
|
||||
// 先把遮罩关掉
|
||||
complete: () => {
|
||||
this.setData({ isMaskVisible: false });
|
||||
}
|
||||
});
|
||||
@ -170,33 +207,36 @@ Page({
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转订单详情
|
||||
// ========= 跳转 & 取消 =========
|
||||
gotoOrderDetail(e) {
|
||||
const orderId = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({
|
||||
url: `/pages/course/orderDetail/orderDetail?id=${orderId}`,
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
// 取消订单
|
||||
cancelOrder(e) {
|
||||
// console.log(e);
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.showModal({
|
||||
title: '取消订单',
|
||||
content: '是否要取消订单?',
|
||||
content: '是否要取消该订单?',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
wx.request({
|
||||
url: baseUrl + "/courseOrder/cancel",
|
||||
method: 'POST',
|
||||
data: { courseId: id },
|
||||
header: { Authorization: wx.getStorageSync('token') },
|
||||
success: () => this.fetchOrders()
|
||||
data: { id }, // 如果后端需要 { orderId: id },改这里的键名即可
|
||||
success: r => {
|
||||
if (r.data && r.data.code !== 1) {
|
||||
wx.showToast({ title: r.data.message || '取消失败', icon: 'none' });
|
||||
}
|
||||
this.fetchOrders();
|
||||
},
|
||||
fail: () => wx.showToast({ title: '网络错误', icon: 'none' })
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -14,7 +14,7 @@
|
||||
<view wx:for="{{ orderList }}"
|
||||
wx:for-item="item"
|
||||
wx:for-index="index"
|
||||
wx:key="item.id"
|
||||
wx:key="id"
|
||||
class="card order-item"
|
||||
bind:tap="gotoOrderDetail"
|
||||
data-id="{{ item.id }}">
|
||||
|
@ -130,7 +130,10 @@ Page({
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
this.getBannerList()
|
||||
this.getCourseList()
|
||||
// 停止下拉刷新动画
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -51,7 +51,7 @@
|
||||
/* 列表(滚动) */
|
||||
.list {
|
||||
flex: 1;
|
||||
padding: 0 20rpx 20rpx;
|
||||
padding: 0 30rpx;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
overflow: auto;
|
||||
}
|
||||
@ -61,11 +61,13 @@
|
||||
/* 宫格布局 */
|
||||
.grid {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 20rpx;
|
||||
padding-bottom: 30rpx;
|
||||
}
|
||||
.grid-item {
|
||||
width: 345rpx;
|
||||
width: 335rpx;
|
||||
background: #fff;
|
||||
border-radius: 16rpx;
|
||||
overflow: hidden;
|
||||
@ -87,6 +89,7 @@
|
||||
font-size: 26rpx;
|
||||
color: #111;
|
||||
line-height: 36rpx;
|
||||
min-height: 72rpx;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
|
@ -2,27 +2,165 @@ import { baseUrl, globalImgUrl } from "../../../request";
|
||||
|
||||
Page({
|
||||
data: {
|
||||
countdown: '',
|
||||
countdown: "",
|
||||
orderId: 0,
|
||||
orderObj: {}, // 订单详情对象
|
||||
_secondsRemaining: 0, // 内部倒计时秒数
|
||||
_hasShownTimeout: false, // 是否已弹过“超时未支付”弹窗
|
||||
_hasShownTimeout: false, // 是否已弹过“超时未支付”弹窗(本次页面停留期内)
|
||||
globalImgUrl,
|
||||
isMaskVisible: false
|
||||
isMaskVisible: false,
|
||||
_isActive: false // 页面是否处于可见状态
|
||||
},
|
||||
|
||||
// —— 非 data 状态,避免无谓 setData
|
||||
_timer: null,
|
||||
|
||||
onLoad(options) {
|
||||
console.log('options---->',options);
|
||||
this.setData({ orderId: options.id });
|
||||
this.setData({ orderId: options.id || 0 });
|
||||
this.getOrderDetail();
|
||||
},
|
||||
showIsPayModal() {
|
||||
const {orderId} = this.data
|
||||
|
||||
onShow() {
|
||||
this.setData({ _isActive: true });
|
||||
},
|
||||
|
||||
onHide() {
|
||||
this.setData({ _isActive: false });
|
||||
this._clearTimer();
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
this.setData({ _isActive: false });
|
||||
this._clearTimer();
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.getOrderDetail(); // stopPullDownRefresh 放到 complete 里,更稳
|
||||
},
|
||||
|
||||
// ====== 工具函数 ======
|
||||
_clearTimer() {
|
||||
if (this._timer) {
|
||||
clearInterval(this._timer);
|
||||
this._timer = null;
|
||||
}
|
||||
},
|
||||
_pad2(n) {
|
||||
return String(n).padStart(2, "0");
|
||||
},
|
||||
_format(sec) {
|
||||
const m = Math.floor(sec / 60);
|
||||
const s = sec % 60;
|
||||
return `${this._pad2(m)}分${this._pad2(s)}秒`;
|
||||
},
|
||||
|
||||
// ====== 拉取订单详情并初始化倒计时 ======
|
||||
getOrderDetail() {
|
||||
wx.request({
|
||||
url: baseUrl + "/courseOrder/query/detail",
|
||||
method: "POST",
|
||||
data: { id: this.data.orderId },
|
||||
header: { Authorization: wx.getStorageSync("token") },
|
||||
success: (res) => {
|
||||
if (res.data.code !== 1) {
|
||||
wx.showToast({ title: res.data.message || "获取失败", icon: "none" });
|
||||
return;
|
||||
}
|
||||
|
||||
const order = res.data.data || {};
|
||||
this.setData({ orderObj: order });
|
||||
|
||||
// 只有“待支付”才需要倒计时;其它状态关掉计时器并清空文案
|
||||
if (order.orderStatus === "待支付") {
|
||||
this._initFromCreateTime(order.createTime);
|
||||
} else {
|
||||
this._clearTimer();
|
||||
this.setData({ countdown: "" });
|
||||
}
|
||||
},
|
||||
fail: () => wx.showToast({ title: "网络错误", icon: "none" }),
|
||||
complete: () => wx.stopPullDownRefresh(),
|
||||
});
|
||||
},
|
||||
|
||||
// 计算剩余秒数并启动定时器
|
||||
_initFromCreateTime(createTime) {
|
||||
const ts = new Date(String(createTime).replace(/-/g, "/")).getTime();
|
||||
const createMs = Number.isFinite(ts) ? ts : Date.now();
|
||||
const ttlMs = 15 * 60 * 1000; // 15分钟有效
|
||||
const now = Date.now();
|
||||
let diff = Math.floor((createMs + ttlMs - now) / 1000);
|
||||
diff = Math.max(0, diff);
|
||||
|
||||
// 初始化阶段:如果已过期,静默转“交易关闭”(不弹窗,避免干扰)
|
||||
if (diff === 0) {
|
||||
const o = { ...this.data.orderObj, orderStatus: "交易关闭" };
|
||||
this._clearTimer();
|
||||
this.setData({ orderObj: o, countdown: "" });
|
||||
return;
|
||||
}
|
||||
|
||||
// 未过期:初始化倒计时并启动
|
||||
this._clearTimer();
|
||||
this.setData({
|
||||
_secondsRemaining: diff,
|
||||
countdown: this._format(diff),
|
||||
_hasShownTimeout: false, // 重置本页弹窗标记
|
||||
});
|
||||
this._startTimer();
|
||||
},
|
||||
|
||||
// 每秒递减
|
||||
_startTimer() {
|
||||
this._clearTimer();
|
||||
this._timer = setInterval(() => {
|
||||
const sec = this.data._secondsRemaining - 1;
|
||||
|
||||
if (sec <= 0) {
|
||||
this._clearTimer();
|
||||
this._handleTimeout(); // 到点且在当前页,才弹窗
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({
|
||||
_secondsRemaining: sec,
|
||||
countdown: this._format(sec),
|
||||
});
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// 超时处理:仅在当前页可见时弹一次,并把状态改为“交易关闭”
|
||||
_handleTimeout() {
|
||||
const { _isActive, _hasShownTimeout } = this.data;
|
||||
|
||||
// 更新状态并隐藏倒计时
|
||||
const o = { ...this.data.orderObj, orderStatus: "交易关闭" };
|
||||
this.setData({ orderObj: o, countdown: "" });
|
||||
|
||||
// 只在当前页面 & 未弹过 时弹一次
|
||||
if (_isActive && !_hasShownTimeout) {
|
||||
wx.showModal({
|
||||
title: '下单成功',
|
||||
content: '您确定要支付吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
title: "提示",
|
||||
content: "订单超时未支付,已关闭",
|
||||
showCancel: false,
|
||||
complete: () => {
|
||||
// 标记已弹
|
||||
this.setData({ _hasShownTimeout: true });
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.setData({ _hasShownTimeout: true });
|
||||
}
|
||||
},
|
||||
|
||||
// ====== 支付相关 ======
|
||||
showIsPayModal() {
|
||||
const { orderId } = this.data;
|
||||
wx.showModal({
|
||||
title: "确认支付",
|
||||
content: "是否立即支付该订单?",
|
||||
cancelText: "取消",
|
||||
confirmText: "去支付",
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
this.payOrder(orderId);
|
||||
@ -32,163 +170,70 @@ Page({
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
wx.showToast({
|
||||
title: '网络错误,下单失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
wx.showToast({ title: "网络错误", icon: "none" });
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
payOrder(orderId) {
|
||||
// 同样先显示遮罩
|
||||
this.setData({ isMaskVisible: true });
|
||||
wx.showLoading({ title: '支付中...'});
|
||||
wx.showLoading({ title: "支付中..." });
|
||||
|
||||
wx.request({
|
||||
url: baseUrl + '/courseOrder/payment',
|
||||
method: 'POST',
|
||||
header: { Authorization: wx.getStorageSync('token') },
|
||||
data: { id: orderId},
|
||||
success: res => {
|
||||
url: baseUrl + "/courseOrder/payment",
|
||||
method: "POST",
|
||||
header: { Authorization: wx.getStorageSync("token") },
|
||||
data: { id: orderId }, // 若后端用 orderId,则把键名改为 orderId
|
||||
success: (res) => {
|
||||
wx.hideLoading();
|
||||
if (res.data.code === 1) {
|
||||
// 支付成功,跳转详情页
|
||||
wx.redirectTo({
|
||||
url: `/pages/course/orderDetail/orderDetail?id=${orderId}`,
|
||||
success: res => {
|
||||
// 先把遮罩关掉
|
||||
this.setData({ isMaskVisible: false });
|
||||
}
|
||||
complete: () => this.setData({ isMaskVisible: false }),
|
||||
});
|
||||
} else {
|
||||
this.setData({ isMaskVisible: false });
|
||||
wx.showToast({ title: res.data.message || '支付失败', icon: 'none' });
|
||||
wx.showToast({ title: res.data.message || "支付失败", icon: "none" });
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
wx.hideLoading();
|
||||
this.setData({ isMaskVisible: false });
|
||||
wx.showToast({ title: '网络错误,支付失败', icon: 'none' });
|
||||
}
|
||||
});
|
||||
wx.showToast({ title: "网络错误,支付失败", icon: "none" });
|
||||
},
|
||||
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 + 15 * 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 => {
|
||||
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()
|
||||
method: "POST",
|
||||
header: { Authorization: wx.getStorageSync("token") },
|
||||
data: { id: this.data.orderId }, // 后端如果需要 { orderId },改键名
|
||||
success: (r) => {
|
||||
if (!r.data || r.data.code !== 1) {
|
||||
wx.showToast({ title: (r.data && r.data.message) || "取消失败", icon: "none" });
|
||||
}
|
||||
this.getOrderDetail();
|
||||
},
|
||||
fail: () => wx.showToast({ title: "网络错误", icon: "none" }),
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
// 去支付(示例跳转)
|
||||
goPay() {
|
||||
// wx.navigateTo({ url: `/pages/pay/pay?orderId=${this.data.orderId}` });
|
||||
wx.showToast({ title: '支付功能稍后开放', icon: 'none' });
|
||||
wx.showToast({ title: "支付功能稍后开放", icon: "none" });
|
||||
},
|
||||
|
||||
// 退款(示例弹窗)
|
||||
refundOrder() {
|
||||
wx.showToast({ title: '退款功能稍后开放', icon: 'none' });
|
||||
}
|
||||
wx.showToast({ title: "退款功能稍后开放", icon: "none" });
|
||||
},
|
||||
});
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -130,3 +130,9 @@
|
||||
/* ===== 如你项目里已有的工具类,可保留或删除 ===== */
|
||||
.ml-3 { margin-left: 6rpx; }
|
||||
.mt-17 { margin-top: 12rpx; }
|
||||
|
||||
::-webkit-scrollbar {
|
||||
width: 0;
|
||||
height: 0;
|
||||
background: transparent;
|
||||
}
|
@ -57,6 +57,11 @@ Page({
|
||||
else if (trueCount === 1) this.setData({widthRate: '100%'})
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.fetchPerformance()
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
fetchPerformance() {
|
||||
wx.request({
|
||||
url: baseUrl + '/perform/mini/query/dashboard',
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -6,14 +6,17 @@ Page({
|
||||
// 用于存储输入框数据
|
||||
nickName: '',
|
||||
phoneNumber: '',
|
||||
selectedSortField: '员工数量', // 默认选择"待选择"
|
||||
selectedSortOrder: '升序', // 默认选择升序
|
||||
selectedSortField: '员工数量', // 默认选择"员工数量"
|
||||
selectedSortOrder: '降序', // 默认选择升序
|
||||
sortFieldsByManager: ['员工数量', '推广人数', '下单数量', '总订单金额', '净成交金额'],
|
||||
sortFieldsBySupervisor: ['推广人数', '下单数量', '总订单金额', '净成交金额'],
|
||||
sortField: 'empCount',
|
||||
sortOrder: 'descend',
|
||||
sortOrders: ['升序', '降序'],
|
||||
items: [], // 用于存储查询结果
|
||||
role: '', // 假设初始为主管角色,可以根据实际情况动态设置
|
||||
k: 1
|
||||
k: 1,
|
||||
showRole: ''
|
||||
},
|
||||
|
||||
// 主管名称输入
|
||||
@ -32,7 +35,6 @@ Page({
|
||||
|
||||
// 选择排序字段
|
||||
onSortFieldChange(e) {
|
||||
const { role } = this.data;
|
||||
const sortFieldsMap = {
|
||||
'员工数量': 'empCount',
|
||||
'推广人数': 'promoCount',
|
||||
@ -40,8 +42,8 @@ Page({
|
||||
'总订单金额': 'totalAmount',
|
||||
'净成交金额': 'netAmount'
|
||||
};
|
||||
|
||||
const selectedField = this.data.sortFieldsByManager[e.detail.value] || this.data.sortFieldsBySupervisor[e.detail.value];
|
||||
const { showRole, sortFieldsByManager, sortFieldsBySupervisor } = this.data
|
||||
let selectedField = showRole === '主管' ? sortFieldsByManager[e.detail.value] : sortFieldsBySupervisor[e.detail.value];
|
||||
this.setData({
|
||||
selectedSortField: selectedField,
|
||||
sortField: sortFieldsMap[selectedField], // 默认是 id
|
||||
@ -61,7 +63,7 @@ Page({
|
||||
|
||||
// 搜索按钮点击
|
||||
onSearch() {
|
||||
const { role } = this.data;
|
||||
const { showRole, role } = this.data;
|
||||
// // —— 新增:校验主管名称 ——
|
||||
// const nameRegex = /^[\u4e00-\u9fa5]+$/;
|
||||
// if (!this.data.nickName) {
|
||||
@ -98,12 +100,17 @@ Page({
|
||||
mask: true // 显示遮罩层
|
||||
});
|
||||
|
||||
if (showRole === '员工') {
|
||||
this.setData({ sortField: 'promoCount' })
|
||||
}
|
||||
|
||||
const requestData = {
|
||||
nickName: this.data.nickName,
|
||||
phoneNumber: this.data.phoneNumber,
|
||||
sortField: this.data.sortField || '',
|
||||
sortOrder: this.data.sortOrder || 'ascend'
|
||||
};
|
||||
console.log('requestData====>', requestData)
|
||||
|
||||
if(role === 'manager') {
|
||||
wx.request({
|
||||
@ -129,7 +136,6 @@ Page({
|
||||
fail: () => {
|
||||
// 请求失败后,隐藏loading
|
||||
wx.hideLoading();
|
||||
console.log('111');
|
||||
wx.showToast({
|
||||
title: '请求失败',
|
||||
icon: 'none'
|
||||
@ -193,5 +199,11 @@ Page({
|
||||
}
|
||||
this.setData({ showRole });
|
||||
this.onSearch()
|
||||
}
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.onSearch()
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
});
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -46,7 +46,7 @@
|
||||
bindchange="onSortFieldChange">
|
||||
<view class="picker-inner">
|
||||
<text class="picker-text">{{ selectedSortField }}</text>
|
||||
<image class="arrow" src="./images/bottom.png" />
|
||||
<image class="arrow" src="./images/bottom.png"/>
|
||||
</view>
|
||||
</picker>
|
||||
|
||||
|
@ -77,17 +77,18 @@
|
||||
background: #ffffff;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
position: relative;
|
||||
}
|
||||
.picker-inner {
|
||||
padding: 0 20rpx;
|
||||
width: 100%;
|
||||
width: 270rpx;
|
||||
height: 84rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.picker-text { font-size: 28rpx; color: #1f1f1f; }
|
||||
.arrow { width: 28rpx; height: 28rpx; }
|
||||
.picker-text { font-size: 28rpx; color: #1f1f1f;}
|
||||
.arrow { width: 28rpx; height: 28rpx; position: absolute; right: 20rpx;}
|
||||
|
||||
/* 搜索按钮 */
|
||||
.btn {
|
||||
|
@ -106,6 +106,11 @@ Page({
|
||||
this.onSearchSupId();
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.onSearchSupId()
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
// 跳转用户订单
|
||||
gotoUser(e) {
|
||||
const { id } = e.currentTarget.dataset;
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -126,7 +126,7 @@
|
||||
}
|
||||
.row-key { font-size: 26rpx; color: #666666; }
|
||||
.row-val { display: flex; align-items: center; gap: 16rpx; }
|
||||
.mono { font-size: 28rpx; color: #1f1f1f; font-family: monospace; letter-spacing: 1rpx; }
|
||||
.mono { font-size: 28rpx; color: #1f1f1f; }
|
||||
.copy {
|
||||
font-size: 24rpx;
|
||||
color: #ff8a00;
|
||||
|
@ -83,6 +83,11 @@ Page({
|
||||
this.onSearch()
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.onSearch()
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
changeStaff(e) {
|
||||
|
||||
const { id } = e.currentTarget.dataset;
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -163,8 +163,6 @@
|
||||
.mono {
|
||||
font-size: 28rpx;
|
||||
color: #1f1f1f;
|
||||
font-family: monospace;
|
||||
letter-spacing: 1rpx;
|
||||
}
|
||||
|
||||
.copy {
|
||||
|
@ -17,6 +17,11 @@ Page({
|
||||
this.searchOrderByStaffId()
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.searchOrderByStaffId()
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
|
||||
// 输入框内容变化
|
||||
onOrderNumberInput(e) {
|
||||
this.setData({
|
||||
|
@ -1,3 +1,4 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
@ -87,7 +87,7 @@
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.label { font-size: 26rpx; color: #666666; }
|
||||
.mono { font-size: 28rpx; color: #1f1f1f; font-family: monospace; letter-spacing: 1rpx; }
|
||||
.mono { font-size: 28rpx; color: #1f1f1f; }
|
||||
|
||||
.badge {
|
||||
height: 40rpx;
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 5.4 KiB |
BIN
pages/personCenter/mine/images/order1.png
Normal file
BIN
pages/personCenter/mine/images/order1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.1 KiB |
@ -3,7 +3,7 @@
|
||||
"projectname": "qingcheng-xiaochengxu",
|
||||
"setting": {
|
||||
"compileHotReLoad": true,
|
||||
"urlCheck": false,
|
||||
"urlCheck": true,
|
||||
"bigPackageSizeSupport": false
|
||||
},
|
||||
"condition": {},
|
||||
|
@ -4,6 +4,6 @@ export const dev = 'http://160.202.242.36:9091';
|
||||
export const test = 'http://160.202.242.36:9092';
|
||||
export const localTest = 'http://localhost:9092';
|
||||
export const ssl = 'https://www.chenxinzhi.top'
|
||||
export const baseUrl = test;
|
||||
export const baseUrl = ssl;
|
||||
|
||||
export const globalImgUrl = baseUrl + '/file/download/'
|
Reference in New Issue
Block a user