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

pet-2.0^2
zhaohongyu 2025-04-20 18:29:45 +08:00
commit 1c53c0573a
1 changed files with 52 additions and 17 deletions

View File

@ -1,12 +1,33 @@
// export var requestPath = 'https://skqhdg.porthebei.com:9005/qa-regulatory-gwj/'; // 后台请求地址
export var requestPath = 'http://192.168.0.101:8060/new_template';
let videoApiPath = 'https://arqsp.qhdsafety.com:10010'; // 视频平台后台请求地址
import store from '../store/index'
import dayjs from "dayjs";
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) {
return new Promise((resolve, reject) => {
if (data && data.loading !== false) {
@ -41,9 +62,13 @@ function post(url, data) {
});
reject(res.data)
}else{
if(res.data.code === 401){
logOut(reject,res.data)
return
}
uni.showToast({
title: res.data.msg || '系统开小差了',
icon: 'error',
icon: 'none',
duration: 2000
});
reject(res.data)
@ -83,15 +108,20 @@ function upload(url, data) {
},
success: (res) => {
uni.hideLoading();
if (JSON.parse(res.data).result === 'success') {
resolve(JSON.parse(res.data))
const data = JSON.parse(res.data)
if (data.result === 'success') {
resolve(data)
} else {
if(data.code === 401){
logOut(reject,data)
return
}
uni.showToast({
title: JSON.parse(res.data).msg || '系统开小差了',
icon: 'error',
title: data.msg || '系统开小差了',
icon: 'none',
duration: 2000
});
reject(JSON.parse(res.data))
reject(data)
}
},
fail: (err) => {
@ -123,15 +153,20 @@ function uploads(url, data) {
},
success: (res) => {
uni.hideLoading();
if (JSON.parse(res.data).result === 'success') {
resolve(JSON.parse(res.data))
const data = JSON.parse(res.data)
if (data.result === 'success') {
resolve(data)
} else {
if(data.code === 401){
logOut(reject,data)
return
}
uni.showToast({
title: JSON.parse(res.data).msg || '系统开小差了',
icon: 'error',
title: data.msg || '系统开小差了',
icon: 'none',
duration: 2000
});
reject(JSON.parse(res.data))
reject(data)
}
},
fail: (err) => {