Преглед изворни кода

登录相关持久化键名统一加上APP_前缀

yangguanjin пре 2 недеља
родитељ
комит
58d0ca0f8e

+ 1 - 1
src/api/sign.ts

@@ -115,7 +115,7 @@ export const uploadSignImage = (data: any) => {
   } else {
     requestUrl = getEnvBaseUrl() + url
   }
-  const token = uni.getStorageSync('ACCESS_TOKEN')
+  const token = uni.getStorageSync('APP_ACCESS_TOKEN')
   const headers: Record<string, string> = {}
   if (token) {
     headers.Authorization = `Bearer ${token}`

+ 1 - 1
src/components/SpreadDesigner/SpreadPDFViewer.vue

@@ -106,7 +106,7 @@ const getPDFForH5 = async (url: string, formData: FormData): Promise<ArrayBuffer
     requestUrl = getEnvBaseUrl() + url
   }
 
-  const token = uni.getStorageSync('ACCESS_TOKEN')
+  const token = uni.getStorageSync('APP_ACCESS_TOKEN')
   const headers: Record<string, string> = {}
   if (token) {
     headers.Authorization = `Bearer ${token}`

+ 1 - 1
src/interceptors/request.ts

@@ -55,7 +55,7 @@ const httpInterceptor = {
       ...options.header,
     }
     // 3. 添加 token 请求头标识 - 从本地存储获取
-    const token = uni.getStorageSync('ACCESS_TOKEN')
+    const token = uni.getStorageSync('APP_ACCESS_TOKEN')
     if (token && !whiteList.includes(options.url)) {
       options.header.Authorization = `Bearer ${token}`
     }

+ 1 - 1
src/pages/equipment/detail/components/BoilerInspectProject.vue

@@ -680,7 +680,7 @@ const showSelectTemplatePopup = ref(false)
 const templateList = ref<any[]>([])
 const selectedTemplate = ref<any>(null)
 
-const userInfo = computed(() => uni.getStorageSync('USER_INFO'))
+const userInfo = computed(() => uni.getStorageSync('APP_USER_INFO'))
 
 const canModifyChecker = computed(() => {
   return props.canModifyAssignments && props.isMainChecker

+ 1 - 1
src/pages/equipment/detail/components/ContainerInspectProject.vue

@@ -411,7 +411,7 @@ const showSelectTemplatePopup = ref(false)
 const templateList = ref<any[]>([])
 const selectedTemplate = ref<any>(null)
 
-const userInfo = computed(() => uni.getStorageSync('USER_INFO'))
+const userInfo = computed(() => uni.getStorageSync('APP_USER_INFO'))
 
 const canModifyChecker = computed(() => {
   return props.canModifyAssignments && props.isMainChecker

+ 1 - 1
src/pages/equipment/detail/components/PipeInspectProject.vue

@@ -406,7 +406,7 @@ const showSelectTemplatePopup = ref(false)
 const templateList = ref<any[]>([])
 const selectedTemplate = ref<any>(null)
 
-const userInfo = computed(() => uni.getStorageSync('USER_INFO'))
+const userInfo = computed(() => uni.getStorageSync('APP_USER_INFO'))
 
 const canModifyChecker = computed(() => {
   return props.canModifyAssignments && props.isMainChecker

+ 1 - 1
src/pages/home/index.vue

@@ -190,7 +190,7 @@ onUnmounted(() => {
 // 获取用户 id
 const getUserId = async () => {
   try {
-    const res = await uni.getStorage({ key: 'USER_INFO' })
+    const res = await uni.getStorage({ key: 'APP_USER_INFO' })
     if (res.data?.id) {
       userId.value = res.data.id
     } else if (userInfo.value?.id) {

+ 2 - 2
src/pages/login/login.vue

@@ -147,7 +147,7 @@ const handleSubmit = async () => {
 
     if (loginRes) {
       // 存储 token
-      uni.setStorageSync('ACCESS_TOKEN', loginRes.accessToken)
+      uni.setStorageSync('APP_ACCESS_TOKEN', loginRes.accessToken)
 
       // 获取用户信息
       await fetchUserInfo(loginRes.userId)
@@ -176,7 +176,7 @@ const fetchUserInfo = async (userId: string) => {
 
     if (user) {
       // 存储用户信息
-      uni.setStorageSync('USER_INFO', user)
+      uni.setStorageSync('APP_USER_INFO', user)
 
       // 更新 store
       userStore.setUserInfo(user)

+ 7 - 2
src/pages/sign/index.vue

@@ -99,10 +99,12 @@
     <!-- 底部按钮 -->
     <view class="footer-bar">
       <button class="footer-btn more-btn" @click="handlePushOrder">更多操作</button>
-      <button class="footer-btn confirm-btn" @click="signSubmit">
+      <button v-show="isSigned == '0'" class="footer-btn confirm-btn" @click="signSubmit">
         {{ signButtonText }}
       </button>
-      <!-- <button v-show="isSigned == '1'" class="footer-btn confirm-btn">重新签名</button> -->
+      <button v-show="isSigned == '1'" class="footer-btn resign-btn" @click="signSubmit">
+        重新签名
+      </button>
     </view>
 
     <!-- 底部操作面板 -->
@@ -952,6 +954,9 @@ onMounted(() => {
 
   .resign-btn {
     background-color: #ffffff;
+    border-width: 2px;
+    border-color: #000000;
+    color: #000000;
   }
 }
 

+ 3 - 3
src/pages/unClaim/components/TaskItemInfo.vue

@@ -49,7 +49,7 @@ const props = defineProps<Props>()
 const emit = defineEmits<{
   click: []
   securityCheck: []
-  pdfDetail: [businessType: number, signFilePdf: string]
+  pdfDetail: [businessType: any, signFilePdf: string]
 }>()
 
 // 服务单/受理单状态
@@ -81,9 +81,9 @@ const resultStatusText = computed(() => {
 // PDF 点击事件
 const pdfClickFun = (businessType: number) => {
   if (businessType === 100) {
-    emit('pdfDetail', businessType, serviceOrderStatus.value?.signFilePdf || '')
+    emit('pdfDetail', 'FWD', serviceOrderStatus.value?.signFilePdf || '')
   } else if (businessType === 200) {
-    emit('pdfDetail', businessType, resultStatus.value?.signFilePdf || '')
+    emit('pdfDetail', 'JYRS', resultStatus.value?.signFilePdf || '')
   }
 }
 

+ 2 - 2
src/pages/unClaim/unClaimList.vue

@@ -297,10 +297,10 @@ const closeUpdateContactPopup = () => {
 }
 
 // PDF 详情(告知单/服务单/受理单)
-const handlePdfDetail = (businessType: number, signFilePdf: string, orderId: string) => {
+const handlePdfDetail = (businessType: any, signFilePdf: string, orderId: string) => {
   const businessTypeTitle = businessType === 200 ? '告知单' : '服务单/受理单'
   uni.navigateTo({
-    url: `/pages/serviceOrderDetail/index?businessType=${businessType}&orderId=${orderId}&businessTypeTitle=${businessTypeTitle}`,
+    url: `/pages/sign/index?type=${businessType}&orderId=${orderId}&businessTypeTitle=${businessTypeTitle}`,
   })
 }
 

+ 3 - 3
src/pages/user/index.vue

@@ -84,7 +84,7 @@ onMounted(() => {
 // 加载用户信息
 const loadUserInfo = () => {
   try {
-    const userInfo = uni.getStorageSync('USER_INFO')
+    const userInfo = uni.getStorageSync('APP_USER_INFO')
     if (userInfo) {
       const info = { ...userInfo }
       currentUserInfo.value = info
@@ -120,8 +120,8 @@ const handleLogout = async () => {
     userStore.clearUserInfo()
 
     // 清除本地存储
-    uni.removeStorageSync('ACCESS_TOKEN')
-    uni.removeStorageSync('USER_INFO')
+    uni.removeStorageSync('APP_ACCESS_TOKEN')
+    uni.removeStorageSync('APP_USER_INFO')
     uni.removeStorageSync('USER_LIST')
 
     // 跳转到登录页

+ 1 - 1
src/router/index.ts

@@ -17,7 +17,7 @@ interface CacheRoute {
 }
 export const beforEach = (to, from, next) => {
   try {
-    const userInfo = uni.getStorageSync('USER_INFO')
+    const userInfo = uni.getStorageSync('APP_USER_INFO')
     if (userInfo) {
       next()
     } else {

+ 1 - 1
src/store/config.ts

@@ -2,7 +2,7 @@ import { EquipmentType } from '@/utils/dictMap'
 import { defineStore } from 'pinia'
 import { ref } from 'vue'
 
-const EQUIP_TYPE_KEY = 'EQUIP_TYPE'
+const EQUIP_TYPE_KEY = 'APP_EQUIP_TYPE'
 
 function getStoredEquipType(): EquipmentType | null {
   try {

+ 4 - 4
src/store/user.ts

@@ -27,7 +27,7 @@ export const useUserStore = defineStore(
 
     // 初始化时从本地存储读取 token
     const initToken = () => {
-      const token = uni.getStorageSync('ACCESS_TOKEN')
+      const token = uni.getStorageSync('APP_ACCESS_TOKEN')
       if (token) {
         userInfo.value.token = token
       }
@@ -40,15 +40,15 @@ export const useUserStore = defineStore(
       userInfo.value = val
       // 同步更新 token 到 store
       if (val.token) {
-        uni.setStorageSync('ACCESS_TOKEN', val.token)
+        uni.setStorageSync('APP_ACCESS_TOKEN', val.token)
       }
     }
 
     const clearUserInfo = () => {
       userInfo.value = { ...initState }
       // 清除本地存储
-      uni.removeStorageSync('ACCESS_TOKEN')
-      uni.removeStorageSync('USER_INFO')
+      uni.removeStorageSync('APP_ACCESS_TOKEN')
+      uni.removeStorageSync('APP_USER_INFO')
     }
 
     const getUserInfo = () => {

+ 4 - 4
src/utils/http.ts

@@ -24,7 +24,7 @@ export const http = <T>(options: CustomRequestOptions) => {
     }
 
     // 从本地存储获取 token
-    const token = uni.getStorageSync('ACCESS_TOKEN')
+    const token = uni.getStorageSync('APP_ACCESS_TOKEN')
 
     uni.request({
       // #ifdef MP-WEIXIN
@@ -53,8 +53,8 @@ export const http = <T>(options: CustomRequestOptions) => {
             case 401:
               // 401 错误  -> 清理用户信息,跳转到登录页
               // userStore.clearUserInfo()
-              uni.removeStorageSync('ACCESS_TOKEN')
-              uni.removeStorageSync('USER_INFO')
+              uni.removeStorageSync('APP_ACCESS_TOKEN')
+              uni.removeStorageSync('APP_USER_INFO')
               uni.navigateTo({ url: '/pages/login/login' })
               break
             // case 500:
@@ -185,7 +185,7 @@ export const httpUpload = <T>(
   return new Promise((resolve, reject) => {
     const next = true
     // 从本地存储获取 token
-    const token = uni.getStorageSync('ACCESS_TOKEN')
+    const token = uni.getStorageSync('APP_ACCESS_TOKEN')
     const globalHeader = {
       'X-Access-Token': token || '',
       'X-Tenant-Id': 1,