From b63d99671684bb6ff7f4481c62eb7c0c0b819fea Mon Sep 17 00:00:00 2001 From: bb_pan Date: Fri, 14 Feb 2025 18:01:24 +0800 Subject: [PATCH] =?UTF-8?q?=E9=83=A8=E7=BD=B2bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/header/index.vue | 5 ++++- src/http/index.ts | 4 ++++ src/layout/header.vue | 4 +++- src/views/cart/index.vue | 9 +++++++-- src/views/home/index.vue | 4 +++- src/views/order/index.vue | 8 ++++++-- src/views/user/contract-manage/index.vue | 4 ++-- .../orderManagement/components/order-home.vue | 19 ++++++++++++++++--- .../components/order-home.vue | 9 +++++++-- 9 files changed, 52 insertions(+), 14 deletions(-) diff --git a/src/components/header/index.vue b/src/components/header/index.vue index d606c90..d297c27 100644 --- a/src/components/header/index.vue +++ b/src/components/header/index.vue @@ -240,7 +240,10 @@ const resetPhone = async () => { } onMounted(() => { - getUserListData() + // 有token才请求用户信息 + if (store.token) { + getUserListData() + } circleUrl.value = store.userInfo.avatar }) diff --git a/src/http/index.ts b/src/http/index.ts index 3e0d642..57d3f77 100644 --- a/src/http/index.ts +++ b/src/http/index.ts @@ -45,6 +45,7 @@ service.interceptors.request.use( if (config.data) { let data = typeof config.data === 'object' ? JSON.stringify(config.data) : config.data config.data = encryptWithSM4(data + '|' + hashWithSM3AndSalt(data)) + // config.data = data } return config }, @@ -67,6 +68,8 @@ service.interceptors.response.use( return data } else if (data.code == '403') { ElMessage.error('请重新登录') + // 清除token + localStorage.removeItem('tokenNew') // 根据环境变量 VITE_API_URL 判断是否是本地开发环境 if (import.meta.env.VITE_API_URL == '/proxyApi') { router.push('/login') @@ -79,6 +82,7 @@ service.interceptors.response.use( } } else if (data.code == '401') { ElMessage.error('请重新登录') + localStorage.removeItem('tokenNew') if (import.meta.env.VITE_API_URL == '/proxyApi') { router.push('/login') } else { diff --git a/src/layout/header.vue b/src/layout/header.vue index bd18261..54fd007 100644 --- a/src/layout/header.vue +++ b/src/layout/header.vue @@ -139,7 +139,9 @@ const getHotSearchListData = async () => { console.log(res, '热词') } -getHotSearchListData() +if (tokenNew) { + getHotSearchListData() +} // 搜索按钮 const searchKeywordBtn = () => { diff --git a/src/views/cart/index.vue b/src/views/cart/index.vue index 6692cc5..5bf7008 100644 --- a/src/views/cart/index.vue +++ b/src/views/cart/index.vue @@ -722,8 +722,13 @@ const handleViewWord = async (index: any) => { console.log('查询参数', queryParams) const res: any = await getBookCarAgreementApi(queryParams) - - wordUrl.value = res.data.url + + if (import.meta.env.VITE_API_URL == '/proxyApi') { + wordUrl.value = res.data.url + } else { + wordUrl.value = 'http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + res.data.url + } + console.log('🚀 ~ handleViewWord ~ wordUrl.value:', wordUrl.value) dialogFormVisibleSettleWord.value = true settleWordTitle.value = '租赁服务合同' diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 0183a61..771b22d 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -22,6 +22,7 @@ const { getCompanyList, getGoodsClassList } = userClass() const router: any = useRouter() const userStore = useStore() const store: any = mainStore() +const tokenNew = localStorage.getItem('tokenNew') // const leftNavList: any = ref([]) const companyList: any = ref([]) @@ -57,6 +58,7 @@ const getCompanyListData = async () => { // console.log('res公司名称', res) } +// console.log('🚀 ~ tokenNew:', tokenNew) getCompanyListData() // 点击跳转装备共享大厅 @@ -166,7 +168,7 @@ const onClickSwiper = (item: any) => { getSwiperListData() onMounted(async () => { - if (!store.token) { + if (!tokenNew) { const origin = window.location.href console.log(origin.split('ticket=')[1], 'origin') diff --git a/src/views/order/index.vue b/src/views/order/index.vue index e79e69d..569fd2d 100644 --- a/src/views/order/index.vue +++ b/src/views/order/index.vue @@ -554,8 +554,12 @@ const handleViewWord = async (index: any) => { console.log('查询参数', queryParams) const res: any = await getBookCarAgreementApi(queryParams) - - wordUrl.value = res.data.url + + if (import.meta.env.VITE_API_URL == '/proxyApi') { + wordUrl.value = res.data.url + } else { + wordUrl.value = 'http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + res.data.url + } dialogFormVisibleSettleWord.value = true settleWordTitle.value = '租赁服务合同' diff --git a/src/views/user/contract-manage/index.vue b/src/views/user/contract-manage/index.vue index 9ce41e0..fbb92ae 100644 --- a/src/views/user/contract-manage/index.vue +++ b/src/views/user/contract-manage/index.vue @@ -539,12 +539,12 @@ const onFileChange = (fileList: any) => { testUrl = e.url // 公司-测试环境 } else { console.log('走入宏源测试环境----------', ) - testUrl = origin + '/ahbns/' + e.url // 宏源-测试环境 + testUrl = 'http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + e.url // 宏源-测试环境 console.log('输出testUrl----------', testUrl) } return { fileName: e.name, - fileUrl: isProd ? 'http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + e.url : testUrl, + fileUrl: testUrl, } }) console.log('22222222查看file路径', fileListTemp) diff --git a/src/views/user/orderManagement/components/order-home.vue b/src/views/user/orderManagement/components/order-home.vue index 460d332..a1176bd 100644 --- a/src/views/user/orderManagement/components/order-home.vue +++ b/src/views/user/orderManagement/components/order-home.vue @@ -70,7 +70,9 @@ const statusList: any = [ ] const orderText = (status: any) => { - return statusList.filter((e: any) => e.id == status)[0].name + // return statusList.filter((e: any) => e.id == status)[0].name + const statusItem = statusList.find((e: any) => e.id == status) + return statusItem ? statusItem.name : '' } const orderType = (status: any) => { if (status == 1 || status == 2 || status == 3 || status == 5) return 'primary' @@ -347,7 +349,12 @@ const handleViewWord = async (index: Number, row: any) => { const res: any = await getContractDetailApi({ orderId }) // cardList.value = res.rows // 打开租赁协议弹框 - wordUrl.value = res.data.url + if (import.meta.env.VITE_API_URL == '/proxyApi') { + wordUrl.value = res.data.url + } else { + wordUrl.value = 'http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + res.data.url + } + console.log('🚀 ~ handleViewWord ~ wordUrl.value:', wordUrl.value) dialogFormVisibleSettleWord.value = true dialogFormVisibleSettleWord.value = true setTimeout(() => { @@ -367,7 +374,13 @@ const handleViewWord = async (index: Number, row: any) => { // 下载合同为 Word 文件 const downloadContract = () => { - window.location.href = wordUrl.value + console.log('🚀 ~ downloadContract ~ wordUrl.value:', wordUrl.value) + window.open(wordUrl.value) + // if (import.meta.env.VITE_API_URL == '/proxyApi') { + // window.open(wordUrl.value) + // } else { + // window.open('http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + wordUrl.value) + // } } const confirmFail = async (index: number) => { diff --git a/src/views/user/orderManagementCz/components/order-home.vue b/src/views/user/orderManagementCz/components/order-home.vue index 34328ab..b492bee 100644 --- a/src/views/user/orderManagementCz/components/order-home.vue +++ b/src/views/user/orderManagementCz/components/order-home.vue @@ -669,7 +669,11 @@ const handleViewWord = async (index: Number, row: any) => { const res: any = await getContractDetailApi({ orderId }) // cardList.value = res.rows // 打开租赁协议弹框 - wordUrl.value = res.data.url + if (import.meta.env.VITE_API_URL == '/proxyApi') { + wordUrl.value = res.data.url + } else { + wordUrl.value = 'http://sgwpdm.ah.sgcc.com.cn/iws/ahbns/' + res.data.url + } dialogFormVisibleSettleWord.value = true setTimeout(() => { const myDocxPreviewer = jsPreviewDocx.init(document.getElementById('mmm')) @@ -694,7 +698,8 @@ const contract = ref({ // 下载合同为 Word 文件 const downloadContract = () => { - window.location.href = wordUrl.value + console.log('🚀 ~ downloadContract ~ wordUrl.value:', wordUrl.value) + window.open(wordUrl.value) } const wordUrl = ref('')