refactor: 统一API请求路径并优化请求逻辑
将多个页面中的API请求路径统一为相对路径,并在`utils/login.js`中自动补全为完整URL。优化了请求方法,默认为POST,同时支持GET请求。简化了代码结构,提高了代码的可维护性和一致性。
This commit is contained in:
parent
764df18ad0
commit
1af84dc1ee
@ -1,66 +1,52 @@
|
|||||||
// pages/duiquan/duiquan.js
|
var t = require("../../utils/login.js");
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面的初始数据
|
|
||||||
*/
|
|
||||||
data: {
|
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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
onSubmitToGroup(e) {
|
||||||
* 生命周期函数--监听页面加载
|
const code = e.detail.value.code
|
||||||
*/
|
if (!code) {
|
||||||
onLoad(options) {
|
wx.showToast({
|
||||||
|
title: '请输入券码',
|
||||||
},
|
icon: 'none'
|
||||||
|
})
|
||||||
/**
|
return
|
||||||
* 生命周期函数--监听页面初次渲染完成
|
}
|
||||||
*/
|
|
||||||
onReady() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面显示
|
|
||||||
*/
|
|
||||||
onShow() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面隐藏
|
|
||||||
*/
|
|
||||||
onHide() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面卸载
|
|
||||||
*/
|
|
||||||
onUnload() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面相关事件处理函数--监听用户下拉动作
|
|
||||||
*/
|
|
||||||
onPullDownRefresh() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面上拉触底事件的处理函数
|
|
||||||
*/
|
|
||||||
onReachBottom() {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 用户点击右上角分享
|
|
||||||
*/
|
|
||||||
onShareAppMessage() {
|
|
||||||
|
|
||||||
|
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'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
@ -2,23 +2,13 @@
|
|||||||
<image src="{{pic}}" mode="widthFix" class="pic"></image>
|
<image src="{{pic}}" mode="widthFix" class="pic"></image>
|
||||||
<view class="content">
|
<view class="content">
|
||||||
<view class="title">请输入券码</view>
|
<view class="title">请输入券码</view>
|
||||||
<form bind:submitToGroup="onSubmitToGroup">
|
<form bindsubmit="onSubmitToGroup">
|
||||||
<input class="input" auto-focus placeholder="支持抖音/美团/聚美券码"/>
|
<input class="input" name="code" auto-focus placeholder="支持抖音/美团/聚美券码"/>
|
||||||
<button class="button" form-type="submit" type="primary">立即兑换</button>
|
<button class="button" form-type="submit" type="primary">立即兑换</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<text class="tips">
|
<text class="tips">
|
||||||
温馨提示:
|
{{tips}}
|
||||||
1、卡券一经兑换,不作退换;
|
|
||||||
2、请在有效期内、在对应网点使用;
|
|
||||||
3、请按网点内安全指引操作洗车机;
|
|
||||||
4、洗车场地湿滑,请小心滑倒;
|
|
||||||
5、不要在洗车场内奔跑、玩耍;
|
|
||||||
6、禁止攀爬;
|
|
||||||
7、照看好老人、小孩;
|
|
||||||
8、喷枪水压极大,禁止使用喷枪对着人体喷水;
|
|
||||||
9、驶出洗车场时注意四周行人及车辆;
|
|
||||||
10、请保管好您的财物,请勿离开洗车区域.
|
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
@ -31,31 +31,31 @@ Page({
|
|||||||
// 获取地理位置
|
// 获取地理位置
|
||||||
wx.getLocation({
|
wx.getLocation({
|
||||||
type: 'gcj02',
|
type: 'gcj02',
|
||||||
success: function(res) {
|
success: function (res) {
|
||||||
// 存储经纬度
|
// 存储经纬度
|
||||||
wx.setStorageSync('latitude', res.latitude);
|
wx.setStorageSync('latitude', res.latitude);
|
||||||
wx.setStorageSync('longitude', res.longitude);
|
wx.setStorageSync('longitude', res.longitude);
|
||||||
e.globalData.latitude = res.latitude;
|
e.globalData.latitude = res.latitude;
|
||||||
e.globalData.longitude = res.longitude;
|
e.globalData.longitude = res.longitude;
|
||||||
// 获取网点列表
|
// 获取网点列表
|
||||||
t.request('https://t-jm.v0750.com/miniprogram/branch/lists', {
|
t.request('/miniprogram/branch/lists', {
|
||||||
latitude: res.latitude || '',
|
latitude: res.latitude || '',
|
||||||
longitude: res.longitude || ''
|
longitude: res.longitude || ''
|
||||||
}, !0).then(function(res) {
|
}, !0).then(function (res) {
|
||||||
a.setData({
|
a.setData({
|
||||||
wangdianList: res.data || []
|
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({
|
a.setData({
|
||||||
wangdianList: res.data || []
|
wangdianList: res.data || []
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
complete: function() {
|
complete: function () {
|
||||||
t.pageStart(e).then(function (t) {
|
t.pageStart(e).then(function (t) {
|
||||||
a.getData();
|
a.getData();
|
||||||
a.setData({
|
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({
|
a.setData({
|
||||||
banner: e.data.banner,
|
banner: e.data.banner,
|
||||||
user: e.data.user,
|
|
||||||
tmplIds: e.data.tmplIds,
|
tmplIds: e.data.tmplIds,
|
||||||
joinUs: e.data.joinUs,
|
joinUs: e.data.joinUs,
|
||||||
notice: e.data.notice,
|
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) {
|
load: function (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
var t = e.currentTarget.dataset.index, a = this.data.swiperWidth * e.detail.height / e.detail.width;
|
var t = e.currentTarget.dataset.index, a = this.data.swiperWidth * e.detail.height / e.detail.width;
|
||||||
@ -100,7 +106,7 @@ Page({
|
|||||||
onShow: function () {
|
onShow: function () {
|
||||||
this.setData({
|
this.setData({
|
||||||
isScan: !!e.globalData.devicecode || this.data.isScan
|
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) {
|
toPage: function (t) {
|
||||||
console.info(t);
|
console.info(t);
|
||||||
@ -127,7 +133,7 @@ Page({
|
|||||||
success: function (i) {
|
success: function (i) {
|
||||||
console.log(i), wx.showLoading({
|
console.log(i), wx.showLoading({
|
||||||
title: ""
|
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,
|
console.log("data", t), wx.hideLoading(), e.globalData.devicecode = t.data.devicecode || e.globalData.devicecode,
|
||||||
a.setData({
|
a.setData({
|
||||||
isScan: !!t.data.devicecode
|
isScan: !!t.data.devicecode
|
||||||
@ -199,7 +205,7 @@ Page({
|
|||||||
wx.requestSubscribeMessage({
|
wx.requestSubscribeMessage({
|
||||||
tmplIds: this.data.tmplIds,
|
tmplIds: this.data.tmplIds,
|
||||||
success: function (e) {
|
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) {
|
fail: function (e) {
|
||||||
console.log("requestSubscribeMessagefail", e);
|
console.log("requestSubscribeMessagefail", e);
|
||||||
|
@ -28,7 +28,7 @@ Page({
|
|||||||
var n = Object.assign(this.userInfo, t, {
|
var n = Object.assign(this.userInfo, t, {
|
||||||
code: a
|
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),
|
if (wx.hideLoading(), console.log("toAuthorization", "app.globalData.needJumpUrl", e.globalData.needJumpUrl, o),
|
||||||
200 != o.code) return wx.showModal({
|
200 != o.code) return wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
|
@ -14,22 +14,22 @@ Page({
|
|||||||
showTips: !1,
|
showTips: !1,
|
||||||
approve: !0
|
approve: !0
|
||||||
},
|
},
|
||||||
onLoad: function(a) {
|
onLoad: function (a) {
|
||||||
var e = this;
|
var e = this;
|
||||||
this.setData({
|
this.setData({
|
||||||
type: a.type || "login"
|
type: a.type || "login"
|
||||||
}), o.pageStart(t).then(function(o) {
|
}), o.pageStart(t).then(function (o) {
|
||||||
console.log(t.globalData), e.setData({
|
console.log(t.globalData), e.setData({
|
||||||
protocol: t.globalData.protocol
|
protocol: t.globalData.protocol
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
input: function(t) {
|
input: function (t) {
|
||||||
this.data.info[t.currentTarget.dataset.name] = t.detail.value, this.setData({
|
this.data.info[t.currentTarget.dataset.name] = t.detail.value, this.setData({
|
||||||
info: this.data.info
|
info: this.data.info
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
bindsubmit: function(t) {
|
bindsubmit: function (t) {
|
||||||
if (console.log(t.detail.formId), this.data.issubmit) return !1;
|
if (console.log(t.detail.formId), this.data.issubmit) return !1;
|
||||||
this.setData({
|
this.setData({
|
||||||
issubmit: !0
|
issubmit: !0
|
||||||
@ -38,26 +38,26 @@ Page({
|
|||||||
});
|
});
|
||||||
var o = this;
|
var o = this;
|
||||||
"reset" == this.data.type ? this.submitForm() : wx.login({
|
"reset" == this.data.type ? this.submitForm() : wx.login({
|
||||||
success: function(t) {
|
success: function (t) {
|
||||||
console.log(t.code), wx.getUserInfo({
|
console.log(t.code), wx.getUserInfo({
|
||||||
success: function(a) {
|
success: function (a) {
|
||||||
o.submitForm(t.code, a);
|
o.submitForm(t.code, a);
|
||||||
},
|
},
|
||||||
fail: function() {
|
fail: function () {
|
||||||
o.submitForm(t.code);
|
o.submitForm(t.code);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
fail: function(t) {}
|
fail: function (t) { }
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
submitForm: function(a, e) {
|
submitForm: function (a, e) {
|
||||||
var i = this, n = {};
|
var i = this, n = {};
|
||||||
Object.assign(n, e, {
|
Object.assign(n, e, {
|
||||||
token: this.data.token,
|
token: this.data.token,
|
||||||
smscode: this.data.info.smscode,
|
smscode: this.data.info.smscode,
|
||||||
code: a
|
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({
|
return wx.hideLoading(), i.setData({
|
||||||
issubmit: !1
|
issubmit: !1
|
||||||
}), 200 == o.code && (i.setData({
|
}), 200 == o.code && (i.setData({
|
||||||
@ -70,40 +70,40 @@ Page({
|
|||||||
}), t.globalData.needJumpUrl = !1, !1) : void wx.navigateBack({
|
}), t.globalData.needJumpUrl = !1, !1) : void wx.navigateBack({
|
||||||
delta: 1
|
delta: 1
|
||||||
}));
|
}));
|
||||||
}).catch(function(t) {
|
}).catch(function (t) {
|
||||||
i.setData({
|
i.setData({
|
||||||
issubmit: !1
|
issubmit: !1
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
sendMsg: function() {
|
sendMsg: function () {
|
||||||
if ("" == this.data.info.mobile.trim()) return wx.showModal({
|
if ("" == this.data.info.mobile.trim()) return wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: "请输入手机号码~"
|
content: "请输入手机号码~"
|
||||||
}), !1;
|
}), !1;
|
||||||
var a = this;
|
var a = this;
|
||||||
o.request(t.globalData.config.verify.sms, {
|
o.request('/miniprogram/verify/sms', {
|
||||||
mobile: a.data.info.mobile,
|
mobile: a.data.info.mobile,
|
||||||
type: a.data.type
|
type: a.data.type
|
||||||
}, !0).then(function(t) {
|
}, !0).then(function (t) {
|
||||||
console.log("daa", t), wx.showToast({
|
console.log("daa", t), wx.showToast({
|
||||||
title: "验证码已发送~",
|
title: "验证码已发送~",
|
||||||
icon: "none"
|
icon: "none"
|
||||||
}), a.setData({
|
}), a.setData({
|
||||||
token: t.data.token,
|
token: t.data.token,
|
||||||
countdowntime: t.data.countdowntime
|
countdowntime: t.data.countdowntime
|
||||||
}, function() {
|
}, function () {
|
||||||
a.timer = setInterval(function() {
|
a.timer = setInterval(function () {
|
||||||
if (0 == a.data.countdowntime) return clearInterval(a.timer), !1;
|
if (0 == a.data.countdowntime) return clearInterval(a.timer), !1;
|
||||||
a.data.countdowntime--, a.setData({
|
a.data.countdowntime--, a.setData({
|
||||||
countdowntime: a.data.countdowntime
|
countdowntime: a.data.countdowntime
|
||||||
});
|
});
|
||||||
}, 1e3);
|
}, 1e3);
|
||||||
});
|
});
|
||||||
}).catch(function(t) {});
|
}).catch(function (t) { });
|
||||||
},
|
},
|
||||||
timer: null,
|
timer: null,
|
||||||
showprovision: function() {
|
showprovision: function () {
|
||||||
this.setData({
|
this.setData({
|
||||||
showTips: !this.data.showTips
|
showTips: !this.data.showTips
|
||||||
});
|
});
|
||||||
|
@ -21,7 +21,7 @@ Page({
|
|||||||
var n = this;
|
var n = this;
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
title: ""
|
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({
|
if (wx.hideLoading(), 200 != t.code) return wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: t.message
|
content: t.message
|
||||||
@ -71,7 +71,7 @@ Page({
|
|||||||
success: function(uploadRes) {
|
success: function(uploadRes) {
|
||||||
var data = JSON.parse(uploadRes.data);
|
var data = JSON.parse(uploadRes.data);
|
||||||
if (data.code == 200) {
|
if (data.code == 200) {
|
||||||
e.request('https://t-jm.v0750.com/miniprogram/user/update', {
|
e.request('/miniprogram/user/update', {
|
||||||
avatar: data.data.url
|
avatar: data.data.url
|
||||||
}, true).then(function(res) {
|
}, true).then(function(res) {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
@ -101,7 +101,8 @@ Page({
|
|||||||
placeholderText: '请输入新昵称',
|
placeholderText: '请输入新昵称',
|
||||||
success: function(res) {
|
success: function(res) {
|
||||||
if (res.confirm && res.content) {
|
if (res.confirm && res.content) {
|
||||||
e.request('https://t-jm.v0750.com/miniprogram/user/update', {
|
// 发送请求到后端,更新用户昵称
|
||||||
|
e.request('/miniprogram/user/update', {
|
||||||
nickname: res.content
|
nickname: res.content
|
||||||
}, true).then(function(res) {
|
}, true).then(function(res) {
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
|
@ -44,7 +44,7 @@ Page({
|
|||||||
loading: !0
|
loading: !0
|
||||||
}), wx.showLoading({
|
}), wx.showLoading({
|
||||||
title: ""
|
title: ""
|
||||||
}), e.request(t.globalData.config.recharge.init, {
|
}), e.request('/miniprogram/recharge', {
|
||||||
page: this.data.page.next_page
|
page: this.data.page.next_page
|
||||||
}, !0).then(function (t) {
|
}, !0).then(function (t) {
|
||||||
if (wx.hideLoading(), a.setData({
|
if (wx.hideLoading(), a.setData({
|
||||||
@ -68,7 +68,7 @@ Page({
|
|||||||
var i = a.currentTarget.dataset.id;
|
var i = a.currentTarget.dataset.id;
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
title: ""
|
title: ""
|
||||||
}), e.request(t.globalData.config.recharge.create, {
|
}), e.request('/miniprogram/recharge/create', {
|
||||||
id: i
|
id: i
|
||||||
}, !0).then(function (t) {
|
}, !0).then(function (t) {
|
||||||
if (wx.hideLoading(), 200 != t.code) return wx.showModal({
|
if (wx.hideLoading(), 200 != t.code) return wx.showModal({
|
||||||
@ -125,7 +125,7 @@ Page({
|
|||||||
title: ""
|
title: ""
|
||||||
});
|
});
|
||||||
var i = this;
|
var i = this;
|
||||||
e.request(t.globalData.config.recharge.create, {
|
e.request('/miniprogram/recharge/create', {
|
||||||
id: i.data.selectItemID
|
id: i.data.selectItemID
|
||||||
}, !0).then(function (t) {
|
}, !0).then(function (t) {
|
||||||
if (wx.hideLoading(), i.isSubmit = !1, 200 != t.code) return wx.showModal({
|
if (wx.hideLoading(), i.isSubmit = !1, 200 != t.code) return wx.showModal({
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
// pages/wangdian/wangdian.js
|
// pages/wangdian/wangdian.js
|
||||||
|
var t = require("../../utils/login.js");
|
||||||
|
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,39 +100,31 @@ Page({
|
|||||||
},
|
},
|
||||||
// 获取网点详情信息
|
// 获取网点详情信息
|
||||||
getBranchDetail() {
|
getBranchDetail() {
|
||||||
wx.request({
|
t.request('/miniprogram/branch/detail', {
|
||||||
url: 'https://t-jm.v0750.com/miniprogram/branch/detail',
|
|
||||||
data: {
|
|
||||||
number: this.data.number,
|
number: this.data.number,
|
||||||
latitude: wx.getStorageSync('latitude'),
|
latitude: wx.getStorageSync('latitude'),
|
||||||
longitude: wx.getStorageSync('longitude'),
|
longitude: wx.getStorageSync('longitude'),
|
||||||
},
|
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
success: (res) => {
|
}, !0).then((res) => {
|
||||||
if (res.data && res.data.code == 200) {
|
if (res.code == 200) {
|
||||||
this.setData({
|
this.setData({
|
||||||
banner: res.data.data.banner || [],
|
banner: res.data.banner || [],
|
||||||
info: res.data.data.info || {}
|
info: res.data.info || {},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 获取机器列表
|
// 获取机器列表
|
||||||
getMachineList() {
|
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 || []
|
|
||||||
});
|
|
||||||
|
|
||||||
|
t.request('/miniprogram/branch/machine', {
|
||||||
|
number: this.data.number,
|
||||||
|
}).then((res) => {
|
||||||
|
if (res.code == 200) {
|
||||||
|
this.setData({
|
||||||
|
jiqilist: res.data || [],
|
||||||
|
});
|
||||||
// 计算机器数量, 与空闲机器数量 free machine
|
// 计算机器数量, 与空闲机器数量 free machine
|
||||||
let machineCount = this.data.jiqilist.length;
|
let machineCount = this.data.jiqilist.length;
|
||||||
let freeMachineCount = 0;
|
let freeMachineCount = 0;
|
||||||
@ -144,9 +138,7 @@ Page({
|
|||||||
machineCount,
|
machineCount,
|
||||||
freeMachineCount
|
freeMachineCount
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
});
|
|
||||||
},
|
},
|
||||||
})
|
})
|
@ -6,23 +6,23 @@ Page({
|
|||||||
info: {},
|
info: {},
|
||||||
id: ""
|
id: ""
|
||||||
},
|
},
|
||||||
onLoad: function(t) {
|
onLoad: function (t) {
|
||||||
var o = this;
|
var o = this;
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
title: ""
|
title: ""
|
||||||
}), this.setData({
|
}), this.setData({
|
||||||
id: t.id || 1
|
id: t.id || 1
|
||||||
}), i.pageStart(e).then(function(e) {
|
}), i.pageStart(e).then(function (e) {
|
||||||
o.getList();
|
o.getList();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getList: function() {
|
getList: function () {
|
||||||
var o = this;
|
var o = this;
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
title: ""
|
title: ""
|
||||||
}), i.request(e.globalData.config.carwashcoupon.details, {
|
}), i.request('/miniprogram/carwashcoupon/details', {
|
||||||
id: this.data.id
|
id: this.data.id
|
||||||
}, !0).then(function(e) {
|
}, !0).then(function (e) {
|
||||||
if (wx.hideLoading(), 200 != e.code) return wx.showModal({
|
if (wx.hideLoading(), 200 != e.code) return wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: e.message
|
content: e.message
|
||||||
@ -31,34 +31,34 @@ Page({
|
|||||||
o.setData({
|
o.setData({
|
||||||
info: e.data,
|
info: e.data,
|
||||||
showLoding: !1
|
showLoding: !1
|
||||||
}, function() {});
|
}, function () { });
|
||||||
}).catch(function(e) {
|
}).catch(function (e) {
|
||||||
wx.hideLoading();
|
wx.hideLoading();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
isSubmit: !1,
|
isSubmit: !1,
|
||||||
received: function() {
|
received: function () {
|
||||||
if (this.isSubmit) return !1;
|
if (this.isSubmit) return !1;
|
||||||
var t = this;
|
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,
|
id: t.data.id,
|
||||||
token: t.data.info.token
|
token: t.data.info.token
|
||||||
}, !0).then(function(e) {
|
}, !0).then(function (e) {
|
||||||
console.log("receiveddqta", e), wx.hideLoading(), t.isSubmit = !1, console.log("recief"),
|
console.log("receiveddqta", e), wx.hideLoading(), t.isSubmit = !1, console.log("recief"),
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: e.message,
|
content: e.message,
|
||||||
success: function(e) {
|
success: function (e) {
|
||||||
e.confirm && wx.redirectTo({
|
e.confirm && wx.redirectTo({
|
||||||
url: "/pages/index/index"
|
url: "/pages/index/index"
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).catch(function(e) {
|
}).catch(function (e) {
|
||||||
wx.hideLoading(), t.isSubmit = !1, console.log("提示提示提示提示", e), 201 == e.code && wx.showModal({
|
wx.hideLoading(), t.isSubmit = !1, console.log("提示提示提示提示", e), 201 == e.code && wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: e.message,
|
content: e.message,
|
||||||
success: function(e) {
|
success: function (e) {
|
||||||
if (!e.confirm) return console.log("弹窗取消"), !1;
|
if (!e.confirm) return console.log("弹窗取消"), !1;
|
||||||
wx.redirectTo({
|
wx.redirectTo({
|
||||||
url: "/pages/index/index"
|
url: "/pages/index/index"
|
||||||
|
@ -10,21 +10,21 @@ Page({
|
|||||||
selectID: null,
|
selectID: null,
|
||||||
isScan: !1
|
isScan: !1
|
||||||
},
|
},
|
||||||
onLoad: function(a) {
|
onLoad: function (a) {
|
||||||
var i = this;
|
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.getList(), console.log("app.globalData.devicecode", t.globalData.user.money, t.globalData.devicecode),
|
||||||
i.setData({
|
i.setData({
|
||||||
isScan: !!t.globalData.devicecode
|
isScan: !!t.globalData.devicecode
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function () {
|
||||||
this.isneedUpload && (this.getList(), this.isneedUpload = !1);
|
this.isneedUpload && (this.getList(), this.isneedUpload = !1);
|
||||||
},
|
},
|
||||||
onPullDownRefresh: function() {},
|
onPullDownRefresh: function () { },
|
||||||
onShareAppMessage: function() {},
|
onShareAppMessage: function () { },
|
||||||
toPage: function(t) {
|
toPage: function (t) {
|
||||||
var e = t.currentTarget.dataset.url;
|
var e = t.currentTarget.dataset.url;
|
||||||
e ? wx.navigateTo({
|
e ? wx.navigateTo({
|
||||||
url: "/pages/".concat(e)
|
url: "/pages/".concat(e)
|
||||||
@ -34,7 +34,7 @@ Page({
|
|||||||
duration: 2e3
|
duration: 2e3
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
selectItem: function(t) {
|
selectItem: function (t) {
|
||||||
var e = t.currentTarget.dataset, a = (e.index, e.code);
|
var e = t.currentTarget.dataset, a = (e.index, e.code);
|
||||||
if (1 != e.available) return wx.showToast({
|
if (1 != e.available) return wx.showToast({
|
||||||
title: "该洗车券不可用~",
|
title: "该洗车券不可用~",
|
||||||
@ -45,39 +45,39 @@ Page({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
isloading: !1,
|
isloading: !1,
|
||||||
getList: function(i) {
|
getList: function (i) {
|
||||||
var o = this;
|
var o = this;
|
||||||
if (this.isloading) return !1;
|
if (this.isloading) return !1;
|
||||||
wx.showLoading(), this.setData({
|
wx.showLoading(), this.setData({
|
||||||
loading: !0
|
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({
|
if (o.isloading = !1, o.setData({
|
||||||
loading: !1
|
loading: !1
|
||||||
}), wx.hideLoading(), 200 != t.code) return wx.showModal({
|
}), wx.hideLoading(), 200 != t.code) return wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: t.message
|
content: t.message
|
||||||
}), !1;
|
}), !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));
|
t.starttime = a.changeTimeyear(new Date(1e3 * t.starttime)), t.deadline = a.changeTimeyear(new Date(1e3 * t.deadline));
|
||||||
}), o.setData({
|
}), o.setData({
|
||||||
list: t.data.list,
|
list: t.data.data,
|
||||||
user: t.data.user,
|
user: t.data.user,
|
||||||
showLoding: !1
|
showLoding: !1
|
||||||
});
|
});
|
||||||
}).catch(function(t) {
|
}).catch(function (t) {
|
||||||
o.isloading = !1, o.setData({
|
o.isloading = !1, o.setData({
|
||||||
loading: !1
|
loading: !1
|
||||||
}), wx.hideLoading();
|
}), wx.hideLoading();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
toScan: function() {
|
toScan: function () {
|
||||||
var a = this;
|
var a = this;
|
||||||
if (this.isSubmit) return !1;
|
if (this.isSubmit) return !1;
|
||||||
wx.scanCode({
|
wx.scanCode({
|
||||||
success: function(i) {
|
success: function (i) {
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
title: ""
|
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({
|
if (wx.hideLoading(), 200 != e.code) return wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: e.message
|
content: e.message
|
||||||
@ -85,7 +85,7 @@ Page({
|
|||||||
t.globalData.devicecode = e.data.devicecode || t.globalData.devicecode, a.setData({
|
t.globalData.devicecode = e.data.devicecode || t.globalData.devicecode, a.setData({
|
||||||
isScan: !!e.data.devicecode
|
isScan: !!e.data.devicecode
|
||||||
}), a.getList();
|
}), a.getList();
|
||||||
}).catch(function(t) {
|
}).catch(function (t) {
|
||||||
wx.hideLoading(), a.isSubmit = !1;
|
wx.hideLoading(), a.isSubmit = !1;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -94,7 +94,7 @@ Page({
|
|||||||
isSubmit: !1,
|
isSubmit: !1,
|
||||||
isneedUpload: !1,
|
isneedUpload: !1,
|
||||||
isshowModal: !1,
|
isshowModal: !1,
|
||||||
toStart: function() {
|
toStart: function () {
|
||||||
var t = this;
|
var t = this;
|
||||||
return console.log("this.isSubmit", this.isSubmit), !this.isSubmit && (0 == this.data.list.length ? (wx.showModal({
|
return console.log("this.isSubmit", this.isSubmit), !this.isSubmit && (0 == this.data.list.length ? (wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
@ -104,25 +104,25 @@ Page({
|
|||||||
content: "请选择洗车券"
|
content: "请选择洗车券"
|
||||||
}), !1));
|
}), !1));
|
||||||
},
|
},
|
||||||
startup: function() {
|
startup: function () {
|
||||||
var a = this;
|
var a = this;
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: "提示",
|
title: "提示",
|
||||||
content: "你当前将要使用的机器编号是:".concat(t.globalData.devicecode, ",确认开机吗?"),
|
content: "你当前将要使用的机器编号是:".concat(t.globalData.devicecode, ",确认开机吗?"),
|
||||||
success: function(i) {
|
success: function (i) {
|
||||||
i.confirm && (a.isSubmit = !0, wx.showLoading({
|
i.confirm && (a.isSubmit = !0, wx.showLoading({
|
||||||
title: "正在启动"
|
title: "正在启动"
|
||||||
}), e.request(t.globalData.config.machine.carwashcodestartup, {
|
}), e.request('/miniprogram/machine/carwashcodestartup', {
|
||||||
washcode: a.data.selectID
|
washcode: a.data.selectID
|
||||||
}, !0).then(function(t) {
|
}, !0).then(function (t) {
|
||||||
a.isSubmit = !1, wx.hideLoading(), 200 == t.code && wx.redirectTo({
|
a.isSubmit = !1, wx.hideLoading(), 200 == t.code && wx.redirectTo({
|
||||||
url: "/pages/user/user"
|
url: "/pages/user/user"
|
||||||
});
|
});
|
||||||
}).catch(function(t) {
|
}).catch(function (t) {
|
||||||
a.isSubmit = !1, wx.hideLoading();
|
a.isSubmit = !1, wx.hideLoading();
|
||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
fail: function(t) {
|
fail: function (t) {
|
||||||
console.log("fail:", t);
|
console.log("fail:", t);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
var e = require("../@babel/runtime/helpers/typeof"), o = (require("./common.js"),
|
var e = require("../@babel/runtime/helpers/typeof"), o = (require("./common.js"),
|
||||||
null), a = null;
|
null), a = null;
|
||||||
|
|
||||||
function t() {
|
function t() {
|
||||||
return new Promise(function(e, o) {
|
return new Promise(function (e, o) {
|
||||||
return wx.login({
|
return wx.login({
|
||||||
success: e,
|
success: e,
|
||||||
fail: o
|
fail: o
|
||||||
@ -12,7 +12,20 @@ function t() {
|
|||||||
|
|
||||||
function n(a) {
|
function n(a) {
|
||||||
var t = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
|
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);
|
console.log("requestdevicecode", o.globalData.devicecode);
|
||||||
var i = Object.assign({}, {
|
var i = Object.assign({}, {
|
||||||
devicecode: o.globalData.devicecode
|
devicecode: o.globalData.devicecode
|
||||||
@ -26,8 +39,8 @@ function n(a) {
|
|||||||
Cookie: "_miucms_session=" + wx.getStorageSync("_miucms_session"),
|
Cookie: "_miucms_session=" + wx.getStorageSync("_miucms_session"),
|
||||||
token: wx.getStorageSync("session") || ""
|
token: wx.getStorageSync("session") || ""
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: method,
|
||||||
success: function(o) {
|
success: function (o) {
|
||||||
var t = o.data;
|
var t = o.data;
|
||||||
if ("object" != e(t) && null != t) {
|
if ("object" != e(t) && null != t) {
|
||||||
t = t.replace("\ufeff", "");
|
t = t.replace("\ufeff", "");
|
||||||
@ -70,7 +83,7 @@ function n(a) {
|
|||||||
}), c(l);
|
}), c(l);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: function(e) {
|
fail: function (e) {
|
||||||
wx.hideLoading(), console.log("reqest error", e), c("fail");
|
wx.hideLoading(), console.log("reqest error", e), c("fail");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -80,7 +93,7 @@ function n(a) {
|
|||||||
function c(e, a) {
|
function c(e, a) {
|
||||||
console.log("appstart", e), o = a, n("https://t-jm.v0750.com/miniprogram", {
|
console.log("appstart", e), o = a, n("https://t-jm.v0750.com/miniprogram", {
|
||||||
code: e
|
code: e
|
||||||
}, !0).then(function(e) {
|
}, !0).then(function (e) {
|
||||||
var o = e.data;
|
var o = e.data;
|
||||||
console.log("总接口", o), a.globalData.user = o.user, wx.setStorageSync("session", o.user.session),
|
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.isUserAuthorization = o.user > 0 ? 2 : 1, a.globalData.config = o.config,
|
||||||
@ -92,23 +105,23 @@ module.exports = {
|
|||||||
initial_url: "https://t-jm.v0750.com/miniprogram",
|
initial_url: "https://t-jm.v0750.com/miniprogram",
|
||||||
login: t,
|
login: t,
|
||||||
request: n,
|
request: n,
|
||||||
pageStart: function(e) {
|
pageStart: function (e) {
|
||||||
return new Promise(function(o, t) {
|
return new Promise(function (o, t) {
|
||||||
e.globalData.canGetData ? o() : a = setInterval(function() {
|
e.globalData.canGetData ? o() : a = setInterval(function () {
|
||||||
e.globalData.canGetData && (clearInterval(a), o());
|
e.globalData.canGetData && (clearInterval(a), o());
|
||||||
}, 1e3);
|
}, 1e3);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getLogin: function(e) {
|
getLogin: function (e) {
|
||||||
o = e, t().then(function(a) {
|
o = e, t().then(function (a) {
|
||||||
console.log("获取用户登录态成功!", a.code), o.globalData.code = a.code, c(a.code, e);
|
console.log("获取用户登录态成功!", a.code), o.globalData.code = a.code, c(a.code, e);
|
||||||
}).catch(function(o) {
|
}).catch(function (o) {
|
||||||
c(res.code, e);
|
c(res.code, e);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
baseUrl: "https://t-jm.v0750.com/",
|
baseUrl: "https://t-jm.v0750.com/",
|
||||||
getDevicecode: function(e, a) {
|
getDevicecode: function (e, a) {
|
||||||
o = e, n("https://t-jm.v0750.com/miniprogram/identify/reload", a, !0).then(function(e) {
|
o = e, n("https://t-jm.v0750.com/miniprogram/identify/reload", a, !0).then(function (e) {
|
||||||
var a = e.data;
|
var a = e.data;
|
||||||
console.log("onshow获取到的数据", a), o.globalData.devicecode = a.devicecode || o.globalData.devicecode;
|
console.log("onshow获取到的数据", a), o.globalData.devicecode = a.devicecode || o.globalData.devicecode;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user