@pisell/pisellos 0.0.26 → 0.0.27
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/dist/modules/Cart/index.js +7 -9
- package/dist/solution/BookingByStep/index.d.ts +2 -0
- package/dist/solution/BookingByStep/index.js +61 -38
- package/dist/solution/ShopDiscount/index.js +0 -1
- package/lib/modules/Cart/index.js +0 -2
- package/lib/solution/BookingByStep/index.d.ts +2 -0
- package/lib/solution/BookingByStep/index.js +8 -3
- package/lib/solution/ShopDiscount/index.js +0 -1
- package/package.json +1 -1
|
@@ -61,7 +61,6 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
61
61
|
case 0:
|
|
62
62
|
this.core = core;
|
|
63
63
|
this.store = options.store;
|
|
64
|
-
debugger;
|
|
65
64
|
if (Array.isArray((_options$initialState = options.initialState) === null || _options$initialState === void 0 ? void 0 : _options$initialState.list)) {
|
|
66
65
|
this.store.list = options.initialState.list;
|
|
67
66
|
this.core.effects.emit("".concat(this.name, ":changed"), this.store.list);
|
|
@@ -80,20 +79,20 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
80
79
|
this.request = core.getPlugin("request");
|
|
81
80
|
this.window = core.getPlugin("window");
|
|
82
81
|
if (this.request) {
|
|
83
|
-
_context.next =
|
|
82
|
+
_context.next = 9;
|
|
84
83
|
break;
|
|
85
84
|
}
|
|
86
85
|
throw new Error("购物车模块需要 request 插件支持");
|
|
87
|
-
case
|
|
86
|
+
case 9:
|
|
88
87
|
if (this.window) {
|
|
89
|
-
_context.next =
|
|
88
|
+
_context.next = 11;
|
|
90
89
|
break;
|
|
91
90
|
}
|
|
92
91
|
throw new Error("购物车模块需要 window 插件支持");
|
|
93
|
-
case
|
|
92
|
+
case 11:
|
|
94
93
|
// this.store.temp = {};
|
|
95
94
|
console.log("[CartModule] 初始化完成");
|
|
96
|
-
case
|
|
95
|
+
case 12:
|
|
97
96
|
case "end":
|
|
98
97
|
return _context.stop();
|
|
99
98
|
}
|
|
@@ -116,7 +115,6 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
116
115
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
117
116
|
while (1) switch (_context2.prev = _context2.next) {
|
|
118
117
|
case 0:
|
|
119
|
-
debugger;
|
|
120
118
|
account = params.account, product = params.product, bundle = params.bundle, options = params.options; // 生成一个唯一的 ID
|
|
121
119
|
cartItem = {
|
|
122
120
|
_id: getUniqueId(),
|
|
@@ -143,9 +141,9 @@ export var CartModule = /*#__PURE__*/function (_BaseModule) {
|
|
|
143
141
|
this.store.list = items;
|
|
144
142
|
|
|
145
143
|
// 触发事件
|
|
146
|
-
_context2.next =
|
|
144
|
+
_context2.next = 8;
|
|
147
145
|
return this.core.effects.emit("".concat(this.name, ":onAddItem"), cartItem);
|
|
148
|
-
case
|
|
146
|
+
case 8:
|
|
149
147
|
case "end":
|
|
150
148
|
return _context2.stop();
|
|
151
149
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore } from "../../types";
|
|
2
2
|
import { BaseModule } from "../../modules/BaseModule";
|
|
3
|
+
import { Response } from "../../plugins";
|
|
3
4
|
import { BookingByStepState } from "./types";
|
|
4
5
|
import { CartItem, IUpdateItemParams, ProductData } from "../../modules";
|
|
5
6
|
import { Account } from "../../modules/Account/types";
|
|
@@ -59,6 +60,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
59
60
|
getProducts(): Promise<ProductData[]>;
|
|
60
61
|
setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
|
|
61
62
|
generateCartData(): Promise<void>;
|
|
63
|
+
getFreeProduct(id: string | number): Promise<Response<any>>;
|
|
62
64
|
submitOrder(): Promise<void>;
|
|
63
65
|
pay(): Promise<void>;
|
|
64
66
|
getPayInfo(): Promise<void>;
|
|
@@ -75,8 +75,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
75
75
|
}
|
|
76
76
|
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
77
77
|
case 9:
|
|
78
|
-
debugger;
|
|
79
|
-
|
|
80
78
|
// 如果有传 cacheid,默认需要收集上面这些模块里用户操作选中的数据
|
|
81
79
|
// 并且在上面 registerModule 的时候,读取 sessionStroage 里的数据,塞进默认值
|
|
82
80
|
targetCacheData = {};
|
|
@@ -107,7 +105,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
107
105
|
}
|
|
108
106
|
});
|
|
109
107
|
this.core.effects.emit(BookingByStepHooks.onInited, {});
|
|
110
|
-
case
|
|
108
|
+
case 14:
|
|
111
109
|
case "end":
|
|
112
110
|
return _context.stop();
|
|
113
111
|
}
|
|
@@ -533,17 +531,42 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
533
531
|
return _generateCartData.apply(this, arguments);
|
|
534
532
|
}
|
|
535
533
|
return generateCartData;
|
|
536
|
-
}() //
|
|
534
|
+
}() // 免费领取商品相关逻辑,上线了来不及加了,先放在这,后面要做到 payment 里面的
|
|
537
535
|
}, {
|
|
538
|
-
key: "
|
|
536
|
+
key: "getFreeProduct",
|
|
539
537
|
value: function () {
|
|
540
|
-
var
|
|
541
|
-
var
|
|
538
|
+
var _getFreeProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(id) {
|
|
539
|
+
var res;
|
|
542
540
|
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
543
541
|
while (1) switch (_context13.prev = _context13.next) {
|
|
544
542
|
case 0:
|
|
545
|
-
|
|
546
|
-
|
|
543
|
+
_context13.next = 2;
|
|
544
|
+
return this.request.post("/pay/order/free-pay/".concat(id));
|
|
545
|
+
case 2:
|
|
546
|
+
res = _context13.sent;
|
|
547
|
+
return _context13.abrupt("return", res);
|
|
548
|
+
case 4:
|
|
549
|
+
case "end":
|
|
550
|
+
return _context13.stop();
|
|
551
|
+
}
|
|
552
|
+
}, _callee13, this);
|
|
553
|
+
}));
|
|
554
|
+
function getFreeProduct(_x9) {
|
|
555
|
+
return _getFreeProduct.apply(this, arguments);
|
|
556
|
+
}
|
|
557
|
+
return getFreeProduct;
|
|
558
|
+
}() // 购物车提交订单
|
|
559
|
+
}, {
|
|
560
|
+
key: "submitOrder",
|
|
561
|
+
value: function () {
|
|
562
|
+
var _submitOrder = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
|
|
563
|
+
var cartItems, newCartItems;
|
|
564
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
565
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
566
|
+
case 0:
|
|
567
|
+
cartItems = this.store.cart.getItems();
|
|
568
|
+
newCartItems = cloneDeep(cartItems); // 先整个临时的逻辑,把购物车里所有商品的资源给他格式化一下
|
|
569
|
+
newCartItems.forEach(function (item) {
|
|
547
570
|
item._origin.resources = item._origin.resources.map(function (n) {
|
|
548
571
|
var newResourcesItem = cloneDeep(n);
|
|
549
572
|
delete newResourcesItem.id;
|
|
@@ -552,16 +575,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
552
575
|
return _objectSpread({}, newResourcesItem);
|
|
553
576
|
});
|
|
554
577
|
});
|
|
555
|
-
return
|
|
578
|
+
return _context14.abrupt("return", this.store.order.commitOrder({
|
|
556
579
|
query: {
|
|
557
|
-
cartItems:
|
|
580
|
+
cartItems: newCartItems
|
|
558
581
|
}
|
|
559
582
|
}));
|
|
560
|
-
case
|
|
583
|
+
case 4:
|
|
561
584
|
case "end":
|
|
562
|
-
return
|
|
585
|
+
return _context14.stop();
|
|
563
586
|
}
|
|
564
|
-
},
|
|
587
|
+
}, _callee14, this);
|
|
565
588
|
}));
|
|
566
589
|
function submitOrder() {
|
|
567
590
|
return _submitOrder.apply(this, arguments);
|
|
@@ -571,14 +594,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
571
594
|
}, {
|
|
572
595
|
key: "pay",
|
|
573
596
|
value: function () {
|
|
574
|
-
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
575
|
-
return _regeneratorRuntime().wrap(function
|
|
576
|
-
while (1) switch (
|
|
597
|
+
var _pay = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
598
|
+
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
599
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
577
600
|
case 0:
|
|
578
601
|
case "end":
|
|
579
|
-
return
|
|
602
|
+
return _context15.stop();
|
|
580
603
|
}
|
|
581
|
-
},
|
|
604
|
+
}, _callee15);
|
|
582
605
|
}));
|
|
583
606
|
function pay() {
|
|
584
607
|
return _pay.apply(this, arguments);
|
|
@@ -588,14 +611,14 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
588
611
|
}, {
|
|
589
612
|
key: "getPayInfo",
|
|
590
613
|
value: function () {
|
|
591
|
-
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
592
|
-
return _regeneratorRuntime().wrap(function
|
|
593
|
-
while (1) switch (
|
|
614
|
+
var _getPayInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
615
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
616
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
594
617
|
case 0:
|
|
595
618
|
case "end":
|
|
596
|
-
return
|
|
619
|
+
return _context16.stop();
|
|
597
620
|
}
|
|
598
|
-
},
|
|
621
|
+
}, _callee16);
|
|
599
622
|
}));
|
|
600
623
|
function getPayInfo() {
|
|
601
624
|
return _getPayInfo.apply(this, arguments);
|
|
@@ -605,15 +628,15 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
605
628
|
}, {
|
|
606
629
|
key: "setOtherParams",
|
|
607
630
|
value: function () {
|
|
608
|
-
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
631
|
+
var _setOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(params) {
|
|
609
632
|
var _ref4,
|
|
610
633
|
_ref4$cover,
|
|
611
634
|
cover,
|
|
612
|
-
|
|
613
|
-
return _regeneratorRuntime().wrap(function
|
|
614
|
-
while (1) switch (
|
|
635
|
+
_args17 = arguments;
|
|
636
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
637
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
615
638
|
case 0:
|
|
616
|
-
_ref4 =
|
|
639
|
+
_ref4 = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {}, _ref4$cover = _ref4.cover, cover = _ref4$cover === void 0 ? false : _ref4$cover;
|
|
617
640
|
if (cover) {
|
|
618
641
|
this.otherParams = params;
|
|
619
642
|
} else {
|
|
@@ -621,11 +644,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
621
644
|
}
|
|
622
645
|
case 2:
|
|
623
646
|
case "end":
|
|
624
|
-
return
|
|
647
|
+
return _context17.stop();
|
|
625
648
|
}
|
|
626
|
-
},
|
|
649
|
+
}, _callee17, this);
|
|
627
650
|
}));
|
|
628
|
-
function setOtherParams(
|
|
651
|
+
function setOtherParams(_x10) {
|
|
629
652
|
return _setOtherParams.apply(this, arguments);
|
|
630
653
|
}
|
|
631
654
|
return setOtherParams;
|
|
@@ -633,16 +656,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
633
656
|
}, {
|
|
634
657
|
key: "getOtherParams",
|
|
635
658
|
value: function () {
|
|
636
|
-
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
637
|
-
return _regeneratorRuntime().wrap(function
|
|
638
|
-
while (1) switch (
|
|
659
|
+
var _getOtherParams = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
660
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
661
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
639
662
|
case 0:
|
|
640
|
-
return
|
|
663
|
+
return _context18.abrupt("return", this.otherParams);
|
|
641
664
|
case 1:
|
|
642
665
|
case "end":
|
|
643
|
-
return
|
|
666
|
+
return _context18.stop();
|
|
644
667
|
}
|
|
645
|
-
},
|
|
668
|
+
}, _callee18, this);
|
|
646
669
|
}));
|
|
647
670
|
function getOtherParams() {
|
|
648
671
|
return _getOtherParams.apply(this, arguments);
|
|
@@ -165,7 +165,6 @@ export var ShopDiscountImpl = /*#__PURE__*/function (_BaseModule) {
|
|
|
165
165
|
targetCacheData = data[this.options.otherParams.cacheId];
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
debugger;
|
|
169
168
|
// 注册优惠模块
|
|
170
169
|
var discount = new DiscountModule("".concat(this.name, "_discount"));
|
|
171
170
|
this.core.registerModule(discount, {
|
|
@@ -42,7 +42,6 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
42
42
|
var _a, _b, _c;
|
|
43
43
|
this.core = core;
|
|
44
44
|
this.store = options.store;
|
|
45
|
-
debugger;
|
|
46
45
|
if (Array.isArray((_a = options.initialState) == null ? void 0 : _a.list)) {
|
|
47
46
|
this.store.list = options.initialState.list;
|
|
48
47
|
this.core.effects.emit(`${this.name}:changed`, this.store.list);
|
|
@@ -70,7 +69,6 @@ var CartModule = class extends import_BaseModule.BaseModule {
|
|
|
70
69
|
* 添加商品到购物车
|
|
71
70
|
*/
|
|
72
71
|
async addItem(params) {
|
|
73
|
-
debugger;
|
|
74
72
|
const { account, product, bundle, options } = params;
|
|
75
73
|
let cartItem = {
|
|
76
74
|
_id: (0, import_utils.getUniqueId)(),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Module, PisellCore } from "../../types";
|
|
2
2
|
import { BaseModule } from "../../modules/BaseModule";
|
|
3
|
+
import { Response } from "../../plugins";
|
|
3
4
|
import { BookingByStepState } from "./types";
|
|
4
5
|
import { CartItem, IUpdateItemParams, ProductData } from "../../modules";
|
|
5
6
|
import { Account } from "../../modules/Account/types";
|
|
@@ -59,6 +60,7 @@ export declare class BookingByStepImpl extends BaseModule implements Module {
|
|
|
59
60
|
getProducts(): Promise<ProductData[]>;
|
|
60
61
|
setLoginAccount(accountId: string, accountInfo: Account): Promise<void>;
|
|
61
62
|
generateCartData(): Promise<void>;
|
|
63
|
+
getFreeProduct(id: string | number): Promise<Response<any>>;
|
|
62
64
|
submitOrder(): Promise<void>;
|
|
63
65
|
pay(): Promise<void>;
|
|
64
66
|
getPayInfo(): Promise<void>;
|
|
@@ -59,7 +59,6 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
59
59
|
if (!this.request) {
|
|
60
60
|
throw new Error("bookingByStep解决方案需要 request 插件支持");
|
|
61
61
|
}
|
|
62
|
-
debugger;
|
|
63
62
|
let targetCacheData = {};
|
|
64
63
|
if ((_a = this.otherParams) == null ? void 0 : _a.cacheId) {
|
|
65
64
|
const sessionData = this.window.sessionStorage.getItem(this.name);
|
|
@@ -257,10 +256,16 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
257
256
|
// 生成购物车的正规数据
|
|
258
257
|
async generateCartData() {
|
|
259
258
|
}
|
|
259
|
+
// 免费领取商品相关逻辑,上线了来不及加了,先放在这,后面要做到 payment 里面的
|
|
260
|
+
async getFreeProduct(id) {
|
|
261
|
+
const res = await this.request.post(`/pay/order/free-pay/${id}`);
|
|
262
|
+
return res;
|
|
263
|
+
}
|
|
260
264
|
// 购物车提交订单
|
|
261
265
|
async submitOrder() {
|
|
262
266
|
const cartItems = this.store.cart.getItems();
|
|
263
|
-
|
|
267
|
+
const newCartItems = (0, import_lodash_es.cloneDeep)(cartItems);
|
|
268
|
+
newCartItems.forEach((item) => {
|
|
264
269
|
item._origin.resources = item._origin.resources.map((n) => {
|
|
265
270
|
const newResourcesItem = (0, import_lodash_es.cloneDeep)(n);
|
|
266
271
|
delete newResourcesItem.id;
|
|
@@ -269,7 +274,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
|
|
|
269
274
|
return { ...newResourcesItem };
|
|
270
275
|
});
|
|
271
276
|
});
|
|
272
|
-
return this.store.order.commitOrder({ query: { cartItems } });
|
|
277
|
+
return this.store.order.commitOrder({ query: { cartItems: newCartItems } });
|
|
273
278
|
}
|
|
274
279
|
// 拉起支付模块
|
|
275
280
|
async pay() {
|
|
@@ -91,7 +91,6 @@ var ShopDiscountImpl = class extends import_BaseModule.BaseModule {
|
|
|
91
91
|
targetCacheData = data[this.options.otherParams.cacheId];
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
debugger;
|
|
95
94
|
const discount = new import_Discount.DiscountModule(`${this.name}_discount`);
|
|
96
95
|
this.core.registerModule(discount, {
|
|
97
96
|
initialState: targetCacheData == null ? void 0 : targetCacheData[discount.name],
|