gateList.vue
3.26 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<template>
<view class="">
<headerComp
:leftImgSrc="leftSrc"
@leftClick="backClick"
:title="titleStr"></headerComp>
<searchBox @handleEvent="searchFun"></searchBox>
<view class="list">
<view class="list-item" @tap="itemFun(index)" v-for="(item, index) in cacheList" :key="item.id">
<text>{{ item.name }}</text>
</view>
<view class="empty-list-item" v-if="!cacheList.length">
<text>暂无数据</text>
</view>
</view>
</view>
</template>
<script>
import { mapState, mapActions } from 'vuex'
import headerComp from '../../components/header'
import searchBox from '../../components/search'
export default {
components: {
headerComp, searchBox
},
data() {
return {
backUrl: '',
analysisLevel: '',
titleStr: this.$t('index').storeSelect,
leftSrc:'../../static/header/backArrow.png',
isQuerying: false,
cacheCheckedGateId: [],
cacheList: []
}
},
onLoad(options) {
// console.log('multimalllist load options', options)
this.backUrl = options.backUrl;
this.analysisLevel = options.analysisLevel;
let lists = JSON.parse(JSON.stringify(this.gateList));
if(lists.length) {
this.cacheList = lists.map(item => {
// item._selected = item.id = this.checkedMallId['id'];
return item;
})
}
this.cacheCheckedGateId = JSON.parse(JSON.stringify(this.checkedGateId));
},
computed: {
...mapState({
gateList: state => state.malls.gateList,
checkedGateId: state => state.malls.checkedGateId
}),
},
watch: {
},
created() {
},
mounted() {
},
methods: {
backClick() {
uni.navigateBack({
delta:1
})
},
searchFun(queryStr) {
let that = this;
this.isQuerying = queryStr.length > 0 ? true : false;
this.query(queryStr, function(res) {
console.log('query res', res)
that.cacheList = res;
// .length
// ? res.map(item => {
// let isChecked = that.multiCheckedMallId.some(checkedItem => {
// return item.id === checkedItem.id;
// })
// item._selected = isChecked;
// return item;
// })
// : res;
})
},
query(queryString, cb) {
queryString = queryString.toLocaleLowerCase();
let result = queryString
? this.mallList.length > 0
? this.mallList.filter(item => {
if(!!~item['name'].toLocaleLowerCase().indexOf(queryString)) {
return true;
}
})
: []
: this.mallList;
cb(result);
},
itemFun(index) {
this.cacheCheckedGateId = {
id: this.cacheList[index].id,
name: this.cacheList[index].name
}
this.$store.dispatch('malls/updateCheckedGate', this.cacheCheckedGateId)
uni.reLaunch({
url: `${this.backUrl}?type=${this.analysisLevel}`
})
},
}
}
</script>
<style>
.hide-item {
display: none;
}
.list-item {
border-bottom: 1px solid #979797;
height: 72.46upx;
line-height: 72.46upx;
font-size: 25.37upx;
background: #FFFFFF;
position: relative;
}
.list-item > image{
width: 28.99upx;
height: 28.99upx;
position: absolute;
top:23.55upx;
left: 25.36upx;
}
.list-item text{
margin-left: 77.89upx;
}
.empty-list-item {
font-size: 25.37upx;
text-align: center;
padding-top: 54.34upx;
}
.empty-list-item text {
margin-left: 0;
color: #c9c9c9;
}
</style>