@pisell/pisellos 0.0.177 → 0.0.179

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.
@@ -54,6 +54,7 @@ export declare const getProductOriginTotalPrice: (params: {
54
54
  bundle?: any;
55
55
  options?: any;
56
56
  num?: number;
57
+ discounts?: any[];
57
58
  }) => number | undefined;
58
59
  /**
59
60
  * 格式化套餐规格信息
@@ -71,7 +71,8 @@ export var formatProductToCartItem = function formatProductToCartItem(params) {
71
71
  product: product,
72
72
  bundle: bundle,
73
73
  options: options,
74
- num: num
74
+ num: num,
75
+ discounts: discounts
75
76
  });
76
77
  cartItem.image = product === null || product === void 0 ? void 0 : product.cover;
77
78
  cartItem.like_status = 'common';
@@ -206,19 +207,11 @@ export var getProductTotalPrice = function getProductTotalPrice(params) {
206
207
  export var getProductOriginTotalPrice = function getProductOriginTotalPrice(params) {
207
208
  var product = params.product,
208
209
  bundle = params.bundle,
209
- options = params.options;
210
+ options = params.options,
211
+ discounts = params.discounts;
210
212
  var num = (params === null || params === void 0 ? void 0 : params.num) || 1;
211
213
  var price = Number(product.original_price);
212
-
213
- // if (product.discount_list?.length) {
214
- // price = product.discount_list.reduce((accumulator: any, currentValue: any) => {
215
- // return (
216
- // accumulator + Number(currentValue.price) * Number(currentValue.num)
217
- // );
218
- // }, price);
219
- // }
220
-
221
- if (isNaN(price) || price === 0) {
214
+ if ((isNaN(price) || price === 0) && !(discounts !== null && discounts !== void 0 && discounts.length)) {
222
215
  return undefined;
223
216
  }
224
217
  if (bundle !== null && bundle !== void 0 && bundle.length) {
@@ -154,7 +154,7 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
154
154
  return n.date === item.date;
155
155
  });
156
156
  if (currentItemIndex !== -1) {
157
- var _item$resource;
157
+ var _item$resource, _currentItem$resource3;
158
158
  var currentItem = currentDateList[currentItemIndex];
159
159
  // 看那一天的数据有没有相同的,把不同的资源合并进去即可
160
160
  var newResource = (_item$resource = item.resource) === null || _item$resource === void 0 ? void 0 : _item$resource.filter(function (n) {
@@ -163,6 +163,16 @@ export var DateModule = /*#__PURE__*/function (_BaseModule) {
163
163
  return m.id === n.id;
164
164
  }));
165
165
  });
166
+ // 如果有相同的资源,则使用 item 中的新的resource.times,而不是 currentItem 中的
167
+ (_currentItem$resource3 = currentItem.resource) === null || _currentItem$resource3 === void 0 || _currentItem$resource3.forEach(function (n) {
168
+ var _item$resource2;
169
+ var newResource = (_item$resource2 = item.resource) === null || _item$resource2 === void 0 ? void 0 : _item$resource2.find(function (m) {
170
+ return m.id === n.id;
171
+ });
172
+ if (newResource) {
173
+ n.times = newResource.times;
174
+ }
175
+ });
166
176
  currentItem.resource = [].concat(_toConsumableArray(currentItem.resource || []), _toConsumableArray(newResource || []));
167
177
  currentDateList[currentItemIndex] = currentItem;
168
178
  } else {
@@ -54,6 +54,7 @@ export declare const getProductOriginTotalPrice: (params: {
54
54
  bundle?: any;
55
55
  options?: any;
56
56
  num?: number;
57
+ discounts?: any[];
57
58
  }) => number | undefined;
58
59
  /**
59
60
  * 格式化套餐规格信息
@@ -82,7 +82,8 @@ var formatProductToCartItem = (params) => {
82
82
  product,
83
83
  bundle,
84
84
  options,
85
- num
85
+ num,
86
+ discounts
86
87
  });
87
88
  cartItem.image = product == null ? void 0 : product.cover;
88
89
  cartItem.like_status = "common";
@@ -189,10 +190,10 @@ var getProductTotalPrice = (params) => {
189
190
  return price;
190
191
  };
191
192
  var getProductOriginTotalPrice = (params) => {
192
- const { product, bundle, options } = params;
193
+ const { product, bundle, options, discounts } = params;
193
194
  const num = (params == null ? void 0 : params.num) || 1;
194
195
  let price = Number(product.original_price);
195
- if (isNaN(price) || price === 0) {
196
+ if ((isNaN(price) || price === 0) && !(discounts == null ? void 0 : discounts.length)) {
196
197
  return void 0;
197
198
  }
198
199
  if (bundle == null ? void 0 : bundle.length) {
@@ -95,7 +95,7 @@ var DateModule = class extends import_BaseModule.BaseModule {
95
95
  setDateList(dateList) {
96
96
  const currentDateList = (0, import_cloneDeep.default)(this.store.dateList) || [];
97
97
  dateList.forEach((item) => {
98
- var _a;
98
+ var _a, _b;
99
99
  const currentItemIndex = currentDateList.findIndex(
100
100
  (n) => n.date === item.date
101
101
  );
@@ -107,6 +107,13 @@ var DateModule = class extends import_BaseModule.BaseModule {
107
107
  return !((_a2 = currentItem.resource) == null ? void 0 : _a2.some((m) => m.id === n.id));
108
108
  }
109
109
  );
110
+ (_b = currentItem.resource) == null ? void 0 : _b.forEach((n) => {
111
+ var _a2;
112
+ const newResource2 = (_a2 = item.resource) == null ? void 0 : _a2.find((m) => m.id === n.id);
113
+ if (newResource2) {
114
+ n.times = newResource2.times;
115
+ }
116
+ });
110
117
  currentItem.resource = [
111
118
  ...currentItem.resource || [],
112
119
  ...newResource || []
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "@pisell/pisellos",
4
- "version": "0.0.177",
4
+ "version": "0.0.179",
5
5
  "description": "一个可扩展的前端模块化SDK框架,支持插件系统",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",