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.
120 lines
3.4 KiB
120 lines
3.4 KiB
// let baseUrl = 'http://192.168.66.221:8000'
|
|
let baseUrl = 'http://192.168.66.16:8084'
|
|
// baseUrl = 'https://ggl.xingtongworld.com'
|
|
// baseUrl = 'https://ggl.dingguagua.vip'
|
|
|
|
let API = {
|
|
baseUrl: baseUrl,
|
|
// 注册
|
|
register(data, success, fail){
|
|
API.sendRequest('post', data, '/passport/register', success, fail)
|
|
},
|
|
// 找回密码
|
|
retrieve(data, success, fail){
|
|
API.sendRequest('post', data, '/passport/retrieve', success, fail)
|
|
},
|
|
// 登录
|
|
login(data, success, fail){
|
|
API.sendRequest('post', data, '/passport/login', success, fail)
|
|
},
|
|
// 修改密码
|
|
modifyPassword(data, success, fail){
|
|
API.sendRequest('post', data, '/user/modifyPassword', success, fail, true)
|
|
},
|
|
// 短信验证码
|
|
sendCode(data, success, fail){
|
|
API.sendRequest('post', data, '/passport/sendCode', success, fail, true)
|
|
},
|
|
// 提现记录
|
|
getWithdrawal(data, success, fail){
|
|
API.sendRequest('post', data, '/user/withdrawalRecords', success, fail, true)
|
|
},
|
|
getRecharge(data, success, fail){
|
|
API.sendRequest('post', data, '/user/rechargeRecords', success, fail, true)
|
|
},
|
|
// 消费记录
|
|
getConsumption(data, success, fail){
|
|
API.sendRequest('post', data, '/user/consumptionRecords', success, fail, true)
|
|
},
|
|
// 中奖记录
|
|
getAwards(data, success, fail){
|
|
API.sendRequest('post', data, '/user/awardsRecords', success, fail, true)
|
|
},
|
|
// 首页专区
|
|
getZoneList(data, success, fail){
|
|
API.sendRequest('post', data, '/index/zoneList', success, fail, true)
|
|
},
|
|
// 首页专区-专区列表
|
|
getGoodsList(data, success, fail){
|
|
API.sendRequest('post', data, '/zone/zoneGoodsList', success, fail, true)
|
|
},
|
|
// 开始刮奖
|
|
beginLottery(data, success, fail){
|
|
API.sendRequest('post', data, '/zone/beginLottery', success, fail, true)
|
|
},
|
|
// 刮完奖请求
|
|
endLottery(data, success, fail){
|
|
API.sendRequest('post', data, '/zone/endLottery', success, fail, true)
|
|
},
|
|
// 首页中奖纪录
|
|
getAwardRecords(data, success, fail){
|
|
API.sendRequest('post', data, '/index/awardRecords', success, fail, true)
|
|
},
|
|
// 首页轮播图
|
|
getRotationChart(data, success, fail){
|
|
API.sendRequest('post', data, '/index/rotationChart', success, fail, true)
|
|
},
|
|
// 通用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('user_token')||''
|
|
}
|
|
}
|
|
uni.request({
|
|
url:baseUrl+url,
|
|
method: method,
|
|
data: data,
|
|
...requestObj,
|
|
success(res) {
|
|
// console.log(res, '000');
|
|
// 200=成功, 400 = 失败错误返回、404 token验证失败 ,403 token已过2小时失效
|
|
if(res.data.code==200){
|
|
success && success(res.data);
|
|
return;
|
|
}
|
|
|
|
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;
|