@fonixtree/magic-design 0.0.74 → 0.0.76

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.
@@ -458,7 +458,7 @@ var FilteredProductModal = function FilteredProductModal(props) {
458
458
  minPrice: minimum * precision || '',
459
459
  maxPrice: maximum * precision || '',
460
460
  // storeName:storeName,
461
- cmpTypeId: promotions.key || '',
461
+ campaignType: promotions.key || '',
462
462
  pageSize: paginationParams.pageSize,
463
463
  pageIndex: paginationParams.current,
464
464
  state: 'A'
@@ -485,7 +485,7 @@ var FilteredProductModal = function FilteredProductModal(props) {
485
485
  minPrice: minimum * precision || '',
486
486
  maxPrice: maximum * precision || '',
487
487
  storeName: storeName || '',
488
- cmpTypeId: promotions.key || '',
488
+ campaignType: promotions.key || '',
489
489
  state: 'A'
490
490
  }),
491
491
  total: res.total
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactDom = _interopRequireDefault(require("react-dom"));
11
+
12
+ require("./index.less");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ var _default = {
17
+ dom: null,
18
+ success: function success(_a) {
19
+ var _this = this;
20
+
21
+ var title = _a.title,
22
+ content = _a.content,
23
+ onOk = _a.onOk,
24
+ onCancel = _a.onCancel,
25
+ okText = _a.okText,
26
+ cancelText = _a.cancelText;
27
+ this.close();
28
+ this.dom = document.createElement('div');
29
+ this.dom.setAttribute('id', 'message_modal');
30
+
31
+ var JSXdom = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
32
+ className: "message-container"
33
+ }, /*#__PURE__*/_react["default"].createElement("div", {
34
+ className: "modal-shadow",
35
+ onClick: this.close
36
+ }), /*#__PURE__*/_react["default"].createElement("div", {
37
+ className: "modal-content"
38
+ }, title && /*#__PURE__*/_react["default"].createElement("div", {
39
+ className: "modal-title"
40
+ }, title), /*#__PURE__*/_react["default"].createElement("div", {
41
+ className: "modal-message"
42
+ }, content), /*#__PURE__*/_react["default"].createElement("div", {
43
+ className: "modal-btn-wrap"
44
+ }, cancelText && /*#__PURE__*/_react["default"].createElement("button", {
45
+ className: "cancel",
46
+ onClick: function onClick() {
47
+ return _this.onCancel(onCancel);
48
+ }
49
+ }, cancelText), okText && /*#__PURE__*/_react["default"].createElement("button", {
50
+ className: "confirm",
51
+ onClick: function onClick() {
52
+ return _this.onOk(onOk);
53
+ }
54
+ }, okText)))));
55
+
56
+ _reactDom["default"].render(JSXdom, this.dom);
57
+
58
+ document.body.appendChild(this.dom);
59
+ },
60
+ onCancel: function onCancel(_onCancel) {
61
+ _onCancel instanceof Function && _onCancel();
62
+ this.close();
63
+ },
64
+ onOk: function onOk(_onOk) {
65
+ _onOk instanceof Function && _onOk();
66
+ this.close();
67
+ },
68
+ close: function close() {
69
+ var dom = document.querySelector('#message_modal');
70
+ dom && dom.remove();
71
+ }
72
+ };
73
+ exports["default"] = _default;
@@ -0,0 +1,86 @@
1
+ #message_modal {
2
+ .message-container {
3
+ display: flex;
4
+ position: fixed;
5
+ left: 0;
6
+ top: 0;
7
+ right: 0;
8
+ bottom: 0;
9
+ flex-direction: column;
10
+ width: 100%;
11
+ z-index: 99;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+
16
+
17
+ .modal-shadow {
18
+ width: 100%;
19
+ height: 100%;
20
+ background-color: rgba(0, 0, 0, .5);
21
+ position: absolute;
22
+ left: 0;
23
+ top: 0;
24
+ z-index: -1;
25
+ }
26
+
27
+ .modal-content {
28
+ width: 80%;
29
+ padding: 16px;
30
+ display: flex;
31
+ flex-direction: column;
32
+ background-color: #fff;
33
+ box-shadow: 0px 4px 8px rgba(96, 97, 112, 0.16);
34
+ animation: bounceIn .5s linear;
35
+ margin-top: -80px;
36
+
37
+ .modal-title {
38
+ font-family: var(--truenoSBd-family);
39
+ color: #000;
40
+ font-size: 16px;
41
+ font-weight: 600;
42
+ text-align: center;
43
+ }
44
+
45
+ .modal-message {
46
+ padding: 24px 0px;
47
+ color: rgb(0, 0, 0);
48
+ text-align: center;
49
+ font-family: var(--regular-font);
50
+ }
51
+
52
+ .modal-btn-wrap {
53
+ display: flex;
54
+ flex-direction: column;
55
+
56
+ .confirm {
57
+ border: none;
58
+ margin: 8px 0;
59
+ background-color: #FF1659;
60
+ font-size: 14px;
61
+ font-weight: 600;
62
+ font-family: var(--regular-font);
63
+ line-height: 21px;
64
+ color: #FFFFFF;
65
+ opacity: 1;
66
+ height: 46px;
67
+ }
68
+
69
+ .cancel {
70
+ border: none;
71
+ margin: 8px 0;
72
+ background-color: #FFFFFF;
73
+ font-size: 14px;
74
+ font-weight: 600;
75
+ font-family: var(--regular-font);
76
+ line-height: 21px;
77
+ color: #FF1659;
78
+ opacity: 1;
79
+ height: 46px;
80
+ }
81
+ }
82
+ }
83
+
84
+ }
85
+
86
+ }
@@ -700,7 +700,7 @@ var ProductModal = function ProductModal(props) {
700
700
  productName: productName,
701
701
  productCode: productCode,
702
702
  storeId: storeId,
703
- cmpTypeId: promotions || '',
703
+ campaignType: promotions || '',
704
704
  minPrice: minPrice === '' ? '' : minPrice * Math.pow(10, precision),
705
705
  maxPrice: maxPrice === '' ? '' : maxPrice * Math.pow(10, precision),
706
706
  catgIds: selCatgsList.join(','),
@@ -730,7 +730,7 @@ var ProductModal = function ProductModal(props) {
730
730
  queryGoods({
731
731
  productName: productName,
732
732
  productCode: productCode,
733
- cmpTypeId: promotions || '',
733
+ campaignType: promotions || '',
734
734
  minPrice: minPrice === '' ? '' : minPrice * Math.pow(10, precision),
735
735
  maxPrice: maxPrice === '' ? '' : maxPrice * Math.pow(10, precision),
736
736
  catgIds: selCatgsList.join(','),
@@ -1,4 +1,5 @@
1
1
  {
2
+ "VOUCHER_SUCCESS": "Voucher received successfully!",
2
3
  "NAVIGATION_NAME": "Navigation Name",
3
4
  "ADD_NAVIGATION": "Add Navigation",
4
5
  "SAVE": "Save",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "VOUCHER_SUCCESS": "Voucher received successfully!",
2
3
  "NAVIGATION_NAME": "Navigation Name",
3
4
  "ADD_NAVIGATION": "Add Navigation",
4
5
  "SAVE": "Guardar",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "VOUCHER_SUCCESS": "Voucher received successfully!",
2
3
  "NAVIGATION_NAME": "Navigation Name",
3
4
  "ADD_NAVIGATION": "Add Navigation",
4
5
  "SAVE": "Save",
@@ -49,7 +49,7 @@ function commonFetch(url, data, method) {
49
49
 
50
50
  var _method = method.toUpperCase();
51
51
 
52
- return new Promise(function (resolve) {
52
+ return new Promise(function (resolve, reject) {
53
53
  var _a, _b;
54
54
 
55
55
  var isLoginUrl = url.includes('portal/login');
@@ -64,6 +64,8 @@ function commonFetch(url, data, method) {
64
64
  params: data
65
65
  }).then(function (res) {
66
66
  resolve(res);
67
+ })["catch"](function (err) {
68
+ reject(err);
67
69
  });
68
70
  return;
69
71
  }
@@ -73,6 +75,8 @@ function commonFetch(url, data, method) {
73
75
  headers: headers
74
76
  }).then(function (res) {
75
77
  resolve(res.data);
78
+ })["catch"](function (err) {
79
+ reject(err.response.data);
76
80
  });
77
81
  }
78
82
 
@@ -83,6 +87,8 @@ function commonFetch(url, data, method) {
83
87
  data: data
84
88
  }).then(function (res) {
85
89
  resolve(res);
90
+ })["catch"](function (err) {
91
+ reject(err);
86
92
  });
87
93
  return;
88
94
  }
@@ -91,6 +97,8 @@ function commonFetch(url, data, method) {
91
97
  headers: headers
92
98
  }).then(function (res) {
93
99
  resolve(res.data);
100
+ })["catch"](function (err) {
101
+ reject(err.response.data);
94
102
  });
95
103
  }
96
104
  });
@@ -13,6 +13,14 @@ var _commonUtil = require("./commonUtil");
13
13
 
14
14
  var _androidUtil = require("./androidUtil");
15
15
 
16
+ var _constants = require("../constants");
17
+
18
+ var _MessageModal = _interopRequireDefault(require("../common/MessageModal"));
19
+
20
+ var _locale = require("../locale");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
16
24
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
17
25
 
18
26
  var __assign = void 0 && (void 0).__assign || function () {
@@ -31,6 +39,149 @@ var __assign = void 0 && (void 0).__assign || function () {
31
39
  return __assign.apply(this, arguments);
32
40
  };
33
41
 
42
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
43
+ function adopt(value) {
44
+ return value instanceof P ? value : new P(function (resolve) {
45
+ resolve(value);
46
+ });
47
+ }
48
+
49
+ return new (P || (P = Promise))(function (resolve, reject) {
50
+ function fulfilled(value) {
51
+ try {
52
+ step(generator.next(value));
53
+ } catch (e) {
54
+ reject(e);
55
+ }
56
+ }
57
+
58
+ function rejected(value) {
59
+ try {
60
+ step(generator["throw"](value));
61
+ } catch (e) {
62
+ reject(e);
63
+ }
64
+ }
65
+
66
+ function step(result) {
67
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
68
+ }
69
+
70
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
71
+ });
72
+ };
73
+
74
+ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
75
+ var _ = {
76
+ label: 0,
77
+ sent: function sent() {
78
+ if (t[0] & 1) throw t[1];
79
+ return t[1];
80
+ },
81
+ trys: [],
82
+ ops: []
83
+ },
84
+ f,
85
+ y,
86
+ t,
87
+ g;
88
+ return g = {
89
+ next: verb(0),
90
+ "throw": verb(1),
91
+ "return": verb(2)
92
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
93
+ return this;
94
+ }), g;
95
+
96
+ function verb(n) {
97
+ return function (v) {
98
+ return step([n, v]);
99
+ };
100
+ }
101
+
102
+ function step(op) {
103
+ if (f) throw new TypeError("Generator is already executing.");
104
+
105
+ while (_) {
106
+ try {
107
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
108
+ if (y = 0, t) op = [op[0] & 2, t.value];
109
+
110
+ switch (op[0]) {
111
+ case 0:
112
+ case 1:
113
+ t = op;
114
+ break;
115
+
116
+ case 4:
117
+ _.label++;
118
+ return {
119
+ value: op[1],
120
+ done: false
121
+ };
122
+
123
+ case 5:
124
+ _.label++;
125
+ y = op[1];
126
+ op = [0];
127
+ continue;
128
+
129
+ case 7:
130
+ op = _.ops.pop();
131
+
132
+ _.trys.pop();
133
+
134
+ continue;
135
+
136
+ default:
137
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
138
+ _ = 0;
139
+ continue;
140
+ }
141
+
142
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
143
+ _.label = op[1];
144
+ break;
145
+ }
146
+
147
+ if (op[0] === 6 && _.label < t[1]) {
148
+ _.label = t[1];
149
+ t = op;
150
+ break;
151
+ }
152
+
153
+ if (t && _.label < t[2]) {
154
+ _.label = t[2];
155
+
156
+ _.ops.push(op);
157
+
158
+ break;
159
+ }
160
+
161
+ if (t[2]) _.ops.pop();
162
+
163
+ _.trys.pop();
164
+
165
+ continue;
166
+ }
167
+
168
+ op = body.call(thisArg, _);
169
+ } catch (e) {
170
+ op = [6, e];
171
+ y = 0;
172
+ } finally {
173
+ f = t = 0;
174
+ }
175
+ }
176
+
177
+ if (op[0] & 5) throw op[1];
178
+ return {
179
+ value: op[0] ? op[1] : void 0,
180
+ done: true
181
+ };
182
+ }
183
+ };
184
+
34
185
  var _this = void 0;
35
186
 
36
187
  var isDesignMode = function isDesignMode() {
@@ -58,10 +209,64 @@ var renderPreview = function renderPreview() {
58
209
  bubbles: false
59
210
  });
60
211
  window.document.dispatchEvent(evt);
61
- };
212
+ }; // 领取优惠券
213
+
62
214
 
63
215
  exports.renderPreview = renderPreview;
64
216
 
217
+ var getCoupon = function getCoupon(couponId) {
218
+ return __awaiter(void 0, void 0, void 0, function () {
219
+ var err_1;
220
+ return __generator(this, function (_a) {
221
+ switch (_a.label) {
222
+ case 0:
223
+ _a.trys.push([0, 2,, 3]);
224
+
225
+ return [4
226
+ /*yield*/
227
+ , (0, _commonUtil.commonFetch)(window.magicDesign.MBaseUrl + "/h5/coupons/usercoupon", {
228
+ couponId: Number(couponId)
229
+ }, 'POST')];
230
+
231
+ case 1:
232
+ res = _a.sent();
233
+
234
+ _MessageModal["default"].success({
235
+ content: (0, _locale.i18n)('VOUCHER_SUCCESS'),
236
+ okText: 'Ok'
237
+ });
238
+
239
+ return [3
240
+ /*break*/
241
+ , 3];
242
+
243
+ case 2:
244
+ err_1 = _a.sent();
245
+
246
+ if (err_1.code === _constants.respCodeMap.NOT_LOGGED_IN) {
247
+ return [2
248
+ /*return*/
249
+ ];
250
+ }
251
+
252
+ _MessageModal["default"].success({
253
+ content: err_1.message,
254
+ okText: 'Ok'
255
+ });
256
+
257
+ return [3
258
+ /*break*/
259
+ , 3];
260
+
261
+ case 3:
262
+ return [2
263
+ /*return*/
264
+ ];
265
+ }
266
+ });
267
+ });
268
+ };
269
+
65
270
  var clickUrl = function clickUrl(url) {
66
271
  console.log('url', url);
67
272
 
@@ -78,8 +283,7 @@ var clickUrl = function clickUrl(url) {
78
283
  data = params.data; // 领取优惠券
79
284
 
80
285
  if (type === 'GET_COUPON') {
81
- _this.getCoupon(data.couponId);
82
-
286
+ getCoupon(data.couponId);
83
287
  return;
84
288
  }
85
289
 
@@ -458,7 +458,7 @@ var FilteredProductModal = function FilteredProductModal(props) {
458
458
  minPrice: minimum * precision || '',
459
459
  maxPrice: maximum * precision || '',
460
460
  // storeName:storeName,
461
- cmpTypeId: promotions.key || '',
461
+ campaignType: promotions.key || '',
462
462
  pageSize: paginationParams.pageSize,
463
463
  pageIndex: paginationParams.current,
464
464
  state: 'A'
@@ -485,7 +485,7 @@ var FilteredProductModal = function FilteredProductModal(props) {
485
485
  minPrice: minimum * precision || '',
486
486
  maxPrice: maximum * precision || '',
487
487
  storeName: storeName || '',
488
- cmpTypeId: promotions.key || '',
488
+ campaignType: promotions.key || '',
489
489
  state: 'A'
490
490
  }),
491
491
  total: res.total
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+
8
+ var _react = _interopRequireDefault(require("react"));
9
+
10
+ var _reactDom = _interopRequireDefault(require("react-dom"));
11
+
12
+ require("./index.less");
13
+
14
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
+
16
+ var _default = {
17
+ dom: null,
18
+ success: function success(_a) {
19
+ var _this = this;
20
+
21
+ var title = _a.title,
22
+ content = _a.content,
23
+ onOk = _a.onOk,
24
+ onCancel = _a.onCancel,
25
+ okText = _a.okText,
26
+ cancelText = _a.cancelText;
27
+ this.close();
28
+ this.dom = document.createElement('div');
29
+ this.dom.setAttribute('id', 'message_modal');
30
+
31
+ var JSXdom = /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
32
+ className: "message-container"
33
+ }, /*#__PURE__*/_react["default"].createElement("div", {
34
+ className: "modal-shadow",
35
+ onClick: this.close
36
+ }), /*#__PURE__*/_react["default"].createElement("div", {
37
+ className: "modal-content"
38
+ }, title && /*#__PURE__*/_react["default"].createElement("div", {
39
+ className: "modal-title"
40
+ }, title), /*#__PURE__*/_react["default"].createElement("div", {
41
+ className: "modal-message"
42
+ }, content), /*#__PURE__*/_react["default"].createElement("div", {
43
+ className: "modal-btn-wrap"
44
+ }, cancelText && /*#__PURE__*/_react["default"].createElement("button", {
45
+ className: "cancel",
46
+ onClick: function onClick() {
47
+ return _this.onCancel(onCancel);
48
+ }
49
+ }, cancelText), okText && /*#__PURE__*/_react["default"].createElement("button", {
50
+ className: "confirm",
51
+ onClick: function onClick() {
52
+ return _this.onOk(onOk);
53
+ }
54
+ }, okText)))));
55
+
56
+ _reactDom["default"].render(JSXdom, this.dom);
57
+
58
+ document.body.appendChild(this.dom);
59
+ },
60
+ onCancel: function onCancel(_onCancel) {
61
+ _onCancel instanceof Function && _onCancel();
62
+ this.close();
63
+ },
64
+ onOk: function onOk(_onOk) {
65
+ _onOk instanceof Function && _onOk();
66
+ this.close();
67
+ },
68
+ close: function close() {
69
+ var dom = document.querySelector('#message_modal');
70
+ dom && dom.remove();
71
+ }
72
+ };
73
+ exports["default"] = _default;
@@ -0,0 +1,86 @@
1
+ #message_modal {
2
+ .message-container {
3
+ display: flex;
4
+ position: fixed;
5
+ left: 0;
6
+ top: 0;
7
+ right: 0;
8
+ bottom: 0;
9
+ flex-direction: column;
10
+ width: 100%;
11
+ z-index: 99;
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+
16
+
17
+ .modal-shadow {
18
+ width: 100%;
19
+ height: 100%;
20
+ background-color: rgba(0, 0, 0, .5);
21
+ position: absolute;
22
+ left: 0;
23
+ top: 0;
24
+ z-index: -1;
25
+ }
26
+
27
+ .modal-content {
28
+ width: 80%;
29
+ padding: 16px;
30
+ display: flex;
31
+ flex-direction: column;
32
+ background-color: #fff;
33
+ box-shadow: 0px 4px 8px rgba(96, 97, 112, 0.16);
34
+ animation: bounceIn .5s linear;
35
+ margin-top: -80px;
36
+
37
+ .modal-title {
38
+ font-family: var(--truenoSBd-family);
39
+ color: #000;
40
+ font-size: 16px;
41
+ font-weight: 600;
42
+ text-align: center;
43
+ }
44
+
45
+ .modal-message {
46
+ padding: 24px 0px;
47
+ color: rgb(0, 0, 0);
48
+ text-align: center;
49
+ font-family: var(--regular-font);
50
+ }
51
+
52
+ .modal-btn-wrap {
53
+ display: flex;
54
+ flex-direction: column;
55
+
56
+ .confirm {
57
+ border: none;
58
+ margin: 8px 0;
59
+ background-color: #FF1659;
60
+ font-size: 14px;
61
+ font-weight: 600;
62
+ font-family: var(--regular-font);
63
+ line-height: 21px;
64
+ color: #FFFFFF;
65
+ opacity: 1;
66
+ height: 46px;
67
+ }
68
+
69
+ .cancel {
70
+ border: none;
71
+ margin: 8px 0;
72
+ background-color: #FFFFFF;
73
+ font-size: 14px;
74
+ font-weight: 600;
75
+ font-family: var(--regular-font);
76
+ line-height: 21px;
77
+ color: #FF1659;
78
+ opacity: 1;
79
+ height: 46px;
80
+ }
81
+ }
82
+ }
83
+
84
+ }
85
+
86
+ }
@@ -700,7 +700,7 @@ var ProductModal = function ProductModal(props) {
700
700
  productName: productName,
701
701
  productCode: productCode,
702
702
  storeId: storeId,
703
- cmpTypeId: promotions || '',
703
+ campaignType: promotions || '',
704
704
  minPrice: minPrice === '' ? '' : minPrice * Math.pow(10, precision),
705
705
  maxPrice: maxPrice === '' ? '' : maxPrice * Math.pow(10, precision),
706
706
  catgIds: selCatgsList.join(','),
@@ -730,7 +730,7 @@ var ProductModal = function ProductModal(props) {
730
730
  queryGoods({
731
731
  productName: productName,
732
732
  productCode: productCode,
733
- cmpTypeId: promotions || '',
733
+ campaignType: promotions || '',
734
734
  minPrice: minPrice === '' ? '' : minPrice * Math.pow(10, precision),
735
735
  maxPrice: maxPrice === '' ? '' : maxPrice * Math.pow(10, precision),
736
736
  catgIds: selCatgsList.join(','),
@@ -1,4 +1,5 @@
1
1
  {
2
+ "VOUCHER_SUCCESS": "Voucher received successfully!",
2
3
  "NAVIGATION_NAME": "Navigation Name",
3
4
  "ADD_NAVIGATION": "Add Navigation",
4
5
  "SAVE": "Save",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "VOUCHER_SUCCESS": "Voucher received successfully!",
2
3
  "NAVIGATION_NAME": "Navigation Name",
3
4
  "ADD_NAVIGATION": "Add Navigation",
4
5
  "SAVE": "Guardar",
@@ -1,4 +1,5 @@
1
1
  {
2
+ "VOUCHER_SUCCESS": "Voucher received successfully!",
2
3
  "NAVIGATION_NAME": "Navigation Name",
3
4
  "ADD_NAVIGATION": "Add Navigation",
4
5
  "SAVE": "Save",
@@ -49,7 +49,7 @@ function commonFetch(url, data, method) {
49
49
 
50
50
  var _method = method.toUpperCase();
51
51
 
52
- return new Promise(function (resolve) {
52
+ return new Promise(function (resolve, reject) {
53
53
  var _a, _b;
54
54
 
55
55
  var isLoginUrl = url.includes('portal/login');
@@ -64,6 +64,8 @@ function commonFetch(url, data, method) {
64
64
  params: data
65
65
  }).then(function (res) {
66
66
  resolve(res);
67
+ })["catch"](function (err) {
68
+ reject(err);
67
69
  });
68
70
  return;
69
71
  }
@@ -73,6 +75,8 @@ function commonFetch(url, data, method) {
73
75
  headers: headers
74
76
  }).then(function (res) {
75
77
  resolve(res.data);
78
+ })["catch"](function (err) {
79
+ reject(err.response.data);
76
80
  });
77
81
  }
78
82
 
@@ -83,6 +87,8 @@ function commonFetch(url, data, method) {
83
87
  data: data
84
88
  }).then(function (res) {
85
89
  resolve(res);
90
+ })["catch"](function (err) {
91
+ reject(err);
86
92
  });
87
93
  return;
88
94
  }
@@ -91,6 +97,8 @@ function commonFetch(url, data, method) {
91
97
  headers: headers
92
98
  }).then(function (res) {
93
99
  resolve(res.data);
100
+ })["catch"](function (err) {
101
+ reject(err.response.data);
94
102
  });
95
103
  }
96
104
  });
@@ -13,6 +13,14 @@ var _commonUtil = require("./commonUtil");
13
13
 
14
14
  var _androidUtil = require("./androidUtil");
15
15
 
16
+ var _constants = require("../constants");
17
+
18
+ var _MessageModal = _interopRequireDefault(require("../common/MessageModal"));
19
+
20
+ var _locale = require("../locale");
21
+
22
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
23
+
16
24
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
17
25
 
18
26
  var __assign = void 0 && (void 0).__assign || function () {
@@ -31,6 +39,149 @@ var __assign = void 0 && (void 0).__assign || function () {
31
39
  return __assign.apply(this, arguments);
32
40
  };
33
41
 
42
+ var __awaiter = void 0 && (void 0).__awaiter || function (thisArg, _arguments, P, generator) {
43
+ function adopt(value) {
44
+ return value instanceof P ? value : new P(function (resolve) {
45
+ resolve(value);
46
+ });
47
+ }
48
+
49
+ return new (P || (P = Promise))(function (resolve, reject) {
50
+ function fulfilled(value) {
51
+ try {
52
+ step(generator.next(value));
53
+ } catch (e) {
54
+ reject(e);
55
+ }
56
+ }
57
+
58
+ function rejected(value) {
59
+ try {
60
+ step(generator["throw"](value));
61
+ } catch (e) {
62
+ reject(e);
63
+ }
64
+ }
65
+
66
+ function step(result) {
67
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
68
+ }
69
+
70
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
71
+ });
72
+ };
73
+
74
+ var __generator = void 0 && (void 0).__generator || function (thisArg, body) {
75
+ var _ = {
76
+ label: 0,
77
+ sent: function sent() {
78
+ if (t[0] & 1) throw t[1];
79
+ return t[1];
80
+ },
81
+ trys: [],
82
+ ops: []
83
+ },
84
+ f,
85
+ y,
86
+ t,
87
+ g;
88
+ return g = {
89
+ next: verb(0),
90
+ "throw": verb(1),
91
+ "return": verb(2)
92
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
93
+ return this;
94
+ }), g;
95
+
96
+ function verb(n) {
97
+ return function (v) {
98
+ return step([n, v]);
99
+ };
100
+ }
101
+
102
+ function step(op) {
103
+ if (f) throw new TypeError("Generator is already executing.");
104
+
105
+ while (_) {
106
+ try {
107
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
108
+ if (y = 0, t) op = [op[0] & 2, t.value];
109
+
110
+ switch (op[0]) {
111
+ case 0:
112
+ case 1:
113
+ t = op;
114
+ break;
115
+
116
+ case 4:
117
+ _.label++;
118
+ return {
119
+ value: op[1],
120
+ done: false
121
+ };
122
+
123
+ case 5:
124
+ _.label++;
125
+ y = op[1];
126
+ op = [0];
127
+ continue;
128
+
129
+ case 7:
130
+ op = _.ops.pop();
131
+
132
+ _.trys.pop();
133
+
134
+ continue;
135
+
136
+ default:
137
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
138
+ _ = 0;
139
+ continue;
140
+ }
141
+
142
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
143
+ _.label = op[1];
144
+ break;
145
+ }
146
+
147
+ if (op[0] === 6 && _.label < t[1]) {
148
+ _.label = t[1];
149
+ t = op;
150
+ break;
151
+ }
152
+
153
+ if (t && _.label < t[2]) {
154
+ _.label = t[2];
155
+
156
+ _.ops.push(op);
157
+
158
+ break;
159
+ }
160
+
161
+ if (t[2]) _.ops.pop();
162
+
163
+ _.trys.pop();
164
+
165
+ continue;
166
+ }
167
+
168
+ op = body.call(thisArg, _);
169
+ } catch (e) {
170
+ op = [6, e];
171
+ y = 0;
172
+ } finally {
173
+ f = t = 0;
174
+ }
175
+ }
176
+
177
+ if (op[0] & 5) throw op[1];
178
+ return {
179
+ value: op[0] ? op[1] : void 0,
180
+ done: true
181
+ };
182
+ }
183
+ };
184
+
34
185
  var _this = void 0;
35
186
 
36
187
  var isDesignMode = function isDesignMode() {
@@ -58,10 +209,64 @@ var renderPreview = function renderPreview() {
58
209
  bubbles: false
59
210
  });
60
211
  window.document.dispatchEvent(evt);
61
- };
212
+ }; // 领取优惠券
213
+
62
214
 
63
215
  exports.renderPreview = renderPreview;
64
216
 
217
+ var getCoupon = function getCoupon(couponId) {
218
+ return __awaiter(void 0, void 0, void 0, function () {
219
+ var err_1;
220
+ return __generator(this, function (_a) {
221
+ switch (_a.label) {
222
+ case 0:
223
+ _a.trys.push([0, 2,, 3]);
224
+
225
+ return [4
226
+ /*yield*/
227
+ , (0, _commonUtil.commonFetch)(window.magicDesign.MBaseUrl + "/h5/coupons/usercoupon", {
228
+ couponId: Number(couponId)
229
+ }, 'POST')];
230
+
231
+ case 1:
232
+ res = _a.sent();
233
+
234
+ _MessageModal["default"].success({
235
+ content: (0, _locale.i18n)('VOUCHER_SUCCESS'),
236
+ okText: 'Ok'
237
+ });
238
+
239
+ return [3
240
+ /*break*/
241
+ , 3];
242
+
243
+ case 2:
244
+ err_1 = _a.sent();
245
+
246
+ if (err_1.code === _constants.respCodeMap.NOT_LOGGED_IN) {
247
+ return [2
248
+ /*return*/
249
+ ];
250
+ }
251
+
252
+ _MessageModal["default"].success({
253
+ content: err_1.message,
254
+ okText: 'Ok'
255
+ });
256
+
257
+ return [3
258
+ /*break*/
259
+ , 3];
260
+
261
+ case 3:
262
+ return [2
263
+ /*return*/
264
+ ];
265
+ }
266
+ });
267
+ });
268
+ };
269
+
65
270
  var clickUrl = function clickUrl(url) {
66
271
  console.log('url', url);
67
272
 
@@ -78,8 +283,7 @@ var clickUrl = function clickUrl(url) {
78
283
  data = params.data; // 领取优惠券
79
284
 
80
285
  if (type === 'GET_COUPON') {
81
- _this.getCoupon(data.couponId);
82
-
286
+ getCoupon(data.couponId);
83
287
  return;
84
288
  }
85
289
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "0.0.74",
4
+ "version": "0.0.76",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",