diff --git a/.env b/.env index f5ea089..ab839ac 100644 --- a/.env +++ b/.env @@ -43,5 +43,5 @@ VITE_APP_PROD_SERVICE = http://60.12.184.86:8089/api #VITE_APP_PROD_SERVICE = http://59.202.170.152:81/api # 信创线上 # ******************** end 生产环境 end ******************** -VITE_DEV_ENV = dev -# VITE_DEV_ENV = prod +#VITE_DEV_ENV = dev + VITE_DEV_ENV = prod diff --git a/src/pages.json b/src/pages.json index 4c0f952..8ea3c23 100644 --- a/src/pages.json +++ b/src/pages.json @@ -16,6 +16,30 @@ "disableScroll": true } }, + { + "path": "pages/integrated/visitor/index", + "style": { + "navigationBarTitleText": "访客申请" + } + }, + { + "path": "pages/integrated/visitor/myvisitor", + "style": { + "navigationBarTitleText": "申请记录" + } + }, + { + "path": "pages/integrated/visitor/myyyvisitor", + "style": { + "navigationBarTitleText": "主动邀约" + } + }, + { + "path": "pages/integrated/visitor/myyyvisitorlist", + "style": { + "navigationBarTitleText": "邀约记录" + } + }, { "path": "pages/integrated/visitor/verify", "style": { diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue index 69407a4..796cbdf 100644 --- a/src/pages/tabbar/my.vue +++ b/src/pages/tabbar/my.vue @@ -12,7 +12,6 @@ {{ state.userInfo?.sysUser?.name }} - ID {{ state.userInfo?.sysUser?.userId }} @@ -37,11 +36,6 @@ 退出登录 - - - 切换角色 - - @@ -55,7 +49,6 @@ import { hooks, router, constant } from "@@/index" import { userApi } from "@@/api" import isDevEnv from "@/sheep/utils/isDevEnv" import { usePayStore } from "@/sheep/stores/pay" -// import dd from "gdt-jsapi" const state = reactive<{ wallet: any[] @@ -65,26 +58,12 @@ const state = reactive<{ icon: string router: string }[] - appInfo: string }>({ wallet: [], userInfo: {}, menuList: [ - // { text: "扫一扫", icon: "/static/icon/scan.png", router: "" }, - // { text: "钱包管理", icon: "/static/icon/service_3.png", router: "/pages/wallet/list" }, - // { text: "包厢预定", icon: "/static/icon/service_4.png", router: "/pages/boxes/apply-list" }, - // { text: "外来人员就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/foreign-list" }, - // { text: "跨单位就餐", icon: "/static/icon/service_1.png", router: "/pages/apply/stride-list" }, { text: "人脸管理", icon: "/static/icon/service_5.png", router: "/pages/human-face/list" }, - // { text: "访客", icon: "/static/icon/service_5.png", router: "/pages/integrated/visitor/index" }, - // { text: "访客记录", icon: "/static/icon/service_5.png", router: "/pages/integrated/visitor/myvisitor" }, - // { text: "访客邀约", icon: "/static/icon/service_5.png", router: "/pages/integrated/visitor/myyyvisitor" }, - // { text: "邀约记录", icon: "/static/icon/service_5.png", router: "/pages/integrated/visitor/myyyvisitorlist" }, - // { text: "访客核销", icon: "/static/icon/service_5.png", router: "/pages/integrated/visitor/verify" }, - - // { text: "意见反馈", icon: "/static/icon/service_5.png", router: "/pages/integrated/feedback/index" } ], - appInfo: "", }) // 常量 @@ -126,115 +105,6 @@ const storage = { } const login = { - // 检查应用环境并登录 - checkAppInfo: async () => { - try { - // 先尝试诗画登录 - const shihuaResult = await login.shihuaLogin() - if (shihuaResult) return - - // 尝试浙政钉登录 - const zhengdingResult = login.zhengdingLogin() - if (zhengdingResult) return - - // 显示账号密码登录界面 - uni.navigateTo({ - url: '/pages/user/login' - }) - } catch (error) { - console.error("登录失败:", error) - uni.showToast({ title: "登录失败", icon: "none" }) - } - }, - - // 诗画环境登录 - shihuaLogin: async () => { - const appInfo = await (window as any).CP2.getAppInfo() - if (appInfo.code == 0) return false - - const userInfo = await (window as any).CP2.getUserInfo() - if (userInfo.code == 0) { - uni.showToast({ title: "获取诗画用户信息失败", icon: "none" }) - return false - } else { - const { accountId, sessionId } = userInfo.data - return login.doLogin(1, "", accountId, sessionId) - // return login.doLogin(1, "", "67186e49d63fea141aad6772", "67186e49d63fea141aad6776") - } - }, - - // 浙政钉登录 - zhengdingLogin: () => { - const params = new URL(window.location.href).searchParams - const token = params.get("uabaseToken") - if (token) { - return login.doLogin(2, token, "", "") - } - return false - }, - - // 执行登录操作 - loginType 1:诗画登录 2:浙政钉登录 - doLogin: async (loginType: number, token: string, accountId: string, sessionId: string) => { - const tokenStorage = uni.getStorageSync(STORAGE_KEYS.TOKEN) - const userStorage = uni.getStorageSync(STORAGE_KEYS.USER_INFO) - - switch (loginType) { - case 1: // 诗画登录 - uni.showLoading({ title: "登录中...", mask: true }) - const response = await userApi.authsh({ accountId, sessionId }) - - if (response.code == 0) { - storage.saveToken({ accessToken: response.data.accessToken }) - uni.hideLoading() - uni.showToast({ title: "登录成功", icon: "none" }) - - const { data: userData } = await userApi.userInfo() - storage.saveUserInfo(userData) - } else { - uni.hideLoading() - storage.clearUserStorage() - if (response.msg == "token已失效") { - uni.showToast({ title: "用户凭证已失效,请退出并重新进入智慧后勤应用", icon: "none", duration: 6000 }) - } else { - uni.showToast({ title: response.msg || "登录失败", icon: "none" }) - } - } - break - - case 2: // 浙政钉登录 - if (isEmpty(tokenStorage) || isEmpty(userStorage)) { - try { - uni.showLoading({ title: "登录中...", mask: true }) - const res = await userApi.auth(token) - - if (res.code == 0) { - storage.saveToken(res.data) - uni.hideLoading() - uni.showToast({ title: "登录成功", icon: "none" }) - - const { data: userData } = await userApi.userInfo() - storage.saveUserInfo(userData) - } else { - storage.clearUserStorage() - if (res.msg == "token已失效") { - uni.showToast({ title: "用户凭证已失效,请退出并重新进入智慧后勤应用", icon: "none", duration: 6000 }) - } else { - uni.showToast({ title: res.msg || "登录失败", icon: "none" }) - } - } - } catch (error) { - uni.showToast({ title: "登录错误", icon: "none" }) - } finally { - uni.hideLoading() - } - } - break - - default: - uni.showToast({ title: "当前登录环境未知", icon: "none" }) - } - }, - // 退出登录 logout: async () => { const isLogin = await hooks.useCheckLogin() @@ -245,182 +115,52 @@ const login = { uni.hideLoading() uni.showToast({ title: "退出登录成功", icon: "none" }) }, - - // 切换角色 - changeRole: () => { - router.jump("/pages/user/userRole") - }, - - // 账号密码登录 - accountLogin: async (username: string, password: string) => { - try { - uni.showLoading({ title: "登录中...", mask: true }) - const response = await userApi.login({ username, password }) - - if (response.code == 0) { - storage.saveToken({ accessToken: response.data.accessToken }) - uni.hideLoading() - uni.showToast({ title: "登录成功", icon: "none" }) - - const { data: userData } = await userApi.userInfo() - storage.saveUserInfo(userData) - return true - } else { - uni.hideLoading() - storage.clearUserStorage() - uni.showToast({ title: response.msg || "登录失败", icon: "none" }) - return false - } - } catch (error) { - uni.hideLoading() - uni.showToast({ title: "登录失败", icon: "none" }) - return false - } - }, } -const scanCode = { - // 扫一扫 - scan: async () => { - usePayStore().setPayData({}) - try { - const decodedString = await scanCode.getScanResult() - - if (decodedString) { - scanCode.processScanResult(decodedString) - } - // else { - // uni.showToast({ title: "无效的二维码", icon: "none" }) - // } - } catch (error: any) { - // if (error) { - // uni.showToast({ title: error, icon: "none" }) - // } - } - }, - - // 获取扫码结果 - getScanResult: async (): Promise => { - if (isDevEnv()) { - // 开发环境模拟扫码 - // const testQrCode = "eyJpZCI6IjE4OTYxNTcyMDc2NDQwNTM1MDYiLCJuYW1lIjoi5rWL6K+V5ZWG5oi3In0=" // 线上-测试超市-收款码 - // const testQrCode = "eyJpZCI6IjE5MDU4MTY3NTEwNDM0NTI5MzAiLCJuYW1lIjoi5paw5Y6/5bqc6LaF5biCIn0=" // 测试环境-邓本地-新县府超市-收款码 - const testQrCode = "eyJpZCI6IjE5MDc2ODQwNTY4NDA4NDMyNjYiLCJuYW1lIjoi5pm66IO95p+c6Ieq6JCl5ZWG5oi3MSJ9" // 测试环境-邓本地-智能柜自营商户1-收款码 - uni.showToast({ title: "开发环境不是浙政钉环境,扫码仅供测试,收款商家为测试商户超市", icon: "none" }) - return scanCode.decodeBase64(testQrCode) - } else if (state.appInfo == "dd") { - // 浙政钉扫码 - const res: any = await (window as any).dd.scan({ type: "all" }) - return scanCode.decodeBase64(res.text) - } else if (state.appInfo == "sh") { - // 诗画扫码 - const res = await (window as any).CP2.showScanQr({ needResult: 1 }) - if (res.code == 1) return scanCode.decodeBase64(res.data.qrCode) - } else { - uni.showToast({ title: "当前环境未知", icon: "none" }) - } - }, - - // 处理扫码结果 - processScanResult: (decodedString: string) => { - try { - const decodedJson = JSON.parse(decodedString) - if (decodedJson?.id && decodedJson?.name) { - usePayStore().setPayData(decodedJson) - router.jump("/pages/pay/scanPay") - } else { - uni.showToast({ title: "无效的二维码", icon: "none" }) - } - } catch (error) { - uni.showToast({ title: "无效的二维码内容", icon: "none" }) - } - }, - - // 解码base64 - decodeBase64: (base64String: string): string | undefined => { - try { - const decodedBinaryString = atob(base64String) - const uint8Array = new Uint8Array(decodedBinaryString.length) - for (let i = 0; i < decodedBinaryString.length; i++) { - uint8Array[i] = decodedBinaryString.charCodeAt(i) - } - const decoder = new TextDecoder("utf-8") - const decodedString = decoder.decode(uint8Array) - console.log("解码结果", decodedString) - return decodedString - } catch (error) { - console.error("Base64 解码失败:", error) - uni.showToast({ title: "无效的二维码", icon: "none" }) - return undefined - } - }, +// 点击登录 +const onTabLogin = () => { + uni.navigateTo({ + url: '/pages/test/login' + }) } -const onTabLogin = () => (isDevEnv() ? router.jump("/pages/test/login") : login.checkAppInfo()) - -const onTabMenu = async (item: any, index: number) => { - if (index == state.menuList.length - 1) { - router.jump(item.router) - return - } - - const isLogin = await hooks.useCheckLogin() - if (isLogin) { - if (item.text === "扫一扫") { - await scanCode.scan() - } else { - router.jump(item.router) - } +// 点击菜单 +const onTabMenu = (v: any, i: number) => { + if (v.router) { + uni.navigateTo({ + url: v.router + }) } } // 退出登录 -const doLogout = async () => { - await login.logout() +const doLogout = () => { + uni.showModal({ + title: "提示", + content: "确定要退出登录吗?", + success: async (res) => { + if (res.confirm) { + await login.logout() + } + } + }) } -// 切换角色 -const doChangeRole = () => { - login.changeRole() -} - -// 初始化配置菜单 -const initMenuConfig = () => { - if (isDevEnv()) { - state.menuList.push({ - text: "测试-登录", - icon: "/static/icon/login.png", - router: "/pages/test/login", - }) - state.menuList.push({ - text: "测试-角色选择", - icon: "/static/icon/login.png", - router: "/pages/user/userRole", - }) - } -} - -onLoad(async () => { - const app = getApp() - app._initTabbar() - - // 初始化配置菜单 - initMenuConfig() - - // 获取应用信息 - state.appInfo = await getAppInfo() +onLoad(() => { + storage.getUserInfo() }) onShow(() => { - // 获取存储中的用户信息 storage.getUserInfo() })