| | |
| | | <template> |
| | | <Splash v-if="showSplash" /> |
| | | <div v-else> |
| | | <router-view /> |
| | | </div> |
| | | <Splash v-if="showSplash" /> |
| | | <view v-else> |
| | | <router-view /> |
| | | </view> |
| | | </template> |
| | | <script setup> |
| | | import { ref, onMounted } from "vue"; |
| | | import Splash from "./components/Splash.vue"; |
| | | import { confirmMessage } from "@/api/login.js"; |
| | | import { ref, onMounted } from "vue"; |
| | | import Splash from "./components/Splash.vue"; |
| | | import { confirmMessage } from "@/api/login.js"; |
| | | |
| | | const showSplash = ref(true); |
| | | const showSplash = ref(true); |
| | | |
| | | onMounted(() => { |
| | | setTimeout(() => { |
| | | showSplash.value = false; |
| | | }, 5000); |
| | | onMounted(() => { |
| | | setTimeout(() => { |
| | | showSplash.value = false; |
| | | }, 5000); |
| | | |
| | | // 初始化推送服务,暂时注释,客户需要打开 |
| | | // initPushService(); |
| | | }); |
| | | // 初始化推送服务(uni-push 1.0) |
| | | const initPushService = () => { |
| | | // #ifdef APP-PLUS |
| | | console.log("开始初始化推送服务(uni-push 1.0)"); |
| | | if (typeof plus !== "undefined" && plus.push) { |
| | | console.log("plus.push 存在:", plus.push); |
| | | |
| | | // 获取客户端推送标识 |
| | | console.log("使用 plus.push.getClientInfo 获取客户端标识"); |
| | | plus.push.getClientInfoAsync(info => { |
| | | console.log("客户端推送标识:", info); |
| | | uni.setStorageSync("clientid", info.clientid); |
| | | |
| | | // 这里可以将客户端标识发送到服务器 |
| | | }); |
| | | setTimeout(() => { |
| | | console.log("使用 plus.push.getClientInfoAsync 获取客户端标识"); |
| | | plus.push.getClientInfoAsync(info => { |
| | | console.log("客户端推送标识:", info); |
| | | // 这里可以将客户端标识发送到服务器 |
| | | }); |
| | | }, 1000); |
| | | |
| | | // 监听推送消息点击事件 |
| | | plus.push.addEventListener("click", handlePushClick, false); |
| | | // 监听推送消息接收事件 |
| | | plus.push.addEventListener("receive", handlePushReceive, false); |
| | | console.log("推送服务注册成功"); |
| | | } else { |
| | | console.log("推送服务不可用"); |
| | | } |
| | | // #endif |
| | | }; |
| | | |
| | | // 初始化推送服务,暂时注释,客户需要打开 |
| | | // initPushService(); |
| | | }); |
| | | // 初始化推送服务(uni-push 1.0) |
| | | const initPushService = () => { |
| | | // #ifdef APP-PLUS |
| | | console.log("开始初始化推送服务(uni-push 1.0)"); |
| | | if (typeof plus !== "undefined" && plus.push) { |
| | | console.log("plus.push 存在:", plus.push); |
| | | // 处理推送消息点击事件 |
| | | const handlePushClick = msg => { |
| | | console.log("点击推送消息:", msg); |
| | | console.log("解析后:", msg.payload.noticeId); |
| | | try { |
| | | if (msg.payload.needMarkRead) { |
| | | confirmMessage(msg.payload.noticeId, 1).then(res => { |
| | | if (msg.payload.url) { |
| | | if (msg.payload.url.indexOf("/") === 0) { |
| | | uni.navigateTo({ |
| | | url: msg.payload.url, |
| | | }); |
| | | } else { |
| | | uni.navigateTo({ |
| | | url: "/" + msg.payload.url, |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | if (msg.payload.url) { |
| | | if (msg.payload.url.indexOf("/") === 0) { |
| | | uni.navigateTo({ |
| | | url: msg.payload.url, |
| | | }); |
| | | } else { |
| | | uni.navigateTo({ |
| | | url: "/" + msg.payload.url, |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } catch (error) { |
| | | uni.showToast({ |
| | | title: "路径:" + msg.payload, |
| | | icon: "none", |
| | | }); |
| | | uni.showToast({ |
| | | title: "跳转失败:" + error.message, |
| | | icon: "none", |
| | | }); |
| | | } |
| | | // 解析并处理推送消息... |
| | | }; |
| | | |
| | | // 获取客户端推送标识 |
| | | console.log("使用 plus.push.getClientInfo 获取客户端标识"); |
| | | plus.push.getClientInfoAsync(info => { |
| | | console.log("客户端推送标识:", info); |
| | | uni.setStorageSync("clientid", info.clientid); |
| | | |
| | | // 这里可以将客户端标识发送到服务器 |
| | | }); |
| | | setTimeout(() => { |
| | | console.log("使用 plus.push.getClientInfoAsync 获取客户端标识"); |
| | | plus.push.getClientInfoAsync(info => { |
| | | console.log("客户端推送标识:", info); |
| | | // 这里可以将客户端标识发送到服务器 |
| | | }); |
| | | }, 1000); |
| | | |
| | | // 监听推送消息点击事件 |
| | | plus.push.addEventListener("click", handlePushClick, false); |
| | | // 监听推送消息接收事件 |
| | | plus.push.addEventListener("receive", handlePushReceive, false); |
| | | console.log("推送服务注册成功"); |
| | | } else { |
| | | console.log("推送服务不可用"); |
| | | } |
| | | // #endif |
| | | }; |
| | | |
| | | // 处理推送消息点击事件 |
| | | const handlePushClick = msg => { |
| | | console.log("点击推送消息:", msg); |
| | | console.log("解析后:", msg.payload.noticeId); |
| | | try { |
| | | if (msg.payload.needMarkRead) { |
| | | confirmMessage(msg.payload.noticeId, 1).then(res => { |
| | | if (msg.payload.url) { |
| | | if (msg.payload.url.indexOf("/") === 0) { |
| | | uni.navigateTo({ |
| | | url: msg.payload.url, |
| | | }); |
| | | } else { |
| | | uni.navigateTo({ |
| | | url: "/" + msg.payload.url, |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | } else { |
| | | if (msg.payload.url) { |
| | | if (msg.payload.url.indexOf("/") === 0) { |
| | | uni.navigateTo({ |
| | | url: msg.payload.url, |
| | | }); |
| | | } else { |
| | | uni.navigateTo({ |
| | | url: "/" + msg.payload.url, |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } catch (error) { |
| | | uni.showToast({ |
| | | title: "路径:" + msg.payload, |
| | | icon: "none", |
| | | }); |
| | | uni.showToast({ |
| | | title: "跳转失败:" + error.message, |
| | | icon: "none", |
| | | }); |
| | | } |
| | | // 解析并处理推送消息... |
| | | }; |
| | | |
| | | // 处理推送消息接收事件 |
| | | const handlePushReceive = msg => { |
| | | console.log("收到推送消息:", msg); |
| | | // 处理接收的推送消息... |
| | | }; |
| | | // 处理推送消息接收事件 |
| | | const handlePushReceive = msg => { |
| | | console.log("收到推送消息:", msg); |
| | | // 处理接收的推送消息... |
| | | }; |
| | | </script> |
| | | |
| | | <style lang="scss"> |
| | | @import "uview-plus/index.scss"; |
| | | @import "@/static/scss/index.scss"; |
| | | @import "uview-plus/index.scss"; |
| | | @import "@/static/scss/index.scss"; |
| | | </style> |
| | |
| | | getTravelStandardByTier, |
| | | } from "../_utils/travelReimburseUtils.js"; |
| | | |
| | | const userStore = useUserStore(); |
| | | // 延迟初始化 userStore,避免在模块加载时调用 |
| | | let userStore = null; |
| | | function getUserStore() { |
| | | if (!userStore) { |
| | | userStore = useUserStore(); |
| | | } |
| | | return userStore; |
| | | } |
| | | |
| | | function buildOverBudgetWarnings(f, detailTotal, hotelLimit, transportLimit, mealLimit) { |
| | | const warnings = []; |
| | |
| | | /** 新增时默认带出当前登录人,减少选人步骤 */ |
| | | function tryApplyCurrentUser() { |
| | | if (modeRef.value === "edit" || form.applicantId) return; |
| | | const id = userStore.id; |
| | | const store = getUserStore(); |
| | | const id = store.id; |
| | | if (!id) return; |
| | | let u = userById(id); |
| | | if (!u) { |
| | | u = { |
| | | userId: id, |
| | | nickName: userStore.nickName, |
| | | userName: userStore.name, |
| | | nickName: store.nickName, |
| | | userName: store.name, |
| | | }; |
| | | } |
| | | fillApplicantFromUser(u); |
| | |
| | | currentLoginTime: "", |
| | | roles: Array(), |
| | | permissions: [], |
| | | routers: [], // 路由权限数据 |
| | | routers: [], |
| | | }), |
| | | actions: { |
| | | // 部门登录 |
| | | loginCheckFactory(userInfo: any) { |
| | | const userName = userInfo.userName.trim(); |
| | | const password = userInfo.password; |
| | |
| | | return new Promise((resolve, reject) => { |
| | | loginCheckFactory(userName, password, factoryId) |
| | | .then((res: any) => { |
| | | const token = res.token || res.data?.token; |
| | | const token = res.token || (res.data && res.data.token); |
| | | if (token) { |
| | | setToken(token); |
| | | this.token = token; |
| | |
| | | }); |
| | | }); |
| | | }, |
| | | // 获取用户信息 |
| | | getInfo() { |
| | | return new Promise((resolve, reject) => { |
| | | getInfo() |
| | |
| | | }); |
| | | }); |
| | | }, |
| | | // 退出系统 |
| | | logOut() { |
| | | return new Promise<null>((resolve, reject) => { |
| | | logout() |
| | |
| | | const seconds = String(now.getSeconds()).padStart(2, "0"); // 秒数补零 |
| | | return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`; |
| | | }, |
| | | // 获取路由权限 |
| | | getRouters() { |
| | | return new Promise((resolve, reject) => { |
| | | getRoutersApi() |
| | |
| | | } |
| | | |
| | | async function getCurrentVersion(logPrefix) { |
| | | let currentVersion = config?.appInfo?.version || "1.0.0"; |
| | | let currentVersion = (config && config.appInfo && config.appInfo.version) || "1.0.0"; |
| | | console.log(`${logPrefix} 开始获取当前版本,默认值:`, currentVersion); |
| | | // #ifdef MP-WEIXIN |
| | | try { |
| | | const accountInfo = uni.getAccountInfoSync(); |
| | | if (accountInfo?.miniProgram?.version) { |
| | | if (accountInfo && accountInfo.miniProgram && accountInfo.miniProgram.version) { |
| | | currentVersion = accountInfo.miniProgram.version; |
| | | console.log(`${logPrefix} 当前环境=MP-WEIXIN,版本=`, currentVersion); |
| | | return currentVersion; |
| | |
| | | // APP-PLUS 下,plus.runtime.version 不是业务版本号(经常是运行时/SDK版本), |
| | | // 这里改用 getProperty 取系统层面的 app version。 |
| | | // @ts-ignore |
| | | if (plus?.runtime?.getProperty) { |
| | | if (plus && plus.runtime && plus.runtime.getProperty) { |
| | | // @ts-ignore |
| | | const appid = plus.runtime.appid; |
| | | const appInfo = await new Promise((resolve) => { |
| | | // @ts-ignore |
| | | plus.runtime.getProperty(appid, (info) => resolve(info || {})); |
| | | }); |
| | | const v = appInfo?.version || appInfo?.versionName || appInfo?.appVersion || ""; |
| | | const v = (appInfo && appInfo.version) || (appInfo && appInfo.versionName) || (appInfo && appInfo.appVersion) || ""; |
| | | if (v) { |
| | | currentVersion = String(v); |
| | | console.log(`${logPrefix} 当前环境=APP-PLUS,版本=`, currentVersion); |
| | |
| | | }, |
| | | (err) => { |
| | | console.log(`${logPrefix} 安装失败:`, err); |
| | | uni.showToast({ title: err?.message || "安装更新包失败", icon: "none" }); |
| | | uni.showToast({ title: (err && err.message) || "安装更新包失败", icon: "none" }); |
| | | } |
| | | ); |
| | | // #endif |
| | |
| | | if (!u) return ""; |
| | | // 已经是绝对地址,直接返回 |
| | | if (/^https?:\/\//i.test(u)) return u; |
| | | const base = String(config?.fileUrl || config?.baseUrl || "").replace(/\/+$/, ""); |
| | | const base = String((config && config.fileUrl) || (config && config.baseUrl) || "").replace(/\/+$/, ""); |
| | | const path = u.startsWith("/") ? u : `/${u}`; |
| | | return `${base}${path}`; |
| | | } |
| | |
| | | build: { |
| | | minify: true, |
| | | outDir: 'dist', |
| | | target: 'es2015', |
| | | }, |
| | | esbuild: { |
| | | target: 'es2015', |
| | | }, |
| | | server: { |
| | | port: '80' |
| | |
| | | css: { |
| | | preprocessorOptions: { |
| | | scss: { |
| | | api: 'modern-compiler' |
| | | api: 'legacy' |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | optimizeDeps: { |
| | | esbuildOptions: { |
| | | target: 'es2015', |
| | | }, |
| | | }, |
| | | } |
| | | }) |
| | | }) |