diff --git a/pages/duiquan/duiquan.js b/pages/duiquan/duiquan.js
index ccee57e..a31e33a 100644
--- a/pages/duiquan/duiquan.js
+++ b/pages/duiquan/duiquan.js
@@ -1,66 +1,52 @@
-// pages/duiquan/duiquan.js
+var t = require("../../utils/login.js");
+
Page({
-
- /**
- * 页面的初始数据
- */
data: {
- pic:"https://jm-static.v0750.com/image/dui.jpg"
+ pic: "https://jm-static.v0750.com/image/dui.jpg",
+ tips: "温馨提示:\n1、请在30分钟内完成兑换,超时作废\n2、请在兑换完成后,在本页面点击\"确认兑换\"\n3、兑换成功后,将在3个工作日内发放奖品",
+ },
+ onLoad() {
+ t.request('/miniprogram/coupons', {}, !0).then((res) => {
+ if (res.code == 200) {
+ this.setData({
+ tips: res.data.tips,
+ pic: res.data.pic
+ })
+ }
+ })
},
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
-
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
+ onSubmitToGroup(e) {
+ const code = e.detail.value.code
+ if (!code) {
+ wx.showToast({
+ title: '请输入券码',
+ icon: 'none'
+ })
+ return
+ }
+ wx.showLoading({
+ title: '兑换中...'
+ })
+ t.request('/miniprogram/coupons/importDouyin', { code: code }, !0).then((res) => {
+ wx.hideLoading()
+ if (res.code == 200) {
+ wx.showToast({
+ title: '兑换成功',
+ icon: 'success'
+ });
+ setTimeout(() => {
+ wx.navigateTo({
+ url: '/pages/washCodeList/washCodeList'
+ })
+ })
+ } else {
+ wx.showToast({
+ title: res.message || '兑换失败',
+ icon: 'none'
+ })
+ }
+ })
}
})
\ No newline at end of file
diff --git a/pages/duiquan/duiquan.wxml b/pages/duiquan/duiquan.wxml
index 14227f0..5c557c6 100644
--- a/pages/duiquan/duiquan.wxml
+++ b/pages/duiquan/duiquan.wxml
@@ -2,23 +2,13 @@
请输入券码
-
- 温馨提示:
- 1、卡券一经兑换,不作退换;
- 2、请在有效期内、在对应网点使用;
- 3、请按网点内安全指引操作洗车机;
- 4、洗车场地湿滑,请小心滑倒;
- 5、不要在洗车场内奔跑、玩耍;
- 6、禁止攀爬;
- 7、照看好老人、小孩;
- 8、喷枪水压极大,禁止使用喷枪对着人体喷水;
- 9、驶出洗车场时注意四周行人及车辆;
- 10、请保管好您的财物,请勿离开洗车区域.
+ {{tips}}
\ No newline at end of file
diff --git a/pages/index/index.js b/pages/index/index.js
index f161dca..f05f394 100644
--- a/pages/index/index.js
+++ b/pages/index/index.js
@@ -31,31 +31,31 @@ Page({
// 获取地理位置
wx.getLocation({
type: 'gcj02',
- success: function(res) {
+ success: function (res) {
// 存储经纬度
wx.setStorageSync('latitude', res.latitude);
wx.setStorageSync('longitude', res.longitude);
e.globalData.latitude = res.latitude;
e.globalData.longitude = res.longitude;
// 获取网点列表
- t.request('https://t-jm.v0750.com/miniprogram/branch/lists', {
+ t.request('/miniprogram/branch/lists', {
latitude: res.latitude || '',
longitude: res.longitude || ''
- }, !0).then(function(res) {
+ }, !0).then(function (res) {
a.setData({
wangdianList: res.data || []
});
});
},
- fail: function() {
+ fail: function () {
// 即使获取位置失败也加载网点列表,只是不传入经纬度参数
- t.request('https://t-jm.v0750.com/miniprogram/branch/lists', {}, !0).then(function(res) {
+ t.request('/miniprogram/branch/lists', {}, !0).then(function (res) {
a.setData({
wangdianList: res.data || []
});
});
},
- complete: function() {
+ complete: function () {
t.pageStart(e).then(function (t) {
a.getData();
a.setData({
@@ -65,14 +65,11 @@ Page({
});
}
});
- },
- getData: function () {
- var a = this;
+
// 获取首页数据
- t.request(e.globalData.config.home, {}, !0).then(function (e) {
+ t.request('/miniprogram/index/home', { method: 'GET' }, !0).then(function (e) {
a.setData({
banner: e.data.banner,
- user: e.data.user,
tmplIds: e.data.tmplIds,
joinUs: e.data.joinUs,
notice: e.data.notice,
@@ -90,6 +87,15 @@ Page({
});
});
},
+ getData: function () {
+ var a = this;
+ // 获取首页数据
+ t.request('/miniprogram/index/balance', {}, !0).then(function (e) {
+ a.setData({
+ user: e.data || [],
+ });
+ });
+ },
load: function (e) {
console.log(e);
var t = e.currentTarget.dataset.index, a = this.data.swiperWidth * e.detail.height / e.detail.width;
@@ -100,7 +106,7 @@ Page({
onShow: function () {
this.setData({
isScan: !!e.globalData.devicecode || this.data.isScan
- }), e.globalData.config && e.globalData.config.home && (this.getData(), this.isneedUpload = !1);
+ }), (this.getData(), this.isneedUpload = !1);
},
toPage: function (t) {
console.info(t);
@@ -127,7 +133,7 @@ Page({
success: function (i) {
console.log(i), wx.showLoading({
title: ""
- }), e.globalData.qrcode = i.result, t.request("https://t-jm.v0750.com/miniprogram/identify", i, !0).then(function (t) {
+ }), e.globalData.qrcode = i.result, t.request("/miniprogram/identify", i, !0).then(function (t) {
console.log("data", t), wx.hideLoading(), e.globalData.devicecode = t.data.devicecode || e.globalData.devicecode,
a.setData({
isScan: !!t.data.devicecode
@@ -199,7 +205,7 @@ Page({
wx.requestSubscribeMessage({
tmplIds: this.data.tmplIds,
success: function (e) {
- console.log("requestSubscribeMessage", e), t.request("https://t-jm.v0750.com/miniprogram/index/newtmpl", e, !0).then(function (e) { }).catch(function (e) { });
+ console.log("requestSubscribeMessage", e), t.request("/miniprogram/index/newtmpl", e, !0).then(function (e) { }).catch(function (e) { });
},
fail: function (e) {
console.log("requestSubscribeMessagefail", e);
diff --git a/pages/login/login.js b/pages/login/login.js
index 48f4ef1..227d19e 100644
--- a/pages/login/login.js
+++ b/pages/login/login.js
@@ -28,7 +28,7 @@ Page({
var n = Object.assign(this.userInfo, t, {
code: a
});
- o.request(e.globalData.config.authorization, n, !0).then(function(o) {
+ o.request('/miniprogram/index/authorization', n, !0).then(function(o) {
if (wx.hideLoading(), console.log("toAuthorization", "app.globalData.needJumpUrl", e.globalData.needJumpUrl, o),
200 != o.code) return wx.showModal({
title: "提示",
diff --git a/pages/register/register.js b/pages/register/register.js
index 1c8f7ed..31fecc5 100644
--- a/pages/register/register.js
+++ b/pages/register/register.js
@@ -14,22 +14,22 @@ Page({
showTips: !1,
approve: !0
},
- onLoad: function(a) {
+ onLoad: function (a) {
var e = this;
this.setData({
type: a.type || "login"
- }), o.pageStart(t).then(function(o) {
+ }), o.pageStart(t).then(function (o) {
console.log(t.globalData), e.setData({
protocol: t.globalData.protocol
});
});
},
- input: function(t) {
+ input: function (t) {
this.data.info[t.currentTarget.dataset.name] = t.detail.value, this.setData({
info: this.data.info
});
},
- bindsubmit: function(t) {
+ bindsubmit: function (t) {
if (console.log(t.detail.formId), this.data.issubmit) return !1;
this.setData({
issubmit: !0
@@ -38,26 +38,26 @@ Page({
});
var o = this;
"reset" == this.data.type ? this.submitForm() : wx.login({
- success: function(t) {
+ success: function (t) {
console.log(t.code), wx.getUserInfo({
- success: function(a) {
+ success: function (a) {
o.submitForm(t.code, a);
},
- fail: function() {
+ fail: function () {
o.submitForm(t.code);
}
});
},
- fail: function(t) {}
+ fail: function (t) { }
});
},
- submitForm: function(a, e) {
+ submitForm: function (a, e) {
var i = this, n = {};
Object.assign(n, e, {
token: this.data.token,
smscode: this.data.info.smscode,
code: a
- }), console.log(n), o.request(t.globalData.config.verify[i.data.type], n, !0).then(function(o) {
+ }), console.log(n), o.request(t.globalData.config.verify[i.data.type], n, !0).then(function (o) {
return wx.hideLoading(), i.setData({
issubmit: !1
}), 200 == o.code && (i.setData({
@@ -70,40 +70,40 @@ Page({
}), t.globalData.needJumpUrl = !1, !1) : void wx.navigateBack({
delta: 1
}));
- }).catch(function(t) {
+ }).catch(function (t) {
i.setData({
issubmit: !1
});
});
},
- sendMsg: function() {
+ sendMsg: function () {
if ("" == this.data.info.mobile.trim()) return wx.showModal({
title: "提示",
content: "请输入手机号码~"
}), !1;
var a = this;
- o.request(t.globalData.config.verify.sms, {
+ o.request('/miniprogram/verify/sms', {
mobile: a.data.info.mobile,
type: a.data.type
- }, !0).then(function(t) {
+ }, !0).then(function (t) {
console.log("daa", t), wx.showToast({
title: "验证码已发送~",
icon: "none"
}), a.setData({
token: t.data.token,
countdowntime: t.data.countdowntime
- }, function() {
- a.timer = setInterval(function() {
+ }, function () {
+ a.timer = setInterval(function () {
if (0 == a.data.countdowntime) return clearInterval(a.timer), !1;
a.data.countdowntime--, a.setData({
countdowntime: a.data.countdowntime
});
}, 1e3);
});
- }).catch(function(t) {});
+ }).catch(function (t) { });
},
timer: null,
- showprovision: function() {
+ showprovision: function () {
this.setData({
showTips: !this.data.showTips
});
diff --git a/pages/user/user.js b/pages/user/user.js
index 2737367..6ff2944 100644
--- a/pages/user/user.js
+++ b/pages/user/user.js
@@ -21,7 +21,7 @@ Page({
var n = this;
wx.showLoading({
title: ""
- }), e.request(t.globalData.config.user.log, {}, !0).then(function(t) {
+ }), e.request('/miniprogram/user', {}, !0).then(function(t) {
if (wx.hideLoading(), 200 != t.code) return wx.showModal({
title: "提示",
content: t.message
@@ -71,7 +71,7 @@ Page({
success: function(uploadRes) {
var data = JSON.parse(uploadRes.data);
if (data.code == 200) {
- e.request('https://t-jm.v0750.com/miniprogram/user/update', {
+ e.request('/miniprogram/user/update', {
avatar: data.data.url
}, true).then(function(res) {
if (res.code == 200) {
@@ -101,7 +101,8 @@ Page({
placeholderText: '请输入新昵称',
success: function(res) {
if (res.confirm && res.content) {
- e.request('https://t-jm.v0750.com/miniprogram/user/update', {
+ // 发送请求到后端,更新用户昵称
+ e.request('/miniprogram/user/update', {
nickname: res.content
}, true).then(function(res) {
if (res.code == 200) {
diff --git a/pages/voucher/voucher.js b/pages/voucher/voucher.js
index 5af263a..23f0cb1 100644
--- a/pages/voucher/voucher.js
+++ b/pages/voucher/voucher.js
@@ -44,7 +44,7 @@ Page({
loading: !0
}), wx.showLoading({
title: ""
- }), e.request(t.globalData.config.recharge.init, {
+ }), e.request('/miniprogram/recharge', {
page: this.data.page.next_page
}, !0).then(function (t) {
if (wx.hideLoading(), a.setData({
@@ -68,7 +68,7 @@ Page({
var i = a.currentTarget.dataset.id;
wx.showLoading({
title: ""
- }), e.request(t.globalData.config.recharge.create, {
+ }), e.request('/miniprogram/recharge/create', {
id: i
}, !0).then(function (t) {
if (wx.hideLoading(), 200 != t.code) return wx.showModal({
@@ -125,7 +125,7 @@ Page({
title: ""
});
var i = this;
- e.request(t.globalData.config.recharge.create, {
+ e.request('/miniprogram/recharge/create', {
id: i.data.selectItemID
}, !0).then(function (t) {
if (wx.hideLoading(), i.isSubmit = !1, 200 != t.code) return wx.showModal({
diff --git a/pages/wangdian/wangdian.js b/pages/wangdian/wangdian.js
index 91e61ea..df1357b 100644
--- a/pages/wangdian/wangdian.js
+++ b/pages/wangdian/wangdian.js
@@ -1,4 +1,6 @@
// pages/wangdian/wangdian.js
+var t = require("../../utils/login.js");
+
Page({
/**
@@ -98,55 +100,45 @@ Page({
},
// 获取网点详情信息
getBranchDetail() {
- wx.request({
- url: 'https://t-jm.v0750.com/miniprogram/branch/detail',
- data: {
- number: this.data.number,
- latitude: wx.getStorageSync('latitude'),
- longitude: wx.getStorageSync('longitude'),
- },
+ t.request('/miniprogram/branch/detail', {
+ number: this.data.number,
+ latitude: wx.getStorageSync('latitude'),
+ longitude: wx.getStorageSync('longitude'),
method: 'GET',
- success: (res) => {
- if (res.data && res.data.code == 200) {
- this.setData({
- banner: res.data.data.banner || [],
- info: res.data.data.info || {}
- });
- }
+ }, !0).then((res) => {
+ if (res.code == 200) {
+ this.setData({
+ banner: res.data.banner || [],
+ info: res.data.info || {},
+ });
}
- });
+ })
},
// 获取机器列表
getMachineList() {
- wx.request({
- url: 'https://t-jm.v0750.com/miniprogram/branch/machine',
- data: {
- number: this.data.number,
- },
- method: 'POST',
- success: (res) => {
- if (res.data && res.data.code == 200) {
- this.setData({
- jiqilist: res.data.data || []
- });
- // 计算机器数量, 与空闲机器数量 free machine
- let machineCount = this.data.jiqilist.length;
- let freeMachineCount = 0;
- for (let i = 0; i < this.data.jiqilist.length; i++) {
- if (this.data.jiqilist[i].devicestatus == 0) {
- freeMachineCount++;
- }
+ t.request('/miniprogram/branch/machine', {
+ number: this.data.number,
+ }).then((res) => {
+ if (res.code == 200) {
+ this.setData({
+ jiqilist: res.data || [],
+ });
+ // 计算机器数量, 与空闲机器数量 free machine
+ let machineCount = this.data.jiqilist.length;
+ let freeMachineCount = 0;
+ for (let i = 0; i < this.data.jiqilist.length; i++) {
+ if (this.data.jiqilist[i].devicestatus == 0) {
+ freeMachineCount++;
}
- // 更新数据
- this.setData({
- machineCount,
- freeMachineCount
- });
-
}
+ // 更新数据
+ this.setData({
+ machineCount,
+ freeMachineCount
+ });
}
- });
+ })
},
})
\ No newline at end of file
diff --git a/pages/washCodeDetail/washCodeDetail.js b/pages/washCodeDetail/washCodeDetail.js
index 00c51fd..b4432d5 100644
--- a/pages/washCodeDetail/washCodeDetail.js
+++ b/pages/washCodeDetail/washCodeDetail.js
@@ -6,59 +6,59 @@ Page({
info: {},
id: ""
},
- onLoad: function(t) {
+ onLoad: function (t) {
var o = this;
wx.showLoading({
title: ""
}), this.setData({
id: t.id || 1
- }), i.pageStart(e).then(function(e) {
+ }), i.pageStart(e).then(function (e) {
o.getList();
});
},
- getList: function() {
+ getList: function () {
var o = this;
wx.showLoading({
title: ""
- }), i.request(e.globalData.config.carwashcoupon.details, {
+ }), i.request('/miniprogram/carwashcoupon/details', {
id: this.data.id
- }, !0).then(function(e) {
+ }, !0).then(function (e) {
if (wx.hideLoading(), 200 != e.code) return wx.showModal({
title: "提示",
content: e.message
}), !1;
- e.data.starttime = t.changeTimeyear(new Date(1e3 * e.data.starttime)), e.data.deadline = t.changeTimeyear(new Date(1e3 * e.data.deadline)),
- o.setData({
- info: e.data,
- showLoding: !1
- }, function() {});
- }).catch(function(e) {
+ e.data.starttime = t.changeTimeyear(new Date(1e3 * e.data.starttime)), e.data.deadline = t.changeTimeyear(new Date(1e3 * e.data.deadline)),
+ o.setData({
+ info: e.data,
+ showLoding: !1
+ }, function () { });
+ }).catch(function (e) {
wx.hideLoading();
});
},
isSubmit: !1,
- received: function() {
+ received: function () {
if (this.isSubmit) return !1;
var t = this;
- this.isSubmit = !0, wx.showLoading(), console.log("received"), i.request(e.globalData.config.carwashcoupon.receive, {
+ this.isSubmit = !0, wx.showLoading(), console.log("received"), i.request('/miniprogram/carwashcoupon/receive', {
id: t.data.id,
token: t.data.info.token
- }, !0).then(function(e) {
- console.log("receiveddqta", e), wx.hideLoading(), t.isSubmit = !1, console.log("recief"),
- wx.showModal({
- title: "提示",
- content: e.message,
- success: function(e) {
- e.confirm && wx.redirectTo({
- url: "/pages/index/index"
- });
- }
- });
- }).catch(function(e) {
+ }, !0).then(function (e) {
+ console.log("receiveddqta", e), wx.hideLoading(), t.isSubmit = !1, console.log("recief"),
+ wx.showModal({
+ title: "提示",
+ content: e.message,
+ success: function (e) {
+ e.confirm && wx.redirectTo({
+ url: "/pages/index/index"
+ });
+ }
+ });
+ }).catch(function (e) {
wx.hideLoading(), t.isSubmit = !1, console.log("提示提示提示提示", e), 201 == e.code && wx.showModal({
title: "提示",
content: e.message,
- success: function(e) {
+ success: function (e) {
if (!e.confirm) return console.log("弹窗取消"), !1;
wx.redirectTo({
url: "/pages/index/index"
diff --git a/pages/washCodeList/washCodeList.js b/pages/washCodeList/washCodeList.js
index 8b8b404..970977a 100644
--- a/pages/washCodeList/washCodeList.js
+++ b/pages/washCodeList/washCodeList.js
@@ -10,21 +10,21 @@ Page({
selectID: null,
isScan: !1
},
- onLoad: function(a) {
+ onLoad: function (a) {
var i = this;
- e.pageStart(t).then(function(e) {
+ e.pageStart(t).then(function (e) {
i.getList(), console.log("app.globalData.devicecode", t.globalData.user.money, t.globalData.devicecode),
- i.setData({
- isScan: !!t.globalData.devicecode
- });
+ i.setData({
+ isScan: !!t.globalData.devicecode
+ });
});
},
- onShow: function() {
+ onShow: function () {
this.isneedUpload && (this.getList(), this.isneedUpload = !1);
},
- onPullDownRefresh: function() {},
- onShareAppMessage: function() {},
- toPage: function(t) {
+ onPullDownRefresh: function () { },
+ onShareAppMessage: function () { },
+ toPage: function (t) {
var e = t.currentTarget.dataset.url;
e ? wx.navigateTo({
url: "/pages/".concat(e)
@@ -34,7 +34,7 @@ Page({
duration: 2e3
});
},
- selectItem: function(t) {
+ selectItem: function (t) {
var e = t.currentTarget.dataset, a = (e.index, e.code);
if (1 != e.available) return wx.showToast({
title: "该洗车券不可用~",
@@ -45,39 +45,39 @@ Page({
});
},
isloading: !1,
- getList: function(i) {
+ getList: function (i) {
var o = this;
if (this.isloading) return !1;
wx.showLoading(), this.setData({
loading: !0
- }), this.isloading = !0, e.request(t.globalData.config.carwashcoupon.lists, {}, !0).then(function(t) {
+ }), this.isloading = !0, e.request('/miniprogram/coupons/lists', { devicecode: t.globalData.devicecode }, !0).then(function (t) {
if (o.isloading = !1, o.setData({
loading: !1
}), wx.hideLoading(), 200 != t.code) return wx.showModal({
title: "提示",
content: t.message
}), !1;
- t.data.list.map(function(t) {
+ t.data.data.map(function (t) {
t.starttime = a.changeTimeyear(new Date(1e3 * t.starttime)), t.deadline = a.changeTimeyear(new Date(1e3 * t.deadline));
}), o.setData({
- list: t.data.list,
+ list: t.data.data,
user: t.data.user,
showLoding: !1
});
- }).catch(function(t) {
+ }).catch(function (t) {
o.isloading = !1, o.setData({
loading: !1
}), wx.hideLoading();
});
},
- toScan: function() {
+ toScan: function () {
var a = this;
if (this.isSubmit) return !1;
wx.scanCode({
- success: function(i) {
+ success: function (i) {
wx.showLoading({
title: ""
- }), t.globalData.qrcode = i.result, e.request("https://t-jm.v0750.com/miniprogram/identify", i, !0).then(function(e) {
+ }), t.globalData.qrcode = i.result, e.request("/miniprogram/identify", i, !0).then(function (e) {
if (wx.hideLoading(), 200 != e.code) return wx.showModal({
title: "提示",
content: e.message
@@ -85,7 +85,7 @@ Page({
t.globalData.devicecode = e.data.devicecode || t.globalData.devicecode, a.setData({
isScan: !!e.data.devicecode
}), a.getList();
- }).catch(function(t) {
+ }).catch(function (t) {
wx.hideLoading(), a.isSubmit = !1;
});
}
@@ -94,7 +94,7 @@ Page({
isSubmit: !1,
isneedUpload: !1,
isshowModal: !1,
- toStart: function() {
+ toStart: function () {
var t = this;
return console.log("this.isSubmit", this.isSubmit), !this.isSubmit && (0 == this.data.list.length ? (wx.showModal({
title: "提示",
@@ -104,25 +104,25 @@ Page({
content: "请选择洗车券"
}), !1));
},
- startup: function() {
+ startup: function () {
var a = this;
wx.showModal({
title: "提示",
content: "你当前将要使用的机器编号是:".concat(t.globalData.devicecode, ",确认开机吗?"),
- success: function(i) {
+ success: function (i) {
i.confirm && (a.isSubmit = !0, wx.showLoading({
title: "正在启动"
- }), e.request(t.globalData.config.machine.carwashcodestartup, {
+ }), e.request('/miniprogram/machine/carwashcodestartup', {
washcode: a.data.selectID
- }, !0).then(function(t) {
+ }, !0).then(function (t) {
a.isSubmit = !1, wx.hideLoading(), 200 == t.code && wx.redirectTo({
url: "/pages/user/user"
});
- }).catch(function(t) {
+ }).catch(function (t) {
a.isSubmit = !1, wx.hideLoading();
}));
},
- fail: function(t) {
+ fail: function (t) {
console.log("fail:", t);
}
});
diff --git a/utils/login.js b/utils/login.js
index 8d1c197..6fd6ada 100644
--- a/utils/login.js
+++ b/utils/login.js
@@ -1,8 +1,8 @@
var e = require("../@babel/runtime/helpers/typeof"), o = (require("./common.js"),
-null), a = null;
+ null), a = null;
function t() {
- return new Promise(function(e, o) {
+ return new Promise(function (e, o) {
return wx.login({
success: e,
fail: o
@@ -12,7 +12,20 @@ function t() {
function n(a) {
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
- return wx.showLoading(), new Promise(function(n, c) {
+
+ // a 是否 https, 如果不是自动补全
+ if (!/^https/.test(a)) {
+ a = 'https://t-jm.v0750.com' + a;
+ }
+
+ // method 默认为 GET
+ let method = "POST";
+ if (t.method) {
+ method = t.method;
+ delete t.method;
+ }
+
+ return wx.showLoading(), new Promise(function (n, c) {
console.log("requestdevicecode", o.globalData.devicecode);
var i = Object.assign({}, {
devicecode: o.globalData.devicecode
@@ -26,8 +39,8 @@ function n(a) {
Cookie: "_miucms_session=" + wx.getStorageSync("_miucms_session"),
token: wx.getStorageSync("session") || ""
},
- method: "POST",
- success: function(o) {
+ method: method,
+ success: function (o) {
var t = o.data;
if ("object" != e(t) && null != t) {
t = t.replace("\ufeff", "");
@@ -37,40 +50,40 @@ function n(a) {
wx.hideLoading();
var l = o.data;
switch (1 * l.code) {
- case 200:
- case 888:
- n(l);
- break;
+ case 200:
+ case 888:
+ n(l);
+ break;
- case 201:
- a.indexOf("carwashcoupon/receive") > -1 || wx.showModal({
- title: "提示",
- content: l.message
- }), c(l);
- break;
+ case 201:
+ a.indexOf("carwashcoupon/receive") > -1 || wx.showModal({
+ title: "提示",
+ content: l.message
+ }), c(l);
+ break;
- case 404:
- wx.showModal({
- title: "提示",
- content: "未找到当前接口"
- }), c(l);
- break;
+ case 404:
+ wx.showModal({
+ title: "提示",
+ content: "未找到当前接口"
+ }), c(l);
+ break;
- case 401:
- var s = getCurrentPages(), r = s[s.length - 1];
- console.log(401, a), wx.redirectTo({
- url: "/pages/login/login?fromPage=".concat(r.route)
- }), c(l);
- break;
+ case 401:
+ var s = getCurrentPages(), r = s[s.length - 1];
+ console.log(401, a), wx.redirectTo({
+ url: "/pages/login/login?fromPage=".concat(r.route)
+ }), c(l);
+ break;
- default:
- wx.showModal({
- title: "提示",
- content: l.message
- }), c(l);
+ default:
+ wx.showModal({
+ title: "提示",
+ content: l.message
+ }), c(l);
}
},
- fail: function(e) {
+ fail: function (e) {
wx.hideLoading(), console.log("reqest error", e), c("fail");
}
});
@@ -80,11 +93,11 @@ function n(a) {
function c(e, a) {
console.log("appstart", e), o = a, n("https://t-jm.v0750.com/miniprogram", {
code: e
- }, !0).then(function(e) {
+ }, !0).then(function (e) {
var o = e.data;
console.log("总接口", o), a.globalData.user = o.user, wx.setStorageSync("session", o.user.session),
- a.globalData.isUserAuthorization = o.user > 0 ? 2 : 1, a.globalData.config = o.config,
- a.globalData.servicetel = o.servicetel, a.globalData.canGetData = !0, a.globalData.protocol = o.protocol;
+ a.globalData.isUserAuthorization = o.user > 0 ? 2 : 1, a.globalData.config = o.config,
+ a.globalData.servicetel = o.servicetel, a.globalData.canGetData = !0, a.globalData.protocol = o.protocol;
});
}
@@ -92,23 +105,23 @@ module.exports = {
initial_url: "https://t-jm.v0750.com/miniprogram",
login: t,
request: n,
- pageStart: function(e) {
- return new Promise(function(o, t) {
- e.globalData.canGetData ? o() : a = setInterval(function() {
+ pageStart: function (e) {
+ return new Promise(function (o, t) {
+ e.globalData.canGetData ? o() : a = setInterval(function () {
e.globalData.canGetData && (clearInterval(a), o());
}, 1e3);
});
},
- getLogin: function(e) {
- o = e, t().then(function(a) {
+ getLogin: function (e) {
+ o = e, t().then(function (a) {
console.log("获取用户登录态成功!", a.code), o.globalData.code = a.code, c(a.code, e);
- }).catch(function(o) {
+ }).catch(function (o) {
c(res.code, e);
});
},
baseUrl: "https://t-jm.v0750.com/",
- getDevicecode: function(e, a) {
- o = e, n("https://t-jm.v0750.com/miniprogram/identify/reload", a, !0).then(function(e) {
+ getDevicecode: function (e, a) {
+ o = e, n("https://t-jm.v0750.com/miniprogram/identify/reload", a, !0).then(function (e) {
var a = e.data;
console.log("onshow获取到的数据", a), o.globalData.devicecode = a.devicecode || o.globalData.devicecode;
});