Commit fc8d4692 by 李伟康

feat(login): 重构登录页面请求配置逻辑

移除原有在 login.vue 中定义的 HOST 常量及相关环境变量引入,
将 toolkit 请求实例的初始化逻辑从 setToolkitConfig 方法中删除。

在 onLoad 生命周期中重新初始化 uni.$signHttp 实例,
确保每次登录时能正确重置请求参数配置。
1 parent 1adc4cfa
...@@ -97,14 +97,6 @@ ...@@ -97,14 +97,6 @@
<script type="text/ecmascript-6"> <script type="text/ecmascript-6">
const phoneRex = /^[1]([3-9])[0-9]{9}$/; const phoneRex = /^[1]([3-9])[0-9]{9}$/;
import { Request } from 'glsk-toolkit' import { Request } from 'glsk-toolkit'
import { signSecretKey, pathEnum, domain, djDomain, evaluationDomain, merchantDomain } from '@/env'
const HOST = {
scrm: domain,
dj: djDomain,
eva: evaluationDomain,
merchant: merchantDomain,
ip: 'http://192.168.1.169:8292'
}
export default { export default {
data () { data () {
return { return {
...@@ -136,7 +128,7 @@ export default { ...@@ -136,7 +128,7 @@ export default {
} }
}, },
onLoad (options) { onLoad (options) {
console.log(HOST, '===') uni.$signHttp = new Request(uni.signHttpConfig) //重新登录重置请求参数
this.setToolkitConfig() this.setToolkitConfig()
if (options.mobile) this.mobile = options.mobile if (options.mobile) this.mobile = options.mobile
const noSignInUuid = uni.$storage.get('noSignInUuid') const noSignInUuid = uni.$storage.get('noSignInUuid')
...@@ -287,57 +279,6 @@ export default { ...@@ -287,57 +279,6 @@ export default {
this.dateKey[key] = Date.now() this.dateKey[key] = Date.now()
}, 0) }, 0)
}, },
setToolkitConfig () {
uni.$signHttp = new Request({
baseURL: `${HOST['eva']}${pathEnum.evaluation}`,
timeout: 300000,
appId: signSecretKey.appKey,
appSecret: signSecretKey.secret,
session: {
requiresSession: true,
sessionParamName: 'sessionId',
sessionId: _ => uni.$storage?.get('sessionId')
},
response: {
code_key: 'code',
code_success_value: '0',
data_key: 'data',
errId: 'code',
errId_logout_value: '21'
},
events: {
response: (responseData, config) => {
console.log('response事件触发', responseData, config)
},
timeout: 30000,
response: {
code_key: 'code',
code_success_value: '0',
data_key: 'data',
errId: 'errId',
errId_logout_value: '21'
},
request: (request, config) => {
console.log('request事件触发', request, config)
},
error: (error, config) => {
console.log('error事件触发', error, config)
return Promise.reject(error)
},
logout: config => {
console.log('logout事件触发', config)
const pages = getCurrentPages(),
currentPage = pages[pages.length - 1]
uni.hideLoading()
if (currentPage.route != 'pages/common/login')
uni.reLaunch({
url: '/pages/common/login'
})
}
}
})
console.log(uni.$signHttp)
},
}, },
}; };
</script> </script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!