2025-04-05 23:47:00 +08:00
|
|
|
|
var e = getApp(), t = require("../../utils/login.js");
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
showLoding: !0,
|
2025-04-09 23:29:51 +08:00
|
|
|
|
urlList: [],
|
|
|
|
|
wangdianList: [],
|
2025-04-05 23:47:00 +08:00
|
|
|
|
servicetel: "",
|
|
|
|
|
notice: "",
|
|
|
|
|
noticeurl: null,
|
|
|
|
|
banner: [],
|
|
|
|
|
isScan: !1,
|
|
|
|
|
user: {},
|
|
|
|
|
tmplIds: [],
|
|
|
|
|
joinUs: "",
|
|
|
|
|
tabStatus: {
|
|
|
|
|
coupon: !1,
|
|
|
|
|
shop: !1
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
bindViewTap: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: "../logs/logs"
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
onLoad: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
wx.showLoading({
|
|
|
|
|
title: ""
|
|
|
|
|
});
|
|
|
|
|
var a = this;
|
2025-04-09 23:29:51 +08:00
|
|
|
|
// 获取地理位置
|
|
|
|
|
wx.getLocation({
|
|
|
|
|
type: 'gcj02',
|
2025-04-10 19:01:02 +08:00
|
|
|
|
success: function (res) {
|
2025-04-09 23:29:51 +08:00
|
|
|
|
// 存储经纬度
|
|
|
|
|
wx.setStorageSync('latitude', res.latitude);
|
|
|
|
|
wx.setStorageSync('longitude', res.longitude);
|
|
|
|
|
e.globalData.latitude = res.latitude;
|
|
|
|
|
e.globalData.longitude = res.longitude;
|
|
|
|
|
// 获取网点列表
|
2025-04-10 19:01:02 +08:00
|
|
|
|
t.request('/miniprogram/branch/lists', {
|
2025-04-09 23:29:51 +08:00
|
|
|
|
latitude: res.latitude || '',
|
|
|
|
|
longitude: res.longitude || ''
|
2025-04-10 19:01:02 +08:00
|
|
|
|
}, !0).then(function (res) {
|
2025-04-09 23:29:51 +08:00
|
|
|
|
a.setData({
|
|
|
|
|
wangdianList: res.data || []
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-10 19:01:02 +08:00
|
|
|
|
fail: function () {
|
2025-04-09 23:29:51 +08:00
|
|
|
|
// 即使获取位置失败也加载网点列表,只是不传入经纬度参数
|
2025-04-10 19:01:02 +08:00
|
|
|
|
t.request('/miniprogram/branch/lists', {}, !0).then(function (res) {
|
2025-04-09 23:29:51 +08:00
|
|
|
|
a.setData({
|
|
|
|
|
wangdianList: res.data || []
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-10 19:01:02 +08:00
|
|
|
|
complete: function () {
|
2025-04-09 23:29:51 +08:00
|
|
|
|
t.pageStart(e).then(function (t) {
|
|
|
|
|
a.getData();
|
|
|
|
|
a.setData({
|
|
|
|
|
servicetel: e.globalData.servicetel,
|
|
|
|
|
isScan: !!e.globalData.devicecode
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2025-04-05 23:47:00 +08:00
|
|
|
|
});
|
2025-04-10 19:01:02 +08:00
|
|
|
|
|
2025-04-09 23:29:51 +08:00
|
|
|
|
// 获取首页数据
|
2025-04-10 19:01:02 +08:00
|
|
|
|
t.request('/miniprogram/index/home', { method: 'GET' }, !0).then(function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
a.setData({
|
|
|
|
|
banner: e.data.banner,
|
|
|
|
|
tmplIds: e.data.tmplIds,
|
|
|
|
|
joinUs: e.data.joinUs,
|
|
|
|
|
notice: e.data.notice,
|
|
|
|
|
noticeurl: e.data.noticeurl,
|
|
|
|
|
tabStatus: e.data.tabStatus,
|
2025-04-09 23:29:51 +08:00
|
|
|
|
urlList: e.data.urlList
|
|
|
|
|
}, function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
wx.hideLoading(), 0 == e.data.banner.length ? a.setData({
|
|
|
|
|
showLoding: !1
|
2025-04-09 23:29:51 +08:00
|
|
|
|
}) : setTimeout(function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
a.setData({
|
|
|
|
|
showLoding: !1
|
|
|
|
|
});
|
|
|
|
|
}, 50);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-10 19:01:02 +08:00
|
|
|
|
getData: function () {
|
|
|
|
|
var a = this;
|
|
|
|
|
// 获取首页数据
|
|
|
|
|
t.request('/miniprogram/index/balance', {}, !0).then(function (e) {
|
|
|
|
|
a.setData({
|
|
|
|
|
user: e.data || [],
|
|
|
|
|
});
|
2025-04-21 14:12:54 +08:00
|
|
|
|
// 存储进度订单
|
|
|
|
|
wx.setStorageSync('progressorder', e.data.progressorder || []);
|
2025-04-10 19:01:02 +08:00
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
load: function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
console.log(e);
|
2025-04-10 22:36:01 +08:00
|
|
|
|
},
|
|
|
|
|
openLocation: function(e) {
|
|
|
|
|
var latitude = Number(e.currentTarget.dataset.latitude);
|
|
|
|
|
var longitude = Number(e.currentTarget.dataset.longitude);
|
|
|
|
|
var name = e.currentTarget.dataset.name;
|
|
|
|
|
var address = e.currentTarget.dataset.address;
|
|
|
|
|
|
|
|
|
|
wx.openLocation({
|
|
|
|
|
latitude: latitude,
|
|
|
|
|
longitude: longitude,
|
|
|
|
|
name: name,
|
|
|
|
|
address: address,
|
|
|
|
|
scale: 18
|
|
|
|
|
});
|
2025-04-05 23:47:00 +08:00
|
|
|
|
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
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
onShow: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
this.setData({
|
|
|
|
|
isScan: !!e.globalData.devicecode || this.data.isScan
|
2025-04-10 19:01:02 +08:00
|
|
|
|
}), (this.getData(), this.isneedUpload = !1);
|
2025-04-05 23:47:00 +08:00
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
toPage: function (t) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
console.info(t);
|
2025-04-16 23:47:29 +08:00
|
|
|
|
|
|
|
|
|
// 增加打电话
|
|
|
|
|
if (t.currentTarget.dataset.phone) {
|
|
|
|
|
wx.makePhoneCall({
|
|
|
|
|
phoneNumber: "" + t.currentTarget.dataset.phone
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
2025-04-05 23:47:00 +08:00
|
|
|
|
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({
|
2025-04-09 23:29:51 +08:00
|
|
|
|
urls: [this.data.joinUs]
|
2025-04-05 23:47:00 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
toScan: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
e.globalData.needJumpUrl = !1;
|
|
|
|
|
var a = this;
|
|
|
|
|
wx.scanCode({
|
2025-04-09 23:29:51 +08:00
|
|
|
|
success: function (i) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
console.log(i), wx.showLoading({
|
|
|
|
|
title: ""
|
2025-04-10 19:01:02 +08:00
|
|
|
|
}), e.globalData.qrcode = i.result, t.request("/miniprogram/identify", i, !0).then(function (t) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
console.log("data", t), wx.hideLoading(), e.globalData.devicecode = t.data.devicecode || e.globalData.devicecode,
|
2025-04-09 23:29:51 +08:00
|
|
|
|
a.setData({
|
|
|
|
|
isScan: !!t.data.devicecode
|
|
|
|
|
});
|
|
|
|
|
}).catch(function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
wx.hideLoading();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
isSubmit: !1,
|
|
|
|
|
isneedUpload: !1,
|
|
|
|
|
isshowModal: !1,
|
2025-04-09 23:29:51 +08:00
|
|
|
|
needUpload: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
this.isneedUpload = !0;
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
toStart: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
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: "立即启动",
|
2025-04-09 23:29:51 +08:00
|
|
|
|
success: function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
e.confirm ? (wx.navigateTo({
|
|
|
|
|
url: "/pages/voucher/voucher"
|
|
|
|
|
}), t.isneedUpload = !0) : t.startup();
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
fail: function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
console.log("fail:", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else t.startup();
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
startup: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
var a = this;
|
|
|
|
|
wx.showModal({
|
|
|
|
|
title: "提示",
|
|
|
|
|
content: "你当前将要使用的机器编号是:".concat(e.globalData.devicecode, ",确认开机吗?"),
|
2025-04-09 23:29:51 +08:00
|
|
|
|
success: function (i) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
i.confirm && (a.isSubmit = !0, wx.showLoading({
|
|
|
|
|
title: "正在启动"
|
|
|
|
|
}), t.request(e.globalData.config.machine.startup, {
|
|
|
|
|
washcode: a.data.selectID
|
2025-04-09 23:29:51 +08:00
|
|
|
|
}, !0).then(function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
a.isSubmit = !1, wx.hideLoading(), 200 == e.code && (wx.showModal({
|
|
|
|
|
title: "",
|
|
|
|
|
content: e.message
|
|
|
|
|
}), a.data.tmplIds.length > 0 && a.requestSubscribeMessage(), wx.redirectTo({
|
2025-04-30 15:50:25 +08:00
|
|
|
|
url: "/pages/washing/washing"
|
2025-04-05 23:47:00 +08:00
|
|
|
|
}), a.isneedUpload = !0), 888 == e.code && (wx.navigateTo({
|
|
|
|
|
url: "/pages/voucher/voucher"
|
|
|
|
|
}), a.isneedUpload = !0);
|
2025-04-09 23:29:51 +08:00
|
|
|
|
}).catch(function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
a.isSubmit = !1, wx.hideLoading();
|
|
|
|
|
}));
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
fail: function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
console.log("fail:", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
requestSubscribeMessage: function () {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
wx.requestSubscribeMessage({
|
|
|
|
|
tmplIds: this.data.tmplIds,
|
2025-04-09 23:29:51 +08:00
|
|
|
|
success: function (e) {
|
2025-04-10 19:01:02 +08:00
|
|
|
|
console.log("requestSubscribeMessage", e), t.request("/miniprogram/index/newtmpl", e, !0).then(function (e) { }).catch(function (e) { });
|
2025-04-05 23:47:00 +08:00
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
fail: function (e) {
|
2025-04-05 23:47:00 +08:00
|
|
|
|
console.log("requestSubscribeMessagefail", e);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-04-09 23:29:51 +08:00
|
|
|
|
onShareAppMessage: function () { }
|
2025-04-05 23:47:00 +08:00
|
|
|
|
});
|