增加根据env请求不用的地址
This commit is contained in:
15
api/http.js
15
api/http.js
@@ -15,8 +15,13 @@ import {
|
|||||||
} from '@/commons/utils/encryptUtil.js'
|
} from '@/commons/utils/encryptUtil.js'
|
||||||
import infoBox from "@/commons/utils/infoBox.js"
|
import infoBox from "@/commons/utils/infoBox.js"
|
||||||
// let baseUrl = ''
|
// let baseUrl = ''
|
||||||
// let baseUrl = 'https://cashier.sxczgkj.com'
|
let baseUrl_pro = 'https://cashier.sxczgkj.com'
|
||||||
let baseUrl = 'https://frp.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'
|
// let baseUrl = '/api'
|
||||||
// 多少 ms 以内, 不提示loading
|
// 多少 ms 以内, 不提示loading
|
||||||
const loadingShowTime = 200
|
const loadingShowTime = 200
|
||||||
@@ -126,10 +131,11 @@ function commonsProcess(showLoading, httpReqCallback) {
|
|||||||
// 默认 显示loading(控制 xxs 内 不提示loading )
|
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||||
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
||||||
// headerObject[appConfig.tokenKey] = storageManage.token()
|
// headerObject[appConfig.tokenKey] = storageManage.token()
|
||||||
|
const env = localStorage.getItem('env') || 'prod'
|
||||||
return commonsProcess(showLoading, () => {
|
return commonsProcess(showLoading, () => {
|
||||||
return uni.request(
|
return uni.request(
|
||||||
Object.assign({
|
Object.assign({
|
||||||
url: baseUrl + uri,
|
url: baseUrl[env] + uri,
|
||||||
data: data,
|
data: data,
|
||||||
method: method,
|
method: method,
|
||||||
header: getHeader()
|
header: getHeader()
|
||||||
@@ -141,6 +147,7 @@ function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
|
|||||||
|
|
||||||
// 默认 显示loading(控制 xxs 内 不提示loading )
|
// 默认 显示loading(控制 xxs 内 不提示loading )
|
||||||
function request(args) {
|
function request(args) {
|
||||||
|
const env = localStorage.getItem('env') || 'prod'
|
||||||
const {
|
const {
|
||||||
url,
|
url,
|
||||||
data,
|
data,
|
||||||
@@ -155,7 +162,7 @@ function request(args) {
|
|||||||
return commonsProcess(showLoading, () => {
|
return commonsProcess(showLoading, () => {
|
||||||
return uni.request(
|
return uni.request(
|
||||||
Object.assign({
|
Object.assign({
|
||||||
url: baseUrl + url,
|
url: baseUrl[env] + url,
|
||||||
data: params || data,
|
data: params || data,
|
||||||
method: method,
|
method: method,
|
||||||
header: getHeader()
|
header: getHeader()
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ export default {
|
|||||||
onShow() {
|
onShow() {
|
||||||
this.shopId = this.getUrlParam('shopId');
|
this.shopId = this.getUrlParam('shopId');
|
||||||
this.orderId = this.getUrlParam('orderId');
|
this.orderId = this.getUrlParam('orderId');
|
||||||
|
localStorage.setItem('env', this.getUrlParam('env') || 'prod');
|
||||||
|
|
||||||
if (this.getUrlParam('payAmount')) {
|
if (this.getUrlParam('payAmount')) {
|
||||||
this.payAmount = this.getUrlParam('payAmount');
|
this.payAmount = this.getUrlParam('payAmount');
|
||||||
this.disabled = true;
|
this.disabled = true;
|
||||||
@@ -125,7 +127,7 @@ export default {
|
|||||||
// payType: this.payType, //微信 WECHAT; 支付宝 ALIPAY;
|
// payType: this.payType, //微信 WECHAT; 支付宝 ALIPAY;
|
||||||
// appId: appId, //微信 WECHAT; 支付宝 ALIPAY;
|
// appId: appId, //微信 WECHAT; 支付宝 ALIPAY;
|
||||||
source: this.payType == 'WECHAT' ? 'wechat' : 'alipay',
|
source: this.payType == 'WECHAT' ? 'wechat' : 'alipay',
|
||||||
shopId: this.getUrlParam('shopId') //微信 WECHAT; 支付宝 ALIPAY;
|
shopId: this.getUrlParam('shopId') //微信 WECHAT; 支付宝 ALIPAY
|
||||||
};
|
};
|
||||||
getOpenId(params).then((res) => {
|
getOpenId(params).then((res) => {
|
||||||
console.log('获取微信/支付宝openid', res);
|
console.log('获取微信/支付宝openid', res);
|
||||||
|
|||||||
Reference in New Issue
Block a user