Merge branch 'dev-sy-10-10'

This commit is contained in:
BianLzhaoMin 2024-10-18 18:38:01 +08:00
commit d28034fbf4
3 changed files with 105 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import request from '@/utils/request' import request from '@/utils/request_new'
// 获取首页数据 // 获取首页数据
export function getHomePageListApi(data) { export function getHomePageListApi(data) {

View File

@ -1,12 +1,12 @@
// 产线 // 产线
module.exports = { module.exports = {
// http://192.168.0.14:19999 // http://192.168.0.14:19999
loginBaseUrl:'http://112.29.103.165:1616', loginBaseUrl: 'http://112.29.103.165:1616',
baseUrl:'http://112.29.103.165:1616/exam', baseUrl: 'http://112.29.103.165:1616/exam',
// login: 'http://112.29.103.165:1616', // login: 'http://112.29.103.165:1616',
login: 'http://112.29.103.165:1616/exam/exam-auth/', login: 'http://112.29.103.165:1616/exam/exam-auth/',
// 图片展示基础地址 // 图片展示基础地址
fileUrl:'http://112.29.103.165:1616/exam-file/', fileUrl: 'http://112.29.103.165:1616/exam-file/',
// 上传文件地址 // 上传文件地址
uploadUrl: 'http://112.29.103.165:1616/exam-file/file/uploadBase64', uploadUrl: 'http://112.29.103.165:1616/exam-file/file/uploadBase64',
bmwUrl: 'http://112.29.103.165:1616/exam-bmw', bmwUrl: 'http://112.29.103.165:1616/exam-bmw',
@ -14,26 +14,25 @@ module.exports = {
tjBaseUrl: 'http://112.29.103.165:1616/AppPeaManager', tjBaseUrl: 'http://112.29.103.165:1616/AppPeaManager',
tjFile: 'http://112.29.103.165:1616/medicalDocumentation/statics/', tjFile: 'http://112.29.103.165:1616/medicalDocumentation/statics/',
//实名制移动端-登录接口
realLoginUrl: 'http://192.168.0.14:9200/',
//实名制移动端-移动
//实名制移动端-登录接口 realAppUrl: 'http://192.168.0.14:1913/app',
realLoginUrl: 'http://192.168.0.14:9200/', //实名制移动端-安培
//实名制移动端-移动 realExamUrl: 'http://192.168.0.14:1910',
realAppUrl: 'http://192.168.0.14:1913/app', //实名制移动端-文件
//实名制移动端-安培 realFileUrl: 'http://192.168.0.14:1909/file/',
realExamUrl: 'http://192.168.0.14:1910', //实名制移动端
//实名制移动端-文件 realBmwUrl: 'http://192.168.0.14:1911/bmw',
realFileUrl: 'http://192.168.0.14:1909/file/', //实名制移动端 -- 新
//实名制移动端 realNewBmwUrl: 'http://192.168.0.14:1911',
realBmwUrl: 'http://192.168.0.14:1911/bmw',
// 应用信息 // 应用信息
appInfo: { appInfo: {
// 应用名称 // 应用名称
name: "作业管控智慧平台", name: '作业管控智慧平台',
// 应用版本 // 应用版本
version: "1.1.0", version: '1.1.0'
} }
} }
// 测试环境 // 测试环境

85
utils/request_new.js Normal file
View File

@ -0,0 +1,85 @@
import store from '@/store'
import config from '@/config'
import { getToken, setToken } from '@/utils/auth'
import errorCode from '@/utils/errorCode'
import { toast, showConfirm, tansParams } from '@/utils/common'
let timeout = 60000
const baseUrl = config.realNewBmwUrl
console.log('baseUrl-请求', baseUrl)
const request = config => {
// 是否需要设置 token
const isToken = (config.headers || {}).isToken === false
config.header = config.header || {}
if (getToken() && !isToken) {
config.header['Authorization'] = 'Bearer ' + getToken()
}
// get请求映射params参数
if (config.params) {
let url = config.url + '?' + tansParams(config.params)
url = url.slice(0, -1)
config.url = url
}
if (config.method === 'post') {
config.header = {
...config.header,
'Content-Type': 'application/x-www-form-urlencoded'
}
// config.data = JSON.stringify(config.data);
}
return new Promise((resolve, reject) => {
uni
.request({
method: config.method || 'get',
timeout: config.timeout || timeout,
url: baseUrl + config.url,
data: config.data,
header: config.header,
dataType: 'json'
})
.then(response => {
// console.log(response)
let [error, res] = response
if (error) {
toast('后端接口连接异常')
reject('后端接口连接异常')
return
}
const code = res.data.code || 200
const msg = errorCode[code] || res.data.msg || errorCode['default']
if (code === 401) {
showConfirm('登录状态已过期,您可以继续留在该页面,或者重新登录?').then(res => {
if (res.confirm) {
store.dispatch('LogOut').then(res => {
uni.reLaunch({ url: '/pages/login' })
})
}
})
reject('无效的会话,或者会话已过期,请重新登录。')
} else if (code === 500) {
toast(msg)
reject(msg)
} else if (code !== 200) {
toast(msg)
reject(msg)
}
resolve(res.data)
})
.catch(error => {
let { message } = error
if (message === 'Network Error') {
message = '后端接口连接异常'
} else if (message.includes('timeout')) {
message = '系统接口请求超时'
} else if (message.includes('Request failed with status code')) {
message = '系统接口' + message.substr(message.length - 3) + '异常'
}
toast(message)
reject(error)
})
})
}
export default request