zhxy-jzd/src/utils/pageUtil.ts

110 lines
2.7 KiB
TypeScript
Raw Normal View History

2025-09-02 15:45:06 +08:00
import { checkXsXkApi } from "@/api/base/xkApi";
import { useUserStore } from "@/store/modules/user";
import { useDataStore } from "@/store/modules/data";
const userStore = useUserStore();
const dataStore = useDataStore();
const devFlag = true;
/**
*
*/
export const PageUtils = {
/**
*
* @param lxId JC: 就餐816059832: 俱乐部962488654: 兴趣课
*/
2025-09-02 20:57:37 +08:00
async toHome(lxId?: 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 {
if (xsList && xsList.length > 1) {
uni.reLaunch({
url: "/pages/base/home/xsXz",
});
return;
}
}
// 判断业务逻辑,并跳转界面
await this.checkLogicPage(lxId);
},
/**
*
*/
async checkLogicPage(lxId: string) {
switch (lxId) {
// 就餐逻辑单独处理
case "JC": {
} break;
// 默认当作 选课的选课类型IDxkLxId处理
default: {
await this.checkQkLogic(lxId);
}
}
},
/**
*
* @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) {
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;
}
},
}