JMApp/pages/index/index.js
2024-03-20 11:39:05 +08:00

204 lines
7.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var e = getApp(), t = require("../../utils/login.js");
Page({
data: {
showLoding: !0,
urlList: [ {
img: "chongzhi",
name: "充值赠送",
url: "voucher/voucher",
needlogin: !0
}, {
img: "video",
name: "洗车教程",
url: "webview/webview?url=https://jm.v0750.com/video",
needlogin: !1
}, {
img: "xichequan",
name: "网点分布",
url: "map/map"
}, {
img: "huiyuanzhongxin",
name: "会员中心",
url: "user/user",
needlogin: !0
}, {
img: "youhuiquan1",
name: "洗车券",
url: "washCodeList/washCodeList"
}, {
img: "shangjiajiameng",
name: "招募合伙人",
url: "",
showimg: !0
} ],
servicetel: "",
notice: "",
noticeurl: null,
banner: [],
isScan: !1,
user: {},
tmplIds: [],
joinUs: "",
tabStatus: {
coupon: !1,
shop: !1
}
},
bindViewTap: function() {
wx.navigateTo({
url: "../logs/logs"
});
},
onLoad: function() {
wx.showLoading({
title: ""
});
var a = this;
t.pageStart(e).then(function(t) {
a.getData(), a.setData({
servicetel: e.globalData.servicetel,
isScan: !!e.globalData.devicecode
});
});
},
getData: function() {
var a = this;
t.request(e.globalData.config.home, {}, !0).then(function(e) {
a.data.urlList[1].url = e.data.tabStatus.shop ? "mall/mall" : "", a.setData({
banner: e.data.banner,
user: e.data.user,
tmplIds: e.data.tmplIds,
joinUs: e.data.joinUs,
notice: e.data.notice,
noticeurl: e.data.noticeurl,
tabStatus: e.data.tabStatus,
urlList: e.data.urlList
}, function() {
wx.hideLoading(), 0 == e.data.banner.length ? a.setData({
showLoding: !1
}) : setTimeout(function() {
a.setData({
showLoding: !1
});
}, 50);
});
});
},
load: function(e) {
console.log(e);
var t = e.currentTarget.dataset.index, a = this.data.swiperWidth * e.detail.height / e.detail.width;
this.data.banner[t].height = a, this.setData({
swiperHeight: a
});
},
onShow: function() {
this.setData({
isScan: !!e.globalData.devicecode || this.data.isScan
}), e.globalData.config && e.globalData.config.home && (this.getData(), this.isneedUpload = !1);
},
toPage: function(t) {
var a = t.currentTarget.dataset, i = a.url, o = a.needlogin, n = a.showimg;
if (console.log("showImg", n), i) {
this.isneedUpload = !0;
if (o && !e.globalData.user.session) return this.isneedUpload = !0, wx.navigateTo({
url: "/pages/login/login"
}), e.globalData.needJumpUrl = "/pages/".concat(i), !1;
wx.navigateTo({
url: "/pages/".concat(i)
}), this.isneedUpload = !0;
} else {
if (!n) return !1;
wx.previewImage({
urls: [ this.data.joinUs ]
});
}
},
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("https://jm.v0750.com/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
});
}).catch(function(e) {
wx.hideLoading();
});
}
});
},
isSubmit: !1,
isneedUpload: !1,
isshowModal: !1,
needUpload: function() {
this.isneedUpload = !0;
},
toStart: function() {
e.globalData.needJumpUrl = !1, this.isneedUpload = !0;
var t = this;
if (console.log("this.isSubmit", this.isSubmit), this.isSubmit) return !1;
if (t.data.user.money <= 0) return t.startup(), !1;
if (t.data.user.money < 10) {
if (this.isshowModal) return t.startup(), !1;
this.isshowModal = !0, wx.showModal({
title: "提示",
content: "账户余额小于10元是否立即充值",
confirmText: "去充值",
cancelText: "立即启动",
success: function(e) {
e.confirm ? (wx.navigateTo({
url: "/pages/voucher/voucher"
}), t.isneedUpload = !0) : t.startup();
},
fail: function(e) {
console.log("fail:", e);
}
});
} else t.startup();
},
startup: function() {
var a = this;
wx.showModal({
title: "提示",
content: "你当前将要使用的机器编号是:".concat(e.globalData.devicecode, ",确认开机吗?"),
success: function(i) {
i.confirm && (a.isSubmit = !0, wx.showLoading({
title: "正在启动"
}), t.request(e.globalData.config.machine.startup, {
washcode: a.data.selectID
}, !0).then(function(e) {
a.isSubmit = !1, wx.hideLoading(), 200 == e.code && (wx.showModal({
title: "",
content: e.message
}), a.data.tmplIds.length > 0 && a.requestSubscribeMessage(), wx.redirectTo({
url: "/pages/user/user"
}), a.isneedUpload = !0), 888 == e.code && (wx.navigateTo({
url: "/pages/voucher/voucher"
}), a.isneedUpload = !0);
}).catch(function(e) {
a.isSubmit = !1, wx.hideLoading();
}));
},
fail: function(e) {
console.log("fail:", e);
}
});
},
requestSubscribeMessage: function() {
wx.requestSubscribeMessage({
tmplIds: this.data.tmplIds,
success: function(e) {
console.log("requestSubscribeMessage", e), t.request("https://jm.v0750.com/miniprogram/index/newtmpl", e, !0).then(function(e) {}).catch(function(e) {});
},
fail: function(e) {
console.log("requestSubscribeMessagefail", e);
}
});
},
onShareAppMessage: function() {}
});