1234567
This commit is contained in:
@@ -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
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
})
|
||||
@@ -5,49 +5,47 @@
|
||||
<view class="info">
|
||||
<view class="title">
|
||||
<view class="title_c">{{info.name}}</view>
|
||||
<view class="ld" wx:for="{{info.liangdian}}" wx:key="index_i" wx:for-item="item_l" style="background-color: {{item_l.ys}};">{{item_l.name}}</view>
|
||||
<view class="ld" wx:for="{{info.service}}" wx:key="index_i" wx:for-item="s" style="background-color: {{s.color}};">{{s.name}}</view>
|
||||
</view>
|
||||
<view class="tag">{{info.tag}}</view>
|
||||
<view class="ads"><text class="iconfont icon-dingwei"></text>{{info.ads}}</view>
|
||||
<view class="ads yingye"><text class="iconfont icon-shijian"></text>{{info.yingye}}</view>
|
||||
<view class="tag">{{info.tags}}</view>
|
||||
<view class="ads"><text class="iconfont icon-dingwei"></text>{{info.address}}</view>
|
||||
<view class="ads yingye"><text class="iconfont icon-shijian"></text>{{info.businesshours || "24小时"}}</view>
|
||||
<view class="dw">
|
||||
<text class="ico iconfont icon-daohangdaohang"></text>
|
||||
<view class="jl">{{info.juli}}</view>
|
||||
<view class="jl">{{info.distance}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="content">
|
||||
<view class="index-wangdian-title">
|
||||
<view class="more">空闲 {{info.jiqi_kx}}/{{info.jiqi_zs}}台</view>
|
||||
<view class="more">空闲 {{freeMachineCount}}/{{machineCount}}台</view>
|
||||
<view class="title_c">洗车机<view class="line"></view></view>
|
||||
</view>
|
||||
<view class="list">
|
||||
<view class="jiqi" wx:for="{{jiqilist}}" wx:key="index" wx:for-item="i">
|
||||
<view wx:if="{{i.state > 2}}" class="j"> <!-- 禁用 -->
|
||||
<view wx:if="{{i.devicestatus ==-1}}" class="j"> <!-- 禁用 -->
|
||||
<view class="mac_state"><text>禁</text></view>
|
||||
<text class="mac_id">{{i.id}}</text>
|
||||
<view class="pa" wx:if="{{i.isPA}}">PA壶</view>
|
||||
<text class="mac_id">{{i.number}}</text>
|
||||
<view class="pa" wx:if="{{i.ispa}}">PA壶</view>
|
||||
</view>
|
||||
<view wx:elif="{{i.state > 1}}" class="w"> <!-- 使用中 -->
|
||||
<view wx:elif="{{i.devicestatus == 1}}" class="w"> <!-- 使用中 -->
|
||||
<view class="mac_state"><text>洗</text></view>
|
||||
<text class="mac_id">{{i.id}}</text>
|
||||
<view class="pa" wx:if="{{i.isPA}}">PA壶</view>
|
||||
<text class="mac_id">{{i.number}}</text>
|
||||
<view class="pa" wx:if="{{i.ispa}}">PA壶</view>
|
||||
</view>
|
||||
<view wx:elif="{{i.state > 0}}" class="x"> <!-- 空间 -->
|
||||
<view wx:elif="{{i.devicestatus == 0}}" class="x"> <!-- 空间 -->
|
||||
<view class="mac_state"><text>闲</text></view>
|
||||
<text class="mac_id">{{i.id}}</text>
|
||||
<view class="pa" wx:if="{{i.isPA}}">PA壶</view>
|
||||
<text class="mac_id">{{i.number}}</text>
|
||||
<view class="pa" wx:if="{{i.ispa}}">PA壶</view>
|
||||
</view>
|
||||
<view wx:else class="d"> <!-- 离线 -->
|
||||
<view class="mac_state"><text>离</text></view>
|
||||
<text class="mac_id">{{i.id}}</text>
|
||||
<view class="pa" wx:if="{{i.isPA}}">PA壶</view>
|
||||
<text class="mac_id">{{i.number}}</text>
|
||||
<view class="pa" wx:if="{{i.ispa}}">PA壶</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<service-tel></service-tel>
|
||||
|
||||
|
||||
</view>
|
||||
Reference in New Issue
Block a user