var t = getApp(), e = require("../../utils/login.js"), a = require("../../utils/common.js"); Page({ data: { showLoding: !0, list: [], user: {}, loading: !1, selectIndex: null, selectID: null, isScan: !1 }, onLoad: function (a) { var i = this; 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 }); }); }, onShow: function () { this.isneedUpload && (this.getList(), this.isneedUpload = !1); }, onPullDownRefresh: function () { }, onShareAppMessage: function () { }, toPage: function (t) { var e = t.currentTarget.dataset.url; e ? wx.navigateTo({ url: "/pages/".concat(e) }) : wx.showToast({ title: "页面开发中~", icon: "none", duration: 2e3 }); }, selectItem: function (t) { // 1. 提示用户先绑定设备, isScan if (!this.data.isScan) return wx.showModal({ title: "提示", content: "请先扫码设备~" }), !1; var e = t.currentTarget.dataset, a = (e.index, e.code); if (1 != e.available) return wx.showToast({ title: "该洗车券不可用~", icon: "none" }), !1; this.setData({ selectID: this.data.selectID == a ? null : a }); }, isloading: !1, getList: function (i) { var o = this; if (this.isloading) return !1; wx.showLoading(), this.setData({ loading: !0 }), 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.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.data, user: t.data.user, showLoding: !1 }); }).catch(function (t) { o.isloading = !1, o.setData({ loading: !1 }), wx.hideLoading(); }); }, toScan: function () { var a = this; if (this.isSubmit) return !1; wx.scanCode({ success: function (i) { wx.showLoading({ title: "" }), 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 }), !1; t.globalData.devicecode = e.data.devicecode || t.globalData.devicecode, a.setData({ isScan: !!e.data.devicecode }), a.getList(); }).catch(function (t) { wx.hideLoading(), a.isSubmit = !1; }); } }); }, isSubmit: !1, isneedUpload: !1, isshowModal: !1, toStart: function () { var t = this; return console.log("this.isSubmit", this.isSubmit), !this.isSubmit && (0 == this.data.list.length ? (wx.showModal({ title: "提示", content: "暂无可用洗车券~" }), !1) : t.data.selectID ? void this.startup() : (wx.showModal({ title: "提示", content: "请选择洗车券" }), !1)); }, startup: function () { var a = this; wx.showModal({ title: "提示", content: "你当前将要使用的机器编号是:".concat(t.globalData.devicecode, ",确认开机吗?"), success: function (i) { i.confirm && (a.isSubmit = !0, wx.showLoading({ title: "正在启动" }), e.request('/miniprogram/machine/carwashcodestartup', { washcode: a.data.selectID }, !0).then(function (t) { // 成功后返回提示 wx.showToast({ title: t.message || '启动成功', icon: 'success' }); // 成功后跳转 a.isSubmit = !1, wx.hideLoading(), 200 == t.code && wx.redirectTo({ url: "/pages/user/user" }); }).catch(function (t) { a.isSubmit = !1, wx.hideLoading(); })); }, fail: function (t) { console.log("fail:", t); } }); } });