cashier-ipad/http/businessHttp.js

52 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 因为两个小程序接口不一致餐饮商超商家端的接口使用该http
*/
import useStorage from '@/commons/utils/useStroage.js'
import go from '@/commons/utils/go.js';
// const baseURL = 'http://192.168.2.128:9000/cashierService'
// const baseURL = 'http://192.168.2.41:9888/cashierService'
let baseURL = 'https://wxcashiertest.sxczgkj.cn/cashierService'
// #ifdef H5
baseURL = '/ysk'
// #endif
// const baseURL = 'https://cashier.sxczgkj.cn/cashierService'
export default function(api = '', data = {}, method = 'GET') {
return new Promise((resolve, reject) => {
uni.request({
url: `${baseURL}${api}`,
method: method,
data: data,
header: {
'environment': 'wx',
'type': 'ios',
'version': '1.0.0',
'token': useStorage.get('iToken'),
'Authorization': useStorage.get('iToken'),
'Content-Type': 'application/json'
},
success: res => {
if (res.data.code == 0) {
resolve(res.data)
} else {
uni.showToast({
icon: 'none',
"title": res.data.msg
})
if(res.data.code==-4){
setTimeout(()=>{
go.to('PAGES_LOGIN', {}, 'redirect')
},2000)
}
reject(res.data.msg)
}
},
fail: err => {
uni.showToast({
icon: 'none',
"title": err.errMsg
})
reject(err)
}
})
})
}