api.js 文件 封装request
var n = function (t, n, r, o, i, a) {
return i && tt.showLoading({
title: a || "加载中..."
}), o || (o = {
"content-type": "application/json"
}), new Promise(function (a, s) {
tt.request({
url: t,
data: r,
method: n,
header: o,
success: function (t) {
console.log(t), i && tt.hideLoading();
var n = t.data;
//成功回调函数a,传参n,无论怎么样都会回调一个函数
200 == n.code ? (n = n.data, a(n)) : n.msg && i && tt.showToast({
title: n.msg,
icon: "none",
duration: 2e3
});
},
fail: function (t) {
i && (e.hideLoading(), tt.showToast({
title: "服务器繁忙,请稍后再试~",
icon: "none",
duration: 2e3
})), console.log(t), s(t);
}
});
});
};
exports.apiService = n, exports.userLogin = function (t) {
return n("https://platform.qwpo2018.com/cgxcr_jrtt/api/user/login", "POST", t, null, 1);
}, exports.gameConfig = function (t) {
return n("https://platform.qwpo2018.com/cgxcr_jrtt/api/game/config", "POST", t, null, 1);
}, exports.userUpdate = function (t) {
return n("https://platform.qwpo2018.com/cgxcr_jrtt/api/user/update", "POST", t, null, 1);
}, exports.gameTop = function (t) {
return n("https://platform.qwpo2018.com/cgxcr_jrtt/api/game/top", "POST", t, null, 1);
}, exports.prizeIndex = function (t) {
return n("https://platform.qwpo2018.com/cgxcr_jrtt/api/prize/index", "POST", t, null, 1);
}, exports.prizeReceive = function (t) {
return n("https://platform.qwpo2018.com/cgxcr_jrtt/api/prize/receive", "POST", t, null, 1);
}, exports.gameStart = function (t) {
return n("https://platform.qwpo2018.com/cgxcr_jrtt/api/game/start