2025-04-16 18:03:42 +08:00
|
|
|
|
var e = getApp(), t = require("../../utils/login.js");
|
2025-04-05 23:47:00 +08:00
|
|
|
|
|
2025-04-10 19:01:02 +08:00
|
|
|
|
Page({
|
2025-04-05 23:47:00 +08:00
|
|
|
|
data: {
|
2025-04-10 19:01:02 +08:00
|
|
|
|
pic: "https://jm-static.v0750.com/image/dui.jpg",
|
|
|
|
|
tips: "温馨提示:\n1、请在30分钟内完成兑换,超时作废\n2、请在兑换完成后,在本页面点击\"确认兑换\"\n3、兑换成功后,将在3个工作日内发放奖品",
|
2025-04-16 18:03:42 +08:00
|
|
|
|
code: ''
|
2025-04-10 19:01:02 +08:00
|
|
|
|
},
|
|
|
|
|
onLoad() {
|
|
|
|
|
t.request('/miniprogram/coupons', {}, !0).then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
this.setData({
|
|
|
|
|
tips: res.data.tips,
|
|
|
|
|
pic: res.data.pic
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2025-04-16 18:03:42 +08:00
|
|
|
|
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) {
|
2025-04-17 12:01:25 +08:00
|
|
|
|
wx.showToast({ title: startRes.message || '启动成功', icon: 'success' });
|
2025-04-16 18:03:42 +08:00
|
|
|
|
// 跳转到洗车券列表页面
|
2025-04-17 12:01:25 +08:00
|
|
|
|
wx.redirectTo({
|
2025-04-30 15:50:25 +08:00
|
|
|
|
url: "/pages/washing/washing"
|
2025-04-17 12:01:25 +08:00
|
|
|
|
})
|
2025-04-16 18:03:42 +08:00
|
|
|
|
} else {
|
2025-04-17 12:01:25 +08:00
|
|
|
|
wx.redirectTo({
|
|
|
|
|
url: "/pages/washCodeList/washCodeList"
|
|
|
|
|
});
|
2025-04-16 18:03:42 +08:00
|
|
|
|
wx.showToast({ title: startRes.message || '启动失败', icon: 'none' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// 未扫码,提示
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '请先扫码',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-04-10 19:01:02 +08:00
|
|
|
|
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) {
|
2025-04-16 18:03:42 +08:00
|
|
|
|
|
|
|
|
|
// 在当前页面记下券码
|
|
|
|
|
this.setData({
|
|
|
|
|
code: res.data.code
|
|
|
|
|
})
|
|
|
|
|
|
2025-04-14 18:21:46 +08:00
|
|
|
|
wx.showModal({
|
2025-04-10 19:01:02 +08:00
|
|
|
|
title: '兑换成功',
|
2025-04-14 18:21:46 +08:00
|
|
|
|
content: '是否立即使用?',
|
|
|
|
|
success: (result) => {
|
|
|
|
|
if (result.confirm) {
|
|
|
|
|
// 判断是否已扫码
|
|
|
|
|
if (getApp().globalData.devicecode) {
|
2025-04-16 18:03:42 +08:00
|
|
|
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: "提示",
|
|
|
|
|
content: "你当前将要使用的机器编号是:".concat(getApp().globalData.devicecode, ",确认开机吗?"),
|
|
|
|
|
success: (res) => {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
// 用户点击了确认按钮,执行开机操作
|
|
|
|
|
this.startup();
|
|
|
|
|
} else {
|
|
|
|
|
// 用户点击了取消按钮,跳转到洗车券列表页面
|
|
|
|
|
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
|
|
|
|
}
|
2025-04-14 18:21:46 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2025-04-16 18:03:42 +08:00
|
|
|
|
|
2025-04-14 18:21:46 +08:00
|
|
|
|
} else {
|
2025-04-16 18:03:42 +08:00
|
|
|
|
// 未扫码,打开扫码页面
|
|
|
|
|
this.toScan(); // 调用toScan方法,跳转到扫码页面
|
2025-04-14 18:21:46 +08:00
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
wx.navigateTo({ url: '/pages/washCodeList/washCodeList' });
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-04-10 19:01:02 +08:00
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: res.message || '兑换失败',
|
|
|
|
|
icon: 'none'
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-04-05 23:47:00 +08:00
|
|
|
|
}
|
|
|
|
|
})
|