create-weapp-vite 2.0.31 → 2.0.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/README.md +1 -0
  2. package/dist/{chunk-FGMHC2DJ.js → chunk-IT75MAH3.js} +3 -2
  3. package/dist/cli.js +5 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +1 -1
  6. package/package.json +1 -1
  7. package/templates/wevu-retail/.editorconfig +9 -0
  8. package/templates/wevu-retail/.vscode/settings.json +10 -0
  9. package/templates/wevu-retail/AGENTS.md +35 -0
  10. package/templates/wevu-retail/README.md +26 -0
  11. package/templates/wevu-retail/auto-import-components.json +1 -0
  12. package/templates/wevu-retail/gitignore +35 -0
  13. package/templates/wevu-retail/package.json +42 -0
  14. package/templates/wevu-retail/postcss.config.js +6 -0
  15. package/templates/wevu-retail/project.config.json +44 -0
  16. package/templates/wevu-retail/project.private.config.json +8 -0
  17. package/templates/wevu-retail/src/app.vue +104 -0
  18. package/templates/wevu-retail/src/common/updateManager.ts +29 -0
  19. package/templates/wevu-retail/src/components/filter/index.vue +134 -0
  20. package/templates/wevu-retail/src/components/filter-popup/index.vue +67 -0
  21. package/templates/wevu-retail/src/components/goods-card/index.vue +219 -0
  22. package/templates/wevu-retail/src/components/goods-list/index.vue +91 -0
  23. package/templates/wevu-retail/src/components/load-more/index.vue +99 -0
  24. package/templates/wevu-retail/src/components/loading-content/index.vue +48 -0
  25. package/templates/wevu-retail/src/components/price/index.vue +104 -0
  26. package/templates/wevu-retail/src/components/promotion/ui-coupon-card/index.vue +143 -0
  27. package/templates/wevu-retail/src/components/promotion/ui-coupon-card/tools.wxs +18 -0
  28. package/templates/wevu-retail/src/components/swipeout/index.vue +118 -0
  29. package/templates/wevu-retail/src/components/swipeout/swipe.wxs +151 -0
  30. package/templates/wevu-retail/src/components/webp-image/index.vue +105 -0
  31. package/templates/wevu-retail/src/components/webp-image/utils.wxs +140 -0
  32. package/templates/wevu-retail/src/config/index.ts +20437 -0
  33. package/templates/wevu-retail/src/custom-tab-bar/data.ts +22 -0
  34. package/templates/wevu-retail/src/custom-tab-bar/index.vue +62 -0
  35. package/templates/wevu-retail/src/model/activities.ts +7 -0
  36. package/templates/wevu-retail/src/model/activity.ts +18 -0
  37. package/templates/wevu-retail/src/model/address.ts +31 -0
  38. package/templates/wevu-retail/src/model/cart.ts +306 -0
  39. package/templates/wevu-retail/src/model/category.ts +175 -0
  40. package/templates/wevu-retail/src/model/comments/queryDetail.ts +50 -0
  41. package/templates/wevu-retail/src/model/comments.ts +298 -0
  42. package/templates/wevu-retail/src/model/coupon.ts +39 -0
  43. package/templates/wevu-retail/src/model/detailsComments.ts +30 -0
  44. package/templates/wevu-retail/src/model/good.ts +1904 -0
  45. package/templates/wevu-retail/src/model/goods.ts +7 -0
  46. package/templates/wevu-retail/src/model/order/applyService.ts +329 -0
  47. package/templates/wevu-retail/src/model/order/orderConfirm.ts +147 -0
  48. package/templates/wevu-retail/src/model/order/orderDetail.ts +1191 -0
  49. package/templates/wevu-retail/src/model/order/orderList.ts +1033 -0
  50. package/templates/wevu-retail/src/model/promotion.ts +20 -0
  51. package/templates/wevu-retail/src/model/search.ts +60 -0
  52. package/templates/wevu-retail/src/model/submitComment.ts +58 -0
  53. package/templates/wevu-retail/src/model/swiper.ts +39 -0
  54. package/templates/wevu-retail/src/model/usercenter.ts +52 -0
  55. package/templates/wevu-retail/src/pages/cart/components/cart-bar/index.vue +104 -0
  56. package/templates/wevu-retail/src/pages/cart/components/cart-empty/index.vue +41 -0
  57. package/templates/wevu-retail/src/pages/cart/components/cart-group/index.vue +333 -0
  58. package/templates/wevu-retail/src/pages/cart/components/cart-group/index.wxs +5 -0
  59. package/templates/wevu-retail/src/pages/cart/components/cart-group/utils.wxs +20 -0
  60. package/templates/wevu-retail/src/pages/cart/components/goods-card/index.vue +334 -0
  61. package/templates/wevu-retail/src/pages/cart/components/specs-popup/index.vue +100 -0
  62. package/templates/wevu-retail/src/pages/cart/index.vue +342 -0
  63. package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-sidebar/README.md +95 -0
  64. package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-sidebar/c-sidebar-item/index.vue +73 -0
  65. package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-sidebar/index.vue +121 -0
  66. package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-tabbar/c-tabbar-more/index.vue +74 -0
  67. package/templates/wevu-retail/src/pages/category/components/goods-category/components/c-tabbar/index.vue +102 -0
  68. package/templates/wevu-retail/src/pages/category/components/goods-category/index.vue +137 -0
  69. package/templates/wevu-retail/src/pages/category/index.vue +50 -0
  70. package/templates/wevu-retail/src/pages/coupon/components/coupon-card/index.vue +95 -0
  71. package/templates/wevu-retail/src/pages/coupon/components/floating-button/index.vue +44 -0
  72. package/templates/wevu-retail/src/pages/coupon/coupon-activity-goods/index.vue +135 -0
  73. package/templates/wevu-retail/src/pages/coupon/coupon-detail/index.vue +94 -0
  74. package/templates/wevu-retail/src/pages/coupon/coupon-list/index.vue +136 -0
  75. package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/components/images-videos/assets/play.png +0 -0
  76. package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/components/images-videos/index.vue +65 -0
  77. package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/components/my-video/index.vue +92 -0
  78. package/templates/wevu-retail/src/pages/goods/comments/components/comments-card/index.vue +93 -0
  79. package/templates/wevu-retail/src/pages/goods/comments/create/index.vue +196 -0
  80. package/templates/wevu-retail/src/pages/goods/comments/index.vue +293 -0
  81. package/templates/wevu-retail/src/pages/goods/details/components/buy-bar/index.vue +117 -0
  82. package/templates/wevu-retail/src/pages/goods/details/components/goods-specs-popup/index.vue +440 -0
  83. package/templates/wevu-retail/src/pages/goods/details/components/promotion-popup/index.vue +83 -0
  84. package/templates/wevu-retail/src/pages/goods/details/index.vue +598 -0
  85. package/templates/wevu-retail/src/pages/goods/list/index.vue +299 -0
  86. package/templates/wevu-retail/src/pages/goods/result/index.vue +350 -0
  87. package/templates/wevu-retail/src/pages/goods/search/index.vue +196 -0
  88. package/templates/wevu-retail/src/pages/home/home.vue +215 -0
  89. package/templates/wevu-retail/src/pages/home/readme +8 -0
  90. package/templates/wevu-retail/src/pages/order/after-service-detail/api.ts +34 -0
  91. package/templates/wevu-retail/src/pages/order/after-service-detail/index.vue +430 -0
  92. package/templates/wevu-retail/src/pages/order/after-service-list/api.ts +1262 -0
  93. package/templates/wevu-retail/src/pages/order/after-service-list/index.vue +299 -0
  94. package/templates/wevu-retail/src/pages/order/apply-service/index.vue +665 -0
  95. package/templates/wevu-retail/src/pages/order/components/after-service-button-bar/index.vue +142 -0
  96. package/templates/wevu-retail/src/pages/order/components/customer-service/index.vue +75 -0
  97. package/templates/wevu-retail/src/pages/order/components/goods-card/index.vue +356 -0
  98. package/templates/wevu-retail/src/pages/order/components/noGoods/noGood.wxs +17 -0
  99. package/templates/wevu-retail/src/pages/order/components/noGoods/noGoods.vue +125 -0
  100. package/templates/wevu-retail/src/pages/order/components/order-button-bar/index.vue +262 -0
  101. package/templates/wevu-retail/src/pages/order/components/order-card/index.vue +126 -0
  102. package/templates/wevu-retail/src/pages/order/components/order-goods-card/index.vue +86 -0
  103. package/templates/wevu-retail/src/pages/order/components/reason-sheet/index.vue +161 -0
  104. package/templates/wevu-retail/src/pages/order/components/reason-sheet/reasonSheet.ts +25 -0
  105. package/templates/wevu-retail/src/pages/order/components/selectCoupons/mock.ts +22 -0
  106. package/templates/wevu-retail/src/pages/order/components/selectCoupons/selectCoupon.wxs +16 -0
  107. package/templates/wevu-retail/src/pages/order/components/selectCoupons/selectCoupons.vue +207 -0
  108. package/templates/wevu-retail/src/pages/order/components/specs-goods-card/index.vue +185 -0
  109. package/templates/wevu-retail/src/pages/order/config.ts +94 -0
  110. package/templates/wevu-retail/src/pages/order/delivery-detail/index.vue +145 -0
  111. package/templates/wevu-retail/src/pages/order/delivery-detail/isUrl.wxs +7 -0
  112. package/templates/wevu-retail/src/pages/order/fill-tracking-no/api.ts +71 -0
  113. package/templates/wevu-retail/src/pages/order/fill-tracking-no/index.vue +267 -0
  114. package/templates/wevu-retail/src/pages/order/invoice/index.vue +94 -0
  115. package/templates/wevu-retail/src/pages/order/order-confirm/components/address-card/index.vue +78 -0
  116. package/templates/wevu-retail/src/pages/order/order-confirm/getNotes.wxs +11 -0
  117. package/templates/wevu-retail/src/pages/order/order-confirm/handleInvoice.wxs +11 -0
  118. package/templates/wevu-retail/src/pages/order/order-confirm/index.vue +707 -0
  119. package/templates/wevu-retail/src/pages/order/order-confirm/order.wxs +8 -0
  120. package/templates/wevu-retail/src/pages/order/order-confirm/pay.ts +115 -0
  121. package/templates/wevu-retail/src/pages/order/order-detail/index.vue +456 -0
  122. package/templates/wevu-retail/src/pages/order/order-list/index.vue +288 -0
  123. package/templates/wevu-retail/src/pages/order/pay-result/index.vue +77 -0
  124. package/templates/wevu-retail/src/pages/order/receipt/index.vue +336 -0
  125. package/templates/wevu-retail/src/pages/promotion/promotion-detail/index.vue +145 -0
  126. package/templates/wevu-retail/src/pages/user/address/edit/index.vue +514 -0
  127. package/templates/wevu-retail/src/pages/user/address/list/index.vue +249 -0
  128. package/templates/wevu-retail/src/pages/user/components/t-location/index.vue +156 -0
  129. package/templates/wevu-retail/src/pages/user/components/ui-address-item/index.vue +92 -0
  130. package/templates/wevu-retail/src/pages/user/name-edit/index.vue +49 -0
  131. package/templates/wevu-retail/src/pages/user/person-info/index.vue +198 -0
  132. package/templates/wevu-retail/src/pages/usercenter/address/edit/util.ts +33 -0
  133. package/templates/wevu-retail/src/pages/usercenter/components/order-group/index.vue +90 -0
  134. package/templates/wevu-retail/src/pages/usercenter/components/ui-select-picker/index.vue +108 -0
  135. package/templates/wevu-retail/src/pages/usercenter/components/user-center-card/index.vue +82 -0
  136. package/templates/wevu-retail/src/pages/usercenter/index.vue +301 -0
  137. package/templates/wevu-retail/src/services/_utils/delay.ts +3 -0
  138. package/templates/wevu-retail/src/services/_utils/timeout.ts +3 -0
  139. package/templates/wevu-retail/src/services/activity/fetchActivity.ts +20 -0
  140. package/templates/wevu-retail/src/services/activity/fetchActivityList.ts +20 -0
  141. package/templates/wevu-retail/src/services/address/edit.ts +33 -0
  142. package/templates/wevu-retail/src/services/address/fetchAddress.ts +48 -0
  143. package/templates/wevu-retail/src/services/address/list.ts +31 -0
  144. package/templates/wevu-retail/src/services/cart/cart.ts +20 -0
  145. package/templates/wevu-retail/src/services/comments/fetchComments.ts +18 -0
  146. package/templates/wevu-retail/src/services/comments/fetchCommentsCount.ts +18 -0
  147. package/templates/wevu-retail/src/services/coupon/index.ts +65 -0
  148. package/templates/wevu-retail/src/services/good/comments/fetchCommentDetail.ts +20 -0
  149. package/templates/wevu-retail/src/services/good/fetchCategoryList.ts +18 -0
  150. package/templates/wevu-retail/src/services/good/fetchGood.ts +18 -0
  151. package/templates/wevu-retail/src/services/good/fetchGoods.ts +29 -0
  152. package/templates/wevu-retail/src/services/good/fetchGoodsDetailsComments.ts +37 -0
  153. package/templates/wevu-retail/src/services/good/fetchGoodsList.ts +39 -0
  154. package/templates/wevu-retail/src/services/good/fetchSearchHistory.ts +35 -0
  155. package/templates/wevu-retail/src/services/good/fetchSearchResult.ts +38 -0
  156. package/templates/wevu-retail/src/services/home/home.ts +53 -0
  157. package/templates/wevu-retail/src/services/order/applyService.ts +70 -0
  158. package/templates/wevu-retail/src/services/order/orderConfirm.ts +69 -0
  159. package/templates/wevu-retail/src/services/order/orderDetail.ts +39 -0
  160. package/templates/wevu-retail/src/services/order/orderList.ts +39 -0
  161. package/templates/wevu-retail/src/services/order/orderSubmitComment.ts +22 -0
  162. package/templates/wevu-retail/src/services/promotion/detail.ts +18 -0
  163. package/templates/wevu-retail/src/services/usercenter/fetchPerson.ts +28 -0
  164. package/templates/wevu-retail/src/services/usercenter/fetchUsercenter.ts +18 -0
  165. package/templates/wevu-retail/src/sitemap.json +7 -0
  166. package/templates/wevu-retail/src/utils/addressParse.ts +25 -0
  167. package/templates/wevu-retail/src/utils/getPermission.ts +45 -0
  168. package/templates/wevu-retail/src/utils/mock.ts +51 -0
  169. package/templates/wevu-retail/src/utils/util.ts +134 -0
  170. package/templates/wevu-retail/src/vite-env.d.ts +1 -0
  171. package/templates/wevu-retail/tailwind.config.ts +15 -0
  172. package/templates/wevu-retail/tsconfig.app.json +58 -0
  173. package/templates/wevu-retail/tsconfig.json +11 -0
  174. package/templates/wevu-retail/tsconfig.node.json +33 -0
  175. package/templates/wevu-retail/vite.config.ts +14 -0
@@ -0,0 +1,514 @@
1
+ <script lang="ts">
2
+ import Toast from 'tdesign-miniprogram/toast/index';
3
+ import { fetchDeliveryAddress } from '../../../../services/address/fetchAddress';
4
+ import { areaData } from '../../../../config/index';
5
+ import { resolveAddress, rejectAddress } from '../../../../services/address/list';
6
+
7
+ const innerPhoneReg = '^1(?:3\\d|4[4-9]|5[0-35-9]|6[67]|7[0-8]|8\\d|9\\d)\\d{8}$';
8
+ const innerNameReg = '^[a-zA-Z\\d\\u4e00-\\u9fa5]+$';
9
+ const labelsOptions = [
10
+ { id: 0, name: '家' },
11
+ { id: 1, name: '公司' },
12
+ ];
13
+
14
+ Page({
15
+ options: {
16
+ multipleSlots: true,
17
+ },
18
+ externalClasses: ['theme-wrapper-class'],
19
+ data: {
20
+ locationState: {
21
+ labelIndex: null,
22
+ addressId: '',
23
+ addressTag: '',
24
+ cityCode: '',
25
+ cityName: '',
26
+ countryCode: '',
27
+ countryName: '',
28
+ detailAddress: '',
29
+ districtCode: '',
30
+ districtName: '',
31
+ isDefault: false,
32
+ name: '',
33
+ phone: '',
34
+ provinceCode: '',
35
+ provinceName: '',
36
+ isEdit: false,
37
+ isOrderDetail: false,
38
+ isOrderSure: false,
39
+ },
40
+ areaData: areaData,
41
+ labels: labelsOptions,
42
+ areaPickerVisible: false,
43
+ submitActive: false,
44
+ visible: false,
45
+ labelValue: '',
46
+ columns: 3,
47
+ },
48
+ privateData: {
49
+ verifyTips: '',
50
+ },
51
+ onLoad(options) {
52
+ const { id } = options;
53
+ this.init(id);
54
+ },
55
+
56
+ onUnload() {
57
+ if (!this.hasSava) {
58
+ rejectAddress();
59
+ }
60
+ },
61
+
62
+ hasSava: false,
63
+
64
+ init(id) {
65
+ if (id) {
66
+ this.getAddressDetail(Number(id));
67
+ }
68
+ },
69
+ getAddressDetail(id) {
70
+ fetchDeliveryAddress(id).then((detail) => {
71
+ this.setData({ locationState: detail }, () => {
72
+ const { isLegal, tips } = this.onVerifyInputLegal();
73
+ this.setData({
74
+ submitActive: isLegal,
75
+ });
76
+ this.privateData.verifyTips = tips;
77
+ });
78
+ });
79
+ },
80
+ onInputValue(e) {
81
+ const { item } = e.currentTarget.dataset;
82
+ if (item === 'address') {
83
+ const { selectedOptions = [] } = e.detail;
84
+ this.setData(
85
+ {
86
+ 'locationState.provinceCode': selectedOptions[0].value,
87
+ 'locationState.provinceName': selectedOptions[0].label,
88
+ 'locationState.cityName': selectedOptions[1].label,
89
+ 'locationState.cityCode': selectedOptions[1].value,
90
+ 'locationState.districtCode': selectedOptions[2].value,
91
+ 'locationState.districtName': selectedOptions[2].label,
92
+ areaPickerVisible: false,
93
+ },
94
+ () => {
95
+ const { isLegal, tips } = this.onVerifyInputLegal();
96
+ this.setData({
97
+ submitActive: isLegal,
98
+ });
99
+ this.privateData.verifyTips = tips;
100
+ },
101
+ );
102
+ } else {
103
+ const { value = '' } = e.detail;
104
+ this.setData(
105
+ {
106
+ [`locationState.${item}`]: value,
107
+ },
108
+ () => {
109
+ const { isLegal, tips } = this.onVerifyInputLegal();
110
+ this.setData({
111
+ submitActive: isLegal,
112
+ });
113
+ this.privateData.verifyTips = tips;
114
+ },
115
+ );
116
+ }
117
+ },
118
+ onPickArea() {
119
+ this.setData({ areaPickerVisible: true });
120
+ },
121
+ onPickLabels(e) {
122
+ const { item } = e.currentTarget.dataset;
123
+ const {
124
+ locationState: { labelIndex = undefined },
125
+ labels = [],
126
+ } = this.data;
127
+ let payload = {
128
+ labelIndex: item,
129
+ addressTag: labels[item].name,
130
+ };
131
+ if (item === labelIndex) {
132
+ payload = { labelIndex: null, addressTag: '' };
133
+ }
134
+ this.setData({
135
+ 'locationState.labelIndex': payload.labelIndex,
136
+ });
137
+ this.triggerEvent('triggerUpdateValue', payload);
138
+ },
139
+ addLabels() {
140
+ this.setData({
141
+ visible: true,
142
+ });
143
+ },
144
+ confirmHandle() {
145
+ const { labels, labelValue } = this.data;
146
+ this.setData({
147
+ visible: false,
148
+ labels: [...labels, { id: labels[labels.length - 1].id + 1, name: labelValue }],
149
+ labelValue: '',
150
+ });
151
+ },
152
+ cancelHandle() {
153
+ this.setData({
154
+ visible: false,
155
+ labelValue: '',
156
+ });
157
+ },
158
+ onCheckDefaultAddress({ detail }) {
159
+ const { value } = detail;
160
+ this.setData({
161
+ 'locationState.isDefault': value,
162
+ });
163
+ },
164
+
165
+ onVerifyInputLegal() {
166
+ const { name, phone, detailAddress, districtName } = this.data.locationState;
167
+ const prefixPhoneReg = String(this.properties.phoneReg || innerPhoneReg);
168
+ const prefixNameReg = String(this.properties.nameReg || innerNameReg);
169
+ const nameRegExp = new RegExp(prefixNameReg);
170
+ const phoneRegExp = new RegExp(prefixPhoneReg);
171
+
172
+ if (!name || !name.trim()) {
173
+ return {
174
+ isLegal: false,
175
+ tips: '请填写收货人',
176
+ };
177
+ }
178
+ if (!nameRegExp.test(name)) {
179
+ return {
180
+ isLegal: false,
181
+ tips: '收货人仅支持输入中文、英文(区分大小写)、数字',
182
+ };
183
+ }
184
+ if (!phone || !phone.trim()) {
185
+ return {
186
+ isLegal: false,
187
+ tips: '请填写手机号',
188
+ };
189
+ }
190
+ if (!phoneRegExp.test(phone)) {
191
+ return {
192
+ isLegal: false,
193
+ tips: '请填写正确的手机号',
194
+ };
195
+ }
196
+ if (!districtName || !districtName.trim()) {
197
+ return {
198
+ isLegal: false,
199
+ tips: '请选择省市区信息',
200
+ };
201
+ }
202
+ if (!detailAddress || !detailAddress.trim()) {
203
+ return {
204
+ isLegal: false,
205
+ tips: '请完善详细地址',
206
+ };
207
+ }
208
+ if (detailAddress && detailAddress.trim().length > 50) {
209
+ return {
210
+ isLegal: false,
211
+ tips: '详细地址不能超过50个字符',
212
+ };
213
+ }
214
+ return {
215
+ isLegal: true,
216
+ tips: '添加成功',
217
+ };
218
+ },
219
+
220
+ builtInSearch({ code, name }) {
221
+ return new Promise((resolve, reject) => {
222
+ wx.getSetting({
223
+ success: (res) => {
224
+ if (res.authSetting[code] === false) {
225
+ wx.showModal({
226
+ title: `获取${name}失败`,
227
+ content: `获取${name}失败,请在【右上角】-小程序【设置】项中,将【${name}】开启。`,
228
+ confirmText: '去设置',
229
+ confirmColor: '#FA550F',
230
+ cancelColor: '取消',
231
+ success(res) {
232
+ if (res.confirm) {
233
+ wx.openSetting({
234
+ success(settinRes) {
235
+ if (settinRes.authSetting[code] === true) {
236
+ resolve();
237
+ } else {
238
+ console.warn('用户未打开权限', name, code);
239
+ reject();
240
+ }
241
+ },
242
+ });
243
+ } else {
244
+ reject();
245
+ }
246
+ },
247
+ fail() {
248
+ reject();
249
+ },
250
+ });
251
+ } else {
252
+ resolve();
253
+ }
254
+ },
255
+ fail() {
256
+ reject();
257
+ },
258
+ });
259
+ });
260
+ },
261
+
262
+ onSearchAddress() {
263
+ this.builtInSearch({ code: 'scope.userLocation', name: '地址位置' }).then(() => {
264
+ wx.chooseLocation({
265
+ success: (res) => {
266
+ if (res.name) {
267
+ this.triggerEvent('addressParse', {
268
+ address: res.address,
269
+ name: res.name,
270
+ latitude: res.latitude,
271
+ longitude: res.longitude,
272
+ });
273
+ } else {
274
+ Toast({
275
+ context: this,
276
+ selector: '#t-toast',
277
+ message: '地点为空,请重新选择',
278
+ icon: '',
279
+ duration: 1000,
280
+ });
281
+ }
282
+ },
283
+ fail: function (res) {
284
+ console.warn(`wx.chooseLocation fail: ${JSON.stringify(res)}`);
285
+ if (res.errMsg !== 'chooseLocation:fail cancel') {
286
+ Toast({
287
+ context: this,
288
+ selector: '#t-toast',
289
+ message: '地点错误,请重新选择',
290
+ icon: '',
291
+ duration: 1000,
292
+ });
293
+ }
294
+ },
295
+ });
296
+ });
297
+ },
298
+ formSubmit() {
299
+ const { submitActive } = this.data;
300
+ if (!submitActive) {
301
+ Toast({
302
+ context: this,
303
+ selector: '#t-toast',
304
+ message: this.privateData.verifyTips,
305
+ icon: '',
306
+ duration: 1000,
307
+ });
308
+ return;
309
+ }
310
+ const { locationState } = this.data;
311
+
312
+ this.hasSava = true;
313
+
314
+ resolveAddress({
315
+ saasId: '88888888',
316
+ uid: `88888888205500`,
317
+ authToken: null,
318
+ id: locationState.addressId,
319
+ addressId: locationState.addressId,
320
+ phone: locationState.phone,
321
+ name: locationState.name,
322
+ countryName: locationState.countryName,
323
+ countryCode: locationState.countryCode,
324
+ provinceName: locationState.provinceName,
325
+ provinceCode: locationState.provinceCode,
326
+ cityName: locationState.cityName,
327
+ cityCode: locationState.cityCode,
328
+ districtName: locationState.districtName,
329
+ districtCode: locationState.districtCode,
330
+ detailAddress: locationState.detailAddress,
331
+ isDefault: locationState.isDefault === 1 ? 1 : 0,
332
+ addressTag: locationState.addressTag,
333
+ latitude: locationState.latitude,
334
+ longitude: locationState.longitude,
335
+ storeId: null,
336
+ });
337
+
338
+ wx.navigateBack({ delta: 1 });
339
+ },
340
+
341
+ getWeixinAddress(e) {
342
+ const { locationState } = this.data;
343
+ const weixinAddress = e.detail;
344
+ this.setData(
345
+ {
346
+ locationState: { ...locationState, ...weixinAddress },
347
+ },
348
+ () => {
349
+ const { isLegal, tips } = this.onVerifyInputLegal();
350
+ this.setData({
351
+ submitActive: isLegal,
352
+ });
353
+ this.privateData.verifyTips = tips;
354
+ },
355
+ );
356
+ },
357
+ });
358
+ </script>
359
+
360
+ <template>
361
+ <view class="address-detail [font-size:30rpx]">
362
+ <view class="divider-line [width:100%] [height:20rpx] [background-color:#f5f5f5]" />
363
+ <t-location
364
+ title="获取微信收获地址"
365
+ isCustomStyle
366
+ t-class="address-detail-wx-location [background:#fff] [padding:24rpx_32rpx] [display:flex] [align-items:center] [justify-content:space-between]"
367
+ bind:change="getWeixinAddress"
368
+ >
369
+ <t-icon class="address-detail-wx-arrow [align-items:flex-end]" name="arrow_forward" prefix="wr" color="#bbb" size="32rpx" />
370
+ </t-location>
371
+ <view class="divider-line [width:100%] [height:20rpx] [background-color:#f5f5f5]" />
372
+ <view class="form-address [&_.map]:[font-size:48rpx] [&_.map]:[margin-left:20rpx] [&_.map]:[color:#9d9d9f] [&_.label-list]:[background:#f5f5f5] [&_.label-list]:[color:#333] [&_.label-list]:[min-width:100rpx] [&_.label-list]:[margin-right:32rpx] [&_.label-list]:[font-size:26rpx] [&_.label-list]:[border:2rpx_solid_transparent] [&_.label-list]:[width:auto] [&_.active-btn]:[color:#fa4126] [&_.active-btn]:[border:2rpx_solid_#fa4126] [&_.active-btn]:[background:rgba(255,_95,_21,_0.04)]">
373
+ <form class="form-content">
374
+ <t-cell-group>
375
+ <t-cell class="form-cell [&_.t-cell__title]:[width:144rpx] [&_.t-cell__title]:[padding-right:32rpx] [&_.t-cell__title]:[flex:none]" t-class-title="t-cell-title" title="收货人" t-class-note="t-cell-note">
376
+ <t-input
377
+ class="t-input"
378
+ slot="note"
379
+ t-class="field-text"
380
+ borderless
381
+ data-item="name"
382
+ maxlength="20"
383
+ type="text"
384
+ value="{{locationState.name}}"
385
+ placeholder="您的姓名"
386
+ bind:change="onInputValue"
387
+ />
388
+ </t-cell>
389
+ <t-cell class="form-cell [&_.t-cell__title]:[width:144rpx] [&_.t-cell__title]:[padding-right:32rpx] [&_.t-cell__title]:[flex:none]" t-class-title="t-cell-title" title="手机号">
390
+ <t-input
391
+ slot="note"
392
+ class="t-input"
393
+ t-class="field-text"
394
+ borderless
395
+ type="number"
396
+ value="{{locationState.phone}}"
397
+ maxlength="11"
398
+ placeholder="联系您的手机号"
399
+ bind:change="onInputValue"
400
+ data-item="phone"
401
+ />
402
+ </t-cell>
403
+ <t-cell class="form-cell [&_.t-cell__title]:[width:144rpx] [&_.t-cell__title]:[padding-right:32rpx] [&_.t-cell__title]:[flex:none]" t-class-title="t-cell-title" title="地区">
404
+ <t-input
405
+ slot="note"
406
+ class="t-input"
407
+ t-class="field-text"
408
+ borderless
409
+ placeholder="省/市/区"
410
+ data-item="address"
411
+ value="{{locationState.provinceName ? locationState.provinceName+'/':'' }}{{locationState.cityName ? locationState.cityName+'/':''}}{{locationState.districtName}}"
412
+ catch:tap="onPickArea"
413
+ disabled
414
+ />
415
+ <t-icon slot="right-icon" t-class="map" prefix="wr" name="location" catch:tap="onSearchAddress" />
416
+ </t-cell>
417
+ <t-cell class="form-cell [&_.t-cell__title]:[width:144rpx] [&_.t-cell__title]:[padding-right:32rpx] [&_.t-cell__title]:[flex:none]" t-class-title="t-cell-title" title="详细地址" bordered="{{false}}">
418
+ <view slot="note" class="textarea__wrapper [width:100%] [&_.t-textarea]:[padding:0]">
419
+ <t-textarea
420
+ slot="note"
421
+ type="text"
422
+ value="{{locationState.detailAddress}}"
423
+ placeholder="门牌号等(例如:10栋1001号)"
424
+ autosize
425
+ bind:change="onInputValue"
426
+ data-item="detailAddress"
427
+ />
428
+ </view>
429
+ </t-cell>
430
+
431
+ <view class="divider-line [width:100%] [height:20rpx] [background-color:#f5f5f5]" />
432
+ <t-cell
433
+ class="form-cell [&_.t-cell__title]:[width:144rpx] [&_.t-cell__title]:[padding-right:32rpx] [&_.t-cell__title]:[flex:none]"
434
+ t-class-note="t-cell-note address__tag"
435
+ t-class-title="t-cell-title"
436
+ title="标签"
437
+ bordered="{{false}}"
438
+ >
439
+ <view class="t-input address-flex-box [display:flex] [flex-wrap:wrap]" slot="note">
440
+ <t-button
441
+ wx:for="{{labels}}"
442
+ wx:for-item="label"
443
+ wx:key="index"
444
+ size="extra-small"
445
+ t-class="label-list {{locationState.labelIndex === index ? 'active-btn':''}}"
446
+ bindtap="onPickLabels"
447
+ data-item="{{index}}"
448
+ >
449
+ {{label.name}}
450
+ </t-button>
451
+ <t-button size="extra-small" t-class="label-list" bindtap="addLabels">
452
+ <t-icon name="add" size="40rpx" color="#bbb" />
453
+ </t-button>
454
+ </view>
455
+ </t-cell>
456
+ <view class="divider-line [width:100%] [height:20rpx] [background-color:#f5f5f5]" />
457
+ <t-cell title="设置为默认收货地址" bordered="{{false}}">
458
+ <t-switch
459
+ value="{{locationState.isDefault}}"
460
+ slot="note"
461
+ colors="{{['#0ABF5B', '#c6c6c6']}}"
462
+ bind:change="onCheckDefaultAddress"
463
+ />
464
+ </t-cell>
465
+ </t-cell-group>
466
+ <view class="submit [box-sizing:border-box] [padding:64rpx_30rpx_88rpx_30rpx] [&_.btn-submit-address]:[background:#fa4126] [&_.btn-submit-address]:[color:#fff]">
467
+ <t-button shape="round" block disabled="{{!submitActive}}" bind:tap="formSubmit"> 保存 </t-button>
468
+ </view>
469
+ </form>
470
+ </view>
471
+ <t-cascader
472
+ data-item="address"
473
+ data-type="1"
474
+ visible="{{areaPickerVisible}}"
475
+ theme="tab"
476
+ options="{{areaData}}"
477
+ value="{{locationState.districtCode}}"
478
+ title="选择地区"
479
+ bind:change="onInputValue"
480
+ ></t-cascader>
481
+ </view>
482
+ <t-dialog
483
+ visible="{{visible}}"
484
+ t-class-confirm="dialog__button-confirm"
485
+ t-class-cancel="dialog__button-cancel"
486
+ title="填写标签名称"
487
+ confirm-btn="确定"
488
+ cancel-btn="取消"
489
+ bind:confirm="confirmHandle"
490
+ bind:cancel="cancelHandle"
491
+ >
492
+ <t-input slot="content" class="dialog__input [margin-top:32rpx] [border-radius:8rpx] [box-sizing:border-box] [--td-input-vertical-padding:12px] [--td-input-bg-color:#f3f3f3]" model:value="{{labelValue}}" placeholder="请输入标签名称" borderless />
493
+ </t-dialog>
494
+ <t-toast id="t-toast" />
495
+ </template>
496
+
497
+ <json>
498
+ {
499
+ "navigationBarTitleText": "添加新地址",
500
+ "usingComponents": {
501
+ "t-textarea": "tdesign-miniprogram/textarea/textarea",
502
+ "t-icon": "tdesign-miniprogram/icon/icon",
503
+ "t-input": "tdesign-miniprogram/input/input",
504
+ "t-button": "tdesign-miniprogram/button/button",
505
+ "t-cell-group": "tdesign-miniprogram/cell-group/cell-group",
506
+ "t-cell": "tdesign-miniprogram/cell/cell",
507
+ "t-toast": "tdesign-miniprogram/toast/toast",
508
+ "t-dialog": "tdesign-miniprogram/dialog/dialog",
509
+ "t-switch": "tdesign-miniprogram/switch/switch",
510
+ "t-location": "/pages/user/components/t-location/index",
511
+ "t-cascader": "tdesign-miniprogram/cascader/cascader"
512
+ }
513
+ }
514
+ </json>