index.js
2.48 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
const requestapi = require("../restapi.js")
var app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
picture: [
'../../../resources/images/P1.png',
'../../../resources/images/P2.png',
'../../../resources/images/P3.png'
],
securityList: [],
userId: "",
//页面加载标志
loadingFlag: true,
//0加载中 2系统繁忙 1网络异常
loadingStatus: 0,
},
jump(e) {
// console.log(e);
var num = e.currentTarget.dataset.index;
if (num == null || num == undefined){
wx.navigateTo({
url: '../setting/setting?userId=' + this.data.userId
})
}else{
//修改数据
let obj = this.data.securityList[num];
wx.navigateTo({
url: '../setting/setting?startTime=' + obj.startTime + "&endTime=" + obj.endTime + "&group=" + obj.group + "&userId=" + obj.userId + "&weekDayStr=" + obj.weekDayStr + "&mobile=" + obj.mobile
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options);
this.setData({
userId: options.protocolId
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
loadingStatus: 0,
loadingFlag: true
})
this.getIndexInfo();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
//设置云防盗开关
switchSecurity: function(e){
let group = e.currentTarget.dataset.group;
let userId = e.currentTarget.dataset.userid;
let enable = e.detail.value;
if(enable){
enable = "Y"
}else{
enable = "N"
}
var obj = {
group: group,
userId: userId,
enable: enable
}
requestapi.updateCloudSecurityEnable(obj, function (response) {
console.log("updateCloudSecurityEnable", response)
if (response.returnCode != "0") {
let msg = response.message;
if (!msg || msg == ''){
msg = '操作失败';
}
app.showMessage(msg)
}
})
},
//获取云防盗列表
getIndexInfo: function(){
let protocolId = this.data.userId;
var that = this;
requestapi.getCloudSecurity(protocolId,function(response){
console.log(response);
if(response.returnCode == "0"){
that.setData({
securityList: response.data,
loadingFlag: false
})
return;
}
that.setData({
loadingStatus: 2,
loadingFlag: true
})
});
}
})