vant 4.8.9 → 4.8.10

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.
package/lib/vant.js CHANGED
@@ -9079,44 +9079,37 @@
9079
9079
  default: -1
9080
9080
  }
9081
9081
  };
9082
+ const getValue = (coupon) => {
9083
+ const {
9084
+ value,
9085
+ denominations
9086
+ } = coupon;
9087
+ if (isDef(value)) {
9088
+ return value;
9089
+ }
9090
+ if (isDef(denominations)) {
9091
+ return denominations;
9092
+ }
9093
+ return 0;
9094
+ };
9082
9095
  function formatValue({
9083
9096
  coupons,
9084
9097
  chosenCoupon,
9085
9098
  currency
9086
9099
  }) {
9087
- const getValue = (coupon) => {
9088
- let value2 = 0;
9089
- const {
9090
- value: couponValue,
9091
- denominations
9092
- } = coupon;
9093
- if (isDef(coupon.value)) {
9094
- value2 = couponValue;
9095
- } else if (isDef(coupon.denominations)) {
9096
- value2 = denominations;
9097
- }
9098
- return value2;
9099
- };
9100
- let value = 0, isExist = false;
9101
- if (Array.isArray(chosenCoupon)) {
9102
- chosenCoupon.forEach((i) => {
9103
- const coupon = coupons[+i];
9104
- if (coupon) {
9105
- isExist = true;
9106
- value += getValue(coupon);
9107
- }
9108
- });
9109
- } else {
9110
- const coupon = coupons[+chosenCoupon];
9100
+ let value = 0;
9101
+ let isExist = false;
9102
+ (Array.isArray(chosenCoupon) ? chosenCoupon : [chosenCoupon]).forEach((i) => {
9103
+ const coupon = coupons[+i];
9111
9104
  if (coupon) {
9112
9105
  isExist = true;
9113
- value = getValue(coupon);
9106
+ value += getValue(coupon);
9114
9107
  }
9108
+ });
9109
+ if (isExist) {
9110
+ return `-${currency} ${(value / 100).toFixed(2)}`;
9115
9111
  }
9116
- if (!isExist) {
9117
- return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
9118
- }
9119
- return `-${currency} ${(value / 100).toFixed(2)}`;
9112
+ return coupons.length === 0 ? t$a("noCoupon") : t$a("count", coupons.length);
9120
9113
  }
9121
9114
  var stdin_default$_ = vue.defineComponent({
9122
9115
  name: name$R,
@@ -9461,7 +9454,6 @@
9461
9454
  currency: makeStringProp("¥"),
9462
9455
  showCount: truthProp,
9463
9456
  emptyImage: String,
9464
- chosenCoupon: [Number, Array],
9465
9457
  enabledTitle: String,
9466
9458
  disabledTitle: String,
9467
9459
  disabledCoupons: makeArrayProp(),
@@ -9473,7 +9465,11 @@
9473
9465
  exchangeButtonText: String,
9474
9466
  displayedCouponIndex: makeNumberProp(-1),
9475
9467
  exchangeButtonLoading: Boolean,
9476
- exchangeButtonDisabled: Boolean
9468
+ exchangeButtonDisabled: Boolean,
9469
+ chosenCoupon: {
9470
+ type: [Number, Array],
9471
+ default: -1
9472
+ }
9477
9473
  };
9478
9474
  var stdin_default$Y = vue.defineComponent({
9479
9475
  name: name$P,
@@ -9541,18 +9537,16 @@
9541
9537
  };
9542
9538
  const renderCouponTab = () => {
9543
9539
  const {
9544
- coupons
9540
+ coupons,
9541
+ chosenCoupon
9545
9542
  } = props2;
9546
9543
  const count = props2.showCount ? ` (${coupons.length})` : "";
9547
9544
  const title = (props2.enabledTitle || t$9("enable")) + count;
9548
- const getChosenCoupon = (chosenCoupon = [], value = 0) => {
9549
- const unrefChosenCoupon = vue.unref(chosenCoupon);
9550
- const index = unrefChosenCoupon.indexOf(value);
9551
- if (index === -1) {
9552
- return [...unrefChosenCoupon, value];
9545
+ const updateChosenCoupon = (currentValues = [], value = 0) => {
9546
+ if (currentValues.includes(value)) {
9547
+ return currentValues.filter((item) => item !== value);
9553
9548
  }
9554
- unrefChosenCoupon.splice(index, 1);
9555
- return [...unrefChosenCoupon];
9549
+ return [...currentValues, value];
9556
9550
  };
9557
9551
  return vue.createVNode(Tab, {
9558
9552
  "title": title
@@ -9570,9 +9564,9 @@
9570
9564
  "key": coupon.id,
9571
9565
  "ref": setCouponRefs(index),
9572
9566
  "coupon": coupon,
9573
- "chosen": Array.isArray(props2.chosenCoupon) ? props2.chosenCoupon.includes(index) : index === props2.chosenCoupon,
9567
+ "chosen": Array.isArray(chosenCoupon) ? chosenCoupon.includes(index) : index === chosenCoupon,
9574
9568
  "currency": props2.currency,
9575
- "onClick": () => emit("change", Array.isArray(props2.chosenCoupon) ? getChosenCoupon(props2.chosenCoupon, index) : index)
9569
+ "onClick": () => emit("change", Array.isArray(chosenCoupon) ? updateChosenCoupon(chosenCoupon, index) : index)
9576
9570
  }, null)), !coupons.length && renderEmpty(), (_a = slots["list-footer"]) == null ? void 0 : _a.call(slots)])];
9577
9571
  }
9578
9572
  });
@@ -9674,7 +9668,7 @@
9674
9668
  const isMaxYear = (year) => year === props2.maxDate.getFullYear();
9675
9669
  const isMinMonth = (month) => month === props2.minDate.getMonth() + 1;
9676
9670
  const isMaxMonth = (month) => month === props2.maxDate.getMonth() + 1;
9677
- const getValue = (type) => {
9671
+ const getValue2 = (type) => {
9678
9672
  const {
9679
9673
  minDate,
9680
9674
  columnsType
@@ -9694,14 +9688,14 @@
9694
9688
  }
9695
9689
  };
9696
9690
  const genMonthOptions = () => {
9697
- const year = getValue("year");
9691
+ const year = getValue2("year");
9698
9692
  const minMonth = isMinYear(year) ? props2.minDate.getMonth() + 1 : 1;
9699
9693
  const maxMonth = isMaxYear(year) ? props2.maxDate.getMonth() + 1 : 12;
9700
9694
  return genOptions(minMonth, maxMonth, "month", props2.formatter, props2.filter);
9701
9695
  };
9702
9696
  const genDayOptions = () => {
9703
- const year = getValue("year");
9704
- const month = getValue("month");
9697
+ const year = getValue2("year");
9698
+ const month = getValue2("month");
9705
9699
  const minDate = isMinYear(year) && isMinMonth(month) ? props2.minDate.getDate() : 1;
9706
9700
  const maxDate = isMaxYear(year) && isMaxMonth(month) ? props2.maxDate.getDate() : getMonthEndDay(year, month);
9707
9701
  return genOptions(minDate, maxDate, "day", props2.formatter, props2.filter);
@@ -18086,7 +18080,7 @@
18086
18080
  });
18087
18081
  }
18088
18082
  };
18089
- const version = "4.8.9";
18083
+ const version = "4.8.10";
18090
18084
  function install(app) {
18091
18085
  const components = [
18092
18086
  ActionBar,