feat(duiquan): 添加扫码启动洗车机功能
在兑换成功后,用户可以选择立即使用洗车券。如果用户已扫码,则直接启动洗车机;如果未扫码,则跳转到扫码页面。同时,优化了洗车券列表的显示逻辑,当没有可用网点时显示“-”,并支持显示备注信息。
This commit is contained in:
parent
ce8a899841
commit
2ed13ebf88
@ -1,9 +1,10 @@
|
|||||||
var t = require("../../utils/login.js");
|
var e = getApp(), 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个工作日内发放奖品",
|
tips: "温馨提示:\n1、请在30分钟内完成兑换,超时作废\n2、请在兑换完成后,在本页面点击\"确认兑换\"\n3、兑换成功后,将在3个工作日内发放奖品",
|
||||||
|
code: ''
|
||||||
},
|
},
|
||||||
onLoad() {
|
onLoad() {
|
||||||
t.request('/miniprogram/coupons', {}, !0).then((res) => {
|
t.request('/miniprogram/coupons', {}, !0).then((res) => {
|
||||||
@ -15,7 +16,46 @@ Page({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
toScan: function () {
|
||||||
|
e.globalData.needJumpUrl = !1;
|
||||||
|
var a = this;
|
||||||
|
wx.scanCode({
|
||||||
|
success: function (i) {
|
||||||
|
console.log(i), wx.showLoading({
|
||||||
|
title: ""
|
||||||
|
}), e.globalData.qrcode = i.result, t.request("/miniprogram/identify", i, !0).then(function (t) {
|
||||||
|
console.log("data", t), wx.hideLoading();
|
||||||
|
// 保存设备编号
|
||||||
|
getApp().globalData.devicecode = t.data.devicecode || getApp().globalData.devicecode;
|
||||||
|
a.startup();
|
||||||
|
}).catch(function (e) {
|
||||||
|
wx.hideLoading();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 启动
|
||||||
|
startup: function () {
|
||||||
|
if (getApp().globalData.devicecode) {
|
||||||
|
// 已扫码,启动机器
|
||||||
|
t.request('/miniprogram/machine/carwashcodestartup', { devicecode: getApp().globalData.devicecode, washcode: this.data.code }, !0).then((startRes) => {
|
||||||
|
if (startRes.code == 200) {
|
||||||
|
wx.showToast({ title: '启动成功', icon: 'success' });
|
||||||
|
// 跳转到洗车券列表页面
|
||||||
|
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
||||||
|
} else {
|
||||||
|
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
||||||
|
wx.showToast({ title: startRes.message || '启动失败', icon: 'none' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// 未扫码,提示
|
||||||
|
wx.showToast({
|
||||||
|
title: '请先扫码',
|
||||||
|
icon: 'none'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
onSubmitToGroup(e) {
|
onSubmitToGroup(e) {
|
||||||
const code = e.detail.value.code
|
const code = e.detail.value.code
|
||||||
if (!code) {
|
if (!code) {
|
||||||
@ -32,6 +72,12 @@ Page({
|
|||||||
t.request('/miniprogram/coupons/importDouyin', { code: code }, !0).then((res) => {
|
t.request('/miniprogram/coupons/importDouyin', { code: code }, !0).then((res) => {
|
||||||
wx.hideLoading()
|
wx.hideLoading()
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
|
|
||||||
|
// 在当前页面记下券码
|
||||||
|
this.setData({
|
||||||
|
code: res.data.code
|
||||||
|
})
|
||||||
|
|
||||||
wx.showModal({
|
wx.showModal({
|
||||||
title: '兑换成功',
|
title: '兑换成功',
|
||||||
content: '是否立即使用?',
|
content: '是否立即使用?',
|
||||||
@ -39,18 +85,24 @@ Page({
|
|||||||
if (result.confirm) {
|
if (result.confirm) {
|
||||||
// 判断是否已扫码
|
// 判断是否已扫码
|
||||||
if (getApp().globalData.devicecode) {
|
if (getApp().globalData.devicecode) {
|
||||||
// 已扫码,启动机器
|
|
||||||
t.request('/miniprogram/device/start', { devicecode: getApp().globalData.devicecode }, !0).then((startRes) => {
|
wx.showModal({
|
||||||
if (startRes.code == 200) {
|
title: "提示",
|
||||||
wx.showToast({ title: '启动成功', icon: 'success' });
|
content: "你当前将要使用的机器编号是:".concat(getApp().globalData.devicecode, ",确认开机吗?"),
|
||||||
} else {
|
success: (res) => {
|
||||||
wx.showToast({ title: startRes.message || '启动失败', icon: 'none' });
|
if (res.confirm) {
|
||||||
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
// 用户点击了确认按钮,执行开机操作
|
||||||
|
this.startup();
|
||||||
|
} else {
|
||||||
|
// 用户点击了取消按钮,跳转到洗车券列表页面
|
||||||
|
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// 未扫码,跳转到washCodeList页面进行扫码
|
// 未扫码,打开扫码页面
|
||||||
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
this.toScan(); // 调用toScan方法,跳转到扫码页面
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
||||||
|
@ -7,9 +7,15 @@
|
|||||||
<view class="radio"></view>
|
<view class="radio"></view>
|
||||||
<view class="code">{{item.code}}</view>
|
<view class="code">{{item.code}}</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="location">可使用网点:<block wx:for="{{item.agent}}" wx:for-index="i" wx:for-item="s">{{s.t_name+(i<item.agent.length-1?'、':'')}} </block>
|
<view class="location">
|
||||||
|
可使用网点:
|
||||||
|
<block wx:for="{{item.agent}}" wx:for-index="i" wx:for-item="s">{{s.t_name+(i<item.agent.length-1?'、':'')}} </block>
|
||||||
|
<!-- 如果没有限制显示 - -->
|
||||||
|
<block wx:if="{{item.agent.length==0}}">-</block>
|
||||||
</view>
|
</view>
|
||||||
<view class="indate">有效期:{{item.starttime}} - {{item.deadline}}</view>
|
<view class="indate">有效期:{{item.starttime}} - {{item.deadline}}</view>
|
||||||
|
<!-- 如果有note -->
|
||||||
|
<view class="indate" wx:if="{{item.note}}">{{item.note}}</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="no-content" wx:if="{{list.length==0&&!loading}}">
|
<view class="no-content" wx:if="{{list.length==0&&!loading}}">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user