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.
 
 
 
 

116 lines
3.4 KiB

// let baseUrl = 'http://192.168.66.219:8000'
let baseUrl = 'https://intp.xingtongworld.com'
// let baseUrl = 'http://ljclf.dgyq-water.com'
// let baseUrl = 'http://120.234.15.170:8078'
// let baseUrl = 'http://invoice.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)
},
// 获取申请数据
getErrorInfo(data, success, fail, boolean=true){
API.sendRequest('get', data, '/api/InvoiceIssuance/getErrorInfo', 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)
},
// 验证是否缴费
validateFeePay(data, success, fail, boolean=true){
API.sendRequest('post', data, '/api/InvoiceIssuance/validateFeePay', 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)
},
getFeeInvoiceHead(data, success, fail, boolean=true){
API.sendRequest('get', data, '/api/InvoiceIssuance/getFeeInvoiceHead', success, fail, boolean)
},
// 通用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||res.data.code == -8){
success && success(res.data);
return;
}
if(res.data.code == -14||res.data.code == -997){
uni.removeStorageSync('AccessToken');
uni.removeStorageSync('phone');
uni.removeStorageSync('pucode');
uni.removeStorageSync('openid');
setTimeout(()=>{
uni.$emit('tokenExpired');
uni.reLaunch({
url:'/pages/index/index'
})
},2600)
}
if (url !== '/api/InvoiceIssuance/validateFeePay') {
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;