You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
2.6 KiB
97 lines
2.6 KiB
// let baseUrl = 'http://192.168.66.219:8000'
|
|
|
|
let baseUrl = 'https://intp.xingtongworld.com'
|
|
|
|
let API = {
|
|
baseUrl: baseUrl,
|
|
// 获取SDK数据
|
|
getJsSdkData(data, success, fail, boolean=true){
|
|
API.sendRequest('post', data, '/wechat/Wechat/getJsSdkData', success, fail, boolean)
|
|
},
|
|
// 获取申请数据
|
|
getQrCode(data, success, fail, boolean=true){
|
|
API.sendRequest('get', data, '/api/InvoiceIssuance/getQrCode', success, fail, boolean)
|
|
},
|
|
// 获取申请数据
|
|
getApplyData(data, success, fail, boolean=true){
|
|
API.sendRequest('get', data, '/api/InvoiceIssuance/getApplyData', success, fail, boolean)
|
|
},
|
|
// 首页数据列表
|
|
Home(data, success, fail, boolean=true){
|
|
API.sendRequest('post', data, '/api/InvoiceIssuance/getList', success, fail, boolean)
|
|
},
|
|
// 手机号获取验证码
|
|
sendSms(data, success, fail, boolean=true){
|
|
API.sendRequest('post', data, '/wechat/wechat/sendSms', success, fail, boolean)
|
|
},
|
|
// 获取微信授权登录基本信息
|
|
getWxCode(data, success, fail){
|
|
API.sendRequest('get', data, '/wechat/login/getWxCode', success, fail)
|
|
},
|
|
// 获取微信code进行登录
|
|
wx(data, success, fail){
|
|
API.sendRequest('get', data, '/wechat/login/wx', success, fail)
|
|
},
|
|
// 通用api
|
|
request(url, data, success, fail, boolean=true){
|
|
API.sendRequest('post', data, url, success, fail, boolean)
|
|
},
|
|
|
|
// 请求
|
|
sendRequest(method, data, url, success, fail, boolean){
|
|
let types = '';
|
|
if (method == 'post') {
|
|
types = 'application/x-www-form-urlencoded'
|
|
} else {
|
|
types = 'application/json';
|
|
}
|
|
|
|
let requestObj = {}
|
|
if(boolean){
|
|
requestObj.header = {
|
|
'Content-Type': types,
|
|
'Accept': 'application/json, text/javascript, */*; q=0.01',
|
|
// 'Authorization': uni.getStorageSync('user_token')||''
|
|
'token': uni.getStorageSync('AccessToken')||''
|
|
}
|
|
}
|
|
uni.request({
|
|
url:baseUrl+url,
|
|
method: method,
|
|
data: data,
|
|
...requestObj,
|
|
success(res) {
|
|
|
|
if(res.data.code == 1){
|
|
success && success(res.data);
|
|
return;
|
|
}
|
|
if(res.data.code == -14){
|
|
uni.removeStorageSync('AccessToken');
|
|
uni.removeStorageSync('openid');
|
|
setTimeout(()=>{
|
|
uni.navigateTo({
|
|
url:"/pages/wxlogin/wxlogin"
|
|
})
|
|
},2600)
|
|
}
|
|
|
|
uni.showToast({
|
|
title: res.data.msg || res.msg,
|
|
icon: 'none'
|
|
})
|
|
|
|
// if(res.data.code==403 || res.data.code==201){
|
|
// uni.removeStorageSync('user_token');
|
|
// // setTimeout(()=>{
|
|
// // uni.reLaunch({
|
|
// // url: '/pages/login/login'
|
|
// // // url: '/uni_modules/uni-id-pages/pages/login/login-withpwd'
|
|
// // })
|
|
// // }, 1000)
|
|
// }
|
|
}
|
|
})
|
|
}
|
|
}
|
|
export default API;
|