import store from '@/store/index.js'
|
/**
|
* @param {string} url 请求地址
|
* @param {object} data 请求参数
|
* @param {string} method 请求方法
|
*/
|
const request = (url, data, method) => {
|
if (url !== 'business/goods/listForH5' && url !== 'business/brand/list') {
|
uni.showLoading({ title: '请求中', mask: true });
|
}
|
return new Promise((resole, reject) => {
|
// https://dmtest.ahapp.net/preselect_interface/
|
// https://dm.ahapp.net/preselect_interface/
|
// http://mjyx.doumee.com/preselect_interface/
|
// http://yx.doumee.com/preselect_interface/
|
// http://127.0.0.1/interface/ http://192.168.0.15:10024/ preselect_web_interface
|
// https://dmtest.ahapp.net/preselect_h5_interface/${url} http://127.0.0.1:10022/ http://192.168.0.35:10024/
|
// http://127.0.0.1:10024/ 测试
|
// https://yx.ahapp.net/h5_interface/${url}
|
uni.request({
|
url: `https://yx.ahapp.net/h5_interface_v2/${url}`,
|
method,
|
data,
|
header: {
|
'content-type': 'application/json',
|
'Access-Control-Allow-Origin': '*',
|
'zhubo-auth-token': store.state.Cookies ? store.state.Cookies : '111111111111111111111111111111111111'
|
},
|
success: (res) => {
|
if (res.data.code === 401) {
|
uni.redirectTo({
|
url: '/pages/login/login'
|
});
|
}
|
if (res.data.code === 200) {
|
resole(res.data)
|
} else {
|
uni.showToast({ title: res.data.message, icon: 'none', duration: 2000 });
|
}
|
},
|
fail(err) {
|
reject()
|
},
|
complete() {
|
if (url !== 'business/goods/listForH5' && url !== 'business/brand/list') {
|
uni.hideLoading();
|
}
|
}
|
})
|
})
|
}
|
|
const get = (url, data) => request(url, data, 'GET')
|
|
const post = (url, data) => request(url, data, 'POST')
|
|
export {
|
get,
|
post
|
}
|