小程序编译0.0.0
This commit is contained in:
@@ -2,17 +2,27 @@ const uploadUrl = 'https://upload-z2.qbox.me'
|
||||
// const debug = process.env.NODE_ENV === 'development'
|
||||
const debug = process.env.NODE_ENV == 'development' ? true : false;
|
||||
const proxyApi = "/api/"
|
||||
|
||||
// #ifdef H5
|
||||
// const baseUrl = debug ? proxyApi : "https://invoice.sxczgkj.cn/api/"
|
||||
const baseUrl = 'https://invoice.sxczgkj.cn/api/' //正式
|
||||
// const baseUrl = 'http://192.168.2.23:8888/api/'//正式
|
||||
// const baseUrl = 'http://test.invoice.sxczgkj.cn/api/'//测试
|
||||
// #endif
|
||||
import VConsole from "./vConsole.js"
|
||||
// const baseUrl = debug ? proxyApi : "https://invoice.sxczgkj.cn/api"
|
||||
// const baseUrl = 'https://invoice.sxczgkj.cn/api/' //正式
|
||||
// const baseUrl = 'http://192.168.1.6:8888/api/'//本地
|
||||
const baseUrl = 'https://test.invoice.sxczgkj.cn/api/'//测试
|
||||
// import VConsole from "./vConsole.js"
|
||||
if (debug) {
|
||||
// new VConsole()
|
||||
}
|
||||
const version = '120'
|
||||
|
||||
|
||||
// #endif
|
||||
// #ifdef MP-WEIXIN || APP
|
||||
const baseUrl = 'https://invoice.sxczgkj.cn/api/' //正式
|
||||
// const baseUrl = 'http://192.168.1.6:8888/api/'//本地
|
||||
// const baseUrl = 'https://test.invoice.sxczgkj.cn/api/'//测试
|
||||
// #endif
|
||||
|
||||
|
||||
const version = '100'
|
||||
const autoRemoveCache = {
|
||||
count: 100000,
|
||||
size: 100000
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const preCacheKeyClearFetch = 'storage:clear:fetch:'
|
||||
import Api from '@/common/js/api.js'
|
||||
|
||||
uni.pro.interceptor('request', {
|
||||
config(paramOptions) {
|
||||
let options = Object.assign({}, paramOptions)
|
||||
@@ -16,6 +17,22 @@ uni.pro.interceptor('request', {
|
||||
}
|
||||
})
|
||||
|
||||
function requestrequest(options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
uni.request({
|
||||
...options,
|
||||
success: res => {
|
||||
// resolve(res.data) //异步操作执行成功
|
||||
if (res.data.code == 1) {
|
||||
resolve(res.data) //异步操作执行成功
|
||||
} else {
|
||||
resolve(res.data) //异步操作执行失败
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async function request(options) {
|
||||
let networkType = ''
|
||||
uni.getNetworkType({
|
||||
@@ -32,7 +49,7 @@ async function request(options) {
|
||||
}
|
||||
try {
|
||||
if (options.toast) {
|
||||
uni.pro.showLoading({
|
||||
uni.showLoading({
|
||||
title: '加载中',
|
||||
mask: true
|
||||
})
|
||||
@@ -41,26 +58,41 @@ async function request(options) {
|
||||
userId: uni.getStorageSync('userId'),
|
||||
minitype: uni.getStorageSync('Type'),
|
||||
fatoken: uni.getStorageSync('token'),
|
||||
token: uni.getStorageSync('logintoken'),
|
||||
isnew: 'isnew',
|
||||
'content-type': 'application/json'
|
||||
}
|
||||
let res = await uni.pro.request(options)
|
||||
// #ifdef MP-WEIXIN || APP-PLUS
|
||||
options.url = uni.conf.baseUrl + options.url
|
||||
let res = await requestrequest(options);
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
let res = await uni.pro.request(options);
|
||||
// #endif
|
||||
if (res.code != 1) {
|
||||
if (options.toast) {
|
||||
uni.showToast({
|
||||
title: res.message || res.msg,
|
||||
icon: "none",
|
||||
success() {
|
||||
setTimeout(res => {
|
||||
// if (options.toast) {
|
||||
uni.hideLoading()
|
||||
// }
|
||||
}, 2000)
|
||||
}
|
||||
})
|
||||
setTimeout(res => {
|
||||
uni.hideLoading()
|
||||
}, 1000)
|
||||
}
|
||||
if (res.code == 400) {
|
||||
return Promise.reject(res.message)
|
||||
} else if (res.code == 401) {
|
||||
uni.showToast({
|
||||
title: res.message || res.msg,
|
||||
icon: "none",
|
||||
success: () => {
|
||||
uni.removeStorageSync('logintoken');
|
||||
uni.removeStorageSync('token');
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
}
|
||||
})
|
||||
} else if (res.code == 405) {
|
||||
let token = await Api.h5encryption({
|
||||
store_id: uni.cache.get('userId')
|
||||
@@ -98,7 +130,9 @@ async function request(options) {
|
||||
throw err;
|
||||
} finally {
|
||||
if (options.toast) {
|
||||
uni.pro.hideLoading()
|
||||
setTimeout(res => {
|
||||
uni.hideLoading()
|
||||
}, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user