| ¶Ô±ÈÐÂÎļþ |
| | |
| | | import { decryptedData } from '@/utils/decryption.js' |
| | | const install = (Vue, vm) => { |
| | | // æ¯å¦æ£å¨å·æ°çæ è®° |
| | | let isRefreshing = false |
| | | // éè¯éåï¼æ¯ä¸é¡¹å°æ¯ä¸ä¸ªå¾
æ§è¡ç彿°å½¢å¼ |
| | | let requests = [] |
| | | |
| | | // è¯·æ±æ¦æªå¨ |
| | | uni.$u.http.interceptors.request.use((config) => { |
| | | // if (!['mobile/chatLog/unReadMessageNum', 'mobile/Message/messageList'].includes(config.url)) { |
| | | // uni.showLoading({ title: '请æ±ä¸' }); |
| | | // } |
| | | uni.showLoading({ title: '请æ±ä¸' }); |
| | | let Headtoken |
| | | if (vm.$store.state.userInfo) { |
| | | Headtoken = vm.$store.state.userInfo.token |
| | | } |
| | | if (Headtoken) { |
| | | config.header['web_token'] = Headtoken; |
| | | } |
| | | return config |
| | | }, config => { |
| | | return Promise.reject(config) |
| | | }) |
| | | |
| | | // ååºæ¦æªå¨ |
| | | uni.$u.http.interceptors.response.use((response) => { |
| | | uni.hideLoading(); |
| | | // ç»å½è¿æ |
| | | if (response.data.code === 5112) { |
| | | uni.showToast({ |
| | | title: 'ç»å½è¿æï¼æ£å¨éæ°è·³è½¬ææ', |
| | | icon: 'none', |
| | | duration: 2000, |
| | | success() { |
| | | setTimeout(() => { |
| | | let loc_href = encodeURIComponent("https://dmtest.ahapp.net/lianhelihua_web/") |
| | | let corpId = 'wweea8f71b54e3b835'; |
| | | let agentId = '1000095'; |
| | | let wxUrl = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${corpId}&redirect_uri=${loc_href}&response_type=code&scope=snsapi_base&state=#wechat_redirect` |
| | | location.href = wxUrl; |
| | | }, 1500) |
| | | } |
| | | }) |
| | | return |
| | | } |
| | | if (response.data.code !== 200) { |
| | | uni.showToast({ |
| | | title: response.data.message || response.data.msg, |
| | | icon: "none", |
| | | duration: 2000 |
| | | }); |
| | | } |
| | | if (response.data.message) { |
| | | const tm = response.data.message |
| | | const list = tm.split(' ') |
| | | let msg = list[0] |
| | | if (list.length > 1 && response.data.data) { |
| | | msg = decryptedData(list[1], list[0]) |
| | | response.data.data = decryptedData(list[1], response.data.data) |
| | | console.log(response.data.data) |
| | | response.data.message = msg |
| | | } |
| | | } |
| | | return response.data; |
| | | }, (response) => { |
| | | return Promise.reject(response) |
| | | }) |
| | | } |
| | | |
| | | export default { install } |