Sfoglia il codice sorgente

2023年7月6日10:11:32

yxb
wq 2 anni fa
parent
commit
293aee2cff
1 ha cambiato i file con 12 aggiunte e 8 eliminazioni
  1. 12
    8
      utils/network/request.js

+ 12
- 8
utils/network/request.js Vedi File

import { import {
appId,envs
appId,
envs
} from "./api"; } from "./api";
import { import {
encryption encryption
staffId: "54623263cb4d4a289dccbc983b22a4af", staffId: "54623263cb4d4a289dccbc983b22a4af",
terminalId: "999999999999", terminalId: "999999999999",
loginSource: "69af303ba2eb4608a099163f0d2a5dbd", loginSource: "69af303ba2eb4608a099163f0d2a5dbd",
rbacSource:'MINI_PROGRAM'
rbacSource: 'MINI_PROGRAM'
} }
//Url 地址 /api/interfaceMidGroundIn //Url 地址 /api/interfaceMidGroundIn
options.url = 'http://'+ envs[process.env.NODE_ENV].baseUrl +'/ifzt/api/interfaceMidGroundIn'
options.url = 'http://' + envs[process.env.NODE_ENV].baseUrl + '/ifzt/api/interfaceMidGroundIn'
//判断baseUri是否为空 //判断baseUri是否为空
if (options.baseUrl) { if (options.baseUrl) {
options.url = options.baseUrl options.url = options.baseUrl
mask: true mask: true
}); });
} }
console.log('请求参数:', options.data)
//参数返回 //参数返回
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
options.success = (res) => { options.success = (res) => {
console.log('请求成功返回参数:', res)
// 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading) // 请求返回后,隐藏loading(如果请求返回快的话,可能会没有loading)
wx.hideLoading() wx.hideLoading()
if (res.data.statusCode !== 0) { if (res.data.statusCode !== 0) {
if (res.data.statusCode == 600) { if (res.data.statusCode == 600) {
resolve(res.data) resolve(res.data)
} else if(res.data.statusCode == 401){
} else if (res.data.statusCode == 401) {
wx.showModal({ wx.showModal({
title: '提示', title: '提示',
content: res.data.errorMsg, content: res.data.errorMsg,
confirmText:'去登录',
confirmText: '去登录',
showCancel: false, showCancel: false,
success: function(res) { success: function(res) {
if (res.confirm) { if (res.confirm) {
uni.navigateTo({ uni.navigateTo({
url: '/login/login', url: '/login/login',
}) })
}
}
} }
}); });
} else { } else {
reject(res.data.errorMsg) reject(res.data.errorMsg)
return return
} }
let content = res let content = res
// let content = s4.decryptData_CBC(res, sm4Key) // let content = s4.decryptData_CBC(res, sm4Key)
// console.log(content); // console.log(content);
resolve(content.data) resolve(content.data)
} }
options.fail = (err) => { options.fail = (err) => {
console.log('请求失败返回参数:', res)
wx.hideLoading() wx.hideLoading()
console.log('请求错误', err) console.log('请求错误', err)
//处理请求错误 //处理请求错误
} }
wx.request(options) wx.request(options)
}); });
}
}

Loading…
Annulla
Salva