Merge remote-tracking branch 'origin/pet-2.0' into pet-2.0

# Conflicts:
#	utils/request.js
pet-2.0
guoyuepeng 2025-04-20 16:58:30 +08:00
commit f294d336d0
1 changed files with 53 additions and 12 deletions

View File

@ -1,12 +1,39 @@
import store from '../store/index'
// export var requestPath = 'http://192.168.192.201:8992/qa-regulatory-gwj/'; // 后台请求地址 // export var requestPath = 'http://192.168.192.201:8992/qa-regulatory-gwj/'; // 后台请求地址
export var requestPath = 'https://skqhdg.porthebei.com:9005/regulatory_gwj_2.0/'; // 后台请求地址 export var requestPath = 'https://skqhdg.porthebei.com:9005/regulatory_gwj_2.0/'; // 后台请求地址
// export var requestPath = 'http://192.168.151.75:8092/'; // export var requestPath = 'http://192.168.151.75:8092/';
let videoApiPath = 'https://arqsp.qhdsafety.com:10010'; // 视频平台后台请求地址 let videoApiPath = 'https://arqsp.qhdsafety.com:10010'; // 视频平台后台请求地址
import store from '../store/index'
import dayjs from "dayjs"; import dayjs from "dayjs";
import { setRefreshToken } from "@/api"; import { setRefreshToken } from "@/api";
// export var requestPath = 'https://skqhdg.porthebei.com:9005/qa-regulatory-gwj/'; // 后台请求地址
export var requestPath = 'http://192.168.192.201:8992/regulatory_gwj_2.0/';
let videoApiPath = 'https://arqsp.qhdsafety.com:10010'; // 视频平台后台请求地址
function logOut(reject,data) {
uni.showToast({
title: '登录失效,请重新登录',
icon: 'none',
duration: 2000
});
reject(data)
setTimeout(()=>{
let userInfo = {}
for (const userInfoKey in store.state.userInfo) {
if (store.state.userInfo.hasOwnProperty(userInfoKey)) {
userInfo[userInfoKey] = ''
}
}
store.dispatch('setUserInfo', userInfo)
uni.reLaunch({
url: '/pages/login/login'
})
},1000)
}
function post(url, data) { function post(url, data) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (data && data.loading !== false) { if (data && data.loading !== false) {
@ -41,9 +68,13 @@ function post(url, data) {
}); });
reject(res.data) reject(res.data)
}else{ }else{
if(res.data.code === 401){
logOut(reject,res.data)
return
}
uni.showToast({ uni.showToast({
title: res.data.msg || '系统开小差了', title: res.data.msg || '系统开小差了',
icon: 'error', icon: 'none',
duration: 2000 duration: 2000
}); });
reject(res.data) reject(res.data)
@ -83,15 +114,20 @@ function upload(url, data) {
}, },
success: (res) => { success: (res) => {
uni.hideLoading(); uni.hideLoading();
if (JSON.parse(res.data).result === 'success') { const data = JSON.parse(res.data)
resolve(JSON.parse(res.data)) if (data.result === 'success') {
resolve(data)
} else { } else {
if(data.code === 401){
logOut(reject,data)
return
}
uni.showToast({ uni.showToast({
title: JSON.parse(res.data).msg || '系统开小差了', title: data.msg || '系统开小差了',
icon: 'error', icon: 'none',
duration: 2000 duration: 2000
}); });
reject(JSON.parse(res.data)) reject(data)
} }
}, },
fail: (err) => { fail: (err) => {
@ -123,15 +159,20 @@ function uploads(url, data) {
}, },
success: (res) => { success: (res) => {
uni.hideLoading(); uni.hideLoading();
if (JSON.parse(res.data).result === 'success') { const data = JSON.parse(res.data)
resolve(JSON.parse(res.data)) if (data.result === 'success') {
resolve(data)
} else { } else {
if(data.code === 401){
logOut(reject,data)
return
}
uni.showToast({ uni.showToast({
title: JSON.parse(res.data).msg || '系统开小差了', title: data.msg || '系统开小差了',
icon: 'error', icon: 'none',
duration: 2000 duration: 2000
}); });
reject(JSON.parse(res.data)) reject(data)
} }
}, },
fail: (err) => { fail: (err) => {