增加根据env请求不用的地址

This commit is contained in:
gyq
2026-02-04 14:50:18 +08:00
parent 3e64567d52
commit b18bdaf715
2 changed files with 22 additions and 13 deletions

View File

@@ -15,15 +15,20 @@ import {
} from '@/commons/utils/encryptUtil.js'
import infoBox from "@/commons/utils/infoBox.js"
// let baseUrl = ''
// let baseUrl = 'https://cashier.sxczgkj.com'
let baseUrl = 'https://frp.sxczgkj.com'
let baseUrl_pro = 'https://cashier.sxczgkj.com'
let baseUrl_test = 'https://frp.sxczgkj.com'
let baseUrl = {
prod: 'https://cashier.sxczgkj.com',
test: 'https://frp.sxczgkj.com',
dev: 'https://frp.sxczgkj.com'
}
// let baseUrl = '/api'
// 多少 ms 以内, 不提示loading
const loadingShowTime = 200
function getHeader(){
const headerObject={}
function getHeader() {
const headerObject = {}
// headerObject["Authorization"] = storageManage.token()
headerObject["Content-Type"] = 'application/json'
// headerObject["loginname"] = 'admin'
@@ -98,10 +103,10 @@ function commonsProcess(showLoading, httpReqCallback) {
return Promise.resolve(bodyData)
}).catch(res => {
if(res.status==401){
if (res.status == 401) {
infoBox.showToast(`登录失效`)
}
if(res.status==500){
if (res.status == 500) {
infoBox.showToast(`网络异常`)
}
// if(res&&res.msg){
@@ -126,10 +131,11 @@ function commonsProcess(showLoading, httpReqCallback) {
// 默认 显示loading(控制 xxs 内 不提示loading )
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
// headerObject[appConfig.tokenKey] = storageManage.token()
const env = localStorage.getItem('env') || 'prod'
return commonsProcess(showLoading, () => {
return uni.request(
Object.assign({
url: baseUrl + uri,
url: baseUrl[env] + uri,
data: data,
method: method,
header: getHeader()
@@ -141,6 +147,7 @@ function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
// 默认 显示loading(控制 xxs 内 不提示loading )
function request(args) {
const env = localStorage.getItem('env') || 'prod'
const {
url,
data,
@@ -155,8 +162,8 @@ function request(args) {
return commonsProcess(showLoading, () => {
return uni.request(
Object.assign({
url: baseUrl + url,
data: params||data,
url: baseUrl[env] + url,
data: params || data,
method: method,
header: getHeader()
}, extParams)

View File

@@ -35,6 +35,8 @@ export default {
onShow() {
this.shopId = this.getUrlParam('shopId');
this.orderId = this.getUrlParam('orderId');
localStorage.setItem('env', this.getUrlParam('env') || 'prod');
if (this.getUrlParam('payAmount')) {
this.payAmount = this.getUrlParam('payAmount');
this.disabled = true;
@@ -125,7 +127,7 @@ export default {
// payType: this.payType, //微信 WECHAT 支付宝 ALIPAY
// appId: appId, //微信 WECHAT 支付宝 ALIPAY
source: this.payType == 'WECHAT' ? 'wechat' : 'alipay',
shopId: this.getUrlParam('shopId') //微信 WECHAT 支付宝 ALIPAY
shopId: this.getUrlParam('shopId') //微信 WECHAT 支付宝 ALIPAY
};
getOpenId(params).then((res) => {
console.log('获取微信/支付宝openid', res);