index.js
2.87 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
import {
getMalls,
} from "../../../api/login";
import {
getPatrolGateList
} from "../../../api/tour.js";
import _ from 'underscore';
Page({
/**
* 组件的初始数据
*/
data: {
mallList: [],
activeMall: [],
gateId: '',
navHeight: getApp().globalData.navHeight,
type:''
},
onReady() {
this.getMalls()
},
onLoad(option){
let type = option.type;
this.setData({
type
});
},
goBack(){
wx.switchTab({
url: '/pages/home/index'
})
},
onChange(evt) {
this.setData({
activeMall: evt.detail
}, () => {
this.loadGates(evt.detail[evt.detail.length - 1]);
})
},
loadGates(mallId) {
getPatrolGateList({
mallId
}).then(res => {
let mallObj = _.findWhere(this.data.mallList, {
id: mallId
});
if (!res.data || !res.data.list||res.data.list.length==0) {
mallObj.empty = true;
//this.triggerEvent('gateChange',{});
} else {
mallObj.gates = res.data.list;
let gateObj = res.data.list[0];
//this.triggerEvent('gateChange',{id:gateObj.id,name:gateObj.name,mallId:gateObj.mallId});
}
this.setData({
mallList: this.data.mallList
}, () => {
})
})
},
backBtn() {
this.triggerEvent('back');
},
// 获取门店列表
getMalls: function () {
const {
accountId,
atoken
} = this.data
getMalls({
url: '/report/malls',
accountId: wx.getStorageSync('accountId')
}).then((malls) => {
const data = malls.data;
this.setData({
mallList: data
}, () => {
let mallId = wx.getStorageSync('mallId');
if (!mallId) {
mallId = data[0].id;
wx.setStorageSync('mallId', mallId);
}
this.onChange({
detail: [mallId]
});
});
})
},
selectGate(evt) {
let {
id,
channelid,
name,
mallid,
mallname,
platform
} = evt.currentTarget.dataset;
this.setData({
gateId: id
}, () => {
wx.redirectTo({
url: `/pages/tour/webview/index?type=${this.data.type}&id=${id}&channelid=${channelid}&platform=${platform}&mallId=${mallid}&name=${name}&mallName=${mallname}&type=${this.data.type}`,
})
// this.triggerEvent('gateChange', {
// id,
// name,
// mallId
// });
})
}
});