index.js
3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
const restapi = require('../restapi');
// const filter = require('../../../../utils/filter.js');
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
// authToast:false,
shebList: [{
title: "车娱乐",
items: [{
icon: "../../../resources/images/bind_ydh.png",
name: "云导航",
isBind: 1, //1代表暂不支持,true已绑定,false未绑定
bindMethod: "bindDevice",
deviceType: 2,
}, {
icon: "../../../resources/images/bind_znyj.png",
name: "智能云镜",
isBind: 1,
bindMethod: "bindDevice",
deviceType: 12134
}]
}, {
title: "车诊断",
items: [{
icon: "../../../resources/images/bind_jbhz.png",
name: "驾宝盒子",
isBind: false,
bindMethod: "jumpWebpageBox",
deviceType: 1
}]
}, {
title: "车安全",
items: [{
icon: "../../../resources/images/bind_zny.png",
name: "GPS",
isBind: false,
bindMethod: "jumpWebpageBox",
deviceType: 8
}, {
icon: "../../../resources/images/bind_xcjly.png",
name: "行车记录仪",
isBind: false,
bindMethod: "jumpWebpageBox",
deviceType: 6
}]
}],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.showLoading({
title: '',
mask: true
})
// console.log(this.data.authToast)
// if (!this.data.authToast) {
// wx.navigateTo({
// url: "../../../../pages/auth/index/index"
// })
// }
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
let sourcefrom = '';
let self = this;
restapi.getDeviceBindInfo(sourcefrom, function (response) {
wx.hideLoading();
if (response && response.returnCode == 0) {
let bindInfoList = response.bindInfoList;
if (bindInfoList) {
let shebList1 = self.data.shebList;
for (let i = 0; i < bindInfoList.length; i++) {
for (let j = 0; j < shebList1.length; j++) {
for (let k = 0; k < shebList1[j].items.length; k++) {
let curItem = shebList1[j].items[k];
if (curItem.deviceType == bindInfoList[i].deviceType) {
curItem.isBind = true
}
}
}
}
self.setData({
shebList: shebList1
})
}
} else {
app.showMessage("获取设备绑定信息失败!");
}
})
},
onLogin() {
},
jumpWebpageBox: function (e) {
let type = e.currentTarget.dataset.type;
let typeid = e.currentTarget.dataset.typeid;
let bind = e.currentTarget.dataset.bind;
if (bind) {
return;
}
wx.navigateTo({
url: `/packageSmartPlus/pages/bindingDevice/bind/bind?type=${type}&typeid=${typeid}`
})
},
/**
* 扫码
*/
bindDevice: function (e) {
let bind = e.currentTarget.dataset.bind;
if (bind) {
return;
}
// 允许从相机和相册扫码
wx.scanCode({
success: (res) => {
wx.reLaunch({
url: "/packageServices/pages/index/index"
});
}
})
}
})