@subiz/widget-v4 4.1.85 → 4.1.87
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/compiled_src/chatbox/TextMessage.js +7 -2
- package/compiled_src/chatbox/Widget.js +1 -1
- package/compiled_src/store/store.js +1 -1
- package/dist/127.js +273 -0
- package/dist/132.js +2796 -0
- package/dist/185.js +1885 -0
- package/dist/190815938a3.127.js +1 -0
- package/dist/190815938a3.132.js +1 -0
- package/dist/190815938a3.185.js +1 -0
- package/dist/190815938a3.27.js +1 -0
- package/dist/190815938a3.278.js +1 -0
- package/dist/190815938a3.459.js +1 -0
- package/dist/190815938a3.490.js +1 -0
- package/dist/190815938a3.74.js +1 -0
- package/dist/190815938a3.997.js +1 -0
- package/dist/190815938a3.app.js +1 -0
- package/dist/190815938a3.index.html +33 -0
- package/dist/190815938a3.library.html +33 -0
- package/dist/190815938a3.library.js +1 -0
- package/dist/190815938a3.preview.html +759 -0
- package/dist/190815938a3.preview.js +1 -0
- package/dist/190815938a3.screenshoot.js +1 -0
- package/dist/190815938a3.webview.js +1 -0
- package/dist/27.js +107 -0
- package/dist/278.js +406 -0
- package/dist/459.js +107 -0
- package/dist/490.js +305 -0
- package/dist/74.js +372 -0
- package/dist/997.js +107 -0
- package/dist/HASH +1 -0
- package/dist/assets/img/Facebook.64607ec.png +0 -0
- package/dist/assets/img/Zalo.6845707.png +0 -0
- package/dist/assets/img/award1a.1a58e10.png +0 -0
- package/dist/assets/img/award3a.3b74423.png +0 -0
- package/dist/assets/img/award4a.ed6ccd4.png +0 -0
- package/dist/assets/img/award5.39eb7ae.png +0 -0
- package/dist/assets/img/bubble_default.7d5e4ab.svg +20 -0
- package/dist/assets/img/caret.998eb8f.svg +1 -0
- package/dist/assets/img/convos_empty.2353007.svg +72 -0
- package/dist/assets/img/default.06e6ee0.jpg +0 -0
- package/dist/assets/img/default_avatar.5b74dc1.png +0 -0
- package/dist/assets/img/done_gray.d7e8203.svg +4 -0
- package/dist/assets/img/done_green.b817fd4.svg +4 -0
- package/dist/assets/img/emoji/messenger/sub_23.529_58.824.d5faf14.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_23.529_60.784.1420241.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_0.000.1e6b2c0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_45.098.3dfbc08.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_25.490_5.882.4b49e94.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_72.549.7114f58.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_84.314.231e2b7.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_27.451_96.078.ddbb008.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_29.412_5.882.61f3359.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_100.000.6df72bc.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_45.098.3d7a7ad.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_47.059.0f4d6e2.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_54.902.65724c1.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_64.706.9da3cba.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_72.549.edca5cf.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_78.431.f910f2a.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_58.824_88.235.def4e71.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_11.765.49c03d0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_27.451.46b54e5.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_29.412.e36d284.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_3.922.bb191b0.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_35.294.af7b927.png +0 -0
- package/dist/assets/img/emoji/messenger/sub_60.784_7.843.98f2a99.png +0 -0
- package/dist/assets/img/empty.29bed2d.svg +23 -0
- package/dist/assets/img/empty_1.0b98af0.svg +11 -0
- package/dist/assets/img/examplte_logo.f86535f.svg +1 -0
- package/dist/assets/img/external-link.90577cc.svg +1 -0
- package/dist/assets/img/fb_inverse_circle.36c2cfc.png +0 -0
- package/dist/assets/img/ghn.070f8e3.svg +17 -0
- package/dist/assets/img/ghtk.326eac1.svg +18 -0
- package/dist/assets/img/image_default.be0698b.png +0 -0
- package/dist/assets/img/info.ebce7ea.svg +1 -0
- package/dist/assets/img/loader.37000a7.svg +1 -0
- package/dist/assets/img/loading_static.a27f0ac.svg +10 -0
- package/dist/assets/img/main-service1.d536cc2.png +0 -0
- package/dist/assets/img/main-service2.9b99549.png +0 -0
- package/dist/assets/img/not_found_search.2ddb8d1.png +0 -0
- package/dist/assets/img/package.8d37d0f.svg +5 -0
- package/dist/assets/img/package_fade.763c001.svg +1 -0
- package/dist/assets/img/rating--average.1ea492c.svg +12 -0
- package/dist/assets/img/rating--great.e3d712e.svg +16 -0
- package/dist/assets/img/rating--poor.2938a25.svg +12 -0
- package/dist/assets/img/search.f9705ff.svg +1 -0
- package/dist/assets/img/send.6db52a9.svg +3 -0
- package/dist/assets/img/shop.f7dc7d8.svg +1 -0
- package/dist/assets/img/shop_faded.df7845a.svg +1 -0
- package/dist/assets/img/subiz-mono.877e9f5.svg +3 -0
- package/dist/assets/img/x.26fdfa3.svg +5 -0
- package/dist/malicious-app.js +15 -0
- package/dist/screenshoot.html +7 -0
- package/dist/screenshoot.js +10630 -0
- package/package.json +1 -1
- package/preview.js +148 -143
- package/screenshoot.js +2 -2
- package/src/chatbox/TextMessage.js +13 -2
- package/src/chatbox/Widget.js +1 -1
- package/src/store/store.js +1 -1
package/dist/185.js
ADDED
|
@@ -0,0 +1,1885 @@
|
|
|
1
|
+
(self["webpackChunk_subiz_widget_v4"] = self["webpackChunk_subiz_widget_v4"] || []).push([[185],{
|
|
2
|
+
|
|
3
|
+
/***/ 4185:
|
|
4
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
5
|
+
|
|
6
|
+
"use strict";
|
|
7
|
+
// ESM COMPAT FLAG
|
|
8
|
+
__webpack_require__.r(__webpack_exports__);
|
|
9
|
+
|
|
10
|
+
// EXPORTS
|
|
11
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
12
|
+
"default": () => (/* binding */ Order)
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// EXTERNAL MODULE: ./src/util/index.js + 1 modules
|
|
16
|
+
var util = __webpack_require__(8150);
|
|
17
|
+
// EXTERNAL MODULE: ./src/chatbox/releaseAnimation.js
|
|
18
|
+
var releaseAnimation = __webpack_require__(2988);
|
|
19
|
+
// EXTERNAL MODULE: ./src/chatbox/time.js
|
|
20
|
+
var time = __webpack_require__(1620);
|
|
21
|
+
// EXTERNAL MODULE: ./src/common.js
|
|
22
|
+
var common = __webpack_require__(2840);
|
|
23
|
+
// EXTERNAL MODULE: ./node_modules/preact/dist/preact.module.js
|
|
24
|
+
var preact_module = __webpack_require__(172);
|
|
25
|
+
// EXTERNAL MODULE: ./src/chatbox/spinner.js
|
|
26
|
+
var spinner = __webpack_require__(4188);
|
|
27
|
+
;// CONCATENATED MODULE: ./src/chatbox/DropdownSelect.js
|
|
28
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
29
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
30
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class DropdownSelect extends common/* Com */.Mw {
|
|
36
|
+
constructor(props) {
|
|
37
|
+
super(props);
|
|
38
|
+
_defineProperty(this, "state", {
|
|
39
|
+
show: false,
|
|
40
|
+
searchValue: ''
|
|
41
|
+
});
|
|
42
|
+
_defineProperty(this, "filterRef", (0,preact_module/* createRef */._3)());
|
|
43
|
+
_defineProperty(this, "overlayRef", (0,preact_module/* createRef */._3)());
|
|
44
|
+
_defineProperty(this, "onTouchMove", e => {
|
|
45
|
+
if (e.target === this.overlayRef.current) {
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
e.stopPropagation();
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
_defineProperty(this, "hideDropdown", () => {
|
|
51
|
+
this.setState({
|
|
52
|
+
show: false,
|
|
53
|
+
searchValue: ''
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
_defineProperty(this, "onKeydown", e => {
|
|
57
|
+
if (e.key === 'Escape') {
|
|
58
|
+
if (!this.state.show) return;
|
|
59
|
+
if (this.state.searchValue) this.setState({
|
|
60
|
+
searchValue: ''
|
|
61
|
+
});else this.hideDropdown();
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
e.stopPropagation();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
_defineProperty(this, "hasSearch", () => {
|
|
67
|
+
if (this.props.has_search) return true;
|
|
68
|
+
return util/* default */.A.size(this.props.items) >= 10;
|
|
69
|
+
});
|
|
70
|
+
_defineProperty(this, "getFilteredOptions", () => {
|
|
71
|
+
let items = this.props.items;
|
|
72
|
+
if (this.state.searchValue && this.hasSearch()) {
|
|
73
|
+
items = util/* default */.A.filter(items, item => {
|
|
74
|
+
let optionName = util/* default */.A.unicodeToAscii(item.name).toLowerCase().replace(/ /g, '');
|
|
75
|
+
let optionDesc = util/* default */.A.unicodeToAscii(item.desc).toLowerCase().replace(/ /g, '');
|
|
76
|
+
let searchValue = util/* default */.A.unicodeToAscii(this.state.searchValue).toLowerCase().replace(/ /g, '');
|
|
77
|
+
return optionName.indexOf(searchValue) != -1 || optionDesc.indexOf(searchValue) != -1;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return items;
|
|
81
|
+
});
|
|
82
|
+
_defineProperty(this, "onChangeSearchValue", e => {
|
|
83
|
+
this.setState({
|
|
84
|
+
searchValue: e.target.value
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
_defineProperty(this, "toogleDropdown", async () => {
|
|
88
|
+
await this.setState({
|
|
89
|
+
show: true,
|
|
90
|
+
searchValue: ''
|
|
91
|
+
});
|
|
92
|
+
this.focusFilter();
|
|
93
|
+
});
|
|
94
|
+
_defineProperty(this, "onSelect", item => {
|
|
95
|
+
this.props.onSelect(item);
|
|
96
|
+
this.hideDropdown();
|
|
97
|
+
});
|
|
98
|
+
_defineProperty(this, "onBackgroundScroll", e => {
|
|
99
|
+
console.log('EEEEEEE', e);
|
|
100
|
+
alert('y');
|
|
101
|
+
});
|
|
102
|
+
document.addEventListener('touchmove', function (e) {});
|
|
103
|
+
}
|
|
104
|
+
componentDidMount() {
|
|
105
|
+
window.addEventListener('keydown', this.onKeydown);
|
|
106
|
+
}
|
|
107
|
+
componentWillUnmount() {
|
|
108
|
+
window.removeEventListener('keydown', this.onKeydown);
|
|
109
|
+
}
|
|
110
|
+
renderEmpty() {
|
|
111
|
+
return (0,preact_module.h)("div", {
|
|
112
|
+
class: "dropdown_select_filter__empty"
|
|
113
|
+
}, (0,preact_module.h)("img", {
|
|
114
|
+
class: "dropdown_select_filter__empty_img",
|
|
115
|
+
src: __webpack_require__(3142)
|
|
116
|
+
}), (0,preact_module.h)("div", {
|
|
117
|
+
class: "muted",
|
|
118
|
+
style: "text-align: center !important;"
|
|
119
|
+
}, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
|
|
120
|
+
}
|
|
121
|
+
renderLoading() {
|
|
122
|
+
return (0,preact_module.h)("div", {
|
|
123
|
+
class: "dropdown_select_filter__empty pt-3"
|
|
124
|
+
}, (0,preact_module.h)(spinner/* default */.A, {
|
|
125
|
+
size: "40",
|
|
126
|
+
static: true
|
|
127
|
+
}), (0,preact_module.h)("div", {
|
|
128
|
+
class: "muted mt-2",
|
|
129
|
+
style: "text-align: center !important;"
|
|
130
|
+
}, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
|
|
131
|
+
}
|
|
132
|
+
focusFilter() {
|
|
133
|
+
if (!this.filterRef.current) return;
|
|
134
|
+
this.filterRef.current.focus();
|
|
135
|
+
util/* default */.A.setTimeout(() => {
|
|
136
|
+
if (!this.filterRef.current) return;
|
|
137
|
+
this.filterRef.current.focus();
|
|
138
|
+
}, 100);
|
|
139
|
+
}
|
|
140
|
+
renderDropdown() {
|
|
141
|
+
if (!this.state.show) return null;
|
|
142
|
+
let items = this.getFilteredOptions();
|
|
143
|
+
let $items = util/* default */.A.map(items, item => {
|
|
144
|
+
return (0,preact_module.h)("div", {
|
|
145
|
+
class: "dropdown_select__item",
|
|
146
|
+
onClick: _ => this.onSelect(item)
|
|
147
|
+
}, item.name);
|
|
148
|
+
});
|
|
149
|
+
let $filter = null;
|
|
150
|
+
if (this.hasSearch()) {
|
|
151
|
+
let $img = (0,preact_module.h)("img", {
|
|
152
|
+
class: "dropdown_select_filter__icon",
|
|
153
|
+
src: __webpack_require__(5452)
|
|
154
|
+
});
|
|
155
|
+
if (this.props.loading) {
|
|
156
|
+
$img = (0,preact_module.h)("img", {
|
|
157
|
+
class: "dropdown_select_filter__icon",
|
|
158
|
+
src: __webpack_require__(185)
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
$filter = (0,preact_module.h)("div", {
|
|
162
|
+
class: "dropdown_select_filter"
|
|
163
|
+
}, $img, (0,preact_module.h)("input", {
|
|
164
|
+
ref: this.filterRef,
|
|
165
|
+
value: this.state.searchValue,
|
|
166
|
+
onInput: this.onChangeSearchValue,
|
|
167
|
+
type: "text",
|
|
168
|
+
class: "dropdown_select_filter_input "
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
if ($items.length == 0) $items = this.renderEmpty();
|
|
172
|
+
if (this.props.loading) $items = this.renderLoading();
|
|
173
|
+
let style = `width: ${this.props.width || '150px'} !important;`;
|
|
174
|
+
if (this.props.full) {
|
|
175
|
+
style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
|
|
176
|
+
return (0,preact_module.h)("div", {
|
|
177
|
+
class: "dropdown_select__overlay",
|
|
178
|
+
ref: this.overlayRef,
|
|
179
|
+
onClick: this.hideDropdown,
|
|
180
|
+
onTouchMove: this.onTouchMove
|
|
181
|
+
}, (0,preact_module.h)("div", {
|
|
182
|
+
class: "dropdown_select",
|
|
183
|
+
style: style,
|
|
184
|
+
onClick: e => {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
e.stopPropagation();
|
|
187
|
+
}
|
|
188
|
+
}, $filter, (0,preact_module.h)("div", {
|
|
189
|
+
class: "dropdown_select__items"
|
|
190
|
+
}, $items)));
|
|
191
|
+
}
|
|
192
|
+
return (0,preact_module.h)("div", {
|
|
193
|
+
class: "dropdown_select",
|
|
194
|
+
style: style
|
|
195
|
+
}, $filter, (0,preact_module.h)("div", {
|
|
196
|
+
class: "dropdown_select__items"
|
|
197
|
+
}, $items));
|
|
198
|
+
}
|
|
199
|
+
render() {
|
|
200
|
+
let $name = (0,preact_module.h)("div", {
|
|
201
|
+
class: "muted text-truncate",
|
|
202
|
+
style: "flex: 1 !important;"
|
|
203
|
+
}, "Ch\u1ECDn m\u1ED9t ph\u1EA7n t\u1EED");
|
|
204
|
+
if (util/* default */.A.get(this.props, 'selected.name')) $name = (0,preact_module.h)("div", {
|
|
205
|
+
class: "text-truncate",
|
|
206
|
+
style: "flex: 1 !important;"
|
|
207
|
+
}, util/* default */.A.get(this.props, 'selected.name'));
|
|
208
|
+
let style = 'position: relative !important;';
|
|
209
|
+
if (this.props.full) {
|
|
210
|
+
style = '';
|
|
211
|
+
}
|
|
212
|
+
return (0,preact_module.h)("div", {
|
|
213
|
+
style: style
|
|
214
|
+
}, (0,preact_module.h)(common/* Clickaway */.tW, {
|
|
215
|
+
onClickaway: this.hideDropdown
|
|
216
|
+
}, (0,preact_module.h)("div", {
|
|
217
|
+
type: "text",
|
|
218
|
+
class: 'dropdown_select_input ' + this.props.extra_cls,
|
|
219
|
+
onClick: this.toogleDropdown
|
|
220
|
+
}, $name, "\xA0", (0,preact_module.h)("img", {
|
|
221
|
+
class: "dropdown_select__caret",
|
|
222
|
+
src: __webpack_require__(7741)
|
|
223
|
+
})), this.renderDropdown()));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
;// CONCATENATED MODULE: ./src/order/address_picker.js
|
|
227
|
+
function address_picker_defineProperty(e, r, t) { return (r = address_picker_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
228
|
+
function address_picker_toPropertyKey(t) { var i = address_picker_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
229
|
+
function address_picker_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
class AddressPicker extends common/* Com */.Mw {
|
|
235
|
+
constructor(props) {
|
|
236
|
+
super(props);
|
|
237
|
+
address_picker_defineProperty(this, "state", {
|
|
238
|
+
show: false,
|
|
239
|
+
searchValue: '',
|
|
240
|
+
addresses: []
|
|
241
|
+
});
|
|
242
|
+
address_picker_defineProperty(this, "filterRef", (0,preact_module/* createRef */._3)());
|
|
243
|
+
address_picker_defineProperty(this, "overlayRef", (0,preact_module/* createRef */._3)());
|
|
244
|
+
address_picker_defineProperty(this, "onTouchMove", e => {
|
|
245
|
+
if (e.target === this.overlayRef.current) {
|
|
246
|
+
e.preventDefault();
|
|
247
|
+
e.stopPropagation();
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
address_picker_defineProperty(this, "hideDropdown", () => {
|
|
251
|
+
this.setState({
|
|
252
|
+
show: false,
|
|
253
|
+
searchValue: ''
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
address_picker_defineProperty(this, "onKeydown", e => {
|
|
257
|
+
if (e.key === 'Escape') {
|
|
258
|
+
if (!this.state.show) return;
|
|
259
|
+
if (this.state.searchValue) this.setState({
|
|
260
|
+
searchValue: ''
|
|
261
|
+
});else this.hideDropdown();
|
|
262
|
+
e.preventDefault();
|
|
263
|
+
e.stopPropagation();
|
|
264
|
+
}
|
|
265
|
+
if (e.key == 'Enter') {}
|
|
266
|
+
});
|
|
267
|
+
address_picker_defineProperty(this, "doSearch", util/* default */.A.throttle(async () => {
|
|
268
|
+
let requestId = Date.now();
|
|
269
|
+
this.requestId = requestId;
|
|
270
|
+
let res = await this.props.store.suggest_addresses(this.state.searchValue);
|
|
271
|
+
if (this.requestId !== requestId) return;
|
|
272
|
+
this.setState({
|
|
273
|
+
addresses: util/* default */.A.get(res, 'body.addresses', [])
|
|
274
|
+
});
|
|
275
|
+
}, 100));
|
|
276
|
+
address_picker_defineProperty(this, "onChangeSearchValue", e => {
|
|
277
|
+
this.setState({
|
|
278
|
+
searchValue: e.target.value
|
|
279
|
+
});
|
|
280
|
+
this.props.onChangeAddress(e.target.value);
|
|
281
|
+
this.doSearch();
|
|
282
|
+
});
|
|
283
|
+
address_picker_defineProperty(this, "toogleDropdown", async () => {
|
|
284
|
+
await this.setState({
|
|
285
|
+
show: true,
|
|
286
|
+
searchValue: this.props.initAddress || ''
|
|
287
|
+
});
|
|
288
|
+
this.focusFilter();
|
|
289
|
+
});
|
|
290
|
+
address_picker_defineProperty(this, "onSelect", item => {
|
|
291
|
+
this.props.onSelect(item);
|
|
292
|
+
this.hideDropdown();
|
|
293
|
+
});
|
|
294
|
+
address_picker_defineProperty(this, "onBackgroundScroll", e => {
|
|
295
|
+
console.log('EEEEEEE', e);
|
|
296
|
+
});
|
|
297
|
+
document.addEventListener('touchmove', function (e) {});
|
|
298
|
+
}
|
|
299
|
+
componentDidMount() {
|
|
300
|
+
window.addEventListener('keydown', this.onKeydown);
|
|
301
|
+
}
|
|
302
|
+
componentWillUnmount() {
|
|
303
|
+
window.removeEventListener('keydown', this.onKeydown);
|
|
304
|
+
}
|
|
305
|
+
renderEmpty() {
|
|
306
|
+
return (0,preact_module.h)("div", {
|
|
307
|
+
class: "dropdown_select_filter__empty"
|
|
308
|
+
}, (0,preact_module.h)("img", {
|
|
309
|
+
class: "dropdown_select_filter__empty_img",
|
|
310
|
+
src: __webpack_require__(3142)
|
|
311
|
+
}), (0,preact_module.h)("div", {
|
|
312
|
+
class: "muted",
|
|
313
|
+
style: "text-align: center !important;"
|
|
314
|
+
}, "Kh\xF4ng c\xF3 k\u1EBFt qu\u1EA3"));
|
|
315
|
+
}
|
|
316
|
+
renderLoading() {
|
|
317
|
+
return (0,preact_module.h)("div", {
|
|
318
|
+
class: "dropdown_select_filter__empty pt-3"
|
|
319
|
+
}, (0,preact_module.h)(spinner/* default */.A, {
|
|
320
|
+
size: "40",
|
|
321
|
+
static: true
|
|
322
|
+
}), (0,preact_module.h)("div", {
|
|
323
|
+
class: "muted mt-2",
|
|
324
|
+
style: "text-align: center !important;"
|
|
325
|
+
}, "\u0110ang t\u1EA3i d\u1EEF li\u1EC7u"));
|
|
326
|
+
}
|
|
327
|
+
focusFilter() {
|
|
328
|
+
if (!this.filterRef.current) return;
|
|
329
|
+
this.filterRef.current.focus();
|
|
330
|
+
util/* default */.A.setTimeout(() => {
|
|
331
|
+
if (!this.filterRef.current) return;
|
|
332
|
+
this.filterRef.current.focus();
|
|
333
|
+
}, 100);
|
|
334
|
+
}
|
|
335
|
+
renderDropdown() {
|
|
336
|
+
if (!this.state.show) return null;
|
|
337
|
+
let $items = util/* default */.A.map(this.state.addresses, (addr, i) => {
|
|
338
|
+
let label = [((addr.address || '') + ' ' + normalize(addr.street)).trim()].join(', ');
|
|
339
|
+
let desc = [normalize(addr.ward), normalize(addr.district), normalize(addr.province)].join(', ');
|
|
340
|
+
return (0,preact_module.h)("div", {
|
|
341
|
+
class: "dropdown_select__item",
|
|
342
|
+
onClick: _ => this.onSelect(addr),
|
|
343
|
+
key: i
|
|
344
|
+
}, (0,preact_module.h)("div", null, (0,preact_module.h)("b", null, label)), (0,preact_module.h)("div", {
|
|
345
|
+
style: "opacity: 0.7 !important;"
|
|
346
|
+
}, desc));
|
|
347
|
+
});
|
|
348
|
+
let $filter = null;
|
|
349
|
+
let $img = (0,preact_module.h)("img", {
|
|
350
|
+
class: "dropdown_select_filter__icon",
|
|
351
|
+
src: __webpack_require__(5452)
|
|
352
|
+
});
|
|
353
|
+
if (this.props.loading) {
|
|
354
|
+
$img = (0,preact_module.h)("img", {
|
|
355
|
+
class: "dropdown_select_filter__icon",
|
|
356
|
+
src: __webpack_require__(185)
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
$filter = (0,preact_module.h)("div", {
|
|
360
|
+
class: "dropdown_select_filter"
|
|
361
|
+
}, $img, (0,preact_module.h)("input", {
|
|
362
|
+
ref: this.filterRef,
|
|
363
|
+
value: this.state.searchValue,
|
|
364
|
+
onInput: this.onChangeSearchValue,
|
|
365
|
+
type: "text",
|
|
366
|
+
class: "dropdown_select_filter_input "
|
|
367
|
+
}));
|
|
368
|
+
if ($items.length == 0) $items = this.renderEmpty();
|
|
369
|
+
if (this.props.loading) $items = this.renderLoading();
|
|
370
|
+
let style = `width: ${this.props.width || '150px'} !important;`;
|
|
371
|
+
if (this.props.full) {
|
|
372
|
+
style = ` top: 20px !important; left: 20px !important; right: 20px !important; width: unset !important; `;
|
|
373
|
+
return (0,preact_module.h)("div", {
|
|
374
|
+
class: "dropdown_select__overlay",
|
|
375
|
+
ref: this.overlayRef,
|
|
376
|
+
onClick: this.hideDropdown,
|
|
377
|
+
onTouchMove: this.onTouchMove
|
|
378
|
+
}, (0,preact_module.h)("div", {
|
|
379
|
+
class: "dropdown_select",
|
|
380
|
+
style: style,
|
|
381
|
+
onClick: e => {
|
|
382
|
+
e.preventDefault();
|
|
383
|
+
e.stopPropagation();
|
|
384
|
+
}
|
|
385
|
+
}, $filter, (0,preact_module.h)("div", {
|
|
386
|
+
class: "dropdown_select__items"
|
|
387
|
+
}, $items)));
|
|
388
|
+
}
|
|
389
|
+
return (0,preact_module.h)("div", {
|
|
390
|
+
class: "dropdown_select",
|
|
391
|
+
style: style
|
|
392
|
+
}, $filter, (0,preact_module.h)("div", {
|
|
393
|
+
class: "dropdown_select__items"
|
|
394
|
+
}, $items));
|
|
395
|
+
}
|
|
396
|
+
render() {
|
|
397
|
+
let $name = (0,preact_module.h)("div", {
|
|
398
|
+
class: "text-truncate",
|
|
399
|
+
style: "flex: 1 !important;"
|
|
400
|
+
}, this.props.initAddress);
|
|
401
|
+
let style = 'position: relative !important;';
|
|
402
|
+
if (this.props.full) {
|
|
403
|
+
style = '';
|
|
404
|
+
}
|
|
405
|
+
return (0,preact_module.h)("div", {
|
|
406
|
+
style: style
|
|
407
|
+
}, (0,preact_module.h)(common/* Clickaway */.tW, {
|
|
408
|
+
onClickaway: this.hideDropdown
|
|
409
|
+
}, (0,preact_module.h)("div", {
|
|
410
|
+
type: "text",
|
|
411
|
+
class: 'dropdown_select_input ' + this.props.extra_cls,
|
|
412
|
+
onClick: this.toogleDropdown
|
|
413
|
+
}, $name), this.renderDropdown()));
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function normalize(s) {
|
|
417
|
+
let ls = (s + '').toLowerCase();
|
|
418
|
+
if (ls.startsWith('tp ')) return s.substr(3);
|
|
419
|
+
if (ls.startsWith('thanh pho ')) return s.substr('thanh pho '.length);
|
|
420
|
+
if (ls.startsWith('thành phố ')) return s.substr('thành phố '.length);
|
|
421
|
+
if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
|
|
422
|
+
if (ls.startsWith('huyện ')) return s.substr('huyện '.length);
|
|
423
|
+
if (ls.startsWith('tỉnh ')) return s.substr('tỉnh '.length);
|
|
424
|
+
if (ls.startsWith('xã ')) return s.substr('xã '.length);
|
|
425
|
+
if (ls.startsWith('thị trấn ')) return s.substr('thị trấn '.length);
|
|
426
|
+
if (ls.startsWith('thị xã ')) return s.substr('thị xã '.length);
|
|
427
|
+
if (ls.startsWith('đường ') && (s[7] < '0' || s[7] > '9')) return s.substr('đường '.length);
|
|
428
|
+
if (ls.startsWith('phường ') && (s[7] < '0' || s[7] > '9')) return s.substr('phường '.length);
|
|
429
|
+
if (ls.startsWith('quận ') && (s[7] < '0' || s[7] > '9')) return s.substr('quận '.length);
|
|
430
|
+
return s;
|
|
431
|
+
}
|
|
432
|
+
;// CONCATENATED MODULE: ./src/order/icon.js
|
|
433
|
+
|
|
434
|
+
let promiseMainCSS = (() => __webpack_require__.e(/* import() */ 278).then(__webpack_require__.bind(__webpack_require__, 9278)))();
|
|
435
|
+
var $link = document.createElement('link');
|
|
436
|
+
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap';
|
|
437
|
+
$link.rel = 'stylesheet';
|
|
438
|
+
document.head.append($link);
|
|
439
|
+
util/* default */.A.preloadWebfonts(['Inter'], [400, 500]);
|
|
440
|
+
|
|
441
|
+
let defaultAvatar = __webpack_require__(2538);
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
class Icon extends common/* Com */.Mw {
|
|
446
|
+
render() {
|
|
447
|
+
if (this.props.name == 'package') {
|
|
448
|
+
if (this.props.active) return (0,preact_module.h)("img", {
|
|
449
|
+
style: "width: 18px !important;",
|
|
450
|
+
src: __webpack_require__(8512)
|
|
451
|
+
});
|
|
452
|
+
return (0,preact_module.h)("img", {
|
|
453
|
+
style: "width: 18px !important;",
|
|
454
|
+
src: __webpack_require__(6857)
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
if (this.props.name === 'shop') {
|
|
458
|
+
if (this.props.active) return (0,preact_module.h)("img", {
|
|
459
|
+
style: "width: 18px !important;",
|
|
460
|
+
src: __webpack_require__(5244)
|
|
461
|
+
});
|
|
462
|
+
return (0,preact_module.h)("img", {
|
|
463
|
+
style: "width: 18px !important;",
|
|
464
|
+
src: __webpack_require__(2523)
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
;// CONCATENATED MODULE: ./src/order/order.js
|
|
470
|
+
function order_defineProperty(e, r, t) { return (r = order_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
471
|
+
function order_toPropertyKey(t) { var i = order_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
472
|
+
function order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
|
|
481
|
+
var checkedimg = __webpack_require__(5860);
|
|
482
|
+
var ximg = __webpack_require__(3080);
|
|
483
|
+
class order_Order extends common/* Com */.Mw {
|
|
484
|
+
constructor(props) {
|
|
485
|
+
super(props);
|
|
486
|
+
order_defineProperty(this, "state", {
|
|
487
|
+
loadProvince: true,
|
|
488
|
+
g_err: '',
|
|
489
|
+
fullname: '',
|
|
490
|
+
email: '',
|
|
491
|
+
phone: '',
|
|
492
|
+
loading: true,
|
|
493
|
+
order: {},
|
|
494
|
+
err: {},
|
|
495
|
+
shipping_address: 'new',
|
|
496
|
+
selectedProvince: null,
|
|
497
|
+
selectedDistrict: null,
|
|
498
|
+
selectedWard: null,
|
|
499
|
+
street: '',
|
|
500
|
+
address: '',
|
|
501
|
+
sending: false,
|
|
502
|
+
step: ''
|
|
503
|
+
});
|
|
504
|
+
order_defineProperty(this, "renderMobileSuccess", order => {
|
|
505
|
+
return (0,preact_module.h)("div", {
|
|
506
|
+
class: "order",
|
|
507
|
+
style: "height: 100% !important"
|
|
508
|
+
}, (0,preact_module.h)("div", {
|
|
509
|
+
style: "display: flex !important; align-items: center !important; padding-top: 40px !important; padding-bottom: 20px !important; flex-direction: column !important; height: 100% !important"
|
|
510
|
+
}, (0,preact_module.h)("img", {
|
|
511
|
+
style: "width: 60px !important; height: 60px !important;",
|
|
512
|
+
width: "60",
|
|
513
|
+
height: "60",
|
|
514
|
+
src: checkedimg
|
|
515
|
+
}), (0,preact_module.h)("div", {
|
|
516
|
+
style: "margin-top: 20px !important; margin-bottom: 10px !important"
|
|
517
|
+
}, (0,preact_module.h)("b", {
|
|
518
|
+
style: "font-size: 18px !important;"
|
|
519
|
+
}, "\u0110\u01A1n h\xE0ng c\u1EE7a b\u1EA1n \u0111\xE3 \u0111\u01B0\u1EE3c ghi nh\u1EADn")), (0,preact_module.h)("div", {
|
|
520
|
+
class: "muted"
|
|
521
|
+
}, "T\xF4i s\u1EBD li\xEAn h\u1EC7 l\u1EA1i v\u1EDBi b\u1EA1n khi \u0111\u01A1n h\xE0ng \u0111\u01B0\u1EE3c x\u1EED l\xFD"), (0,preact_module.h)("div", {
|
|
522
|
+
style: "flex:1 !important"
|
|
523
|
+
}), (0,preact_module.h)("div", {
|
|
524
|
+
style: "margin-top: 20px !important; padding: 0px 20px 0 20px !important; width: 100% !important"
|
|
525
|
+
}, (0,preact_module.h)("div", {
|
|
526
|
+
class: "order_btn order__btn__light",
|
|
527
|
+
onClick: this.close
|
|
528
|
+
}, this.props.t('close')))));
|
|
529
|
+
});
|
|
530
|
+
order_defineProperty(this, "onSelectProvince", async item => {
|
|
531
|
+
this.setState({
|
|
532
|
+
selectedProvince: item,
|
|
533
|
+
err: {},
|
|
534
|
+
g_err: ''
|
|
535
|
+
});
|
|
536
|
+
this.setState({
|
|
537
|
+
loadDistrict: true
|
|
538
|
+
});
|
|
539
|
+
let out = await this.props.store.list_districts({
|
|
540
|
+
id: item.id
|
|
541
|
+
});
|
|
542
|
+
this.setState({
|
|
543
|
+
loadDistrict: false
|
|
544
|
+
});
|
|
545
|
+
if (!out.error) this.setState({
|
|
546
|
+
districts: util/* default */.A.get(out, 'body.addresses')
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
order_defineProperty(this, "onSelectDistrict", async item => {
|
|
550
|
+
this.setState({
|
|
551
|
+
selectedDistrict: item,
|
|
552
|
+
err: {},
|
|
553
|
+
g_err: ''
|
|
554
|
+
});
|
|
555
|
+
this.setState({
|
|
556
|
+
loadWard: true
|
|
557
|
+
});
|
|
558
|
+
let out = await this.props.store.list_wards({
|
|
559
|
+
id: item.id
|
|
560
|
+
});
|
|
561
|
+
this.setState({
|
|
562
|
+
loadWard: false
|
|
563
|
+
});
|
|
564
|
+
if (!out.error) this.setState({
|
|
565
|
+
wards: util/* default */.A.get(out, 'body.addresses')
|
|
566
|
+
});
|
|
567
|
+
});
|
|
568
|
+
order_defineProperty(this, "onSelectWard", item => this.setState({
|
|
569
|
+
selectedWard: item,
|
|
570
|
+
err: {},
|
|
571
|
+
g_err: ''
|
|
572
|
+
}));
|
|
573
|
+
order_defineProperty(this, "onChangeFullname", e => this.setState({
|
|
574
|
+
fullname: e.target.value,
|
|
575
|
+
err: {},
|
|
576
|
+
g_err: ''
|
|
577
|
+
}));
|
|
578
|
+
order_defineProperty(this, "onChangeAddress", e => this.setState({
|
|
579
|
+
address: e,
|
|
580
|
+
err: {},
|
|
581
|
+
g_err: ''
|
|
582
|
+
}));
|
|
583
|
+
order_defineProperty(this, "onSelectAddress", addr => {
|
|
584
|
+
if (!addr) return;
|
|
585
|
+
this.setState({
|
|
586
|
+
address: [util/* default */.A.trim(addr.address), util/* default */.A.trim(addr.street)].join(' ').trim(),
|
|
587
|
+
street: addr.street,
|
|
588
|
+
err: {},
|
|
589
|
+
g_err: ''
|
|
590
|
+
});
|
|
591
|
+
this.onSelectWard({
|
|
592
|
+
id: addr.ward_id,
|
|
593
|
+
name: addr.ward
|
|
594
|
+
});
|
|
595
|
+
this.onSelectDistrict({
|
|
596
|
+
id: addr.district_id,
|
|
597
|
+
name: addr.district
|
|
598
|
+
});
|
|
599
|
+
this.onSelectProvince({
|
|
600
|
+
id: addr.province_id,
|
|
601
|
+
name: addr.province
|
|
602
|
+
});
|
|
603
|
+
});
|
|
604
|
+
order_defineProperty(this, "onChangeEmail", e => this.setState({
|
|
605
|
+
email: e.target.value,
|
|
606
|
+
err: {},
|
|
607
|
+
g_err: ''
|
|
608
|
+
}));
|
|
609
|
+
order_defineProperty(this, "onChangePhone", e => this.setState({
|
|
610
|
+
phone: e.target.value,
|
|
611
|
+
err: {},
|
|
612
|
+
g_err: ''
|
|
613
|
+
}));
|
|
614
|
+
order_defineProperty(this, "onChangePaymentMethod", id => this.setState({
|
|
615
|
+
pm: id
|
|
616
|
+
}));
|
|
617
|
+
order_defineProperty(this, "onChangeQuantity", (item, text) => {
|
|
618
|
+
let qty = parseInt(text) || 1;
|
|
619
|
+
item.quantity = qty;
|
|
620
|
+
this.forceUpdate();
|
|
621
|
+
});
|
|
622
|
+
order_defineProperty(this, "confirm", async () => {
|
|
623
|
+
this.setState({
|
|
624
|
+
g_err: ''
|
|
625
|
+
});
|
|
626
|
+
let err = {};
|
|
627
|
+
if (!this.state.shipping) {
|
|
628
|
+
this.setState({
|
|
629
|
+
g_err: 'Mời bạn chọn địa chỉ giao hàng trước khi xác nhận'
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
if (this.state.shipping === 'shop') {
|
|
633
|
+
if (!util/* default */.A.isPhone(this.state.phone)) {
|
|
634
|
+
err.phone = true;
|
|
635
|
+
}
|
|
636
|
+
if (!util/* default */.A.trim(this.state.fullname)) {
|
|
637
|
+
err.name = true;
|
|
638
|
+
}
|
|
639
|
+
if (!util/* default */.A.trim(this.state.email)) {
|
|
640
|
+
err.email = true;
|
|
641
|
+
}
|
|
642
|
+
} else if (this.state.shipping_address == 'new') {
|
|
643
|
+
if (!util/* default */.A.isPhone(this.state.phone)) {
|
|
644
|
+
err.phone = true;
|
|
645
|
+
}
|
|
646
|
+
if (!util/* default */.A.trim(this.state.fullname)) {
|
|
647
|
+
err.name = true;
|
|
648
|
+
}
|
|
649
|
+
if (!util/* default */.A.trim(this.state.address)) {
|
|
650
|
+
err.address = true;
|
|
651
|
+
}
|
|
652
|
+
if (util/* default */.A.size(this.state.selectedWard) == 0) {
|
|
653
|
+
err.ward = true;
|
|
654
|
+
}
|
|
655
|
+
if (util/* default */.A.size(this.state.selectedDistrict) == 0) {
|
|
656
|
+
err.district = true;
|
|
657
|
+
}
|
|
658
|
+
if (util/* default */.A.size(this.state.selectedProvince) == 0) {
|
|
659
|
+
err.province = true;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
if (util/* default */.A.size(err) > 0) {
|
|
663
|
+
this.setState({
|
|
664
|
+
err,
|
|
665
|
+
g_err: this.props.t('input_shipping_info_err')
|
|
666
|
+
});
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
let user = this.props.store.matchUser();
|
|
670
|
+
let ufullname = util/* default */.A.getUserAttr(user, 'fullname', 'text');
|
|
671
|
+
let uemail = util/* default */.A.getUserAttr(user, 'emails', 'text');
|
|
672
|
+
let uphone = util/* default */.A.getUserAttr(user, 'phones', 'text');
|
|
673
|
+
let order = util/* default */.A.cloneDeep(this.state.order);
|
|
674
|
+
if (this.state.shipping === 'shop') {
|
|
675
|
+
util/* default */.A.set(order, 'shipping.pickup_at_shop', true);
|
|
676
|
+
util/* default */.A.set(order, 'shipping.address.phone', this.state.phone);
|
|
677
|
+
util/* default */.A.set(order, 'shipping.address.fullname', this.state.fullname);
|
|
678
|
+
util/* default */.A.set(order, 'shipping.address.email', this.state.email);
|
|
679
|
+
} else {
|
|
680
|
+
if (this.state.shipping_address == 'new') {
|
|
681
|
+
let out = await this.props.store.createShippingAddress({
|
|
682
|
+
address: this.state.address,
|
|
683
|
+
country: 'Việt Nam',
|
|
684
|
+
fullname: this.state.fullname,
|
|
685
|
+
email: this.state.email,
|
|
686
|
+
phone: this.state.phone,
|
|
687
|
+
district: this.state.selectedDistrict.name,
|
|
688
|
+
district_id: this.state.selectedDistrict.id,
|
|
689
|
+
province: this.state.selectedProvince.name,
|
|
690
|
+
province_id: this.state.selectedProvince.id,
|
|
691
|
+
ward: this.state.selectedWard.name,
|
|
692
|
+
street: this.state.street,
|
|
693
|
+
ward_id: this.state.selectedWard.id
|
|
694
|
+
});
|
|
695
|
+
if (out.error) return this.setState({
|
|
696
|
+
g_err: this.props.t('update_failed')
|
|
697
|
+
});
|
|
698
|
+
util/* default */.A.set(order, 'shipping.address', out.body);
|
|
699
|
+
} else {
|
|
700
|
+
let addresses = this.props.store.matchShippingAddresses();
|
|
701
|
+
let sa = util/* default */.A.find(addresses, addr => addr.id === this.state.shipping_address);
|
|
702
|
+
if (!sa) {
|
|
703
|
+
return this.setState({
|
|
704
|
+
err,
|
|
705
|
+
g_err: this.props.t('input_shipping_info_err')
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
util/* default */.A.set(order, 'shipping.address', sa);
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
let changeduser = false;
|
|
712
|
+
if (!ufullname && this.state.fullname) {
|
|
713
|
+
changeduser = true;
|
|
714
|
+
util/* default */.A.setUserAttr(user, {
|
|
715
|
+
key: 'fullname',
|
|
716
|
+
text: this.state.fullname
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
if (!uemail && this.state.email) {
|
|
720
|
+
changeduser = true;
|
|
721
|
+
util/* default */.A.setUserAttr(user, {
|
|
722
|
+
key: 'emails',
|
|
723
|
+
text: this.state.email
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
if (!uphone && this.state.phone) {
|
|
727
|
+
changeduser = true;
|
|
728
|
+
util/* default */.A.setUserAttr(user, {
|
|
729
|
+
key: 'phones',
|
|
730
|
+
text: this.state.phone
|
|
731
|
+
});
|
|
732
|
+
}
|
|
733
|
+
if (changeduser) this.props.store.setUser(user);
|
|
734
|
+
this.setState({
|
|
735
|
+
sending: true
|
|
736
|
+
});
|
|
737
|
+
order.user_confirmation = 'confirmed';
|
|
738
|
+
let out = await this.props.store.updateOrder(order);
|
|
739
|
+
this.setState({
|
|
740
|
+
sending: false
|
|
741
|
+
});
|
|
742
|
+
if (out.error) {
|
|
743
|
+
return this.setState({
|
|
744
|
+
g_err: this.props.t('update_failed')
|
|
745
|
+
});
|
|
746
|
+
}
|
|
747
|
+
this.setState({
|
|
748
|
+
step: 'success'
|
|
749
|
+
});
|
|
750
|
+
if (this.props.onResponse) this.props.onResponse('confirmed');
|
|
751
|
+
});
|
|
752
|
+
order_defineProperty(this, "onCancel", () => {
|
|
753
|
+
if (this.props.onResponse) this.props.onResponse('rejected');
|
|
754
|
+
if (this.props.cid && !this.state.order.user_confirmation) {
|
|
755
|
+
let order = util/* default */.A.cloneDeep(this.state.order);
|
|
756
|
+
order.user_confirmation = 'rejected';
|
|
757
|
+
this.props.store.updateOrder(order);
|
|
758
|
+
}
|
|
759
|
+
this.close();
|
|
760
|
+
});
|
|
761
|
+
order_defineProperty(this, "close", () => {
|
|
762
|
+
if (this.props.onClose) this.props.onClose();
|
|
763
|
+
});
|
|
764
|
+
this.load();
|
|
765
|
+
}
|
|
766
|
+
async load() {
|
|
767
|
+
if (!this.props.order_id) return;
|
|
768
|
+
let orderout = await this.props.store.fetchOrder(this.props.order_id);
|
|
769
|
+
this.setState({
|
|
770
|
+
loading: false
|
|
771
|
+
});
|
|
772
|
+
if (!orderout.error) {
|
|
773
|
+
this.setState({
|
|
774
|
+
order: orderout.body
|
|
775
|
+
});
|
|
776
|
+
} else {
|
|
777
|
+
this.setState({
|
|
778
|
+
error: orderout.error
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
let user = this.props.store.matchUser();
|
|
782
|
+
let attributes = util/* default */.A.get(this.props.store.matchUser(), 'attributes', []);
|
|
783
|
+
let fullname = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'fullname'), 'text');
|
|
784
|
+
let email = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'emails'), 'text');
|
|
785
|
+
let phone = util/* default */.A.get(util/* default */.A.find(attributes, att => att.key === 'phones'), 'text');
|
|
786
|
+
this.setState({
|
|
787
|
+
fullname,
|
|
788
|
+
email,
|
|
789
|
+
phone
|
|
790
|
+
});
|
|
791
|
+
await this.props.store.fetchShippingAddresses();
|
|
792
|
+
let out = await this.props.store.list_provinces();
|
|
793
|
+
this.setState({
|
|
794
|
+
loadProvince: false
|
|
795
|
+
});
|
|
796
|
+
if (!out.error) this.setState({
|
|
797
|
+
provinces: util/* default */.A.get(out, 'body.addresses')
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
isMobile() {
|
|
801
|
+
if (this.props.cid) return true;
|
|
802
|
+
if (this.props.isMobile) return true;
|
|
803
|
+
return this.props.store.isMobile();
|
|
804
|
+
}
|
|
805
|
+
onChangeShippingAddress(id) {
|
|
806
|
+
this.setState({
|
|
807
|
+
shipping_address: id,
|
|
808
|
+
err: {},
|
|
809
|
+
g_err: ''
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
onChangeShipping(id) {
|
|
813
|
+
this.setState({
|
|
814
|
+
shipping: id,
|
|
815
|
+
err: {},
|
|
816
|
+
g_err: ''
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
renderDesktopPaymentMethod(order) {
|
|
820
|
+
return null;
|
|
821
|
+
let editmode = false;
|
|
822
|
+
if (!order.status || order.status == 'open') {
|
|
823
|
+
editmode = !order.user_confirmation;
|
|
824
|
+
}
|
|
825
|
+
if (editmode) {
|
|
826
|
+
let pms = this.props.store.matchPaymentMethods();
|
|
827
|
+
let $pms = util/* default */.A.map(pms, pm => {
|
|
828
|
+
let $name = pm.description;
|
|
829
|
+
if (pm.method == 'bank_transfer') {
|
|
830
|
+
$name = pm.description + ' ' + pm.bank_name + ' ' + pm.bank_branch;
|
|
831
|
+
}
|
|
832
|
+
let cls = 'order__card';
|
|
833
|
+
let $desc = null;
|
|
834
|
+
if (this.state.pm === pm.id) {
|
|
835
|
+
cls += ' order__card__active';
|
|
836
|
+
$desc = (0,preact_module.h)("div", {
|
|
837
|
+
class: "muted mt-1",
|
|
838
|
+
style: "margin-left: 26px !important;"
|
|
839
|
+
}, "Tr\u1EA3 ti\u1EC1n m\u1EB7t khi b\u1EA1n nh\u1EADn h\xE0ng");
|
|
840
|
+
if (pm.method == 'bank_transfer') {
|
|
841
|
+
$desc = (0,preact_module.h)("div", {
|
|
842
|
+
class: "muted mt-1",
|
|
843
|
+
style: "margin-left: 26px !important;"
|
|
844
|
+
}, (0,preact_module.h)("div", null, "STK: ", pm.bank_number), (0,preact_module.h)("div", null, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner));
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
return (0,preact_module.h)("div", {
|
|
848
|
+
style: "width: 100% !important; margin-top: 10px !important;"
|
|
849
|
+
}, (0,preact_module.h)("div", {
|
|
850
|
+
class: "radio"
|
|
851
|
+
}, (0,preact_module.h)("input", {
|
|
852
|
+
type: "radio",
|
|
853
|
+
id: 'pm.' + pm.id,
|
|
854
|
+
onInput: e => this.onChangePaymentMethod(pm.id),
|
|
855
|
+
name: "pm",
|
|
856
|
+
checked: this.state.pm === pm.id
|
|
857
|
+
}), (0,preact_module.h)("label", {
|
|
858
|
+
class: "radio--label",
|
|
859
|
+
style: `margin-left: 4px !important; font-weight: ${this.state.pm === pm.id ? 500 : 400} !important;`,
|
|
860
|
+
for: 'pm.' + pm.id
|
|
861
|
+
}, $name), (0,preact_module.h)("div", {
|
|
862
|
+
class: "radio--check"
|
|
863
|
+
}, (0,preact_module.h)("div", {
|
|
864
|
+
class: "inside"
|
|
865
|
+
})), $desc));
|
|
866
|
+
});
|
|
867
|
+
let seccls = 'card_section';
|
|
868
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
869
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
870
|
+
class: "order_section__line"
|
|
871
|
+
}), (0,preact_module.h)("div", {
|
|
872
|
+
class: seccls
|
|
873
|
+
}, (0,preact_module.h)("div", {
|
|
874
|
+
class: "order_label"
|
|
875
|
+
}, this.props.t('payment')), (0,preact_module.h)("div", {
|
|
876
|
+
class: "form",
|
|
877
|
+
style: "justify-content: space-between !important;"
|
|
878
|
+
}, $pms)));
|
|
879
|
+
}
|
|
880
|
+
let pm = order.payment_method || {
|
|
881
|
+
method: 'cod'
|
|
882
|
+
};
|
|
883
|
+
let $body = null;
|
|
884
|
+
if (pm.method === 'cash') $body = (0,preact_module.h)("div", null, this.props.t('pm_cash'));
|
|
885
|
+
if (pm.method === 'cod') $body = (0,preact_module.h)("div", null, this.props.t('pm_cod'));
|
|
886
|
+
if (pm.method === 'bank_transfer') {
|
|
887
|
+
let name = pm.bank_name;
|
|
888
|
+
if (pm.bank_branch) name += ' - ' + pm.bank_branch;
|
|
889
|
+
$body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", null, "Ng\xE2n h\xE0ng: ", name), (0,preact_module.h)("div", {
|
|
890
|
+
class: "mt-1"
|
|
891
|
+
}, "Ch\u1EE7 t\xE0i kho\u1EA3n: ", pm.bank_owner), (0,preact_module.h)("div", {
|
|
892
|
+
class: "mt-1"
|
|
893
|
+
}, "S\u1ED1 t\xE0i kho\u1EA3n: ", pm.bank_number));
|
|
894
|
+
}
|
|
895
|
+
if (!$body) return null;
|
|
896
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
897
|
+
class: "order_label"
|
|
898
|
+
}, this.props.t('payment')), $body);
|
|
899
|
+
}
|
|
900
|
+
renderDesktopShipping(order) {
|
|
901
|
+
let editmode = false;
|
|
902
|
+
if (!order.status || order.status == 'open') {
|
|
903
|
+
editmode = !order.user_confirmation;
|
|
904
|
+
}
|
|
905
|
+
let user = this.props.store.matchUser();
|
|
906
|
+
if (editmode) {
|
|
907
|
+
let addresses = this.props.store.matchShippingAddresses();
|
|
908
|
+
let provinces = util/* default */.A.map(this.state.provinces, province => ({
|
|
909
|
+
id: province.id,
|
|
910
|
+
name: province.province
|
|
911
|
+
}));
|
|
912
|
+
let districts = util/* default */.A.map(this.state.districts, district => ({
|
|
913
|
+
id: district.id,
|
|
914
|
+
name: district.district
|
|
915
|
+
}));
|
|
916
|
+
let wards = util/* default */.A.map(this.state.wards, ward => ({
|
|
917
|
+
id: ward.id,
|
|
918
|
+
name: ward.ward
|
|
919
|
+
}));
|
|
920
|
+
let cls = 'ship_card';
|
|
921
|
+
let $body = null;
|
|
922
|
+
let ship_icon_active = false;
|
|
923
|
+
if (this.state.shipping === 'ship') {
|
|
924
|
+
ship_icon_active = true;
|
|
925
|
+
let $preaddrs = util/* default */.A.map(addresses, addr => {
|
|
926
|
+
let fulladdr = [addr.street, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
927
|
+
let $phone = null;
|
|
928
|
+
if (addr.phone) {
|
|
929
|
+
$phone = (0,preact_module.h)(preact_module/* Fragment */.FK, null, "\xA0\xB7\xA0", this.props.t('phn'), " ", addr.phone);
|
|
930
|
+
}
|
|
931
|
+
return (0,preact_module.h)("div", {
|
|
932
|
+
style: "margin-bottom: 15px !important"
|
|
933
|
+
}, (0,preact_module.h)("div", {
|
|
934
|
+
class: "radio d-flex "
|
|
935
|
+
}, (0,preact_module.h)("input", {
|
|
936
|
+
type: "radio",
|
|
937
|
+
id: 'shipping_addr.' + addr.id,
|
|
938
|
+
onInput: e => this.onChangeShippingAddress(addr.id),
|
|
939
|
+
name: "shipping_address",
|
|
940
|
+
checked: this.state.shipping_address === addr.id
|
|
941
|
+
}), (0,preact_module.h)("label", {
|
|
942
|
+
class: "radio--label",
|
|
943
|
+
for: 'shipping_addr.' + addr.id,
|
|
944
|
+
style: `font-weight: ${this.state.shipping_address === addr.id ? 500 : 400} !important`
|
|
945
|
+
}, addr.fullname, $phone, (0,preact_module.h)("div", {
|
|
946
|
+
class: "mt-1 muted"
|
|
947
|
+
}, "DC ", fulladdr)), (0,preact_module.h)("div", {
|
|
948
|
+
class: "radio--check"
|
|
949
|
+
}, (0,preact_module.h)("div", {
|
|
950
|
+
class: "inside"
|
|
951
|
+
}))));
|
|
952
|
+
});
|
|
953
|
+
$preaddrs.push((0,preact_module.h)("div", {
|
|
954
|
+
style: ""
|
|
955
|
+
}, (0,preact_module.h)("div", {
|
|
956
|
+
class: "radio d-flex "
|
|
957
|
+
}, (0,preact_module.h)("input", {
|
|
958
|
+
type: "radio",
|
|
959
|
+
id: 'shipping_addr.new',
|
|
960
|
+
onInput: e => this.onChangeShippingAddress('new'),
|
|
961
|
+
name: "shipping_address",
|
|
962
|
+
checked: this.state.shipping_address === 'new'
|
|
963
|
+
}), (0,preact_module.h)("label", {
|
|
964
|
+
class: "radio--label",
|
|
965
|
+
for: 'shipping_addr.new'
|
|
966
|
+
}, this.state.shipping_address === 'new' ? (0,preact_module.h)("b", null, "T\u1EDBi \u0111\u1ECBa ch\u1EC9 kh\xE1c") : 'Tới địa chỉ khác'), (0,preact_module.h)("div", {
|
|
967
|
+
class: "radio--check"
|
|
968
|
+
}, (0,preact_module.h)("div", {
|
|
969
|
+
class: "inside"
|
|
970
|
+
})))));
|
|
971
|
+
let $new = (0,preact_module.h)("div", {
|
|
972
|
+
style: "padding-left: 22px !important;"
|
|
973
|
+
}, (0,preact_module.h)("div", {
|
|
974
|
+
class: "d-flex"
|
|
975
|
+
}, (0,preact_module.h)("div", {
|
|
976
|
+
class: "mr-2",
|
|
977
|
+
style: "flex: 1 !important;"
|
|
978
|
+
}, (0,preact_module.h)("div", {
|
|
979
|
+
class: "order_form_label"
|
|
980
|
+
}, this.props.t('fullname')), (0,preact_module.h)("input", {
|
|
981
|
+
type: "text",
|
|
982
|
+
class: 'form-control ' + (this.state.err.name && 'err'),
|
|
983
|
+
onInput: this.onChangeFullname,
|
|
984
|
+
value: this.state.fullname
|
|
985
|
+
})), (0,preact_module.h)("div", {
|
|
986
|
+
class: "ml-2",
|
|
987
|
+
style: "flex: 1 !important;"
|
|
988
|
+
}, (0,preact_module.h)("div", {
|
|
989
|
+
class: "order_form_label"
|
|
990
|
+
}, this.props.t('phones')), (0,preact_module.h)("input", {
|
|
991
|
+
type: "text",
|
|
992
|
+
class: 'form-control ' + (this.state.err.phone && 'err'),
|
|
993
|
+
onInput: this.onChangePhone,
|
|
994
|
+
value: this.state.phone
|
|
995
|
+
}))), (0,preact_module.h)("div", {
|
|
996
|
+
class: "",
|
|
997
|
+
style: "width: 100% !important"
|
|
998
|
+
}, (0,preact_module.h)("div", {
|
|
999
|
+
class: "order_form_label"
|
|
1000
|
+
}, this.props.t('address')), (0,preact_module.h)(AddressPicker, {
|
|
1001
|
+
initAddress: this.state.address,
|
|
1002
|
+
store: this.props.store,
|
|
1003
|
+
width: "100%",
|
|
1004
|
+
onChangeAddress: this.onChangeAddress,
|
|
1005
|
+
full: this.isMobile(),
|
|
1006
|
+
onSelect: this.onSelectAddress,
|
|
1007
|
+
extra_cls: this.state.err.address && 'err'
|
|
1008
|
+
})), (0,preact_module.h)("div", {
|
|
1009
|
+
class: "d-flex",
|
|
1010
|
+
style: "justify-content: space-between !important;"
|
|
1011
|
+
}, (0,preact_module.h)("div", {
|
|
1012
|
+
style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
|
|
1013
|
+
}, (0,preact_module.h)("div", {
|
|
1014
|
+
class: "order_form_label"
|
|
1015
|
+
}, this.props.t('province')), (0,preact_module.h)(DropdownSelect, {
|
|
1016
|
+
width: "194",
|
|
1017
|
+
full: this.isMobile(),
|
|
1018
|
+
has_search: true,
|
|
1019
|
+
loading: this.state.loadProvince,
|
|
1020
|
+
items: provinces,
|
|
1021
|
+
selected: this.state.selectedProvince,
|
|
1022
|
+
onSelect: this.onSelectProvince,
|
|
1023
|
+
extra_cls: this.state.err.province && 'err'
|
|
1024
|
+
})), (0,preact_module.h)("div", {
|
|
1025
|
+
style: "flex: 1 !important; overflow:hidden !important; margin-left: 7px !important;"
|
|
1026
|
+
}, (0,preact_module.h)("div", {
|
|
1027
|
+
class: "order_form_label"
|
|
1028
|
+
}, this.props.t('district')), (0,preact_module.h)(DropdownSelect, {
|
|
1029
|
+
width: "194",
|
|
1030
|
+
full: this.isMobile(),
|
|
1031
|
+
selected: this.state.selectedDistrict,
|
|
1032
|
+
has_search: true,
|
|
1033
|
+
onSelect: this.onSelectDistrict,
|
|
1034
|
+
loading: this.state.loadDistrict,
|
|
1035
|
+
extra_cls: this.state.err.district && 'err',
|
|
1036
|
+
items: districts
|
|
1037
|
+
}))), (0,preact_module.h)("div", {
|
|
1038
|
+
class: "d-flex",
|
|
1039
|
+
style: "justify-content: space-between !important;"
|
|
1040
|
+
}, (0,preact_module.h)("div", {
|
|
1041
|
+
style: "flex: 1 !important; overflow:hidden !important; margin-right: 7px !important;"
|
|
1042
|
+
}, (0,preact_module.h)("div", {
|
|
1043
|
+
class: "order_form_label"
|
|
1044
|
+
}, this.props.t('ward')), (0,preact_module.h)(DropdownSelect, {
|
|
1045
|
+
width: "194",
|
|
1046
|
+
selected: this.state.selectedWard,
|
|
1047
|
+
full: this.isMobile(),
|
|
1048
|
+
has_search: true,
|
|
1049
|
+
onSelect: this.onSelectWard,
|
|
1050
|
+
extra_cls: this.state.err.ward && 'err',
|
|
1051
|
+
loading: this.state.loadWard,
|
|
1052
|
+
items: wards
|
|
1053
|
+
})), (0,preact_module.h)("div", {
|
|
1054
|
+
style: "flex: 1 !important; margin-left: 7px !important;"
|
|
1055
|
+
})));
|
|
1056
|
+
cls += ' ship_card__active';
|
|
1057
|
+
if (util/* default */.A.size(addresses) == 0) {
|
|
1058
|
+
$body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
1059
|
+
class: 'mt-3 mb-2 '
|
|
1060
|
+
}, this.props.t('input_shipping_info')), $new);
|
|
1061
|
+
} else {
|
|
1062
|
+
if (this.state.shipping_address !== 'new') $new = null;
|
|
1063
|
+
$body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
1064
|
+
class: "mt-3 mb-2",
|
|
1065
|
+
style: "margin-bottom: 10px !important;"
|
|
1066
|
+
}, "Vui l\xF2ng ch\u1ECDn \u0111\u1ECBa ch\u1EC9 giao h\xE0ng"), (0,preact_module.h)("div", {
|
|
1067
|
+
class: "form"
|
|
1068
|
+
}, $preaddrs), $new);
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
let shopcls = 'ship_card';
|
|
1072
|
+
let shop_icon_active = false;
|
|
1073
|
+
if (this.state.shipping === 'shop') {
|
|
1074
|
+
shop_icon_active = true;
|
|
1075
|
+
shopcls += ' ship_card__active';
|
|
1076
|
+
$body = (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
1077
|
+
class: "d-flex"
|
|
1078
|
+
}, (0,preact_module.h)("div", {
|
|
1079
|
+
class: "mr-2",
|
|
1080
|
+
style: "flex: 3 !important;"
|
|
1081
|
+
}, (0,preact_module.h)("div", {
|
|
1082
|
+
class: "order_form_label"
|
|
1083
|
+
}, this.props.t('fullname')), (0,preact_module.h)("input", {
|
|
1084
|
+
type: "text",
|
|
1085
|
+
class: 'form-control ' + (this.state.err.name && 'err'),
|
|
1086
|
+
onInput: this.onChangeFullname,
|
|
1087
|
+
value: this.state.fullname
|
|
1088
|
+
})), (0,preact_module.h)("div", {
|
|
1089
|
+
class: "ml-2",
|
|
1090
|
+
style: "flex: 2 !important;"
|
|
1091
|
+
}, (0,preact_module.h)("div", {
|
|
1092
|
+
class: "order_form_label"
|
|
1093
|
+
}, this.props.t('phones')), (0,preact_module.h)("input", {
|
|
1094
|
+
type: "text",
|
|
1095
|
+
class: 'form-control ' + (this.state.err.phone && 'err'),
|
|
1096
|
+
onInput: this.onChangePhone,
|
|
1097
|
+
value: this.state.phone
|
|
1098
|
+
}))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
1099
|
+
class: "order_form_label"
|
|
1100
|
+
}, this.props.t('email')), (0,preact_module.h)("input", {
|
|
1101
|
+
type: "text",
|
|
1102
|
+
class: 'form-control ' + (this.state.err.email && 'err'),
|
|
1103
|
+
onInput: this.onChangeEmail,
|
|
1104
|
+
value: this.state.email
|
|
1105
|
+
})));
|
|
1106
|
+
}
|
|
1107
|
+
let seccls = 'card_section';
|
|
1108
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
1109
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
1110
|
+
class: "order_section__line"
|
|
1111
|
+
}), (0,preact_module.h)("div", {
|
|
1112
|
+
class: seccls
|
|
1113
|
+
}, (0,preact_module.h)("div", {
|
|
1114
|
+
class: "order_label"
|
|
1115
|
+
}, this.props.t('ship_to')), (0,preact_module.h)("div", {
|
|
1116
|
+
class: "d-flex"
|
|
1117
|
+
}, (0,preact_module.h)("div", {
|
|
1118
|
+
class: shopcls + ' mr-3',
|
|
1119
|
+
onClick: e => this.onChangeShipping('shop')
|
|
1120
|
+
}, (0,preact_module.h)(Icon, {
|
|
1121
|
+
name: "shop",
|
|
1122
|
+
active: shop_icon_active
|
|
1123
|
+
}), " ", (0,preact_module.h)("b", {
|
|
1124
|
+
class: "ml-2"
|
|
1125
|
+
}, "Nh\u1EADn h\xE0ng t\u1EA1i shop")), (0,preact_module.h)("div", {
|
|
1126
|
+
class: cls,
|
|
1127
|
+
onClick: e => this.onChangeShipping('ship')
|
|
1128
|
+
}, (0,preact_module.h)(Icon, {
|
|
1129
|
+
name: "package",
|
|
1130
|
+
active: ship_icon_active
|
|
1131
|
+
}), " ", (0,preact_module.h)("b", {
|
|
1132
|
+
class: "ml-2"
|
|
1133
|
+
}, "Giao h\xE0ng cho t\xF4i"))), $body));
|
|
1134
|
+
}
|
|
1135
|
+
let addr = util/* default */.A.get(order, 'shipping.address') || {};
|
|
1136
|
+
let fulladdr = [addr.address, addr.ward, addr.district, addr.region, addr.country].filter(a => a).join(', ');
|
|
1137
|
+
let $phone = null;
|
|
1138
|
+
if (addr.phone) $phone = (0,preact_module.h)("div", {
|
|
1139
|
+
class: "mt-1 muted"
|
|
1140
|
+
}, this.props.t('phn'), ":\xA0", addr.phone);
|
|
1141
|
+
if (util/* default */.A.get(order, 'shipping.pickup_at_shop')) {
|
|
1142
|
+
fulladdr = 'Nhận hàng tại cửa hàng';
|
|
1143
|
+
}
|
|
1144
|
+
let $addr = fulladdr ? (0,preact_module.h)("div", null, fulladdr) : (0,preact_module.h)("i", {
|
|
1145
|
+
class: "i muted"
|
|
1146
|
+
}, "Ch\u01B0a c\xF3 \u0111\u1ECBa ch\u1EC9 giao h\xE0ng");
|
|
1147
|
+
let seccls = 'card_section';
|
|
1148
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
1149
|
+
return (0,preact_module.h)("div", {
|
|
1150
|
+
class: seccls
|
|
1151
|
+
}, (0,preact_module.h)("div", {
|
|
1152
|
+
class: "order_label "
|
|
1153
|
+
}, this.props.t('ship_to')), $addr, $phone);
|
|
1154
|
+
}
|
|
1155
|
+
renderDesktopSummary(order) {
|
|
1156
|
+
let $deposit = null;
|
|
1157
|
+
if (order.deposit > 0) {
|
|
1158
|
+
$deposit = (0,preact_module.h)("span", {
|
|
1159
|
+
class: "muted"
|
|
1160
|
+
}, "(c\u1ECDc ", util/* default */.A.formatCurrency(order.deposit), ")");
|
|
1161
|
+
}
|
|
1162
|
+
let $discount = null;
|
|
1163
|
+
if (order.total_discount > 0) {
|
|
1164
|
+
$discount = (0,preact_module.h)("div", {
|
|
1165
|
+
class: "order_summary_line"
|
|
1166
|
+
}, (0,preact_module.h)("div", null, "Gi\u1EA3m gi\xE1"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_discount)));
|
|
1167
|
+
}
|
|
1168
|
+
let $pay = null;
|
|
1169
|
+
if ($deposit || order.payment_made) {
|
|
1170
|
+
$pay = (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
1171
|
+
class: "order_summary_line"
|
|
1172
|
+
}, (0,preact_module.h)("div", null, "B\u1EA1n \u0111\xE3 tr\u1EA3"), (0,preact_module.h)("div", null, $deposit, " ", util/* default */.A.formatCurrency(order.payment_made))), (0,preact_module.h)("div", {
|
|
1173
|
+
class: "order_summary_line"
|
|
1174
|
+
}, (0,preact_module.h)("div", null, "B\u1EA1n ch\u01B0a tr\u1EA3"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency((order.total || 0) - (order.payment_made || 0)))));
|
|
1175
|
+
}
|
|
1176
|
+
let $tax = (0,preact_module.h)("div", {
|
|
1177
|
+
class: "order_summary_line"
|
|
1178
|
+
}, (0,preact_module.h)("div", null, "Ti\u1EC1n thu\u1EBF"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.total_tax)));
|
|
1179
|
+
let $ship = (0,preact_module.h)("div", {
|
|
1180
|
+
class: "order_summary_line"
|
|
1181
|
+
}, (0,preact_module.h)("div", null, "Ph\xED v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", null, util/* default */.A.get(order, 'shipping.fee', 0), " d"));
|
|
1182
|
+
let editmode = false;
|
|
1183
|
+
if (!order.status || order.status == 'open') {
|
|
1184
|
+
editmode = !order.user_confirmation;
|
|
1185
|
+
}
|
|
1186
|
+
let $note = null;
|
|
1187
|
+
if (editmode) {
|
|
1188
|
+
$ship = null;
|
|
1189
|
+
$tax = null;
|
|
1190
|
+
$note = (0,preact_module.h)("div", {
|
|
1191
|
+
class: "muted"
|
|
1192
|
+
}, (0,preact_module.h)("img", {
|
|
1193
|
+
class: "order_ship_icon",
|
|
1194
|
+
src: __webpack_require__(7324)
|
|
1195
|
+
}), "\xA0 Ch\u01B0a bao g\u1ED3m thu\u1EBF v\xE0 ph\xED v\u1EADn chuy\u1EC3n");
|
|
1196
|
+
}
|
|
1197
|
+
let seccls = '';
|
|
1198
|
+
if (this.isMobile()) seccls = 'order_section';
|
|
1199
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
1200
|
+
class: "order_section__line"
|
|
1201
|
+
}), (0,preact_module.h)("div", {
|
|
1202
|
+
class: seccls
|
|
1203
|
+
}, (0,preact_module.h)("div", {
|
|
1204
|
+
class: "order_label"
|
|
1205
|
+
}, "T\xF3m t\u1EAFt"), (0,preact_module.h)("div", {
|
|
1206
|
+
class: "order_summary_line"
|
|
1207
|
+
}, (0,preact_module.h)("div", null, "T\u1ED5ng ti\u1EC1n h\xE0ng"), (0,preact_module.h)("div", null, util/* default */.A.formatCurrency(order.subtotal))), $tax, $discount, $ship, $note, (0,preact_module.h)("div", {
|
|
1208
|
+
class: "order_summary_line",
|
|
1209
|
+
style: "margin-top: 10px !important; padding-top: 15px !important; border-top: 1px solid #eee !important"
|
|
1210
|
+
}, (0,preact_module.h)("div", null, "B\u1EA1n ph\u1EA3i tr\u1EA3"), (0,preact_module.h)("div", {
|
|
1211
|
+
class: "order__total"
|
|
1212
|
+
}, util/* default */.A.formatCurrency(order.total))), $pay));
|
|
1213
|
+
}
|
|
1214
|
+
renderStatusBadge(order) {
|
|
1215
|
+
let status = order.status || 'open';
|
|
1216
|
+
return (0,preact_module.h)("div", {
|
|
1217
|
+
style: "float: right !important;",
|
|
1218
|
+
class: 'order_status order_status__' + status
|
|
1219
|
+
}, status);
|
|
1220
|
+
}
|
|
1221
|
+
renderShippingInfo(order) {
|
|
1222
|
+
if (order.status != 'open' || order.user_confirmation) {}
|
|
1223
|
+
let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
|
|
1224
|
+
if (!shipping_provider) return null;
|
|
1225
|
+
let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
|
|
1226
|
+
let $tracking_code = null;
|
|
1227
|
+
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
1228
|
+
class: "muted",
|
|
1229
|
+
style: "margin-top: 3px !important"
|
|
1230
|
+
}, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
|
|
1231
|
+
class: "order_tracking_link",
|
|
1232
|
+
target: "_blank",
|
|
1233
|
+
href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
|
|
1234
|
+
}, shipping_code, "\xA0", (0,preact_module.h)("img", {
|
|
1235
|
+
class: "order_tracking_link_icon",
|
|
1236
|
+
src: __webpack_require__(3266)
|
|
1237
|
+
})));
|
|
1238
|
+
if (shipping_provider == 'ghtk') {
|
|
1239
|
+
return (0,preact_module.h)("div", {
|
|
1240
|
+
class: "order_section"
|
|
1241
|
+
}, (0,preact_module.h)("div", {
|
|
1242
|
+
class: "order_section_label"
|
|
1243
|
+
}, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
|
|
1244
|
+
class: "d-flex align-items-center"
|
|
1245
|
+
}, (0,preact_module.h)("img", {
|
|
1246
|
+
class: "order_shipping_provider_logo",
|
|
1247
|
+
src: ShippingProvider.ghtk.logo
|
|
1248
|
+
}), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
|
|
1249
|
+
}
|
|
1250
|
+
return null;
|
|
1251
|
+
}
|
|
1252
|
+
renderDesktopShippingInfo(order) {
|
|
1253
|
+
let shipping_provider = util/* default */.A.get(order, 'shipping.shipping_provider');
|
|
1254
|
+
if (!shipping_provider) return null;
|
|
1255
|
+
let shipping_code = util/* default */.A.get(order, 'shipping.shipping_code');
|
|
1256
|
+
let $tracking_code = null;
|
|
1257
|
+
if (shipping_code) $tracking_code = (0,preact_module.h)("div", {
|
|
1258
|
+
class: "muted",
|
|
1259
|
+
style: "margin-top: 3px !important"
|
|
1260
|
+
}, "V\u1EADn \u0111\u01A1n\xA0", (0,preact_module.h)("a", {
|
|
1261
|
+
class: "order_tracking_link",
|
|
1262
|
+
target: "_blank",
|
|
1263
|
+
href: 'https://giaohangtietkiem.vn/tra-cuu-van-don/' + shipping_code
|
|
1264
|
+
}, shipping_code, "\xA0", (0,preact_module.h)("img", {
|
|
1265
|
+
class: "order_tracking_link_icon",
|
|
1266
|
+
src: __webpack_require__(3266)
|
|
1267
|
+
})));
|
|
1268
|
+
if (shipping_provider == 'ghtk') {
|
|
1269
|
+
return (0,preact_module.h)(preact_module/* Fragment */.FK, null, (0,preact_module.h)("div", {
|
|
1270
|
+
class: "order_label"
|
|
1271
|
+
}, "\u0110\u01A1n v\u1ECB v\u1EADn chuy\u1EC3n"), (0,preact_module.h)("div", {
|
|
1272
|
+
class: "d-flex align-items-center"
|
|
1273
|
+
}, (0,preact_module.h)("img", {
|
|
1274
|
+
class: "order_shipping_provider_logo",
|
|
1275
|
+
src: ShippingProvider.ghtk.logo
|
|
1276
|
+
}), (0,preact_module.h)("div", null, ShippingProvider.ghtk.name, $tracking_code)));
|
|
1277
|
+
}
|
|
1278
|
+
return null;
|
|
1279
|
+
}
|
|
1280
|
+
renderProducts(order) {
|
|
1281
|
+
let $products = null;
|
|
1282
|
+
$products = util/* default */.A.map(order.items, item => {
|
|
1283
|
+
if (!item || !item.product) return null;
|
|
1284
|
+
let product = item.product;
|
|
1285
|
+
return (0,preact_module.h)("div", {
|
|
1286
|
+
class: "order_attachment__product"
|
|
1287
|
+
}, (0,preact_module.h)("img", {
|
|
1288
|
+
class: "order_attachment__product_img",
|
|
1289
|
+
alt: '' + product.id,
|
|
1290
|
+
src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
|
|
1291
|
+
}), (0,preact_module.h)("div", {
|
|
1292
|
+
style: "overflow: hidden !important;"
|
|
1293
|
+
}, (0,preact_module.h)("div", {
|
|
1294
|
+
class: "order_attachment__product_name"
|
|
1295
|
+
}, product.name), (0,preact_module.h)("div", {
|
|
1296
|
+
class: "order_attachment__product_desc"
|
|
1297
|
+
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
1298
|
+
class: "order_attachment__product_desc"
|
|
1299
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", util/* default */.A.formatCurrency(product.price))));
|
|
1300
|
+
});
|
|
1301
|
+
if (!this.isMobile()) return (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
1302
|
+
class: "order_label"
|
|
1303
|
+
}, this.props.t('product')), $products);
|
|
1304
|
+
return (0,preact_module.h)("div", {
|
|
1305
|
+
class: "order_section"
|
|
1306
|
+
}, (0,preact_module.h)("div", {
|
|
1307
|
+
class: "order_section_label"
|
|
1308
|
+
}, this.props.t('product')), $products);
|
|
1309
|
+
}
|
|
1310
|
+
renderDesktopProducts(order) {
|
|
1311
|
+
let $products = null;
|
|
1312
|
+
let editmode = false;
|
|
1313
|
+
if (!order.status || order.status == 'open') {
|
|
1314
|
+
editmode = !order.user_confirmation;
|
|
1315
|
+
}
|
|
1316
|
+
if (editmode) {
|
|
1317
|
+
$products = util/* default */.A.map(order.items, item => {
|
|
1318
|
+
if (!item || !item.product) return null;
|
|
1319
|
+
let product = item.product;
|
|
1320
|
+
return (0,preact_module.h)("div", {
|
|
1321
|
+
class: "order_attachment__product"
|
|
1322
|
+
}, (0,preact_module.h)("img", {
|
|
1323
|
+
class: "order_attachment__product_img",
|
|
1324
|
+
alt: '' + product.id,
|
|
1325
|
+
src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
|
|
1326
|
+
}), (0,preact_module.h)("div", {
|
|
1327
|
+
style: "overflow: hidden !important; flex: 1 !important"
|
|
1328
|
+
}, (0,preact_module.h)("div", {
|
|
1329
|
+
class: "order_attachment__product_name"
|
|
1330
|
+
}, product.name), (0,preact_module.h)("div", {
|
|
1331
|
+
class: "order_attachment__product_desc"
|
|
1332
|
+
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
1333
|
+
class: "order_attachment__product_desc"
|
|
1334
|
+
}, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("input", {
|
|
1335
|
+
class: "form-control",
|
|
1336
|
+
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important",
|
|
1337
|
+
value: item.quantity,
|
|
1338
|
+
onInput: e => this.onChangeQuantity(item, e.target.value),
|
|
1339
|
+
type: "text"
|
|
1340
|
+
}), (0,preact_module.h)("div", {
|
|
1341
|
+
style: "width: 80px !important; text-align: right !important; "
|
|
1342
|
+
}, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.quantity * product.price))));
|
|
1343
|
+
});
|
|
1344
|
+
} else {
|
|
1345
|
+
$products = util/* default */.A.map(order.items, item => {
|
|
1346
|
+
if (!item || !item.product) return null;
|
|
1347
|
+
let product = item.product;
|
|
1348
|
+
return (0,preact_module.h)("div", {
|
|
1349
|
+
class: "order_attachment__product"
|
|
1350
|
+
}, (0,preact_module.h)("img", {
|
|
1351
|
+
class: "order_attachment__product_img",
|
|
1352
|
+
alt: '' + product.id,
|
|
1353
|
+
src: util/* default */.A.get(product, 'images.0') || __webpack_require__(2876)
|
|
1354
|
+
}), (0,preact_module.h)("div", {
|
|
1355
|
+
style: "overflow: hidden !important; flex: 1 !important"
|
|
1356
|
+
}, (0,preact_module.h)("div", {
|
|
1357
|
+
class: "order_attachment__product_name"
|
|
1358
|
+
}, product.name), (0,preact_module.h)("div", {
|
|
1359
|
+
class: "order_attachment__product_desc"
|
|
1360
|
+
}, product.description || product.long_description), (0,preact_module.h)("div", {
|
|
1361
|
+
class: "order_attachment__product_desc"
|
|
1362
|
+
}, util/* default */.A.formatCurrency(product.price))), (0,preact_module.h)("div", {
|
|
1363
|
+
style: "text-align: center !important; font-weight: 400 !important; width: 50px !important"
|
|
1364
|
+
}, item.quantity), (0,preact_module.h)("div", {
|
|
1365
|
+
style: "width: 80px !important; text-align: right !important; "
|
|
1366
|
+
}, (0,preact_module.h)("b", null, util/* default */.A.formatCurrency(item.total))));
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
return (0,preact_module.h)("div", {
|
|
1370
|
+
class: "card_section"
|
|
1371
|
+
}, (0,preact_module.h)("div", {
|
|
1372
|
+
class: "desktop_order__heading"
|
|
1373
|
+
}, this.renderStatusBadge(order), (0,preact_module.h)("b", {
|
|
1374
|
+
style: "font-size: 18px !important;"
|
|
1375
|
+
}, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
|
|
1376
|
+
class: "muted"
|
|
1377
|
+
}, (0,preact_module.h)(time/* default */.A, {
|
|
1378
|
+
style: "font-size: 13px !important;",
|
|
1379
|
+
time: order.issue_date || order.created
|
|
1380
|
+
}))), (0,preact_module.h)("div", {
|
|
1381
|
+
class: "order_label d-flex",
|
|
1382
|
+
style: "margin-top: 20px !important;justify-content: space-between !important; align-items: flex-end !important;"
|
|
1383
|
+
}, (0,preact_module.h)("div", {
|
|
1384
|
+
style: "flex: 1 !important;"
|
|
1385
|
+
}, this.props.t('product')), (0,preact_module.h)("div", {
|
|
1386
|
+
style: "font-weight: 400 !important; text-align:center !important; width: 50px !important"
|
|
1387
|
+
}, this.props.t('qty')), (0,preact_module.h)("div", {
|
|
1388
|
+
style: "font-weight: 400 !important; text-align: right !important; width: 80px !important;"
|
|
1389
|
+
}, this.props.t('total'))), $products);
|
|
1390
|
+
}
|
|
1391
|
+
renderMobile(order) {
|
|
1392
|
+
if (this.state.step === 'success') return this.renderMobileSuccess(order);
|
|
1393
|
+
let $error = null;
|
|
1394
|
+
if (this.state.g_err) {
|
|
1395
|
+
$error = (0,preact_module.h)("div", {
|
|
1396
|
+
class: "mb-2 text__danger"
|
|
1397
|
+
}, (0,preact_module.h)("img", {
|
|
1398
|
+
style: "margin-top: -4px !important; height: 15px !important;",
|
|
1399
|
+
src: ximg
|
|
1400
|
+
}), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
|
|
1401
|
+
}
|
|
1402
|
+
let $status = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
|
|
1403
|
+
class: "btn-confirm-order",
|
|
1404
|
+
style: "margin-top: 0 !important;",
|
|
1405
|
+
onClick: this.confirm
|
|
1406
|
+
}, this.props.t('confirm_order')));
|
|
1407
|
+
let $close = (0,preact_module.h)("div", {
|
|
1408
|
+
class: "order_btn order__btn__light mt-3",
|
|
1409
|
+
onClick: this.onCancel
|
|
1410
|
+
}, this.props.t('cancel_order'));
|
|
1411
|
+
if (order.user_confirmation || order.status != 'open') {
|
|
1412
|
+
$status = null;
|
|
1413
|
+
if (this.props.cid) $close = (0,preact_module.h)("div", {
|
|
1414
|
+
class: "order_btn order__btn__light mt-3",
|
|
1415
|
+
onClick: this.close
|
|
1416
|
+
}, this.props.t('close'));
|
|
1417
|
+
}
|
|
1418
|
+
return (0,preact_module.h)("div", {
|
|
1419
|
+
class: "order",
|
|
1420
|
+
style: "height: 100% !important"
|
|
1421
|
+
}, (0,preact_module.h)("div", {
|
|
1422
|
+
class: "order--content"
|
|
1423
|
+
}, (0,preact_module.h)("div", {
|
|
1424
|
+
class: "order--heading"
|
|
1425
|
+
}, this.renderStatusBadge(order), (0,preact_module.h)("b", {
|
|
1426
|
+
style: "font-size: 16px !important;"
|
|
1427
|
+
}, this.props.t('order'), " #", order.order_number || order.id), (0,preact_module.h)("div", {
|
|
1428
|
+
class: "muted"
|
|
1429
|
+
}, (0,preact_module.h)(time/* default */.A, {
|
|
1430
|
+
style: "font-size: 13px !important;",
|
|
1431
|
+
time: order.issue_date || order.created
|
|
1432
|
+
}))), this.renderProducts(order), this.renderDesktopShipping(order), this.renderShippingInfo(order), this.renderDesktopPaymentMethod(order), this.renderDesktopSummary(order), (0,preact_module.h)("div", {
|
|
1433
|
+
class: "order_section pb-3",
|
|
1434
|
+
style: "padding-top: 0 !important;"
|
|
1435
|
+
}, $status, $close)));
|
|
1436
|
+
}
|
|
1437
|
+
renderActions(order) {
|
|
1438
|
+
let $actions = null;
|
|
1439
|
+
let editmode = false;
|
|
1440
|
+
if (!order.status || order.status == 'open') {
|
|
1441
|
+
editmode = !order.user_confirmation;
|
|
1442
|
+
}
|
|
1443
|
+
if (this.state.step === 'success') return (0,preact_module.h)("div", {
|
|
1444
|
+
class: "d-flex",
|
|
1445
|
+
style: "align-items: center !important; justify-content: flex-end !important"
|
|
1446
|
+
}, (0,preact_module.h)("div", null, "Ghi nh\u1EADn th\xE0nh c\xF4ng"), "\xA0", (0,preact_module.h)("img", {
|
|
1447
|
+
style: "width: 16px !important; height: 16px !important;",
|
|
1448
|
+
width: "16",
|
|
1449
|
+
height: "16",
|
|
1450
|
+
src: checkedimg
|
|
1451
|
+
}));
|
|
1452
|
+
if (editmode) {
|
|
1453
|
+
let $error = null;
|
|
1454
|
+
if (this.state.g_err) {
|
|
1455
|
+
$error = (0,preact_module.h)("div", {
|
|
1456
|
+
class: "mb-2 text__danger"
|
|
1457
|
+
}, (0,preact_module.h)("img", {
|
|
1458
|
+
style: "margin-top: -4px !important; height: 15px !important;",
|
|
1459
|
+
src: ximg
|
|
1460
|
+
}), "\xA0", (0,preact_module.h)("b", null, this.state.g_err));
|
|
1461
|
+
}
|
|
1462
|
+
$actions = (0,preact_module.h)("div", null, $error, (0,preact_module.h)("div", {
|
|
1463
|
+
class: "btn-confirm-order",
|
|
1464
|
+
onClick: this.confirm
|
|
1465
|
+
}, this.props.t('confirm_order')), (0,preact_module.h)("div", {
|
|
1466
|
+
class: "btn-cancel-order",
|
|
1467
|
+
onClick: this.onCancel
|
|
1468
|
+
}, this.props.t('cancel_order')));
|
|
1469
|
+
}
|
|
1470
|
+
return $actions;
|
|
1471
|
+
}
|
|
1472
|
+
renderDesktop(order) {
|
|
1473
|
+
let acc = this.props.store.matchAccount();
|
|
1474
|
+
var uri = acc.logo_url || __webpack_require__(3582);
|
|
1475
|
+
return (0,preact_module.h)("div", {
|
|
1476
|
+
class: "desktop order"
|
|
1477
|
+
}, (0,preact_module.h)("div", {
|
|
1478
|
+
class: "order_acc_header"
|
|
1479
|
+
}, (0,preact_module.h)("img", {
|
|
1480
|
+
class: "order_acc_logo",
|
|
1481
|
+
src: uri
|
|
1482
|
+
}), (0,preact_module.h)("div", {
|
|
1483
|
+
class: "order_acc_name"
|
|
1484
|
+
}, acc.name)), (0,preact_module.h)("div", {
|
|
1485
|
+
class: "desktop_order__content"
|
|
1486
|
+
}, (0,preact_module.h)("div", {
|
|
1487
|
+
style: "flex: 1 !important; padding-right: 20px !important;"
|
|
1488
|
+
}, this.renderDesktopProducts(order), this.renderDesktopShipping(order), this.renderDesktopShippingInfo(order), this.renderDesktopPaymentMethod(order), (0,preact_module.h)("div", {
|
|
1489
|
+
class: "order__footer"
|
|
1490
|
+
}, (0,preact_module.h)("a", {
|
|
1491
|
+
target: "_blank",
|
|
1492
|
+
href: "https://subiz.com.vn",
|
|
1493
|
+
class: "order__footer_link"
|
|
1494
|
+
}, "Cung c\u1EA5p b\u1EDFi ", (0,preact_module.h)("b", null, "Subiz")), (0,preact_module.h)("div", {
|
|
1495
|
+
class: "order__footer_delimiter"
|
|
1496
|
+
}), (0,preact_module.h)("a", {
|
|
1497
|
+
target: "_blank",
|
|
1498
|
+
href: "https://subiz.com.vn/vi/terms-of-service.html",
|
|
1499
|
+
class: "order__footer_link"
|
|
1500
|
+
}, "\u0110i\u1EC1u kho\u1EA3n"), (0,preact_module.h)("a", {
|
|
1501
|
+
target: "_blank",
|
|
1502
|
+
href: "https://subiz.com.vn/vi/privacy-policy.html",
|
|
1503
|
+
class: "order__footer_link"
|
|
1504
|
+
}, "Quy\u1EC1n ri\xEAng t\u01B0"))), (0,preact_module.h)("div", null, (0,preact_module.h)("div", {
|
|
1505
|
+
class: "order_recap"
|
|
1506
|
+
}, this.renderDesktopSummary(order), this.renderActions(order)))));
|
|
1507
|
+
}
|
|
1508
|
+
render() {
|
|
1509
|
+
if (this.state.loading) return (0,preact_module.h)("div", {
|
|
1510
|
+
class: "order_error"
|
|
1511
|
+
}, (0,preact_module.h)(spinner/* default */.A, {
|
|
1512
|
+
class: "mt-4",
|
|
1513
|
+
size: "60",
|
|
1514
|
+
static: true
|
|
1515
|
+
}));
|
|
1516
|
+
if (this.state.error) return (0,preact_module.h)("div", {
|
|
1517
|
+
class: "order_error"
|
|
1518
|
+
}, (0,preact_module.h)("img", {
|
|
1519
|
+
class: "mt-3",
|
|
1520
|
+
src: __webpack_require__(6907)
|
|
1521
|
+
}), (0,preact_module.h)("div", {
|
|
1522
|
+
class: "mt-3"
|
|
1523
|
+
}, this.props.t('order_load_error')));
|
|
1524
|
+
let order = this.state.order;
|
|
1525
|
+
if (this.isMobile()) return this.renderMobile(order);
|
|
1526
|
+
return this.renderDesktop(order);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
let ShippingProvider = {
|
|
1530
|
+
ghtk: {
|
|
1531
|
+
name: 'Giao hàng tiết kiệm',
|
|
1532
|
+
logo: __webpack_require__(7362)
|
|
1533
|
+
},
|
|
1534
|
+
ghn: {
|
|
1535
|
+
name: 'Giao hàng nhanh',
|
|
1536
|
+
logo: __webpack_require__(1113)
|
|
1537
|
+
}
|
|
1538
|
+
};
|
|
1539
|
+
;// CONCATENATED MODULE: ./src/chatbox/Order.js
|
|
1540
|
+
function Order_defineProperty(e, r, t) { return (r = Order_toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
1541
|
+
function Order_toPropertyKey(t) { var i = Order_toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
1542
|
+
function Order_toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1543
|
+
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
const POPUP_MAX_HEIGHT = 400;
|
|
1547
|
+
const POPUP_HARD_MAX_HEIGHT = 500;
|
|
1548
|
+
const POPUP_MIN_HEIGHT = 0;
|
|
1549
|
+
let Order_defaultAvatar = __webpack_require__(2538);
|
|
1550
|
+
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
class Order extends common/* Com */.Mw {
|
|
1554
|
+
constructor(props) {
|
|
1555
|
+
super(props);
|
|
1556
|
+
Order_defineProperty(this, "state", {
|
|
1557
|
+
hide: true,
|
|
1558
|
+
ratingHeight: 0,
|
|
1559
|
+
overlayOpacity: 0.3
|
|
1560
|
+
});
|
|
1561
|
+
Order_defineProperty(this, "onResponse", response => {
|
|
1562
|
+
this.setState({
|
|
1563
|
+
response
|
|
1564
|
+
});
|
|
1565
|
+
});
|
|
1566
|
+
Order_defineProperty(this, "confirm", () => {
|
|
1567
|
+
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
1568
|
+
message: {
|
|
1569
|
+
format: 'plaintext',
|
|
1570
|
+
text: 'confirm',
|
|
1571
|
+
attachments: [{
|
|
1572
|
+
type: 'postback',
|
|
1573
|
+
postback: {
|
|
1574
|
+
payload: JSON.stringify({
|
|
1575
|
+
type: 'order_confirmation',
|
|
1576
|
+
status: 'confirmed'
|
|
1577
|
+
})
|
|
1578
|
+
}
|
|
1579
|
+
}]
|
|
1580
|
+
}
|
|
1581
|
+
});
|
|
1582
|
+
});
|
|
1583
|
+
Order_defineProperty(this, "close", async () => {
|
|
1584
|
+
await util/* default */.A.sleep(100);
|
|
1585
|
+
if (this.state.response === 'confirmed') {
|
|
1586
|
+
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
1587
|
+
message: {
|
|
1588
|
+
format: 'plaintext',
|
|
1589
|
+
text: this.props.t('confirm_order'),
|
|
1590
|
+
attachments: [{
|
|
1591
|
+
type: 'postback',
|
|
1592
|
+
postback: {
|
|
1593
|
+
payload: JSON.stringify({
|
|
1594
|
+
type: 'order_confirmation',
|
|
1595
|
+
status: 'confirmed'
|
|
1596
|
+
})
|
|
1597
|
+
}
|
|
1598
|
+
}]
|
|
1599
|
+
}
|
|
1600
|
+
});
|
|
1601
|
+
} else if (this.state.response === 'rejected') {
|
|
1602
|
+
this.props.store.sendConvoEvent(this.props.cid, 'message_sent', {
|
|
1603
|
+
message: {
|
|
1604
|
+
format: 'plaintext',
|
|
1605
|
+
text: this.props.t('cancel_order'),
|
|
1606
|
+
attachments: [{
|
|
1607
|
+
type: 'postback',
|
|
1608
|
+
postback: {
|
|
1609
|
+
payload: JSON.stringify({
|
|
1610
|
+
type: 'order_confirmation',
|
|
1611
|
+
status: 'cancelled'
|
|
1612
|
+
})
|
|
1613
|
+
}
|
|
1614
|
+
}]
|
|
1615
|
+
}
|
|
1616
|
+
});
|
|
1617
|
+
} else {}
|
|
1618
|
+
this.setState({
|
|
1619
|
+
response: ''
|
|
1620
|
+
});
|
|
1621
|
+
if (this.state.hide) return;
|
|
1622
|
+
if (!this.refRating.current) return;
|
|
1623
|
+
var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
|
|
1624
|
+
var h0 = parseFloat(popupStyle.height);
|
|
1625
|
+
this.animation.play(20, h0, h => {
|
|
1626
|
+
this.setState({
|
|
1627
|
+
ratingHeight: h,
|
|
1628
|
+
overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
1629
|
+
});
|
|
1630
|
+
if (h < POPUP_MIN_HEIGHT + 10) {
|
|
1631
|
+
if (!this.state.hide) {
|
|
1632
|
+
this.setState({
|
|
1633
|
+
hide: true
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1638
|
+
this.props.onClose();
|
|
1639
|
+
});
|
|
1640
|
+
this.refRating = (0,preact_module/* createRef */._3)();
|
|
1641
|
+
this.refHandle = (0,preact_module/* createRef */._3)();
|
|
1642
|
+
}
|
|
1643
|
+
componentDidMount() {
|
|
1644
|
+
this.mouseUp = e => this.onMouseUp(e);
|
|
1645
|
+
this.mouseMove = e => this.onMouseMove(e);
|
|
1646
|
+
this.mouseDown = e => this.onMouseDown(e);
|
|
1647
|
+
var $ratingHandle = this.refHandle.current;
|
|
1648
|
+
$ratingHandle.addEventListener('mousedown', this.mouseDown, {
|
|
1649
|
+
passive: true
|
|
1650
|
+
});
|
|
1651
|
+
$ratingHandle.addEventListener('touchstart', this.mouseDown, {
|
|
1652
|
+
passive: true
|
|
1653
|
+
});
|
|
1654
|
+
window.addEventListener('mouseup', this.mouseUp, {
|
|
1655
|
+
passive: true
|
|
1656
|
+
});
|
|
1657
|
+
window.addEventListener('touchend', this.mouseUp, {
|
|
1658
|
+
passive: true
|
|
1659
|
+
});
|
|
1660
|
+
window.addEventListener('mousemove', this.mouseMove, {
|
|
1661
|
+
passive: true
|
|
1662
|
+
});
|
|
1663
|
+
window.addEventListener('touchmove', this.mouseMove, {
|
|
1664
|
+
passive: true
|
|
1665
|
+
});
|
|
1666
|
+
this.animation = new releaseAnimation/* default */.A({
|
|
1667
|
+
maxY: POPUP_MAX_HEIGHT,
|
|
1668
|
+
minY: POPUP_MIN_HEIGHT,
|
|
1669
|
+
duration: 150
|
|
1670
|
+
});
|
|
1671
|
+
this.close();
|
|
1672
|
+
}
|
|
1673
|
+
componentWillUnmount() {
|
|
1674
|
+
var $ratingHandle = this.refHandle.current;
|
|
1675
|
+
$ratingHandle.removeEventListener('mousedown', this.mouseDown, 0);
|
|
1676
|
+
$ratingHandle.removeEventListener('touchstart', this.mouseDown, 0);
|
|
1677
|
+
window.removeEventListener('mouseup', this.mouseUp, 0);
|
|
1678
|
+
window.removeEventListener('touchend', this.mouseUp, 0);
|
|
1679
|
+
window.removeEventListener('mousemove', this.mouseMove, 0);
|
|
1680
|
+
window.removeEventListener('touchmove', this.mouseMove, 0);
|
|
1681
|
+
}
|
|
1682
|
+
render() {
|
|
1683
|
+
if (this._show != this.props.show) {
|
|
1684
|
+
this._show = this.props.show;
|
|
1685
|
+
util/* default */.A.setTimeout(() => {
|
|
1686
|
+
if (!this._show) this.close();else this.open();
|
|
1687
|
+
});
|
|
1688
|
+
}
|
|
1689
|
+
let cls = this.state.hide ? 'd-none' : '';
|
|
1690
|
+
return (0,preact_module.h)("div", {
|
|
1691
|
+
class: cls
|
|
1692
|
+
}, (0,preact_module.h)("div", {
|
|
1693
|
+
class: "extension--overlay",
|
|
1694
|
+
style: `opacity: ${this.state.overlayOpacity * 0.5} !important;`
|
|
1695
|
+
}), (0,preact_module.h)("div", {
|
|
1696
|
+
class: "extension",
|
|
1697
|
+
ref: this.refRating,
|
|
1698
|
+
style: `height: ${this.state.ratingHeight}px !important;`
|
|
1699
|
+
}, (0,preact_module.h)("div", {
|
|
1700
|
+
class: "extension--close-btn",
|
|
1701
|
+
onClick: this.close
|
|
1702
|
+
}, this.props.t('close')), (0,preact_module.h)("div", {
|
|
1703
|
+
class: "extension--handle",
|
|
1704
|
+
ref: this.refHandle
|
|
1705
|
+
}, (0,preact_module.h)("div", {
|
|
1706
|
+
class: "extension--thumb"
|
|
1707
|
+
})), (0,preact_module.h)("div", {
|
|
1708
|
+
style: "overflow-x: hidden !important; overflow-y: scroll !important; height: 100% !important;"
|
|
1709
|
+
}, (0,preact_module.h)(order_Order, {
|
|
1710
|
+
key: this.props.order_id,
|
|
1711
|
+
store: this.props.store,
|
|
1712
|
+
onResponse: this.onResponse,
|
|
1713
|
+
onClose: this.close,
|
|
1714
|
+
t: this.props.t,
|
|
1715
|
+
order_id: this.props.order_id,
|
|
1716
|
+
cid: this.props.cid
|
|
1717
|
+
}))));
|
|
1718
|
+
}
|
|
1719
|
+
open() {
|
|
1720
|
+
if (!this.state.hide) return;
|
|
1721
|
+
if (!this.props.order_id) return;
|
|
1722
|
+
this.setState({
|
|
1723
|
+
hide: false
|
|
1724
|
+
});
|
|
1725
|
+
if (!this.refRating.current) return;
|
|
1726
|
+
var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
|
|
1727
|
+
var h0 = parseFloat(popupStyle.height);
|
|
1728
|
+
this.animation.play(-20, h0, h => {
|
|
1729
|
+
this.setState({
|
|
1730
|
+
ratingHeight: h,
|
|
1731
|
+
overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
1732
|
+
});
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
onMouseDown(e) {
|
|
1736
|
+
this.mousePushed = true;
|
|
1737
|
+
this.animation.stop();
|
|
1738
|
+
e.preventDefault();
|
|
1739
|
+
if (e.touches && e.touches[0]) e = e.touches[0];
|
|
1740
|
+
this.mousePushedDy = e.pageY - window.pageYOffset - this.refRating.current.getBoundingClientRect().y;
|
|
1741
|
+
}
|
|
1742
|
+
onMouseUp(e) {
|
|
1743
|
+
if (!this.mousePushed) return;
|
|
1744
|
+
if (e.touches && e.touches[0]) e = e.touches[0];
|
|
1745
|
+
this.mousePushed = false;
|
|
1746
|
+
var popupStyle = this.refRating.current.currentStyle || window.getComputedStyle(this.refRating.current);
|
|
1747
|
+
var h0 = parseFloat(popupStyle.height);
|
|
1748
|
+
this.animation.play(this.mouseVelocity, h0, h => {
|
|
1749
|
+
this.setState({
|
|
1750
|
+
ratingHeight: h,
|
|
1751
|
+
overlayOpacity: Math.min(1, (h - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
1752
|
+
});
|
|
1753
|
+
if (h < POPUP_MIN_HEIGHT + 10) {
|
|
1754
|
+
if (!this.state.hide) {
|
|
1755
|
+
this.setState({
|
|
1756
|
+
hide: true
|
|
1757
|
+
});
|
|
1758
|
+
this.props.onRate && this.props.onRate({
|
|
1759
|
+
no_rating: true
|
|
1760
|
+
});
|
|
1761
|
+
}
|
|
1762
|
+
}
|
|
1763
|
+
});
|
|
1764
|
+
}
|
|
1765
|
+
onMouseMove(e) {
|
|
1766
|
+
if (!this.mousePushed) return;
|
|
1767
|
+
if (e.touches && e.touches[0]) e = e.touches[0];
|
|
1768
|
+
var my = e.pageY;
|
|
1769
|
+
this.mouseVelocity = my - this.lastMouseY;
|
|
1770
|
+
this.lastMouseY = my;
|
|
1771
|
+
my = my - this.mousePushedDy;
|
|
1772
|
+
var K = 10000;
|
|
1773
|
+
var height = this.refRating.current.getBoundingClientRect().bottom - my;
|
|
1774
|
+
if (height > POPUP_MAX_HEIGHT) {
|
|
1775
|
+
var beta = K / (POPUP_HARD_MAX_HEIGHT - POPUP_MAX_HEIGHT) - POPUP_MAX_HEIGHT;
|
|
1776
|
+
height = POPUP_HARD_MAX_HEIGHT - K / (height + beta);
|
|
1777
|
+
}
|
|
1778
|
+
this.setState({
|
|
1779
|
+
ratingHeight: height,
|
|
1780
|
+
overlayOpacity: Math.min(1, (height - POPUP_MIN_HEIGHT) / (POPUP_HARD_MAX_HEIGHT - POPUP_MIN_HEIGHT))
|
|
1781
|
+
});
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/***/ }),
|
|
1786
|
+
|
|
1787
|
+
/***/ 7741:
|
|
1788
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1789
|
+
|
|
1790
|
+
module.exports = __webpack_require__.p + "assets/img/caret.998eb8f.svg";
|
|
1791
|
+
|
|
1792
|
+
/***/ }),
|
|
1793
|
+
|
|
1794
|
+
/***/ 5860:
|
|
1795
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1796
|
+
|
|
1797
|
+
module.exports = __webpack_require__.p + "assets/img/done_green.b817fd4.svg";
|
|
1798
|
+
|
|
1799
|
+
/***/ }),
|
|
1800
|
+
|
|
1801
|
+
/***/ 6907:
|
|
1802
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1803
|
+
|
|
1804
|
+
module.exports = __webpack_require__.p + "assets/img/empty_1.0b98af0.svg";
|
|
1805
|
+
|
|
1806
|
+
/***/ }),
|
|
1807
|
+
|
|
1808
|
+
/***/ 1113:
|
|
1809
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1810
|
+
|
|
1811
|
+
module.exports = __webpack_require__.p + "assets/img/ghn.070f8e3.svg";
|
|
1812
|
+
|
|
1813
|
+
/***/ }),
|
|
1814
|
+
|
|
1815
|
+
/***/ 7362:
|
|
1816
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1817
|
+
|
|
1818
|
+
module.exports = __webpack_require__.p + "assets/img/ghtk.326eac1.svg";
|
|
1819
|
+
|
|
1820
|
+
/***/ }),
|
|
1821
|
+
|
|
1822
|
+
/***/ 7324:
|
|
1823
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1824
|
+
|
|
1825
|
+
module.exports = __webpack_require__.p + "assets/img/info.ebce7ea.svg";
|
|
1826
|
+
|
|
1827
|
+
/***/ }),
|
|
1828
|
+
|
|
1829
|
+
/***/ 185:
|
|
1830
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1831
|
+
|
|
1832
|
+
module.exports = __webpack_require__.p + "assets/img/loader.37000a7.svg";
|
|
1833
|
+
|
|
1834
|
+
/***/ }),
|
|
1835
|
+
|
|
1836
|
+
/***/ 3142:
|
|
1837
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1838
|
+
|
|
1839
|
+
module.exports = __webpack_require__.p + "assets/img/not_found_search.2ddb8d1.png";
|
|
1840
|
+
|
|
1841
|
+
/***/ }),
|
|
1842
|
+
|
|
1843
|
+
/***/ 8512:
|
|
1844
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1845
|
+
|
|
1846
|
+
module.exports = __webpack_require__.p + "assets/img/package.8d37d0f.svg";
|
|
1847
|
+
|
|
1848
|
+
/***/ }),
|
|
1849
|
+
|
|
1850
|
+
/***/ 6857:
|
|
1851
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1852
|
+
|
|
1853
|
+
module.exports = __webpack_require__.p + "assets/img/package_fade.763c001.svg";
|
|
1854
|
+
|
|
1855
|
+
/***/ }),
|
|
1856
|
+
|
|
1857
|
+
/***/ 5452:
|
|
1858
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1859
|
+
|
|
1860
|
+
module.exports = __webpack_require__.p + "assets/img/search.f9705ff.svg";
|
|
1861
|
+
|
|
1862
|
+
/***/ }),
|
|
1863
|
+
|
|
1864
|
+
/***/ 5244:
|
|
1865
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1866
|
+
|
|
1867
|
+
module.exports = __webpack_require__.p + "assets/img/shop.f7dc7d8.svg";
|
|
1868
|
+
|
|
1869
|
+
/***/ }),
|
|
1870
|
+
|
|
1871
|
+
/***/ 2523:
|
|
1872
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1873
|
+
|
|
1874
|
+
module.exports = __webpack_require__.p + "assets/img/shop_faded.df7845a.svg";
|
|
1875
|
+
|
|
1876
|
+
/***/ }),
|
|
1877
|
+
|
|
1878
|
+
/***/ 3080:
|
|
1879
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1880
|
+
|
|
1881
|
+
module.exports = __webpack_require__.p + "assets/img/x.26fdfa3.svg";
|
|
1882
|
+
|
|
1883
|
+
/***/ })
|
|
1884
|
+
|
|
1885
|
+
}]);
|