vant 2.13.6 → 2.13.8

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.
@@ -0,0 +1,7 @@
1
+ ### [v2.13.8](https://github.com/vant-ui/vant/compare/v2.13.7...v2.13.8)
2
+
3
+ `2025-05-20`
4
+
5
+ **Bug Fixes**
6
+
7
+ - Sku: set properties when sku change [#13483](https://github.com/vant-ui/vant/issues/13483)
package/es/index.js CHANGED
@@ -87,7 +87,7 @@ import Tag from './tag';
87
87
  import Toast from './toast';
88
88
  import TreeSelect from './tree-select';
89
89
  import Uploader from './uploader';
90
- var version = '2.13.2';
90
+ var version = '2.13.8';
91
91
 
92
92
  function install(Vue) {
93
93
  var components = [ActionSheet, AddressEdit, AddressList, Area, Badge, Button, Calendar, Card, Cascader, Cell, CellGroup, Checkbox, CheckboxGroup, Circle, Col, Collapse, CollapseItem, ContactCard, ContactEdit, ContactList, CountDown, Coupon, CouponCell, CouponList, DatetimePicker, Dialog, Divider, DropdownItem, DropdownMenu, Empty, Field, Form, GoodsAction, GoodsActionButton, GoodsActionIcon, Grid, GridItem, Icon, Image, ImagePreview, IndexAnchor, IndexBar, Info, List, Loading, Locale, NavBar, NoticeBar, Notify, NumberKeyboard, Overlay, Pagination, Panel, PasswordInput, Picker, Popover, Popup, Progress, PullRefresh, Radio, RadioGroup, Rate, Row, Search, ShareSheet, Sidebar, SidebarItem, Skeleton, Sku, Slider, Step, Stepper, Steps, Sticky, SubmitBar, Swipe, SwipeCell, SwipeItem, Switch, SwitchCell, Tab, Tabbar, TabbarItem, Tabs, Tag, Toast, TreeSelect, Uploader];
package/es/sku/Sku.js CHANGED
@@ -30,6 +30,7 @@ export default createComponent({
30
30
  lazyLoad: Boolean,
31
31
  hideStock: Boolean,
32
32
  properties: Array,
33
+ skuProperties: Array,
33
34
  addCartText: String,
34
35
  stepperTitle: String,
35
36
  getContainer: [String, Function],
@@ -118,7 +119,8 @@ export default createComponent({
118
119
  selectedSku: {},
119
120
  selectedProp: {},
120
121
  selectedNum: 1,
121
- show: this.value
122
+ show: this.value,
123
+ currentSkuProperties: []
122
124
  };
123
125
  },
124
126
  watch: {
@@ -151,6 +153,9 @@ export default createComponent({
151
153
  }
152
154
  },
153
155
  computed: {
156
+ isSkuProperties: function isSkuProperties() {
157
+ return this.skuProperties && this.skuProperties.length;
158
+ },
154
159
  skuGroupClass: function skuGroupClass() {
155
160
  return ['van-sku-group-container', {
156
161
  'van-sku-group-container--hide-soldout': !this.showSoldoutSku
@@ -193,7 +198,7 @@ export default createComponent({
193
198
  selectedSkuComb: function selectedSkuComb() {
194
199
  var skuComb = null;
195
200
 
196
- if (this.isSkuCombSelected) {
201
+ if (this.isSkuCombSelected || this.isSkuProperties) {
197
202
  if (this.hasSku) {
198
203
  skuComb = getSkuComb(this.skuList, this.selectedSku);
199
204
  } else {
@@ -202,7 +207,10 @@ export default createComponent({
202
207
  price: Math.round(this.sku.price * 100),
203
208
  stock_num: this.sku.stock_num
204
209
  };
205
- }
210
+ } // 更新当前规格属性数据
211
+
212
+
213
+ this.setCurrentSkuProperties(skuComb ? skuComb.id : null);
206
214
 
207
215
  if (skuComb) {
208
216
  skuComb.properties = getSelectedProperties(this.propList, this.selectedProp);
@@ -242,7 +250,7 @@ export default createComponent({
242
250
  return this.sku.list || [];
243
251
  },
244
252
  propList: function propList() {
245
- return this.properties || [];
253
+ return this.isSkuProperties ? this.currentSkuProperties : this.properties || [];
246
254
  },
247
255
  imageList: function imageList() {
248
256
  var imageList = [this.goods.picture];
@@ -332,6 +340,14 @@ export default createComponent({
332
340
  this.$emit('after-sku-create', skuEventBus);
333
341
  },
334
342
  methods: {
343
+ setCurrentSkuProperties: function setCurrentSkuProperties(id) {
344
+ var _this$skuProperties;
345
+
346
+ var target = ((_this$skuProperties = this.skuProperties) == null ? void 0 : _this$skuProperties.find(function (item) {
347
+ return item.sku_id === id;
348
+ })) || {};
349
+ this.currentSkuProperties = target.properties || [];
350
+ },
335
351
  resetStepper: function resetStepper() {
336
352
  var skuStepper = this.$refs.skuStepper;
337
353
  var selectedNum = this.initialSku.selectedNum;
@@ -465,13 +481,22 @@ export default createComponent({
465
481
  var _extends2, _extends3;
466
482
 
467
483
  // 点击已选中的sku时则取消选中
468
- this.selectedSku = this.selectedSku[skuValue.skuKeyStr] === skuValue.id ? _extends({}, this.selectedSku, (_extends2 = {}, _extends2[skuValue.skuKeyStr] = UNSELECTED_SKU_VALUE_ID, _extends2)) : _extends({}, this.selectedSku, (_extends3 = {}, _extends3[skuValue.skuKeyStr] = skuValue.id, _extends3));
484
+ this.selectedSku = this.selectedSku[skuValue.skuKeyStr] === skuValue.id ? _extends({}, this.selectedSku, (_extends2 = {}, _extends2[skuValue.skuKeyStr] = UNSELECTED_SKU_VALUE_ID, _extends2)) : _extends({}, this.selectedSku, (_extends3 = {}, _extends3[skuValue.skuKeyStr] = skuValue.id, _extends3)); // 切换sku清空当前选择属性数据,触发prop-clear
485
+
486
+ if (this.isSkuProperties) {
487
+ this.selectedProp = {};
488
+ this.onPropClear();
489
+ }
490
+
469
491
  this.$emit('sku-selected', {
470
492
  skuValue: skuValue,
471
493
  selectedSku: this.selectedSku,
472
494
  selectedSkuComb: this.selectedSkuComb
473
495
  });
474
496
  },
497
+ onPropClear: function onPropClear() {
498
+ this.$emit('sku-prop-clear');
499
+ },
475
500
  onPropSelect: function onPropSelect(propValue) {
476
501
  var _extends4;
477
502
 
package/lib/index.js CHANGED
@@ -361,7 +361,7 @@ exports.TreeSelect = _treeSelect.default;
361
361
  var _uploader = _interopRequireDefault(require("./uploader"));
362
362
 
363
363
  exports.Uploader = _uploader.default;
364
- var version = '2.13.2';
364
+ var version = '2.13.8';
365
365
  exports.version = version;
366
366
 
367
367
  function install(Vue) {
package/lib/sku/Sku.js CHANGED
@@ -54,6 +54,7 @@ var _default2 = createComponent({
54
54
  lazyLoad: Boolean,
55
55
  hideStock: Boolean,
56
56
  properties: Array,
57
+ skuProperties: Array,
57
58
  addCartText: String,
58
59
  stepperTitle: String,
59
60
  getContainer: [String, Function],
@@ -142,7 +143,8 @@ var _default2 = createComponent({
142
143
  selectedSku: {},
143
144
  selectedProp: {},
144
145
  selectedNum: 1,
145
- show: this.value
146
+ show: this.value,
147
+ currentSkuProperties: []
146
148
  };
147
149
  },
148
150
  watch: {
@@ -175,6 +177,9 @@ var _default2 = createComponent({
175
177
  }
176
178
  },
177
179
  computed: {
180
+ isSkuProperties: function isSkuProperties() {
181
+ return this.skuProperties && this.skuProperties.length;
182
+ },
178
183
  skuGroupClass: function skuGroupClass() {
179
184
  return ['van-sku-group-container', {
180
185
  'van-sku-group-container--hide-soldout': !this.showSoldoutSku
@@ -217,7 +222,7 @@ var _default2 = createComponent({
217
222
  selectedSkuComb: function selectedSkuComb() {
218
223
  var skuComb = null;
219
224
 
220
- if (this.isSkuCombSelected) {
225
+ if (this.isSkuCombSelected || this.isSkuProperties) {
221
226
  if (this.hasSku) {
222
227
  skuComb = (0, _skuHelper.getSkuComb)(this.skuList, this.selectedSku);
223
228
  } else {
@@ -226,7 +231,10 @@ var _default2 = createComponent({
226
231
  price: Math.round(this.sku.price * 100),
227
232
  stock_num: this.sku.stock_num
228
233
  };
229
- }
234
+ } // 更新当前规格属性数据
235
+
236
+
237
+ this.setCurrentSkuProperties(skuComb ? skuComb.id : null);
230
238
 
231
239
  if (skuComb) {
232
240
  skuComb.properties = (0, _skuHelper.getSelectedProperties)(this.propList, this.selectedProp);
@@ -266,7 +274,7 @@ var _default2 = createComponent({
266
274
  return this.sku.list || [];
267
275
  },
268
276
  propList: function propList() {
269
- return this.properties || [];
277
+ return this.isSkuProperties ? this.currentSkuProperties : this.properties || [];
270
278
  },
271
279
  imageList: function imageList() {
272
280
  var imageList = [this.goods.picture];
@@ -356,6 +364,14 @@ var _default2 = createComponent({
356
364
  this.$emit('after-sku-create', skuEventBus);
357
365
  },
358
366
  methods: {
367
+ setCurrentSkuProperties: function setCurrentSkuProperties(id) {
368
+ var _this$skuProperties;
369
+
370
+ var target = ((_this$skuProperties = this.skuProperties) == null ? void 0 : _this$skuProperties.find(function (item) {
371
+ return item.sku_id === id;
372
+ })) || {};
373
+ this.currentSkuProperties = target.properties || [];
374
+ },
359
375
  resetStepper: function resetStepper() {
360
376
  var skuStepper = this.$refs.skuStepper;
361
377
  var selectedNum = this.initialSku.selectedNum;
@@ -489,13 +505,22 @@ var _default2 = createComponent({
489
505
  var _extends2, _extends3;
490
506
 
491
507
  // 点击已选中的sku时则取消选中
492
- this.selectedSku = this.selectedSku[skuValue.skuKeyStr] === skuValue.id ? (0, _extends5.default)({}, this.selectedSku, (_extends2 = {}, _extends2[skuValue.skuKeyStr] = _constants.UNSELECTED_SKU_VALUE_ID, _extends2)) : (0, _extends5.default)({}, this.selectedSku, (_extends3 = {}, _extends3[skuValue.skuKeyStr] = skuValue.id, _extends3));
508
+ this.selectedSku = this.selectedSku[skuValue.skuKeyStr] === skuValue.id ? (0, _extends5.default)({}, this.selectedSku, (_extends2 = {}, _extends2[skuValue.skuKeyStr] = _constants.UNSELECTED_SKU_VALUE_ID, _extends2)) : (0, _extends5.default)({}, this.selectedSku, (_extends3 = {}, _extends3[skuValue.skuKeyStr] = skuValue.id, _extends3)); // 切换sku清空当前选择属性数据,触发prop-clear
509
+
510
+ if (this.isSkuProperties) {
511
+ this.selectedProp = {};
512
+ this.onPropClear();
513
+ }
514
+
493
515
  this.$emit('sku-selected', {
494
516
  skuValue: skuValue,
495
517
  selectedSku: this.selectedSku,
496
518
  selectedSkuComb: this.selectedSkuComb
497
519
  });
498
520
  },
521
+ onPropClear: function onPropClear() {
522
+ this.$emit('sku-prop-clear');
523
+ },
499
524
  onPropSelect: function onPropSelect(propValue) {
500
525
  var _extends4;
501
526
 
package/lib/vant.js CHANGED
@@ -21088,6 +21088,7 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21088
21088
  lazyLoad: Boolean,
21089
21089
  hideStock: Boolean,
21090
21090
  properties: Array,
21091
+ skuProperties: Array,
21091
21092
  addCartText: String,
21092
21093
  stepperTitle: String,
21093
21094
  getContainer: [String, Function],
@@ -21176,7 +21177,8 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21176
21177
  selectedSku: {},
21177
21178
  selectedProp: {},
21178
21179
  selectedNum: 1,
21179
- show: this.value
21180
+ show: this.value,
21181
+ currentSkuProperties: []
21180
21182
  };
21181
21183
  },
21182
21184
  watch: {
@@ -21209,6 +21211,9 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21209
21211
  }
21210
21212
  },
21211
21213
  computed: {
21214
+ isSkuProperties: function isSkuProperties() {
21215
+ return this.skuProperties && this.skuProperties.length;
21216
+ },
21212
21217
  skuGroupClass: function skuGroupClass() {
21213
21218
  return ['van-sku-group-container', {
21214
21219
  'van-sku-group-container--hide-soldout': !this.showSoldoutSku
@@ -21251,7 +21256,7 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21251
21256
  selectedSkuComb: function selectedSkuComb() {
21252
21257
  var skuComb = null;
21253
21258
 
21254
- if (this.isSkuCombSelected) {
21259
+ if (this.isSkuCombSelected || this.isSkuProperties) {
21255
21260
  if (this.hasSku) {
21256
21261
  skuComb = getSkuComb(this.skuList, this.selectedSku);
21257
21262
  } else {
@@ -21260,7 +21265,10 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21260
21265
  price: Math.round(this.sku.price * 100),
21261
21266
  stock_num: this.sku.stock_num
21262
21267
  };
21263
- }
21268
+ } // 更新当前规格属性数据
21269
+
21270
+
21271
+ this.setCurrentSkuProperties(skuComb ? skuComb.id : null);
21264
21272
 
21265
21273
  if (skuComb) {
21266
21274
  skuComb.properties = sku_helper_getSelectedProperties(this.propList, this.selectedProp);
@@ -21300,7 +21308,7 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21300
21308
  return this.sku.list || [];
21301
21309
  },
21302
21310
  propList: function propList() {
21303
- return this.properties || [];
21311
+ return this.isSkuProperties ? this.currentSkuProperties : this.properties || [];
21304
21312
  },
21305
21313
  imageList: function imageList() {
21306
21314
  var imageList = [this.goods.picture];
@@ -21390,6 +21398,14 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21390
21398
  this.$emit('after-sku-create', skuEventBus);
21391
21399
  },
21392
21400
  methods: {
21401
+ setCurrentSkuProperties: function setCurrentSkuProperties(id) {
21402
+ var _this$skuProperties;
21403
+
21404
+ var target = ((_this$skuProperties = this.skuProperties) == null ? void 0 : _this$skuProperties.find(function (item) {
21405
+ return item.sku_id === id;
21406
+ })) || {};
21407
+ this.currentSkuProperties = target.properties || [];
21408
+ },
21393
21409
  resetStepper: function resetStepper() {
21394
21410
  var skuStepper = this.$refs.skuStepper;
21395
21411
  var selectedNum = this.initialSku.selectedNum;
@@ -21523,13 +21539,22 @@ var Sku_QUOTA_LIMIT = LIMIT_TYPE.QUOTA_LIMIT;
21523
21539
  var _extends2, _extends3; // 点击已选中的sku时则取消选中
21524
21540
 
21525
21541
 
21526
- this.selectedSku = this.selectedSku[skuValue.skuKeyStr] === skuValue.id ? _extends({}, this.selectedSku, (_extends2 = {}, _extends2[skuValue.skuKeyStr] = UNSELECTED_SKU_VALUE_ID, _extends2)) : _extends({}, this.selectedSku, (_extends3 = {}, _extends3[skuValue.skuKeyStr] = skuValue.id, _extends3));
21542
+ this.selectedSku = this.selectedSku[skuValue.skuKeyStr] === skuValue.id ? _extends({}, this.selectedSku, (_extends2 = {}, _extends2[skuValue.skuKeyStr] = UNSELECTED_SKU_VALUE_ID, _extends2)) : _extends({}, this.selectedSku, (_extends3 = {}, _extends3[skuValue.skuKeyStr] = skuValue.id, _extends3)); // 切换sku清空当前选择属性数据,触发prop-clear
21543
+
21544
+ if (this.isSkuProperties) {
21545
+ this.selectedProp = {};
21546
+ this.onPropClear();
21547
+ }
21548
+
21527
21549
  this.$emit('sku-selected', {
21528
21550
  skuValue: skuValue,
21529
21551
  selectedSku: this.selectedSku,
21530
21552
  selectedSkuComb: this.selectedSkuComb
21531
21553
  });
21532
21554
  },
21555
+ onPropClear: function onPropClear() {
21556
+ this.$emit('sku-prop-clear');
21557
+ },
21533
21558
  onPropSelect: function onPropSelect(propValue) {
21534
21559
  var _extends4;
21535
21560
 
@@ -23204,7 +23229,7 @@ TreeSelect.props = {
23204
23229
 
23205
23230
 
23206
23231
 
23207
- var version = '2.13.2';
23232
+ var version = '2.13.8';
23208
23233
 
23209
23234
  function install(Vue) {
23210
23235
  var components = [action_sheet, address_edit, address_list, es_area, badge, es_button, calendar, card, cascader, cell, cell_group, es_checkbox, checkbox_group, circle, col, collapse, collapse_item, contact_card, contact_edit, contact_list, count_down, es_coupon, coupon_cell, coupon_list, datetime_picker, dialog, divider, dropdown_item, dropdown_menu, empty, es_field, es_form, goods_action, goods_action_button, goods_action_icon, grid, grid_item, es_icon, es_image, image_preview, index_anchor, index_bar, es_info, es_list, es_loading, locale["a" /* default */], nav_bar, notice_bar, notify, number_keyboard, es_overlay, pagination, panel, password_input, es_picker, popover, popup, es_progress, pull_refresh, es_radio, radio_group, es_rate, row, search, share_sheet, sidebar, sidebar_item, skeleton, es_sku, slider, es_step, stepper, steps, es_sticky, submit_bar, swipe, swipe_cell, swipe_item, es_switch, switch_cell, tab, tabbar, tabbar_item, tabs, es_tag, es_toast, tree_select, uploader];