Commit a5939341 by 李伟康

feat(api): 替换http请求方法为gscPost统一管理

将api模块中所有使用http.post的请求替换为gscPost方法,统一请求入口,便于维护和扩展。同时在登录页面初始化uni.$signHttp实例,确保全局可访问带签名的HTTP客户端。

涉及文件:
- api/module/evaluation.js
- api/module/usedCar.js
- api/request/signHttp.js
- pages/common/login.vue
- utils/cache/constantData.js
1 parent cef5f11a
import http from '../request/signHttp'
// ${pathEnum.evaluation} // ${pathEnum.evaluation}
import { gscPost } from '../request/signHttp'
module.exports = { module.exports = {
/** 评估单列表 */ /** 评估单列表 */
evalOrderList(data) { evalOrderList(data) {
console.log(http) return gscPost(`/evalOrder/page`, {
return http.post(`/evalOrder/page`, {
...data ...data
}) })
}, },
/** 评估单详情 */ /** 评估单详情 */
evalOrderDetail(data) { evalOrderDetail(data) {
return http.post(`/evalOrder/detail`, { return gscPost(`/evalOrder/detail`, {
...data ...data
}) })
}, },
/** 评估单创建 */ /** 评估单创建 */
evalOrderCreate(data) { evalOrderCreate(data) {
return http.post(`/evalOrder/create`, { return gscPost(`/evalOrder/create`, {
...data ...data
}) })
}, },
/** 评估单分页状态数量 */ /** 评估单分页状态数量 */
evalOrderPageCount(data) { evalOrderPageCount(data) {
return http.post(`/evalOrder/pageCount`, { return gscPost(`/evalOrder/pageCount`, {
...data ...data
}) })
}, },
/** 评估单更新 */ /** 评估单更新 */
evalOrderUpdate(data) { evalOrderUpdate(data) {
return http.post(`/evalOrder/edit`, { return gscPost(`/evalOrder/edit`, {
...data ...data
}) })
}, },
/** 评估单重新报价 */ /** 评估单重新报价 */
evalOrderOwnerReQuote(data) { evalOrderOwnerReQuote(data) {
return http.post(`/evalOrder/ownerReQuote`, { return gscPost(`/evalOrder/ownerReQuote`, {
...data ...data
}) })
}, },
/** 签订买卖合同 */ /** 签订买卖合同 */
evalOrderSignContract(data) { evalOrderSignContract(data) {
return http.post(`/evalOrder/signingSaleContract`, { return gscPost(`/evalOrder/signingSaleContract`, {
...data ...data
}) })
}, },
/** 评估单取消合同 */ /** 评估单取消合同 */
evalOrderCancelContract(data) { evalOrderCancelContract(data) {
return http.post(`/evalOrder/cancelSaleContract`, { return gscPost(`/evalOrder/cancelSaleContract`, {
...data ...data
}) })
}, },
/** 评估单重新提交 */ /** 评估单重新提交 */
evalOrderConfirmVehicleDelivery(data) { evalOrderConfirmVehicleDelivery(data) {
return http.post(`/confirmVehicleDelivery/reSubmit`, { return gscPost(`/confirmVehicleDelivery/reSubmit`, {
...data ...data
}) })
}, },
/** 确认交车 */ /** 确认交车 */
confirmDelivery(data) { confirmDelivery(data) {
return http.post(`/confirmVehicleDelivery/confirmVehicleDelivery`, { return gscPost(`/confirmVehicleDelivery/confirmVehicleDelivery`, {
...data ...data
}) })
}, },
/** 支付定金 */ /** 支付定金 */
payDepositApplication(data) { payDepositApplication(data) {
return http.post(`/applyPayment/payDepositApplication`, { return gscPost(`/applyPayment/payDepositApplication`, {
...data ...data
}) })
}, },
/** 发起代保管协议签署 */ /** 发起代保管协议签署 */
signAgreement(data) { signAgreement(data) {
return http.post(`/applyPayment/payFinal`, { return gscPost(`/applyPayment/payFinal`, {
...data ...data
}) })
}, },
/** 检查代保管协议签署状态 */ /** 检查代保管协议签署状态 */
checkSignAgreement(data) { checkSignAgreement(data) {
return http.post(`/applyPayment/checkSignAgreement`, { return gscPost(`/applyPayment/checkSignAgreement`, {
...data ...data
}) })
}, },
/** 检查车辆是否存在重复评估单 */ /** 检查车辆是否存在重复评估单 */
checkRepeat(data) { checkRepeat(data) {
return http.post(`/evalOrder/checkRepeat`, { return gscPost(`/evalOrder/checkRepeat`, {
...data ...data
}) })
}, },
/** 车辆ocr识别 */ /** 车辆ocr识别 */
vinOcr(data) { vinOcr(data) {
return http.post(`/evalOrder/vinOcr`, { return gscPost(`/evalOrder/vinOcr`, {
...data ...data
}) })
}, },
/** 行驶证ocr识别 */ /** 行驶证ocr识别 */
carLicenseOcr(data) { carLicenseOcr(data) {
return http.post(`/evalOrder/carLicenseOcr`, { return gscPost(`/evalOrder/carLicenseOcr`, {
...data ...data
}) })
}, },
/** 获取合同详情 */ /** 获取合同详情 */
getContractDetail(data) { getContractDetail(data) {
return http.post(`/evalElectronicContract/getDetail`, { return gscPost(`/evalElectronicContract/getDetail`, {
...data ...data
}) })
}, },
/** 获取保管人列表 */ /** 获取保管人列表 */
getCustodyAgreementList(data) { getCustodyAgreementList(data) {
return http.post(`/custodyAgreement/custodyAgreementList`, { return gscPost(`/custodyAgreement/custodyAgreementList`, {
...data ...data
}) })
}, },
/** 新增保管人 */ /** 新增保管人 */
addCustodyAgreement(data) { addCustodyAgreement(data) {
return http.post(`/custodyAgreement/addCustodyAgreement`, { return gscPost(`/custodyAgreement/addCustodyAgreement`, {
...data ...data
}) })
}, },
/** 发送代保管人协议 */ /** 发送代保管人协议 */
sendCustodyAgreement(data) { sendCustodyAgreement(data) {
return http.post(`/custodyAgreement/sendCustodyAgreement`, { return gscPost(`/custodyAgreement/sendCustodyAgreement`, {
...data ...data
}) })
}, },
/** 销售协议预览 */ /** 销售协议预览 */
salesAgreementPreview(data) { salesAgreementPreview(data) {
return http.post(`/evalOrder/salesAgreementPreview`, { return gscPost(`/evalOrder/salesAgreementPreview`, {
...data ...data
}) })
} }
......
import { add } from 'lodash' import { gscPost } from '../request/signHttp'
import http from '../request/signHttp'
module.exports = { module.exports = {
/** 二手车驻店日报列表 */ /** 二手车驻店日报列表 */
getCarDailyReportList(data) { getCarDailyReportList (data) {
return http.post('/carDailyReport/list', { return gscPost('/carDailyReport/list', {
...data ...data
}) })
}, },
/** /**
* 新增二手车驻店日报 * 新增二手车驻店日报
*/ */
addCarDailyReport(data) { addCarDailyReport (data) {
return http.post('/carDailyReport/add', { return gscPost('/carDailyReport/add', {
...data ...data
}) })
}, },
/** /**
* 二手车驻店日报详情 * 二手车驻店日报详情
*/ */
getCarDailyReportDetail(data) { getCarDailyReportDetail (data) {
return http.post('/carDailyReport/detail', { return gscPost('/carDailyReport/detail', {
...data ...data
}) })
}, },
/** /**
* 修改二手车驻店日报 * 修改二手车驻店日报
*/ */
editCarDailyReport(data) { editCarDailyReport (data) {
return http.post('/carDailyReport/edit', { return gscPost('/carDailyReport/edit', {
...data ...data
}) })
}, },
......
import { Request } from 'glsk-toolkit' // import { Request } from 'glsk-toolkit'
import { signSecretKey, pathEnum, domain, djDomain, evaluationDomain, merchantDomain } from '../../env' // import { signSecretKey, pathEnum, domain, djDomain, evaluationDomain, merchantDomain } from '../../env'
const HOST = { // const HOST = {
scrm: domain, // scrm: domain,
dj: djDomain, // dj: djDomain,
eva: evaluationDomain, // eva: evaluationDomain,
merchant: merchantDomain, // merchant: merchantDomain,
ip: 'http://192.168.1.169:8292' // ip: 'http://192.168.1.169:8292'
} // }
const request = new Request({ // const request = new Request({
baseURL: `${HOST['eva']}${pathEnum.evaluation}`, // baseURL: `${HOST['eva']}${pathEnum.evaluation}`,
timeout: 300000, // timeout: 300000,
appId: signSecretKey.appKey, // appId: signSecretKey.appKey,
appSecret: signSecretKey.secret, // appSecret: signSecretKey.secret,
session: { // session: {
requiresSession: true, // requiresSession: true,
sessionParamName: 'sessionId', // sessionParamName: 'sessionId',
sessionId: async () => await getSid() // sessionId: async () => await getSid()
}, // },
response: { // response: {
code_key: 'code', // code_key: 'code',
code_success_value: '0', // code_success_value: '0',
data_key: 'data', // data_key: 'data',
errId: 'code', // errId: 'code',
errId_logout_value: '21' // errId_logout_value: '21'
}, // },
events: { // events: {
response: (responseData, config) => { // response: (responseData, config) => {
console.log('response事件触发', responseData, config) // console.log('response事件触发', responseData, config)
}, // },
timeout: 30000, // timeout: 30000,
response: { // response: {
code_key: 'code', // code_key: 'code',
code_success_value: '0', // code_success_value: '0',
data_key: 'data', // data_key: 'data',
errId: 'errId', // errId: 'errId',
errId_logout_value: '21' // errId_logout_value: '21'
}, // },
request: (request, config) => { // request: (request, config) => {
console.log('request事件触发', request, config) // console.log('request事件触发', request, config)
}, // },
error: (error, config) => { // error: (error, config) => {
console.log('error事件触发', error, config) // console.log('error事件触发', error, config)
return Promise.reject(error) // return Promise.reject(error)
}, // },
logout: config => { // logout: config => {
console.log('logout事件触发', config) // console.log('logout事件触发', config)
const pages = getCurrentPages(), // const pages = getCurrentPages(),
currentPage = pages[pages.length - 1] // currentPage = pages[pages.length - 1]
uni.hideLoading() // uni.hideLoading()
if (currentPage.route != 'pages/common/login') // if (currentPage.route != 'pages/common/login')
uni.reLaunch({ // uni.reLaunch({
url: '/pages/common/login' // url: '/pages/common/login'
}) // })
} // }
} // }
}) // })
// async function getSid() {
// const { sessionId } = uni.$storage?.get() || {}
// console.log('sessionId3333322', sessionId)
// return sessionId
// }
async function getSid() { // export default request
const { sessionId } = uni.$storage?.get() || {}
console.log('sessionId3333322', sessionId)
return sessionId
}
export default request module.exports = {
gscPost: (url, data, _config = {}) => {
return uni.$signHttp.post(url, data, _config)
}
}
\ No newline at end of file \ No newline at end of file
...@@ -96,6 +96,15 @@ ...@@ -96,6 +96,15 @@
</template> </template>
<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 { 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 {
...@@ -127,6 +136,8 @@ export default { ...@@ -127,6 +136,8 @@ export default {
} }
}, },
onLoad (options) { onLoad (options) {
console.log(HOST, '===')
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')
if (noSignInUuid) this.autoLogin(noSignInUuid) if (noSignInUuid) this.autoLogin(noSignInUuid)
...@@ -275,7 +286,58 @@ export default { ...@@ -275,7 +286,58 @@ export default {
this[key] = numbers ? numbers.join('') : '' this[key] = numbers ? numbers.join('') : ''
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>
......
...@@ -43,5 +43,6 @@ export const STORAGE_OBJECTKEY = { ...@@ -43,5 +43,6 @@ export const STORAGE_OBJECTKEY = {
noticeTopInfo: 'noticeTopInfo', noticeTopInfo: 'noticeTopInfo',
studyCenterPermission: 'studyCenterPermission', studyCenterPermission: 'studyCenterPermission',
caseInfo: 'caseInfo', caseInfo: 'caseInfo',
boutique_YQorderSetting: 'boutique_YQorderSetting' boutique_YQorderSetting: 'boutique_YQorderSetting',
sessionId:'sessionId'
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!