2025-09-15 21:06:37 +08:00
|
|
|
|
import { checkXsXkApi, checkXkTfApi } from "@/api/base/xkApi";
|
2025-09-13 20:37:43 +08:00
|
|
|
|
import { checkXsJcApi } from "@/api/base/jcApi";
|
2025-09-02 15:45:06 +08:00
|
|
|
|
import { useUserStore } from "@/store/modules/user";
|
|
|
|
|
|
import { useDataStore } from "@/store/modules/data";
|
|
|
|
|
|
const userStore = useUserStore();
|
|
|
|
|
|
const dataStore = useDataStore();
|
|
|
|
|
|
|
2025-09-03 19:46:26 +08:00
|
|
|
|
// TODO: 记住测试的时候才默认使用第一个
|
|
|
|
|
|
const devFlag = false;
|
2025-09-02 15:45:06 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 页面工具类,主要在于处理抢课、就餐等页面逻辑跳转的处理
|
|
|
|
|
|
*/
|
|
|
|
|
|
export const PageUtils = {
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 跳转逻辑
|
|
|
|
|
|
* @param lxId 类型( JC: 就餐,816059832: 俱乐部,962488654: 兴趣课)
|
2025-09-15 21:06:37 +08:00
|
|
|
|
* @param action 动作(jf: 缴费,tf: 退费)
|
2025-09-02 15:45:06 +08:00
|
|
|
|
*/
|
2025-09-15 21:06:37 +08:00
|
|
|
|
async toHome(lxId: string, action: string) {
|
2025-09-02 15:45:06 +08:00
|
|
|
|
// 没有类型,则跳转首页
|
|
|
|
|
|
if (!lxId) {
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/home/index",
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
// 判断当前学生列表,如果大于1,则跳转学生选择页面
|
|
|
|
|
|
const xsList = userStore.getUser.xsList;
|
|
|
|
|
|
if (devFlag) {
|
|
|
|
|
|
userStore.setCurXs(xsList[0]);
|
|
|
|
|
|
} else {
|
2025-09-03 15:02:20 +08:00
|
|
|
|
if (xsList && xsList.length > 1
|
|
|
|
|
|
&& (dataStore.getGlobal && dataStore.getGlobal.from == 'launch')) {
|
2025-09-02 15:45:06 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/home/xsXz",
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// 判断业务逻辑,并跳转界面
|
2025-09-15 21:06:37 +08:00
|
|
|
|
await this.checkLogicPage(lxId, action);
|
2025-09-02 15:45:06 +08:00
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 判断业务逻辑,并跳转界面
|
|
|
|
|
|
*/
|
2025-09-15 21:06:37 +08:00
|
|
|
|
async checkLogicPage(lxId: string, action: string) {
|
2025-09-02 15:45:06 +08:00
|
|
|
|
switch (lxId) {
|
|
|
|
|
|
// 就餐逻辑单独处理
|
|
|
|
|
|
case "JC": {
|
2025-09-13 20:37:43 +08:00
|
|
|
|
|
2025-09-02 15:45:06 +08:00
|
|
|
|
} break;
|
|
|
|
|
|
// 默认当作 选课的选课类型ID(xkLxId)处理
|
|
|
|
|
|
default: {
|
2025-09-15 21:06:37 +08:00
|
|
|
|
if (action === "jf") {
|
|
|
|
|
|
await this.checkQkLogic(lxId);
|
|
|
|
|
|
} else if (action === "tf") {
|
|
|
|
|
|
await this.checkXkTfLogic(lxId);
|
|
|
|
|
|
}
|
2025-09-02 15:45:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 判断抢课逻辑
|
|
|
|
|
|
* @param xklxId
|
|
|
|
|
|
*/
|
|
|
|
|
|
async checkQkLogic(xklxId: string) {
|
|
|
|
|
|
const res: any = await checkXsXkApi({
|
|
|
|
|
|
xsId: userStore.getCurXs.id,
|
|
|
|
|
|
njmcId: userStore.getCurXs.njmcId,
|
|
|
|
|
|
xklxId: xklxId,
|
|
|
|
|
|
});
|
|
|
|
|
|
console.log('checkQkLogic', res);
|
|
|
|
|
|
if (res.resultCode != 1) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: res.message,
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/home/xsXz",
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const result = res.result || {};
|
|
|
|
|
|
// 记录到缓存数据中
|
|
|
|
|
|
dataStore.setQk(result);
|
|
|
|
|
|
// 状态判断
|
|
|
|
|
|
switch (result.xsXkStatus) {
|
2025-09-03 19:46:26 +08:00
|
|
|
|
case 'WFB': { // KQK可抢课
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/xk/qk/wks?xklxId=" + xklxId,
|
|
|
|
|
|
});
|
|
|
|
|
|
} break;
|
2025-09-02 15:45:06 +08:00
|
|
|
|
case 'KQK': { // KQK可抢课
|
|
|
|
|
|
uni.reLaunch({
|
2025-09-02 21:55:01 +08:00
|
|
|
|
url: "/pages/base/gzs/index?lxId=" + xklxId,
|
2025-09-02 15:45:06 +08:00
|
|
|
|
});
|
|
|
|
|
|
} break;
|
|
|
|
|
|
case 'QKZ': { // QKZ抢课中
|
2025-09-02 20:57:37 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/xk/qk/index?xklxId=" + xklxId,
|
|
|
|
|
|
});
|
2025-09-02 15:45:06 +08:00
|
|
|
|
} break;
|
|
|
|
|
|
case 'YQK': { // YQK已选课
|
2025-09-02 20:57:37 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/xk/pay/index?xklxId=" + xklxId,
|
|
|
|
|
|
});
|
2025-09-02 15:45:06 +08:00
|
|
|
|
} break;
|
|
|
|
|
|
case 'DZF': { // DZF待支付
|
2025-09-02 20:57:37 +08:00
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/xk/pay/index?xklxId=" + xklxId,
|
|
|
|
|
|
});
|
2025-09-02 15:45:06 +08:00
|
|
|
|
} break;
|
|
|
|
|
|
case 'YZF': { // YZF已支付
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/xk/pay/success?xklxId=" + xklxId,
|
|
|
|
|
|
});
|
|
|
|
|
|
} break;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-09-15 21:06:37 +08:00
|
|
|
|
|
|
|
|
|
|
// 判断退费页面切换逻辑
|
|
|
|
|
|
async checkXkTfLogic(xklxId: string) {
|
|
|
|
|
|
const res = await checkXkTfApi({
|
|
|
|
|
|
xsId: userStore.getCurXs.id,
|
|
|
|
|
|
njmcId: userStore.getCurXs.njmcId,
|
|
|
|
|
|
xklxId: xklxId,
|
|
|
|
|
|
});
|
|
|
|
|
|
console.log('checkXkTfLogic', res);
|
|
|
|
|
|
if (res.resultCode != 1) {
|
|
|
|
|
|
uni.showToast({
|
|
|
|
|
|
title: res.message,
|
|
|
|
|
|
icon: 'none',
|
|
|
|
|
|
duration: 2000,
|
|
|
|
|
|
});
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/home/index",
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
const result = res.result || {};
|
|
|
|
|
|
// 记录到缓存数据中
|
|
|
|
|
|
dataStore.setTf(result);
|
|
|
|
|
|
// 状态判断
|
|
|
|
|
|
switch (result.status) {
|
|
|
|
|
|
case 'KTF': { // KTF可退费
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/gzs/tf?lxId=" + xklxId,
|
|
|
|
|
|
});
|
|
|
|
|
|
} break;
|
|
|
|
|
|
case 'TFZ': { // TFZ退费中
|
|
|
|
|
|
uni.reLaunch({
|
|
|
|
|
|
url: "/pages/base/xk/tf/detail?xklxId=" + xklxId,
|
|
|
|
|
|
});
|
|
|
|
|
|
} break;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-09-02 15:45:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|