revert: 还原合并冲突文件

This commit is contained in:
2025-11-12 21:14:53 +08:00
parent 59435dc963
commit 76ece8bfe7
5 changed files with 769 additions and 5140 deletions

View File

@@ -12,59 +12,30 @@ import { toast, showConfirm, tansParams } from '@/utilsRc/common'
let timeout = 10000
const baseUrl = configRc.baseUrl
const zytpBaseUrl = configRc.zytpBaseUrl || ''
const request = config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
config.header = config.header || {}
// 从存储中获取微信登录的 token
const token = getToken()
if (token && !isToken) {
config.header['Authorization'] = 'Bearer ' + token
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
// config.header['Authorization'] = 'Bearer ' + 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJzeXNfdXNlcjoxIiwicm5TdHIiOiJGUVl3YmRUalAzQ1BMNGFVc0RxeGJmdjAyT3JMZllDVSIsInVzZXJJZCI6MX0.kSOXY2QJQPbfjE0Yx2R3S8yQciA33OZBS9xJtr7cQ1A'
// get请求映射params参数
const baseType = config.baseUrlType
const requestBaseUrl = baseType === 'zytp' && zytpBaseUrl ? zytpBaseUrl : baseUrl
let requestUrl = config.fullUrl ? config.fullUrl : (requestBaseUrl + (config.url || ''))
if (config.params) {
let url = tansParams(config.params)
let url = config.url + '?' + tansParams(config.params)
url = url.slice(0, -1)
if (url) {
requestUrl += (requestUrl.includes('?') ? '&' : '?') + url
}
config.url = url
}
// 如果是 getJobPathById 接口,打印完整 URL
if (config.url && config.url.includes('getJobPathById')) {
console.log('[请求URL] getJobPathById 完整请求URL:', requestUrl);
console.log('[请求URL] baseUrl:', requestBaseUrl);
console.log('[请求URL] 接口路径:', config.url);
console.log('[请求URL] 请求参数:', config.params);
}
// 如果是 recommendJob 接口,打印详细信息
if (config.url && config.url.includes('recommendJob')) {
console.log('[请求URL] recommendJob 完整请求URL:', requestUrl);
console.log('[请求URL] baseUrl:', requestBaseUrl);
console.log('[请求URL] 接口路径:', config.url);
console.log('[请求URL] 请求方法:', config.method);
console.log('[请求URL] 请求参数 (params):', config.params);
console.log('[请求URL] 请求数据 (data):', config.data);
console.log('[请求URL] Content-Type:', config.header?.['content-type']);
}
return new Promise((resolve, reject) => {
uni.request({
method: config.method || 'get',
timeout: config.timeout || timeout,
url: requestUrl,
url: baseUrl + config.url,
// url: 'https://gccrcdh.sd-talent.cn:80/zhq' + config.url,
data: config.data,
header: config.header,
dataType: 'json',
responseType: config.responseType || 'text'
dataType: 'json'
}).then(response => {
let res = response.data
let error = response.errMsg!='request:ok'
@@ -73,11 +44,10 @@ const request = config => {
reject('网络出小差,请稍后再试')
return
}
// 处理 code0 和 200 都表示成功
const code = res.code !== undefined && res.code !== null ? res.code : 200
const code = res.code || 200
const msg = errorCode[code] || res.msg || errorCode['default']
const isShowModel = getApp().globalData.isShowModel
if (code === 200 || code === 0) {
if (code == 200) {
resolve(res)
}else if (code === 401) {
if(isShowModel === false) {
@@ -110,15 +80,12 @@ const request = config => {
else if (code === 500) {
toast(msg)
reject('500')
} else if (code !== 200 && code !== 0 && code !== 9999) {
} else if (code !== 200 && code !== 9999) {
// 9999是正常的业务状态码不应该被当作错误处理
// 0 和 200 都表示成功
toast(msg)
reject(code)
}
// 如果 code 是 0 或 200返回完整响应对象而不是 res.data
// 因为有些接口的 data 在 res.data 中,有些在 res 中
resolve(res)
resolve(res.data)
})
.catch(error => {
let message = error.errMsg