chooseArea.js
1.41 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
import wx from '../../utils/wx';
import Yas from '../../common/yas';
import event from '../../common/event';
import accountModel from '../../models/account/index';
const AREA_CACHE_KEY = 'area_cache_key';
let yas;
Page({
data: {
list: []
},
getArea: function() {
accountModel.getArea()
.then(res => {
if (res && res.code === 200) {
let dataList = res.data;
if (dataList && dataList.length > 0) {
this.setData({
list: dataList
});
wx.setStorage({
key: AREA_CACHE_KEY,
data: dataList,
});
}
} else {
this.useCache();
}
});
},
useCache: function() {
let dataList = wx.getStorageSync(AREA_CACHE_KEY);
this.setData({
list: dataList
});
},
chooseArea: function(e) {
const code = e.currentTarget.dataset.code;
const name = e.currentTarget.dataset.name;
event.emit('choose-area', {
code,
name
});
wx.navigateBack({
delta: 1
});
},
onLoad: function() {
this.getArea();
yas = new Yas();
yas.pageOpenReport();
}
});