diff --git a/.env b/.env index c38ef8b..80a1924 100644 --- a/.env +++ b/.env @@ -38,9 +38,9 @@ VITE_APP_DEV_SERVICE = http://123.156.230.15:8089/api/ # 访客线上 #VITE_APP_PROD_SERVICE = http://123.156.228.134:48080/app-api ; #VITE_APP_PROD_SERVICE = http://59.202.170.152:81/api #VITE_APP_PROD_SERVICE = https://stgl.pj.gov.cn/api -VITE_APP_PROD_SERVICE = http://60.12.184.86:8089/api +VITE_APP_PROD_SERVICE = http://123.156.230.15: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/App.vue b/src/App.vue index 2f3028f..fd143f1 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,203 +1,105 @@ - - - + + + diff --git a/src/pages.json b/src/pages.json index 9129d45..86b8eaa 100644 --- a/src/pages.json +++ b/src/pages.json @@ -9,61 +9,42 @@ } }, "pages": [ - // { - // "path": "pages/tabbar/canteen", - // "style": { - // "navigationBarTitleText": "食堂", - // "disableScroll": true - // } - // }, - // { - // "path": "pages/tabbar/selfMerchant", - // "style": { - // "navigationBarTitleText": "自营商家", - // "disableScroll": true - // } - // }, - // { - // "path": "pages/tabbar/coopMerchant", - // "style": { - // "navigationBarTitleText": "合作商家", - // "disableScroll": true - // } - // }, - // { - // "path": "pages/tabbar/order", - // "style": { - // "navigationBarTitleText": "订单", - // "disableScroll": true - // } - // }, - // { - // "path": "pages/tabbar/flowStatistics", - // "style": { - // "navigationBarTitleText": "流水统计", - // "disableScroll": true - // } - // }, - // { - // "path": "pages/tabbar/individualOrder", - // "style": { - // "navigationBarTitleText": "订单", - // "disableScroll": true - // } - // }, - // { - // "path": "pages/integrated/visitor/myvisitor", - // "style": { - // "navigationBarTitleText": "访客", - // "disableScroll": true - // } - // }, { "path": "pages/tabbar/my", "style": { "navigationBarTitleText": "我的", "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": { + "navigationBarTitleText": "访客核销" + } } ], "subPackages": [ @@ -237,158 +218,7 @@ { "path": "login", "style": { - "navigationBarTitleText": "", - "disableScroll": true - } - } - ] - }, - { - "root": "pages/wallet", - "pages": [ - { - "path": "list", - "style": { - "navigationBarTitleText": "", - "disableScroll": true - } - }, - { - "path": "detail", - "style": { - "navigationBarTitleText": "", - "disableScroll": true - } - }, - { - "path": "recharge", - "style": { - "navigationBarTitleText": "", - "disableScroll": true - } - } - ] - }, - { - "root": "pages/human-face", - "pages": [ - { - "path": "list", - "style": { - "navigationBarTitleText": "", - "disableScroll": true - } - }, - { - "path": "apply", - "style": { - "navigationBarTitleText": "", - "disableScroll": true - } - } - ] - }, - { - "root": "pages/user", - "pages": [ - { - "path": "userRole", - "style": { - "navigationBarTitleText": "用户身份", - "disableScroll": true - } - } - ] - }, - { - "root": "pages/pay", - "pages": [ - { - "path": "scanPay", - "style": { - "navigationBarTitleText": "支付", - "disableScroll": true - } - }, - { - "path": "payComplete", - "style": { - "navigationBarTitleText": "支付完成", - "disableScroll": true - } - }, - { - "path": "transferMoney", - "style": { - "navigationBarTitleText": "转账", - "disableScroll": true - } - } - ] - }, - { - "root": "pages/integrated", - "pages": [ - { - "path": "feedback/index", - "style": { - "navigationBarTitleText": "意见反馈" - } - } - ] - }, - { - "root": "pages/integrated", - "pages": [ - { - "path": "visitor/index", - "style": { - "navigationBarTitleText": "访客" - } - } - ] - }, - { - "root": "pages/integrated", - "pages": [ - { - "path": "visitor/myvisitor", - "style": { - "navigationBarTitleText": "访客记录" - } - } - ] - }, - { - "root": "pages/integrated", - "pages": [ - { - "path": "visitor/myyyvisitor", - "style": { - "navigationBarTitleText": "邀约访客" - } - } - ] - }, - { - "root": "pages/integrated", - "pages": [ - { - "path": "visitor/myyyvisitorlist", - "style": { - "navigationBarTitleText": "邀约记录" - } - } - ] - }, - { - "root": "pages/integrated", - "pages": [ - { - "path": "visitor/visitorDetail", - "style": { - "navigationStyle": "custom", - "navigationBarTitleText": "记录详情" + "navigationBarTitleText": "登录" } } ] @@ -396,12 +226,15 @@ ], "globalStyle": { "navigationBarTextStyle": "black", - "navigationBarTitleText": "小程序", - "navigationBarBackgroundColor": "#1777FF", - "backgroundColor": "#ecf4f9", - "navigationStyle": "custom" + "navigationBarTitleText": "uni-app", + "navigationBarBackgroundColor": "#F8F8F8", + "backgroundColor": "#F8F8F8" }, "tabBar": { + "color": "#7A7E83", + "selectedColor": "#3cc51f", + "borderStyle": "black", + "backgroundColor": "#ffffff", "list": [ { "pagePath": "pages/integrated/visitor/index", @@ -415,7 +248,6 @@ "iconPath": "/static/tabbar/my.png", "selectedIconPath": "/static/tabbar/my-select.png" }, - { "pagePath": "pages/integrated/visitor/myyyvisitor", "text": "访客邀约", @@ -430,7 +262,7 @@ }, { "pagePath": "pages/integrated/visitor/verify", - "text": "核销", + "text": "访客核销", "iconPath": "/static/tabbar/my.png", "selectedIconPath": "/static/tabbar/my-select.png" }, diff --git a/src/pages/integrated/visitor/index.vue b/src/pages/integrated/visitor/index.vue index febf505..d01521e 100644 --- a/src/pages/integrated/visitor/index.vue +++ b/src/pages/integrated/visitor/index.vue @@ -221,6 +221,21 @@ + + + {{ user.name }} + + + {{ searchKeyword ? "未找到相关接待人" : "暂无接待人数据" }} + + + 确定 @@ -237,21 +252,21 @@ import deptApi from "@/sheep/api/integrated/dept" // 表单数据 const formData = reactive({ - name: "测试访客", - mobile: "13800138000", - companyName: "测试公司", - isOtherPeople: "1", // 默认有随行人员 - isDrive: "1", // 默认有车辆 - deptId: "", // 这个需要等部门列表加载后设置 - deptName: "", - userId: "", // 这个需要等用户列表加载后设置 - userName: "", - vstartDate: "", // 这个会在页面加载时设置 - vendDate: "", - type: "1", - checkStatus: "0", - reasonValue: "", // 这个需要等原因列表加载后设置 - reasonLabel: "", + name: '测试访客', + mobile: '13800138000', + companyName: '测试公司', + isOtherPeople: '1', // 默认有随行人员 + isDrive: '1', // 默认有车辆 + deptId: '', // 这个需要等部门列表加载后设置 + deptName: '', + receiveId: '', // 这个需要等用户列表加载后设置 + userName: '', + vstartDate: '', // 这个会在页面加载时设置 + vendDate: '', + type: '1', + checkStatus: '0', + reasonValue: '', // 这个需要等原因列表加载后设置 + reasonLabel: '', }) // 随行人员列表默认数据 @@ -316,9 +331,11 @@ const timeList = computed(() => { // 过滤后的用户列表 const filteredUserList = computed(() => { - if (!searchKeyword.value) return userList.value - const keyword = searchKeyword.value.toLowerCase() - return userList.value.filter((user) => user.name.toLowerCase().includes(keyword)) + if (!searchKeyword.value) return userList.value + const keyword = searchKeyword.value.toLowerCase() + return userList.value.filter(user => + user.name.toLowerCase().includes(keyword) + ) }) // 获取部门数据 @@ -395,31 +412,31 @@ const goBack = () => { // 表单验证 const validateForm = () => { - if (!formData.name) { - uni.showToast({ title: "请输入姓名", icon: "none" }) - return false - } - if (!formData.mobile) { - uni.showToast({ title: "请输入联系方式", icon: "none" }) - return false - } - if (!formData.deptId || !formData.deptName) { - uni.showToast({ title: "请选择到访单位", icon: "none" }) - return false - } - if (!formData.userId || !formData.userName) { - uni.showToast({ title: "请选择接待人", icon: "none" }) - return false - } - if (!formData.vstartDate || !formData.vendDate) { - uni.showToast({ title: "请选择到访时间", icon: "none" }) - return false - } - if (!formData.reasonValue || !formData.reasonLabel) { - uni.showToast({ title: "请选择拜访原因", icon: "none" }) - return false - } - return true + if (!formData.name) { + uni.showToast({ title: '请输入姓名', icon: 'none' }) + return false + } + if (!formData.mobile) { + uni.showToast({ title: '请输入联系方式', icon: 'none' }) + return false + } + if (!formData.deptId || !formData.deptName) { + uni.showToast({ title: '请选择到访单位', icon: 'none' }) + return false + } + if (!formData.receiveId || !formData.userName) { + uni.showToast({ title: '请选择接待人', icon: 'none' }) + return false + } + if (!formData.vstartDate || !formData.vendDate) { + uni.showToast({ title: '请选择到访时间', icon: 'none' }) + return false + } + if (!formData.reasonValue || !formData.reasonLabel) { + uni.showToast({ title: '请选择拜访原因', icon: 'none' }) + return false + } + return true } // 提交表单 @@ -443,30 +460,30 @@ const handleSubmit = async () => { uni.hideLoading() - if (code === 0) { - uni.showToast({ - title: "提交成功,请耐心等待您的拜访对象接受此次申请", - icon: "none", - duration: 3000, - }) + if (code === 0) { + uni.showToast({ + title: '提交成功,请耐心等待您的拜访对象接受此次申请', + icon: 'none', + duration: 3000 + }) - // 延迟返回,让用户能看到提示 - setTimeout(() => { - uni.navigateBack() - }, 2000) - } else { - uni.showToast({ - title: msg || "提交失败", - icon: "none", - }) - } - } catch (error) { - uni.hideLoading() - uni.showToast({ - title: "提交失败", - icon: "none", - }) - } + // 延迟返回,让用户能看到提示 + setTimeout(() => { + uni.navigateBack() + }, 2000) + } else { + uni.showToast({ + title: msg || '提交失败', + icon: 'none' + }) + } + } catch (error) { + uni.hideLoading() + uni.showToast({ + title: '提交失败', + icon: 'none' + }) + } } // 显示时间选择器 @@ -534,26 +551,26 @@ const selectDept = (dept: any) => { // 部门选择确认 const confirmDeptSelect = () => { - if (!selectedDeptId.value) { - uni.showToast({ - title: "请选择到访单位", - icon: "none", - }) - return - } + if (!selectedDeptId.value) { + uni.showToast({ + title: '请选择到访单位', + icon: 'none' + }) + return + } - // 更新表单数据,同时保存ID和名称 - formData.deptId = selectedDeptId.value - formData.deptName = selectedDeptName.value + // 更新表单数据,同时保存ID和名称 + formData.deptId = selectedDeptId.value + formData.deptName = selectedDeptName.value - // 清空已选择的接待人 - formData.userId = "" - formData.userName = "" - selectedUserName.value = "" - selectedUserId.value = "" + // 清空已选择的接待人 + formData.receiveId = '' + formData.userName = '' + selectedUserName.value = '' + selectedUserId.value = '' - // 关闭弹窗 - closeDeptPicker() + // 关闭弹窗 + closeDeptPicker() } // 获取部门下的用户列表 @@ -578,42 +595,42 @@ const selectUser = (user: any) => { // 用户选择确认 const confirmUserSelect = () => { - if (!selectedUserId.value) { - uni.showToast({ - title: "请选择接待人", - icon: "none", - }) - return - } + if (!selectedUserId.value) { + uni.showToast({ + title: '请选择接待人', + icon: 'none' + }) + return + } - // 更新表单数据,同时保存ID和名称 - formData.userId = selectedUserId.value - formData.userName = selectedUserName.value + // 更新表单数据,同时保存ID和名称 + formData.receiveId = selectedUserId.value + formData.userName = selectedUserName.value - // 关闭弹窗 - closeUserPicker() + // 关闭弹窗 + closeUserPicker() } // 显示用户选择器 const showUserPicker = async () => { - if (!formData.deptId) { - uni.showToast({ - title: "请先选择到访单位", - icon: "none", - }) - return - } + if (!formData.deptId) { + uni.showToast({ + title: '请先选择到访单位', + icon: 'none' + }) + return + } - // 如果切换了部门,重新获取用户列表 - if (formData.deptId !== currentDeptId.value) { - await getUserList(formData.deptId) - currentDeptId.value = formData.deptId - // 清空选择 - selectedUserId.value = "" - selectedUserName.value = "" - } + // 如果切换了部门,重新获取用户列表 + if (formData.deptId !== currentDeptId.value) { + await getUserList(formData.deptId) + currentDeptId.value = formData.deptId + // 清空选择 + selectedUserId.value = '' + selectedUserName.value = '' + } - showUserPopup.value = true + showUserPopup.value = true } // 关闭用户选择器 @@ -660,8 +677,18 @@ onMounted(async () => { formData.deptId = firstDept.id formData.deptName = firstDept.name - // 获取该部门的用户列表 - await getUserList(firstDept.id) + // 获取该部门的用户列表 + await getUserList(firstDept.id) + + // 设置默认的接待人(选择第一个用户) + if (userList.value.length > 0) { + const firstUser = userList.value[0] + selectedUserId.value = firstUser.userId + selectedUserName.value = firstUser.name + formData.receiveId = firstUser.userId + formData.userName = firstUser.name + } + } // 设置默认的接待人(选择第一个用户) if (userList.value.length > 0) { diff --git a/src/pages/integrated/visitor/myvisitor.vue b/src/pages/integrated/visitor/myvisitor.vue index 3d1ac70..bb1c96e 100644 --- a/src/pages/integrated/visitor/myvisitor.vue +++ b/src/pages/integrated/visitor/myvisitor.vue @@ -321,170 +321,159 @@ onMounted(() => { \ No newline at end of file diff --git a/src/pages/integrated/visitor/myyyvisitorlist.vue b/src/pages/integrated/visitor/myyyvisitorlist.vue index bb4b466..5c100bf 100644 --- a/src/pages/integrated/visitor/myyyvisitorlist.vue +++ b/src/pages/integrated/visitor/myyyvisitorlist.vue @@ -46,7 +46,7 @@ 拜访原因: - {{ getReasonText(item.description) }} + {{ getReasonText(item.reasonValue) }} diff --git a/src/pages/tabbar/my.vue b/src/pages/tabbar/my.vue index 543b15b..4b32651 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 }} @@ -55,7 +54,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 +63,10 @@ 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: "", + menuList: [{ text: "人脸管理", icon: "/static/icon/service_5.png", router: "/pages/human-face/list" }], }) // 常量 @@ -126,112 +108,6 @@ const storage = { } const login = { - // 检查应用环境并登录 - checkAppInfo: async () => { - try { - // 先尝试诗画登录 - const shihuaResult = await login.shihuaLogin() - if (shihuaResult) return - - // 尝试浙政钉登录 - const zhengdingResult = login.zhengdingLogin() - if (zhengdingResult) return - - uni.showToast({ title: "当前登录环境未知", icon: "none" }) - } 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() @@ -242,156 +118,52 @@ const login = { uni.hideLoading() uni.showToast({ title: "退出登录成功", icon: "none" }) }, - - // 切换角色 - changeRole: () => { - router.jump("/pages/user/userRole") - }, } -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 onTabLogin = () => router.jump("/pages/test/login") - -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() }) diff --git a/src/sheep/utils/request.ts b/src/sheep/utils/request.ts index 3f76b23..f19f7c7 100644 --- a/src/sheep/utils/request.ts +++ b/src/sheep/utils/request.ts @@ -34,10 +34,10 @@ function showLoading(message: string) { // 读取token并处理Authorization请求头 const getAuthHeader = (tokenStorage: any) => { - if (isDevEnv()) { + // if (isDevEnv()) { return tokenStorage?.access_token ? `Bearer ${tokenStorage.access_token}` : null - } - return tokenStorage?.accessToken?.tokenValue ? `Bearer ${tokenStorage.accessToken.tokenValue}` : null + // } + // return tokenStorage?.accessToken?.tokenValue ? `Bearer ${tokenStorage.accessToken.tokenValue}` : null } // 浙政钉登录 登录成功返回true,否则返回false