step-three.vue
4.04 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<template>
<view class="pageBox">
<view class="width-calc">
<view class="content-title">
品牌偏好<span class="content-title-span"> (多选)</span>
<view v-if="vehicleBrandList.length" @click="handleClear()" class="clearBox">
<uni-icons type="trash" size="13" color="#141E34" />
<span class="clear-text">清空</span>
</view>
</view>
<view class="reason-select" @click="handleBrandSelect()">
<text v-if="vehicleBrandList.length"> 已选 {{ vehicleBrandList.length }} 个品牌</text>
<text v-else class="placeholder">请选择品牌偏好</text>
<uni-icons type="right" size="14" color="#999999" />
</view>
<view class="brandListBox">
<view v-for="(item, index) in vehicleBrandList" :key="index" class="brand-item">
{{ item.name }}
<uni-icons type="closeempty" size="12" color="#828CA0" @click="handleRemove(item)" />
</view>
</view>
</view>
</view>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-facing-decorator';
@Component({})
export default class stepThree extends Vue {
vehicleBrandList: any = []
//初始化数据
initData(data: any) {
this.vehicleBrandList = data.brandList || [];
}
//清空选择的品牌
handleClear() {
this.vehicleBrandList = [];
this.$emit('threeData', { brandList: this.vehicleBrandList });
}
//删除选中的品牌
handleRemove(item: any) {
const index = this.vehicleBrandList.indexOf(item);
if (index !== -1) {
this.vehicleBrandList.splice(index, 1);
}
this.$emit('threeData', { brandList: this.vehicleBrandList });
}
//选择偏好品牌
handleBrandSelect() {
const that = this;
uni.setStorageSync('storagVehicleBrandList', JSON.stringify(that.vehicleBrandList));
uni.navigateTo({
url: '/module/preference/selectVehicleBrand', events: {
onReturnData: function (res: any) {
that.vehicleBrandList = res.data || [];
that.$emit('threeData', { brandList: that.vehicleBrandList });
}
},
});
}
}
</script>
<style scoped lang="scss">
.pageBox {
width: 100%;
background: #fff;
float: left;
padding-bottom: 20px;
}
.width-calc {
width: -webkit-calc(100% - 40px);
width: -moz-calc(100% - 40px);
width: calc(100% - 40px);
float: left;
margin: 0 20px;
}
.content-title {
width: 100%;
height: 24px;
color: #141e34;
font-size: 16px;
font-weight: 中黑体;
font-family: "苹方-简";
line-height: 24px;
float: left;
margin-top: 16px;
position: relative;
}
.content-title-span {
color: #333333;
font-size: 14px;
}
.reason-select {
width: 100%;
height: 52px;
line-height: 52px;
float: left;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
border-bottom: 1px solid #e6ebf5;
cursor: pointer;
color: #333333;
}
.placeholder {
color: #999999;
font-size: 14px;
}
.clearBox {
position: absolute;
right: 2px;
top: 50%;
transform: translateY(-50%);
height: 20px;
cursor: pointer;
}
.clear-text {
height: 20px;
line-height: 20px;
color: #333333;
font-size: 14px;
text-align: center;
padding-left: 4px;
}
.brandListBox {
width: 100%;
float: left;
margin-top: 6px;
}
.brand-item {
max-width: 180px;
height: 36px;
line-height: 36px;
border-radius: 4px;
background: #f8f9fb;
font-size: 14px;
color: #333333;
float: left;
margin-top: 10px;
margin-right: 10px;
align-items: center;
padding: 0 8px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.brand-item uni-icons {
margin-left: 2px;
flex-shrink: 0;
}
</style>