zhxy-jzd/src/utils/pageUtil.ts
2025-09-02 21:55:01 +08:00

110 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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: 兴趣课)
*/
async toHome(lxId?: string) {
// 没有类型,则跳转首页
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({
url: "/pages/base/gzs/index?lxId=" + xklxId,
});
} break;
case 'QKZ': { // QKZ抢课中
uni.reLaunch({
url: "/pages/base/xk/qk/index?xklxId=" + xklxId,
});
} break;
case 'YQK': { // YQK已选课
uni.reLaunch({
url: "/pages/base/xk/pay/index?xklxId=" + xklxId,
});
} break;
case 'DZF': { // DZF待支付
uni.reLaunch({
url: "/pages/base/xk/pay/index?xklxId=" + xklxId,
});
} break;
case 'YZF': { // YZF已支付
uni.reLaunch({
url: "/pages/base/xk/pay/success?xklxId=" + xklxId,
});
} break;
}
},
}