@fonixtree/magic-design 0.0.75 → 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.
|
@@ -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;
|
package/es/utils/commonUtil.js
CHANGED
|
@@ -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
|
});
|
package/es/utils/coreUtil.js
CHANGED
|
@@ -13,6 +13,8 @@ var _commonUtil = require("./commonUtil");
|
|
|
13
13
|
|
|
14
14
|
var _androidUtil = require("./androidUtil");
|
|
15
15
|
|
|
16
|
+
var _constants = require("../constants");
|
|
17
|
+
|
|
16
18
|
var _MessageModal = _interopRequireDefault(require("../common/MessageModal"));
|
|
17
19
|
|
|
18
20
|
var _locale = require("../locale");
|
|
@@ -207,7 +209,8 @@ var renderPreview = function renderPreview() {
|
|
|
207
209
|
bubbles: false
|
|
208
210
|
});
|
|
209
211
|
window.document.dispatchEvent(evt);
|
|
210
|
-
};
|
|
212
|
+
}; // 领取优惠券
|
|
213
|
+
|
|
211
214
|
|
|
212
215
|
exports.renderPreview = renderPreview;
|
|
213
216
|
|
|
@@ -217,15 +220,7 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
217
220
|
return __generator(this, function (_a) {
|
|
218
221
|
switch (_a.label) {
|
|
219
222
|
case 0:
|
|
220
|
-
|
|
221
|
-
content: 'test',
|
|
222
|
-
okText: 'Ok'
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
_a.label = 1;
|
|
226
|
-
|
|
227
|
-
case 1:
|
|
228
|
-
_a.trys.push([1, 3,, 4]);
|
|
223
|
+
_a.trys.push([0, 2,, 3]);
|
|
229
224
|
|
|
230
225
|
return [4
|
|
231
226
|
/*yield*/
|
|
@@ -233,8 +228,8 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
233
228
|
couponId: Number(couponId)
|
|
234
229
|
}, 'POST')];
|
|
235
230
|
|
|
236
|
-
case
|
|
237
|
-
_a.sent();
|
|
231
|
+
case 1:
|
|
232
|
+
res = _a.sent();
|
|
238
233
|
|
|
239
234
|
_MessageModal["default"].success({
|
|
240
235
|
content: (0, _locale.i18n)('VOUCHER_SUCCESS'),
|
|
@@ -243,21 +238,27 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
243
238
|
|
|
244
239
|
return [3
|
|
245
240
|
/*break*/
|
|
246
|
-
,
|
|
241
|
+
, 3];
|
|
247
242
|
|
|
248
|
-
case
|
|
243
|
+
case 2:
|
|
249
244
|
err_1 = _a.sent();
|
|
250
245
|
|
|
246
|
+
if (err_1.code === _constants.respCodeMap.NOT_LOGGED_IN) {
|
|
247
|
+
return [2
|
|
248
|
+
/*return*/
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
|
|
251
252
|
_MessageModal["default"].success({
|
|
252
|
-
content: err_1,
|
|
253
|
+
content: err_1.message,
|
|
253
254
|
okText: 'Ok'
|
|
254
255
|
});
|
|
255
256
|
|
|
256
257
|
return [3
|
|
257
258
|
/*break*/
|
|
258
|
-
,
|
|
259
|
+
, 3];
|
|
259
260
|
|
|
260
|
-
case
|
|
261
|
+
case 3:
|
|
261
262
|
return [2
|
|
262
263
|
/*return*/
|
|
263
264
|
];
|
|
@@ -268,8 +269,6 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
268
269
|
|
|
269
270
|
var clickUrl = function clickUrl(url) {
|
|
270
271
|
console.log('url', url);
|
|
271
|
-
getCoupon(100);
|
|
272
|
-
return;
|
|
273
272
|
|
|
274
273
|
if (window.magicDesign.readOnly || window.magicDesign.mode !== 'renderer' || !url) {
|
|
275
274
|
return;
|
|
@@ -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;
|
package/lib/utils/commonUtil.js
CHANGED
|
@@ -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
|
});
|
package/lib/utils/coreUtil.js
CHANGED
|
@@ -13,6 +13,8 @@ var _commonUtil = require("./commonUtil");
|
|
|
13
13
|
|
|
14
14
|
var _androidUtil = require("./androidUtil");
|
|
15
15
|
|
|
16
|
+
var _constants = require("../constants");
|
|
17
|
+
|
|
16
18
|
var _MessageModal = _interopRequireDefault(require("../common/MessageModal"));
|
|
17
19
|
|
|
18
20
|
var _locale = require("../locale");
|
|
@@ -207,7 +209,8 @@ var renderPreview = function renderPreview() {
|
|
|
207
209
|
bubbles: false
|
|
208
210
|
});
|
|
209
211
|
window.document.dispatchEvent(evt);
|
|
210
|
-
};
|
|
212
|
+
}; // 领取优惠券
|
|
213
|
+
|
|
211
214
|
|
|
212
215
|
exports.renderPreview = renderPreview;
|
|
213
216
|
|
|
@@ -217,15 +220,7 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
217
220
|
return __generator(this, function (_a) {
|
|
218
221
|
switch (_a.label) {
|
|
219
222
|
case 0:
|
|
220
|
-
|
|
221
|
-
content: 'test',
|
|
222
|
-
okText: 'Ok'
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
_a.label = 1;
|
|
226
|
-
|
|
227
|
-
case 1:
|
|
228
|
-
_a.trys.push([1, 3,, 4]);
|
|
223
|
+
_a.trys.push([0, 2,, 3]);
|
|
229
224
|
|
|
230
225
|
return [4
|
|
231
226
|
/*yield*/
|
|
@@ -233,8 +228,8 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
233
228
|
couponId: Number(couponId)
|
|
234
229
|
}, 'POST')];
|
|
235
230
|
|
|
236
|
-
case
|
|
237
|
-
_a.sent();
|
|
231
|
+
case 1:
|
|
232
|
+
res = _a.sent();
|
|
238
233
|
|
|
239
234
|
_MessageModal["default"].success({
|
|
240
235
|
content: (0, _locale.i18n)('VOUCHER_SUCCESS'),
|
|
@@ -243,21 +238,27 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
243
238
|
|
|
244
239
|
return [3
|
|
245
240
|
/*break*/
|
|
246
|
-
,
|
|
241
|
+
, 3];
|
|
247
242
|
|
|
248
|
-
case
|
|
243
|
+
case 2:
|
|
249
244
|
err_1 = _a.sent();
|
|
250
245
|
|
|
246
|
+
if (err_1.code === _constants.respCodeMap.NOT_LOGGED_IN) {
|
|
247
|
+
return [2
|
|
248
|
+
/*return*/
|
|
249
|
+
];
|
|
250
|
+
}
|
|
251
|
+
|
|
251
252
|
_MessageModal["default"].success({
|
|
252
|
-
content: err_1,
|
|
253
|
+
content: err_1.message,
|
|
253
254
|
okText: 'Ok'
|
|
254
255
|
});
|
|
255
256
|
|
|
256
257
|
return [3
|
|
257
258
|
/*break*/
|
|
258
|
-
,
|
|
259
|
+
, 3];
|
|
259
260
|
|
|
260
|
-
case
|
|
261
|
+
case 3:
|
|
261
262
|
return [2
|
|
262
263
|
/*return*/
|
|
263
264
|
];
|
|
@@ -268,8 +269,6 @@ var getCoupon = function getCoupon(couponId) {
|
|
|
268
269
|
|
|
269
270
|
var clickUrl = function clickUrl(url) {
|
|
270
271
|
console.log('url', url);
|
|
271
|
-
getCoupon(100);
|
|
272
|
-
return;
|
|
273
272
|
|
|
274
273
|
if (window.magicDesign.readOnly || window.magicDesign.mode !== 'renderer' || !url) {
|
|
275
274
|
return;
|