This commit is contained in:
2025-04-09 23:29:51 +08:00
parent bb3f1aaa6e
commit b55e98d0b9
10 changed files with 253 additions and 290 deletions

View File

@@ -5,97 +5,38 @@ Page({
* 页面的初始数据
*/
data: {
banner: [{
"subject": "安全",
"url": "",
"aid": 81,
"image": "https:\/\/jmqf.v0750.com\/attachment\/Zvt57TuJSUvkyhw-xGrY2l-d__Y-fiaMucgip5B4ELaVVGL3d_RgQwUIEt40NDI5"
}, {
"subject": "网约车",
"url": null,
"aid": 89,
"image": "https:\/\/jmqf.v0750.com\/attachment\/Zvt57TuJSUvkyhw-xGrY2l-d9_Y-fiaMucgip5B4ELbDBWWicKZgQwUIEt40NDI5"
}, {
"subject": "肇康店",
"url": "pages\/map\/map",
"aid": 88,
"image": "https:\/\/jmqf.v0750.com\/attachment\/Zvt57TuJSUvkyhw-xGrY2l-d9vY-fiaMucgip5B4ELaZUm6jcvdgQwUIEt40NDI5"
}],
info: {
name:"三和大道店",
liangdian: [
{"name":"券","ys":"#FF6600"},
{"name":"PA壶","ys":"#37CE05"},
{"name":"人工帮洗","ys":"#0056A3"},
{"name":"轮胎打气","ys":"#08AFDE"},
],
tag:"冲水|泡沫|吸尘|吹气|洗手",
ads:"会城帝临南路18号",
yingye:"24小时",
juli:"12.68KM",
bili: "83%",
jiqi_zs: 12,
jiqi_kx: 10
},
jiqilist: [
{
"id": "1840001",
"state": 1, //0:离线,1:空间,2:使用中,3:禁用
"isPA": 1, //用接PA壶,0:不要,1:可接
},{
"id": "1840002",
"state": 2,
"isPA": 1,
},{
"id": "1840003",
"state": 0,
"isPA": 1,
},{
"id": "1840004",
"state": 3,
"isPA": 1,
},{
"id": "1840005",
"state": 1,
"isPA": 0,
},{
"id": "1840006",
"state": 2,
"isPA": 0,
},{
"id": "1840007",
"state": 0,
"isPA": 1,
},{
"id": "1840008",
"state": 1,
"isPA": 0,
},{
"id": "1840009",
"state": 1,
"isPA": 0,
},{
"id": "1840010",
"state": 2,
"isPA": 1,
},{
"id": "1840011",
"state": 0,
"isPA": 0,
},{
"id": "1840012",
"state": 1,
"isPA": 1,
}
]
banner: [],
info: {},
jiqilist: [],
number: '',
machineCount: 0,
freeMachineCount: 0,
timer: null,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
// 如果没有wx.getStorageSync('latitude') 或者 wx.getStorageSync('longitude') 则获取当前位置
if (!wx.getStorageSync('latitude') || !wx.getStorageSync('longitude')) {
wx.getLocation({
type: 'wgs84',
success: (res) => {
wx.setStorageSync('latitude', res.latitude);
wx.setStorageSync('longitude', res.longitude);
this.getBranchDetail();
}
});
}
this.setData({
number: options.number || ''
});
this.getBranchDetail();
this.getMachineList();
// 设置定时器每10秒刷新一次机器状态
this.data.timer = setInterval(() => {
this.getMachineList();
}, 10000);
},
/**
@@ -117,13 +58,22 @@ Page({
*/
onHide() {
// 页面卸载时清除定时器
if (this.data.timer) {
clearInterval(this.data.timer);
this.data.timer = null;
}
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
// 页面卸载时清除定时器
if (this.data.timer) {
clearInterval(this.data.timer);
this.data.timer = null;
}
},
/**
@@ -145,5 +95,58 @@ Page({
*/
onShareAppMessage() {
}
},
// 获取网点详情信息
getBranchDetail() {
wx.request({
url: 'https://t-jm.v0750.com/miniprogram/branch/detail',
data: {
number: this.data.number,
latitude: wx.getStorageSync('latitude'),
longitude: wx.getStorageSync('longitude'),
},
method: 'GET',
success: (res) => {
if (res.data && res.data.code == 200) {
this.setData({
banner: res.data.data.banner || [],
info: res.data.data.info || {}
});
}
}
});
},
// 获取机器列表
getMachineList() {
wx.request({
url: 'https://t-jm.v0750.com/miniprogram/branch/machine',
data: {
number: this.data.number,
},
method: 'POST',
success: (res) => {
if (res.data && res.data.code == 200) {
this.setData({
jiqilist: res.data.data || []
});
// 计算机器数量, 与空闲机器数量 free machine
let machineCount = this.data.jiqilist.length;
let freeMachineCount = 0;
for (let i = 0; i < this.data.jiqilist.length; i++) {
if (this.data.jiqilist[i].devicestatus == 0) {
freeMachineCount++;
}
}
// 更新数据
this.setData({
machineCount,
freeMachineCount
});
}
}
});
},
})