1
|
<template>
|
1
|
<template>
|
2
|
<LayoutApp title="选择地址" :show-back="true">
|
2
|
<LayoutApp title="选择地址" :show-back="true">
|
3
|
- <AddressItem :list="addressList" :pageName="pageName" :selectedAddressId="selectedAddressId"></AddressItem>
|
3
|
+ <CubeScroll class="main-container" ref="scroll" :options="scrollOpts">
|
|
|
4
|
+ <div class="user-list">
|
|
|
5
|
+ <div
|
|
|
6
|
+ v-for="(item, index) in addressList"
|
|
|
7
|
+ :key="index"
|
|
|
8
|
+ class="item"
|
|
|
9
|
+ @click="toOrderPage(item)"
|
|
|
10
|
+ >
|
|
|
11
|
+ <slot name="item" :data="item">
|
|
|
12
|
+ <div class="user-item">
|
|
|
13
|
+ <div
|
|
|
14
|
+ :class="{'uncheck-item' : item.address_id !== selectedAddressId , 'check-item' : item.address_id === selectedAddressId }"
|
|
|
15
|
+ ></div>
|
|
|
16
|
+ <div class="user-info">
|
|
|
17
|
+ <div class="extra">
|
|
|
18
|
+ <p class="name">{{item.consignee}}</p>
|
|
|
19
|
+ <p class="mobile">{{item.mobile}}</p>
|
|
|
20
|
+ <div v-if="item.is_default === 'Y'" class="tag-btn">默认</div>
|
|
|
21
|
+ <div v-if="item.tag_code" class="tag-btn">{{item.tag}}</div>
|
|
|
22
|
+ <div
|
|
|
23
|
+ class="option-btn"
|
|
|
24
|
+ :data-item="JSON.stringify(item)"
|
|
|
25
|
+ :data-add="0"
|
|
|
26
|
+ @click="toEditorPage"
|
|
|
27
|
+ >编辑</div>
|
|
|
28
|
+ </div>
|
|
|
29
|
+ <p class="address">{{item.area}}{{item.address}}</p>
|
|
|
30
|
+ </div>
|
|
|
31
|
+ </div>
|
|
|
32
|
+ </slot>
|
|
|
33
|
+ <div class="border-line"></div>
|
|
|
34
|
+ </div>
|
|
|
35
|
+ </div>
|
|
|
36
|
+ <div class="add-btn" :data-add="1" @click="toEditorPage">新增地址</div>
|
|
|
37
|
+ </CubeScroll>
|
4
|
</LayoutApp>
|
38
|
</LayoutApp>
|
5
|
</template>
|
39
|
</template>
|
6
|
|
40
|
|
7
|
<script>
|
41
|
<script>
|
8
|
import Layout from "../../../components/layout/layout-app";
|
42
|
import Layout from "../../../components/layout/layout-app";
|
9
|
-import AddressItem from "./components/address-item";
|
43
|
+import { get } from "lodash";
|
|
|
44
|
+import { Scroll, Loading } from "cube-ui";
|
|
|
45
|
+import { SET_USER_ADDRESS_INFO } from "store/address/address/types";
|
10
|
|
46
|
|
11
|
import { createNamespacedHelpers } from "vuex";
|
47
|
import { createNamespacedHelpers } from "vuex";
|
12
|
const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
|
48
|
const { mapState, mapMutations, mapActions } = createNamespacedHelpers(
|
|
@@ -17,59 +53,197 @@ export default { |
|
@@ -17,59 +53,197 @@ export default { |
17
|
name: "addressManager",
|
53
|
name: "addressManager",
|
18
|
components: {
|
54
|
components: {
|
19
|
LayoutApp: Layout,
|
55
|
LayoutApp: Layout,
|
20
|
- AddressItem
|
56
|
+ CubeScroll: Scroll
|
21
|
},
|
57
|
},
|
22
|
data() {
|
58
|
data() {
|
23
|
return {
|
59
|
return {
|
|
|
60
|
+ scrollOpts: {
|
|
|
61
|
+ bounce: false
|
|
|
62
|
+ },
|
24
|
pageName: "",
|
63
|
pageName: "",
|
25
|
- selectedAddressId: ""
|
64
|
+ selectedAddressId: "",
|
|
|
65
|
+ query: {}
|
26
|
};
|
66
|
};
|
27
|
},
|
67
|
},
|
28
|
computed: {
|
68
|
computed: {
|
29
|
...mapState(["addressList"])
|
69
|
...mapState(["addressList"])
|
30
|
},
|
70
|
},
|
31
|
methods: {
|
71
|
methods: {
|
32
|
- ...mapMutations({}),
|
|
|
33
|
- ...mapActions(["fetchUserAddressList"])
|
72
|
+ ...mapMutations({ SET_USER_ADDRESS_INFO }),
|
|
|
73
|
+ ...mapActions(["fetchUserAddressList"]),
|
|
|
74
|
+ toOrderPage(item) {
|
|
|
75
|
+ this.SET_USER_ADDRESS_INFO(item);
|
|
|
76
|
+ this.$router.push({
|
|
|
77
|
+ name: this.pageName,
|
|
|
78
|
+ query: this.query
|
|
|
79
|
+ });
|
|
|
80
|
+ },
|
|
|
81
|
+
|
|
|
82
|
+ toEditorPage(event) {
|
|
|
83
|
+ event.stopPropagation();
|
|
|
84
|
+ let isAdd = !!parseInt(event.currentTarget.dataset.add);
|
|
|
85
|
+ let item = event.currentTarget.dataset.item || {};
|
|
|
86
|
+
|
|
|
87
|
+ if (isAdd) {
|
|
|
88
|
+ if (this.addressList.length >= 5) {
|
|
|
89
|
+ this.toast = this.$createToast({
|
|
|
90
|
+ type: "error",
|
|
|
91
|
+ txt: "地址不能超过5个",
|
|
|
92
|
+ mask: true
|
|
|
93
|
+ }).show();
|
|
|
94
|
+
|
|
|
95
|
+ return;
|
|
|
96
|
+ }
|
|
|
97
|
+ }
|
|
|
98
|
+
|
|
|
99
|
+ this.$router.push({
|
|
|
100
|
+ name: "addressEdit",
|
|
|
101
|
+ params: {
|
|
|
102
|
+ item: item,
|
|
|
103
|
+ update: !isAdd,
|
|
|
104
|
+ title: isAdd ? "添加地址" : "编辑地址"
|
|
|
105
|
+ }
|
|
|
106
|
+ });
|
|
|
107
|
+ }
|
34
|
},
|
108
|
},
|
35
|
activated() {
|
109
|
activated() {
|
|
|
110
|
+ this.selectedAddressId = this.$route.query.addressId;
|
36
|
this.fetchUserAddressList();
|
111
|
this.fetchUserAddressList();
|
37
|
},
|
112
|
},
|
38
|
beforeRouteEnter(to, from, next) {
|
113
|
beforeRouteEnter(to, from, next) {
|
39
|
next(vm => {
|
114
|
next(vm => {
|
40
|
// 通过 `vm` 访问组件实例
|
115
|
// 通过 `vm` 访问组件实例
|
|
|
116
|
+ vm.query = from.query;
|
41
|
vm.pageName = from.name;
|
117
|
vm.pageName = from.name;
|
42
|
});
|
118
|
});
|
43
|
- },
|
|
|
44
|
- mounted() {
|
|
|
45
|
- this.selectedAddressId = this.$route.query.address_id;
|
|
|
46
|
}
|
119
|
}
|
47
|
};
|
120
|
};
|
48
|
</script>
|
121
|
</script>
|
49
|
|
122
|
|
50
|
<style lang="scss" scoped>
|
123
|
<style lang="scss" scoped>
|
51
|
-.body {
|
|
|
52
|
- height: 100%;
|
|
|
53
|
- background-color: #e0e0e0;
|
|
|
54
|
- overflow-y: auto;
|
|
|
55
|
-}
|
124
|
+/deep/ {
|
|
|
125
|
+ .cube-scroll-content {
|
|
|
126
|
+ min-height: 100%;
|
|
|
127
|
+ }
|
56
|
|
128
|
|
57
|
-.address-container {
|
|
|
58
|
- margin-bottom: 120px;
|
129
|
+ .cube-scroll-list-wrapper {
|
|
|
130
|
+ overflow: auto;
|
|
|
131
|
+ }
|
|
|
132
|
+
|
|
|
133
|
+ .cube-loading-spinners {
|
|
|
134
|
+ margin: auto;
|
|
|
135
|
+ }
|
59
|
}
|
136
|
}
|
60
|
|
137
|
|
61
|
-.addNew {
|
|
|
62
|
- display: block;
|
|
|
63
|
- height: 80px;
|
|
|
64
|
- margin-top: 20px;
|
138
|
+.user-list {
|
65
|
background-color: white;
|
139
|
background-color: white;
|
|
|
140
|
+
|
|
|
141
|
+ .border-line {
|
|
|
142
|
+ width: 100%;
|
|
|
143
|
+ height: 1px;
|
|
|
144
|
+ background-color: #eee;
|
|
|
145
|
+ }
|
|
|
146
|
+}
|
|
|
147
|
+
|
|
|
148
|
+.user-item {
|
|
|
149
|
+ display: flex;
|
|
|
150
|
+ padding-top: 40px;
|
|
|
151
|
+ padding-bottom: 44px;
|
|
|
152
|
+ padding-left: 28px;
|
|
|
153
|
+ padding-right: 40px;
|
|
|
154
|
+ align-items: center;
|
|
|
155
|
+
|
|
|
156
|
+ .check-item {
|
|
|
157
|
+ width: 40px;
|
|
|
158
|
+ height: 40px;
|
|
|
159
|
+ background: url(~statics/image/address/selected.png) no-repeat;
|
|
|
160
|
+ background-size: cover;
|
|
|
161
|
+ }
|
|
|
162
|
+ .uncheck-item {
|
|
|
163
|
+ width: 40px;
|
|
|
164
|
+ height: 40px;
|
|
|
165
|
+ background: url(~statics/image/address/unselected.png) no-repeat;
|
|
|
166
|
+ background-size: cover;
|
|
|
167
|
+ }
|
|
|
168
|
+
|
|
|
169
|
+ .user-info {
|
|
|
170
|
+ flex-grow: 1;
|
|
|
171
|
+ overflow: hidden;
|
|
|
172
|
+ margin-left: 32px;
|
|
|
173
|
+ }
|
|
|
174
|
+
|
|
|
175
|
+ .extra {
|
|
|
176
|
+ display: flex;
|
|
|
177
|
+ flex-direction: row;
|
|
|
178
|
+
|
|
|
179
|
+ .name {
|
|
|
180
|
+ font-size: 28px;
|
|
|
181
|
+ font-weight: 400;
|
|
|
182
|
+ color: #000000;
|
|
|
183
|
+ line-height: 40px;
|
|
|
184
|
+ }
|
|
|
185
|
+
|
|
|
186
|
+ .mobile {
|
|
|
187
|
+ display: block;
|
|
|
188
|
+ margin-left: 20px;
|
|
|
189
|
+ font-size: 28px;
|
|
|
190
|
+ font-weight: 400;
|
|
|
191
|
+ color: #000000;
|
|
|
192
|
+ line-height: 40px;
|
|
|
193
|
+ }
|
|
|
194
|
+
|
|
|
195
|
+ .tag-btn {
|
|
|
196
|
+ width: 80px;
|
|
|
197
|
+ line-height: 44px;
|
|
|
198
|
+ font-size: 22px;
|
|
|
199
|
+ text-align: center;
|
|
|
200
|
+ background-color: #002b47;
|
|
|
201
|
+ margin-left: 18px;
|
|
|
202
|
+ color: white;
|
|
|
203
|
+ border-radius: 4px;
|
|
|
204
|
+ }
|
|
|
205
|
+
|
|
|
206
|
+ .option-btn {
|
|
|
207
|
+ display: block;
|
|
|
208
|
+ width: 48px;
|
|
|
209
|
+ line-height: 44px;
|
|
|
210
|
+ letter-spacing: -0.29;
|
|
|
211
|
+ color: black;
|
|
|
212
|
+ font-size: 24px;
|
|
|
213
|
+ position: absolute;
|
|
|
214
|
+ right: 40px;
|
|
|
215
|
+ }
|
|
|
216
|
+ }
|
|
|
217
|
+
|
|
|
218
|
+ .address {
|
|
|
219
|
+ width: 100%;
|
|
|
220
|
+ font-size: 24px;
|
|
|
221
|
+ line-height: 34px;
|
|
|
222
|
+ margin-top: 16px;
|
|
|
223
|
+ color: #999;
|
|
|
224
|
+ display: -webkit-box;
|
|
|
225
|
+ -webkit-box-orient: vertical;
|
|
|
226
|
+ -webkit-line-clamp: 2;
|
|
|
227
|
+ overflow: hidden;
|
|
|
228
|
+ }
|
66
|
}
|
229
|
}
|
67
|
|
230
|
|
68
|
-.newText {
|
|
|
69
|
- line-height: 80px;
|
|
|
70
|
- font-size: 28px;
|
|
|
71
|
- letter-spacing: 0.6px;
|
|
|
72
|
- white-space: nowrap;
|
231
|
+.add-btn {
|
|
|
232
|
+ height: 88px;
|
|
|
233
|
+ line-height: 88px;
|
|
|
234
|
+ font-size: 32px;
|
|
|
235
|
+ font-weight: bold;
|
73
|
text-align: center;
|
236
|
text-align: center;
|
|
|
237
|
+ color: #252525;
|
|
|
238
|
+ background-color: #fff;
|
|
|
239
|
+ border-radius: 44px;
|
|
|
240
|
+ border-style: solid;
|
|
|
241
|
+ border-width: 1px;
|
|
|
242
|
+ border-color: #e0e0e0;
|
|
|
243
|
+
|
|
|
244
|
+ position: absolute;
|
|
|
245
|
+ left: 32px;
|
|
|
246
|
+ right: 32px;
|
|
|
247
|
+ bottom: 40px;
|
74
|
}
|
248
|
}
|
75
|
</style> |
249
|
</style> |