代理处理 首页处理
This commit is contained in:
@@ -13,7 +13,6 @@ const proxyApi = "/api"
|
||||
const proxyApi = 'https://cashier.sxczgkj.cn/cashierService' // 线上
|
||||
const proxyApiwws = 'wss://cashier.sxczgkj.cn/netty' // 线上
|
||||
// #endif
|
||||
|
||||
// #ifdef H5
|
||||
const baseUrl = debug ? proxyApi + '/cashierService' : "https://cashier.sxczgkj.cn/cashierService"
|
||||
const baseUrlwws = 'ws://cashier.sxczgkj.cn/cashierService'
|
||||
|
||||
@@ -46,7 +46,7 @@ async function request(options) {
|
||||
environment: 'app',
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
environment: 'h5',
|
||||
environment: 'H5',
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
environment: 'wx',
|
||||
@@ -57,8 +57,6 @@ async function request(options) {
|
||||
token: uni.cache.get('token'),
|
||||
openId: uni.cache.get('miniAppOpenId'),
|
||||
id: uni.cache.get('userInfo').id,
|
||||
loginName: "",
|
||||
clientType: ''
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -67,15 +65,6 @@ async function request(options) {
|
||||
let res = await requestrequest(options);
|
||||
if (res.code != 0) {
|
||||
if (res.code == -4) {
|
||||
// uni.showToast({
|
||||
// title: res.message || res.msg,
|
||||
// icon: "none",
|
||||
// success: () => {
|
||||
// // setTimeout(res => {
|
||||
// // store.dispatch("loginEvent"); //获取shapid
|
||||
// // }, 1000)
|
||||
// }
|
||||
// })
|
||||
|
||||
|
||||
} else if (res.code == 482) {
|
||||
|
||||
66
framework/apis.js
Normal file
66
framework/apis.js
Normal file
@@ -0,0 +1,66 @@
|
||||
export function request(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
url: uni.conf.baseUrl + options.url,
|
||||
data: options.data || {},
|
||||
method: options.method,
|
||||
// 设置请求头,添加版本号
|
||||
header: {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
version: uni.conf.version,
|
||||
type: uni.getSystemInfoSync().platform,
|
||||
// #ifdef APP-PLUS
|
||||
environment: 'app',
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
environment: 'h5',
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN
|
||||
environment: 'wx',
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
environment: 'alipay',
|
||||
// #endif
|
||||
token: uni.cache.get('token'),
|
||||
openId: uni.cache.get('miniAppOpenId'),
|
||||
id: uni.cache.get('userInfo').id,
|
||||
loginName: "",
|
||||
},
|
||||
success(res) {
|
||||
const data = res.data || res;
|
||||
// 根据项目返回的code判断
|
||||
if (data.code != 0){
|
||||
switch (data.code) {
|
||||
case '200':
|
||||
resolve(data.data);
|
||||
break;
|
||||
case '500':
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
icon: "none"
|
||||
});
|
||||
reject(false);
|
||||
break;
|
||||
case '400':
|
||||
uni.showToast({
|
||||
title: data.message,
|
||||
icon: "none"
|
||||
});
|
||||
// 跳转到登录页面等操作
|
||||
reject(false);
|
||||
break;
|
||||
default:
|
||||
reject(false);
|
||||
break;
|
||||
}
|
||||
}else{
|
||||
resolve(data.data);
|
||||
}
|
||||
},
|
||||
fail(res) {
|
||||
// 失败处理
|
||||
reject(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user