@subiz/widget-v4 4.1.71 → 4.1.73
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/app.js +0 -42
- package/assets/less/widget.less +6 -5
- package/assets/less/widget_header.less +5 -3
- package/compiled_src/chatbox/AudioAttachments.js +25 -32
- package/compiled_src/chatbox/Event.js +19 -3
- package/compiled_src/chatbox/InfoMessage.js +2 -1
- package/compiled_src/chatbox/OrderAttachments.js +102 -6
- package/compiled_src/chatbox/PoweredBy.js +20 -27
- package/compiled_src/chatbox/TextMessage.js +0 -14
- package/compiled_src/chatbox/VideoAttachments.js +1 -0
- package/compiled_src/chatbox/Widget.js +21 -21
- package/compiled_src/chatbox/time.js +46 -28
- package/compiled_src/lib.js +2 -2
- package/compiled_src/order/icon.js +2 -2
- package/compiled_src/order/index.js +2 -2
- package/compiled_src/plugin.js +2 -4
- package/compiled_src/store/api.js +1 -16
- package/compiled_src/store/store.js +2 -5
- package/compiled_src/util/common.js +12 -494
- package/compiled_src/util/index.js +0 -2
- package/dist/127.js +273 -0
- package/dist/132.js +2 -2
- package/dist/185.js +1885 -0
- package/dist/18eaf7ad0c6.127.js +1 -0
- package/dist/{18e74ca84ff.132.js → 18eaf7ad0c6.132.js} +1 -1
- package/dist/18eaf7ad0c6.185.js +1 -0
- package/dist/18eaf7ad0c6.278.js +1 -0
- package/dist/{18e74ca84ff.490.js → 18eaf7ad0c6.490.js} +1 -1
- package/dist/{18e74ca84ff.74.js → 18eaf7ad0c6.74.js} +1 -1
- package/dist/18eaf7ad0c6.app.js +1 -0
- package/dist/{18e74ca84ff.index.html → 18eaf7ad0c6.index.html} +1 -1
- package/dist/{18e74ca84ff.library.html → 18eaf7ad0c6.library.html} +1 -1
- package/dist/18eaf7ad0c6.library.js +1 -0
- package/dist/{18e74ca84ff.preview.html → 18eaf7ad0c6.preview.html} +1 -1
- package/dist/18eaf7ad0c6.preview.js +1 -0
- package/dist/18eaf7ad0c6.screenshoot.js +1 -0
- package/dist/18eaf7ad0c6.webview.js +1 -0
- package/dist/18ed1c3d33e.127.js +1 -0
- package/dist/18ed1c3d33e.132.js +1 -0
- package/dist/18ed1c3d33e.185.js +1 -0
- package/dist/18ed1c3d33e.27.js +1 -0
- package/dist/18ed1c3d33e.278.js +1 -0
- package/dist/18ed1c3d33e.459.js +1 -0
- package/dist/18ed1c3d33e.490.js +1 -0
- package/dist/18ed1c3d33e.74.js +1 -0
- package/dist/18ed1c3d33e.997.js +1 -0
- package/dist/18ed1c3d33e.app.js +1 -0
- package/dist/18ed1c3d33e.index.html +33 -0
- package/dist/18ed1c3d33e.library.html +33 -0
- package/dist/18ed1c3d33e.library.js +1 -0
- package/dist/18ed1c3d33e.preview.html +759 -0
- package/dist/18ed1c3d33e.preview.js +1 -0
- package/dist/18ed1c3d33e.screenshoot.js +1 -0
- package/dist/18ed1c3d33e.webview.js +1 -0
- package/dist/278.js +1 -1
- package/dist/490.js +1 -1
- package/dist/74.js +1 -1
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +1 -1
- package/dist/screenshoot.js +4740 -627
- package/inject.js +3 -3
- package/package.json +6 -6
- package/src/chatbox/AudioAttachments.js +19 -26
- package/src/chatbox/Event.js +22 -3
- package/src/chatbox/InfoMessage.js +11 -11
- package/src/chatbox/OrderAttachments.js +118 -5
- package/src/chatbox/PoweredBy.js +14 -22
- package/src/chatbox/TextMessage.js +0 -14
- package/src/chatbox/VideoAttachments.js +1 -1
- package/src/chatbox/Widget.js +16 -20
- package/src/chatbox/time.js +54 -24
- package/src/lib.js +2 -2
- package/src/order/icon.js +2 -2
- package/src/order/index.js +2 -2
- package/src/plugin.js +4 -3
- package/src/store/api.js +1 -14
- package/src/store/store.js +3 -11
- package/src/util/common.js +13 -215
- package/src/util/index.js +0 -3
- package/compiled_src/util/order.js +0 -112
- package/dist/18e74ca84ff.278.js +0 -1
- package/dist/18e74ca84ff.497.js +0 -1
- package/dist/18e74ca84ff.app.js +0 -1
- package/dist/18e74ca84ff.library.js +0 -1
- package/dist/18e74ca84ff.preview.js +0 -1
- package/dist/18e74ca84ff.screenshoot.js +0 -1
- package/dist/18e74ca84ff.webview.js +0 -1
- package/dist/497.js +0 -6721
- package/src/util/order.js +0 -120
- /package/dist/{18e74ca84ff.27.js → 18eaf7ad0c6.27.js} +0 -0
- /package/dist/{18e74ca84ff.459.js → 18eaf7ad0c6.459.js} +0 -0
- /package/dist/{18e74ca84ff.997.js → 18eaf7ad0c6.997.js} +0 -0
package/app.js
CHANGED
|
@@ -21,19 +21,6 @@ if (!VERSION) throw new Error('subiz cannot detect version')
|
|
|
21
21
|
|
|
22
22
|
var apiV4 = new ApiV4(config.ApiURL, config.FileURL, config.RealtimeURL)
|
|
23
23
|
|
|
24
|
-
// isV4 tells whether the website is using widget version 4.1 or not
|
|
25
|
-
function isV4_1() {
|
|
26
|
-
var scripts = document.getElementsByTagName('script')
|
|
27
|
-
if (!(window._sbzq instanceof Array)) return false
|
|
28
|
-
|
|
29
|
-
for (var s of scripts) {
|
|
30
|
-
if (!s || !s.src) continue
|
|
31
|
-
if (s.src.indexOf(config.BaseURL) !== -1) return true
|
|
32
|
-
if (s.src.indexOf('https://widgetv4.subiz.com') !== -1) return true // old
|
|
33
|
-
}
|
|
34
|
-
return false
|
|
35
|
-
}
|
|
36
|
-
|
|
37
24
|
// isV4 tells whether the website is using widget version 4.2 or not
|
|
38
25
|
function isV4_2() {
|
|
39
26
|
if (window.sbz_v4) return true
|
|
@@ -50,24 +37,11 @@ function isV4_2() {
|
|
|
50
37
|
return false
|
|
51
38
|
}
|
|
52
39
|
|
|
53
|
-
// isV2 tells whether the website is using widget version 2 or not
|
|
54
|
-
function isV2() {
|
|
55
|
-
if (!window._sbzq) return false
|
|
56
|
-
var scripts = document.getElementsByTagName('script')
|
|
57
|
-
for (var s of scripts) {
|
|
58
|
-
if (!s || !s.src) continue
|
|
59
|
-
if (s.src.indexOf('static.subiz.com') !== -1) return true
|
|
60
|
-
}
|
|
61
|
-
return false
|
|
62
|
-
}
|
|
63
|
-
|
|
64
40
|
// return widget version
|
|
65
41
|
function detect() {
|
|
66
42
|
if (window._sbzaccid) return '4.3'
|
|
67
43
|
if (isV4_2()) return '4.2'
|
|
68
44
|
if (window.subiz_account_id && window.subiz_account_id > 0) return '1'
|
|
69
|
-
if (isV4_1()) return '4.1'
|
|
70
|
-
if (isV2()) return '2'
|
|
71
45
|
return undefined
|
|
72
46
|
}
|
|
73
47
|
|
|
@@ -139,20 +113,6 @@ function loopTitle(laststate) {
|
|
|
139
113
|
loopTitle()
|
|
140
114
|
|
|
141
115
|
function init() {
|
|
142
|
-
// backward compatible api
|
|
143
|
-
if (VERSION === '1' || VERSION === '2') {
|
|
144
|
-
console.error('DETECTED SUBIZ OUTDATED V3 EMBEDED CODE', v3accid, '. Please visit https://subiz.com.vn for support')
|
|
145
|
-
return
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (VERSION === '1') apiV4._setAccount(window.subiz_account_id)
|
|
149
|
-
if (VERSION === '2' || VERSION === '4.1') {
|
|
150
|
-
let queue = window._sbzq || []
|
|
151
|
-
if (!Array.isArray(queue)) queue = []
|
|
152
|
-
window._sbzq = {push: callV2}
|
|
153
|
-
queue.forEach(callV2)
|
|
154
|
-
}
|
|
155
|
-
|
|
156
116
|
if (VERSION === '4.2' || VERSION === '4.3') {
|
|
157
117
|
let queue = (window.subiz && window.subiz.q) || []
|
|
158
118
|
window.subiz = function () {
|
|
@@ -169,5 +129,3 @@ function init() {
|
|
|
169
129
|
}
|
|
170
130
|
|
|
171
131
|
init()
|
|
172
|
-
|
|
173
|
-
// TODO: should print example v4_1, v4_2, v4_3, ...
|
package/assets/less/widget.less
CHANGED
|
@@ -451,20 +451,21 @@
|
|
|
451
451
|
.widget-preview--btn-close {
|
|
452
452
|
display: block;
|
|
453
453
|
cursor: pointer;
|
|
454
|
+
opacity: 0.5;
|
|
454
455
|
align-self: flex-start;
|
|
455
456
|
background-color: #e5e5e5;
|
|
456
457
|
background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMzMzMiIHN0cm9rZS13aWR0aD0iMi4yIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXIteCI+PGxpbmUgeDE9IjE4IiB5MT0iNiIgeDI9IjYiIHkyPSIxOCI+PC9saW5lPjxsaW5lIHgxPSI2IiB5MT0iNiIgeDI9IjE4IiB5Mj0iMTgiPjwvbGluZT48L3N2Zz4K');
|
|
457
458
|
background-size: 16px 16px;
|
|
458
459
|
background-repeat: no-repeat;
|
|
459
460
|
background-position: center;
|
|
460
|
-
width:
|
|
461
|
-
height:
|
|
461
|
+
width: 24px;
|
|
462
|
+
height: 24px;
|
|
462
463
|
display: block;
|
|
463
464
|
border-radius: 100%;
|
|
464
465
|
transition: background-color 0.2s;
|
|
465
466
|
|
|
466
467
|
&:hover {
|
|
467
|
-
|
|
468
|
+
opacity: 1;
|
|
468
469
|
}
|
|
469
470
|
}
|
|
470
471
|
|
|
@@ -481,14 +482,14 @@
|
|
|
481
482
|
.widget-preview--body {
|
|
482
483
|
display: flex;
|
|
483
484
|
padding: 15px;
|
|
484
|
-
align-items: center;
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
.widget-preview--title {
|
|
488
488
|
display: block;
|
|
489
489
|
font-size: 15px;
|
|
490
|
-
.color(
|
|
490
|
+
.color(black);
|
|
491
491
|
margin-bottom: 5px;
|
|
492
|
+
opacity: 0.7;
|
|
492
493
|
}
|
|
493
494
|
|
|
494
495
|
.widget-preview--content {
|
|
@@ -36,15 +36,16 @@
|
|
|
36
36
|
.widget-header--title {
|
|
37
37
|
white-space: nowrap;
|
|
38
38
|
overflow: hidden;
|
|
39
|
+
font-weight: 500;
|
|
39
40
|
text-overflow: ellipsis;
|
|
40
41
|
font-size: 16px;
|
|
41
42
|
.color(@text-color);
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
.widget-header--description {
|
|
45
|
-
font-size:
|
|
46
|
+
font-size: 15px;
|
|
46
47
|
white-space: pre-wrap;
|
|
47
|
-
opacity: 0.
|
|
48
|
+
opacity: 0.7;
|
|
48
49
|
flex: 1;
|
|
49
50
|
.color(@text-color);
|
|
50
51
|
margin-top: 2.5px;
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
.widget-header--title {
|
|
77
78
|
white-space: nowrap;
|
|
78
79
|
overflow: hidden;
|
|
80
|
+
font-weight: 500;
|
|
79
81
|
text-overflow: ellipsis;
|
|
80
82
|
flex: 1;
|
|
81
83
|
font-size: 16px;
|
|
@@ -121,7 +123,7 @@
|
|
|
121
123
|
flex: 1;
|
|
122
124
|
display: flex;
|
|
123
125
|
flex-direction: column;
|
|
124
|
-
margin-left:
|
|
126
|
+
margin-left: 10px;
|
|
125
127
|
z-index: 1;
|
|
126
128
|
}
|
|
127
129
|
|
|
@@ -3,39 +3,32 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = AudioAttachments;
|
|
7
7
|
var _index = _interopRequireDefault(require("../util/index.js"));
|
|
8
|
-
var _common = require("../common.js");
|
|
9
8
|
var _preact = require("preact");
|
|
10
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (_index.default.includes(att.mimetype, 'audio')) audios.push(att);
|
|
22
|
-
});
|
|
23
|
-
if (audios.length === 0) return null;
|
|
24
|
-
var $audios = _index.default.map(audios, (audio, index) => {
|
|
25
|
-
return (0, _preact.h)("div", {
|
|
26
|
-
key: index,
|
|
27
|
-
class: `audio-attachment audio-attachment--${byType}`
|
|
28
|
-
}, (0, _preact.h)("audio", {
|
|
29
|
-
class: "audio-attachment__audio",
|
|
30
|
-
controls: true
|
|
31
|
-
}, (0, _preact.h)("source", {
|
|
32
|
-
src: this.props.store.replaceFileUrl(audio.url),
|
|
33
|
-
type: audio.mimetype
|
|
34
|
-
})));
|
|
35
|
-
});
|
|
10
|
+
function AudioAttachments(props) {
|
|
11
|
+
let byType = _index.default.get(props.ev, 'by.type');
|
|
12
|
+
var attachments = _index.default.get(props.ev, 'data.message.attachments', []);
|
|
13
|
+
var audios = [];
|
|
14
|
+
_index.default.each(attachments, (att, i) => {
|
|
15
|
+
if (!att) return;
|
|
16
|
+
if (_index.default.includes(att.mimetype, 'audio')) audios.push(att);
|
|
17
|
+
});
|
|
18
|
+
if (audios.length === 0) return null;
|
|
19
|
+
var $audios = _index.default.map(audios, (audio, index) => {
|
|
36
20
|
return (0, _preact.h)("div", {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
key: index,
|
|
22
|
+
class: `audio-attachment audio-attachment--${byType}`
|
|
23
|
+
}, (0, _preact.h)("audio", {
|
|
24
|
+
class: "audio-attachment__audio",
|
|
25
|
+
controls: true
|
|
26
|
+
}, (0, _preact.h)("source", {
|
|
27
|
+
src: props.store.replaceFileUrl(audio.url),
|
|
28
|
+
type: audio.mimetype
|
|
29
|
+
})));
|
|
30
|
+
});
|
|
31
|
+
return (0, _preact.h)("div", {
|
|
32
|
+
class: `message-${byType} message-${byType}-audio`
|
|
33
|
+
}, $audios);
|
|
34
|
+
}
|
|
@@ -13,7 +13,6 @@ var _FormAttachments = _interopRequireDefault(require("./FormAttachments.js"));
|
|
|
13
13
|
var _FormSubmitAttachments = _interopRequireDefault(require("./FormSubmitAttachments.js"));
|
|
14
14
|
var _GenericTemplateAttachments = _interopRequireDefault(require("./GenericTemplateAttachments.js"));
|
|
15
15
|
var _ProductAttachments = _interopRequireDefault(require("./ProductAttachments.js"));
|
|
16
|
-
var _OrderAttachments = _interopRequireDefault(require("./OrderAttachments.js"));
|
|
17
16
|
var _VideoAttachments = _interopRequireDefault(require("./VideoAttachments.js"));
|
|
18
17
|
var _TextMessage = _interopRequireDefault(require("./TextMessage.js"));
|
|
19
18
|
var _InfoMessage = _interopRequireDefault(require("./InfoMessage.js"));
|
|
@@ -22,6 +21,10 @@ var _time = _interopRequireDefault(require("./time.js"));
|
|
|
22
21
|
var _common = require("../common.js");
|
|
23
22
|
var _preact = require("preact");
|
|
24
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
|
+
let OrderAttachments = false;
|
|
27
|
+
const LoadOrderAttachments = () => Promise.resolve().then(() => _interopRequireWildcard(require('./OrderAttachments.js')));
|
|
25
28
|
class Event extends _common.Com {
|
|
26
29
|
constructor(props) {
|
|
27
30
|
super(props);
|
|
@@ -115,14 +118,27 @@ class Event extends _common.Com {
|
|
|
115
118
|
class: "message-sender-name"
|
|
116
119
|
}, senderName));
|
|
117
120
|
}
|
|
121
|
+
tryLoadOrder(ev) {
|
|
122
|
+
let byType = _index.default.get(ev, 'by.type');
|
|
123
|
+
if (byType === 'user') return;
|
|
124
|
+
let acc = this.props.store.matchAccount();
|
|
125
|
+
var attachments = _index.default.get(ev, 'data.message.attachments', []);
|
|
126
|
+
let orders = _index.default.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
|
|
127
|
+
if (orders.length === 0) return;
|
|
128
|
+
if (!OrderAttachments) _index.default.setTimeout(async () => {
|
|
129
|
+
OrderAttachments = (await LoadOrderAttachments()).default;
|
|
130
|
+
});
|
|
131
|
+
}
|
|
118
132
|
renderMessageSent() {
|
|
119
133
|
let ev = this.props.event.ev;
|
|
134
|
+
this.tryLoadOrder(ev);
|
|
120
135
|
var $time = null;
|
|
121
136
|
if (this.props.event.show_time) {
|
|
122
137
|
$time = (0, _preact.h)("div", {
|
|
123
138
|
class: "convo-event-time"
|
|
124
139
|
}, (0, _preact.h)(_time.default, {
|
|
125
|
-
time: ev.created
|
|
140
|
+
time: ev.created,
|
|
141
|
+
t: this.props.t
|
|
126
142
|
}));
|
|
127
143
|
}
|
|
128
144
|
let t = new _index.default.Date(ev.created).toLocaleString();
|
|
@@ -172,7 +188,7 @@ class Event extends _common.Com {
|
|
|
172
188
|
onPostback: e => this.choosePostbackBtn(e),
|
|
173
189
|
store: this.props.store,
|
|
174
190
|
ev: ev
|
|
175
|
-
}), (0, _preact.h)(
|
|
191
|
+
}), (0, _preact.h)(OrderAttachments, {
|
|
176
192
|
t: this.props.t,
|
|
177
193
|
store: this.props.store,
|
|
178
194
|
ev: ev
|
|
@@ -17,7 +17,7 @@ class ProductAttachments extends _common.Com {
|
|
|
17
17
|
let orders = _index.default.filter(attachments, att => att.type === 'order' && att.order).map(att => att.order);
|
|
18
18
|
if (orders.length === 0) return null;
|
|
19
19
|
let $orders = _index.default.map(orders, (order, index) => {
|
|
20
|
-
|
|
20
|
+
calcOrderTotal(order);
|
|
21
21
|
let $note = null;
|
|
22
22
|
if (order.note) {
|
|
23
23
|
$note = (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
@@ -46,7 +46,7 @@ class ProductAttachments extends _common.Com {
|
|
|
46
46
|
title: this.props.t.i18n(product.i18n_name) || product.name
|
|
47
47
|
}, this.props.t.i18n(product.i18n_name) || product.name), (0, _preact.h)("div", {
|
|
48
48
|
class: "order_attachment__product_desc"
|
|
49
|
-
},
|
|
49
|
+
}, getProductPropName(product, ' / ')), (0, _preact.h)("div", {
|
|
50
50
|
class: "order_attachment__product_desc"
|
|
51
51
|
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(product.price))));
|
|
52
52
|
}));
|
|
@@ -66,10 +66,10 @@ class ProductAttachments extends _common.Com {
|
|
|
66
66
|
phone = phone || _index.default.trim(phoneattr.text);
|
|
67
67
|
if (phone) phone = this.props.t('phn') + ': ' + phone;
|
|
68
68
|
let $shipto = null;
|
|
69
|
-
if (
|
|
69
|
+
if (displayOrderShippingAddress(order) || phone) {
|
|
70
70
|
$shipto = (0, _preact.h)("div", null, (0, _preact.h)("div", {
|
|
71
71
|
class: "order_attachment__label"
|
|
72
|
-
}, this.props.t('ship_to')), (0, _preact.h)("div", null,
|
|
72
|
+
}, this.props.t('ship_to')), (0, _preact.h)("div", null, displayOrderShippingAddress(order)), (0, _preact.h)("div", {
|
|
73
73
|
class: "order_attachment__text_truncate"
|
|
74
74
|
}, phone));
|
|
75
75
|
}
|
|
@@ -160,9 +160,105 @@ class ProductAttachments extends _common.Com {
|
|
|
160
160
|
class: "order_attachment__header"
|
|
161
161
|
}, this.props.t('order'), (0, _preact.h)("span", {
|
|
162
162
|
class: "order_attachment__text_muted order_attachment__text_sm"
|
|
163
|
-
},
|
|
163
|
+
}, getOrderDisplayName(order))), $products, $shipto, $note, $beforeTax, $subtotal, $total);
|
|
164
164
|
});
|
|
165
165
|
return $orders;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
168
|
-
exports.default = ProductAttachments;
|
|
168
|
+
exports.default = ProductAttachments;
|
|
169
|
+
function getProductPropName(product, seperator = ' - ') {
|
|
170
|
+
let options = op.get(product, 'options', []);
|
|
171
|
+
let props = op.get(product, 'props', []);
|
|
172
|
+
let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
|
|
173
|
+
let names = [];
|
|
174
|
+
op.each(multiPropsOptions, option => {
|
|
175
|
+
let prop = op.find(props, prop => prop.key === option.key) || {};
|
|
176
|
+
if (prop.value) names.push(prop.value);
|
|
177
|
+
});
|
|
178
|
+
return names.join(seperator);
|
|
179
|
+
}
|
|
180
|
+
function getOrderDisplayName(order = {}) {
|
|
181
|
+
return order.number || order.id || '';
|
|
182
|
+
}
|
|
183
|
+
function displayOrderShippingAddress(order, isShorten) {
|
|
184
|
+
let addr = op.get(order, 'shipping.address', {});
|
|
185
|
+
let fulladdr = [addr.address, addr.ward, addr.district, addr.province].filter(a => a).join(', ').trim();
|
|
186
|
+
if (isShorten) fulladdr = shortenAddr(fulladdr);
|
|
187
|
+
return fulladdr;
|
|
188
|
+
}
|
|
189
|
+
function shortenAddr(str) {
|
|
190
|
+
str = str || '';
|
|
191
|
+
str = str.replace(/Hà Nội/gi, 'HN');
|
|
192
|
+
str = str.replace(/Hồ Chí Minh/gi, 'HCM');
|
|
193
|
+
str = str.replace(/Thành Phố/gi, 'TP');
|
|
194
|
+
return str;
|
|
195
|
+
}
|
|
196
|
+
function calcOrderTotal(order) {
|
|
197
|
+
let subtotal = 0;
|
|
198
|
+
let beforeTaxDiscount = 0;
|
|
199
|
+
let ordervalue = 0;
|
|
200
|
+
op.map(order.items, item => {
|
|
201
|
+
if (!item.product) return 0;
|
|
202
|
+
let price = op.get(item, 'product.price', 0) * (item.quantity || 0);
|
|
203
|
+
ordervalue += price;
|
|
204
|
+
if (item.discount_type == 'percentage') {
|
|
205
|
+
if (item.discount_percentage > 0) {
|
|
206
|
+
beforeTaxDiscount += price * item.discount_percentage / 10000;
|
|
207
|
+
price = price * (1 - (item.discount_percentage || 0) / 10000);
|
|
208
|
+
}
|
|
209
|
+
} else if (item.discount_type == 'amount') {
|
|
210
|
+
if (item.discount_amount > 0) {
|
|
211
|
+
beforeTaxDiscount += item.discount_amount;
|
|
212
|
+
price = price - (item.discount_amount || 0);
|
|
213
|
+
if (price <= 0) price = 0;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
item.total = price;
|
|
217
|
+
subtotal += price;
|
|
218
|
+
});
|
|
219
|
+
let taxM = {};
|
|
220
|
+
op.map(order.items, (item, i) => {
|
|
221
|
+
if (!item.product) return;
|
|
222
|
+
let tax = item.product.tax;
|
|
223
|
+
if (!tax) return;
|
|
224
|
+
if (!tax.id) return;
|
|
225
|
+
let taxprice = item.total * tax.percentage / 10000;
|
|
226
|
+
item.total_tax = taxprice;
|
|
227
|
+
taxM[i] = {
|
|
228
|
+
tax: tax,
|
|
229
|
+
taxprice: taxprice
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
let totaltax = 0;
|
|
233
|
+
op.map(taxM, t => totaltax += t.taxprice);
|
|
234
|
+
let computed_discount = 0;
|
|
235
|
+
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
236
|
+
computed_discount = (subtotal + totaltax) * order.discount_percentage / 10000;
|
|
237
|
+
} else if (order.discount_type == 'amount') {
|
|
238
|
+
computed_discount = order.discount_amount || 0;
|
|
239
|
+
}
|
|
240
|
+
let shippingfee = op.get(order, 'shipping.nominal_fee', 0);
|
|
241
|
+
if (shippingfee > 0) {
|
|
242
|
+
if (op.get(order, 'shipping.tax.id')) {
|
|
243
|
+
let tax = order.shipping.tax;
|
|
244
|
+
let taxprice = shippingfee * (tax.percentage / 10000);
|
|
245
|
+
taxM['ship'] = {
|
|
246
|
+
tax: tax,
|
|
247
|
+
taxprice: taxprice
|
|
248
|
+
};
|
|
249
|
+
order.shipping.total_tax = taxprice;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
totaltax = 0;
|
|
253
|
+
op.map(taxM, t => totaltax += t.taxprice);
|
|
254
|
+
let total = subtotal + totaltax - computed_discount + shippingfee;
|
|
255
|
+
total += order.adjustment || 0;
|
|
256
|
+
if (total < 0) total = 0;
|
|
257
|
+
order.subtotal = subtotal;
|
|
258
|
+
order._computed_discount = computed_discount;
|
|
259
|
+
order._taxM = taxM;
|
|
260
|
+
order.total = total;
|
|
261
|
+
order.total_tax = totaltax;
|
|
262
|
+
order._discount_before_tax = beforeTaxDiscount;
|
|
263
|
+
order._order_value = ordervalue;
|
|
264
|
+
}
|
|
@@ -3,32 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
7
|
-
var _common = require("../common.js");
|
|
6
|
+
exports.default = PoweredBy;
|
|
8
7
|
var _preact = require("preact");
|
|
9
8
|
var logo = require('../../assets/img/subiz-mono.svg');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
src: logo,
|
|
30
|
-
alt: "power by subiz"
|
|
31
|
-
}), " Subiz"));
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.default = PoweredBy;
|
|
9
|
+
function PoweredBy(props) {
|
|
10
|
+
if (props.store.isMobile()) return null;
|
|
11
|
+
let user = props.store.matchUser() || {};
|
|
12
|
+
var link = `https://subiz.com.vn/?utm_source=${window.location.host || `id-${user.account_id}`}&utm_medium=widget&utm_campaign=widget_referral`;
|
|
13
|
+
return (0, _preact.h)("div", {
|
|
14
|
+
class: "poweredby"
|
|
15
|
+
}, (0, _preact.h)("a", {
|
|
16
|
+
href: link,
|
|
17
|
+
class: "poweredby--text",
|
|
18
|
+
target: "_blank",
|
|
19
|
+
title: "Subiz"
|
|
20
|
+
}, (0, _preact.h)("img", {
|
|
21
|
+
width: "14",
|
|
22
|
+
height: "10",
|
|
23
|
+
class: "poweredby--subiz-logo",
|
|
24
|
+
src: logo,
|
|
25
|
+
alt: "powerred by subiz"
|
|
26
|
+
}), " Subiz"));
|
|
27
|
+
}
|
|
@@ -66,20 +66,6 @@ class TextMessage extends _common.Com {
|
|
|
66
66
|
if (insert.dynamicField) {
|
|
67
67
|
return _index.default.get(insert, 'dynamicField.text', '');
|
|
68
68
|
}
|
|
69
|
-
if (insert.mention) {
|
|
70
|
-
if (insert.mention.id == '*' || insert.mention.id == 'all') {
|
|
71
|
-
return (0, _preact.h)("span", {
|
|
72
|
-
class: "mention"
|
|
73
|
-
}, "@", this.$t('all'));
|
|
74
|
-
}
|
|
75
|
-
let ag = store.matchAgent(insert.mention.id);
|
|
76
|
-
let name = _index.default.getAgentDisplayName(ag, insert.mention.fullname);
|
|
77
|
-
return (0, _preact.h)("span", {
|
|
78
|
-
class: "mention",
|
|
79
|
-
"data-agent-id": ag.id,
|
|
80
|
-
"data-agent-fullname": name
|
|
81
|
-
}, "@", name);
|
|
82
|
-
}
|
|
83
69
|
if (insert.emoji) return (0, _preact.h)(_Emoji.default, {
|
|
84
70
|
emojiCode: `:${insert.emoji}:`
|
|
85
71
|
});
|
|
@@ -23,6 +23,7 @@ class VideoAttachments extends _common.Com {
|
|
|
23
23
|
if (videos.length === 0) return null;
|
|
24
24
|
var $videos = _index.default.map(videos, (video, index) => {
|
|
25
25
|
return (0, _preact.h)("div", {
|
|
26
|
+
key: index,
|
|
26
27
|
class: `video-attachment video-attachment--${byType}`
|
|
27
28
|
}, (0, _preact.h)("video", {
|
|
28
29
|
class: "video-attachment__video",
|
|
@@ -13,7 +13,6 @@ var _MessageInput = _interopRequireDefault(require("./MessageInput.js"));
|
|
|
13
13
|
var _Events = _interopRequireDefault(require("./Events.js"));
|
|
14
14
|
var _Typing = _interopRequireDefault(require("./Typing.js"));
|
|
15
15
|
var _Rating = _interopRequireDefault(require("./Rating.js"));
|
|
16
|
-
var _Order = _interopRequireDefault(require("./Order.js"));
|
|
17
16
|
var _ListField = _interopRequireDefault(require("./ListField.js"));
|
|
18
17
|
var _spinner = _interopRequireDefault(require("./spinner.js"));
|
|
19
18
|
var _time = _interopRequireDefault(require("./time.js"));
|
|
@@ -23,9 +22,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
23
22
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
23
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
25
24
|
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); }
|
|
25
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
26
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
26
27
|
var send = require('../../assets/img/send.svg');
|
|
27
28
|
var checkedimg = require('../../assets/img/done_gray.svg');
|
|
28
29
|
var empty = require('../../assets/img/empty.svg');
|
|
30
|
+
let Order = false;
|
|
31
|
+
const LoadOrder = () => Promise.resolve().then(() => _interopRequireWildcard(require('./Order.js')));
|
|
29
32
|
const defaultAvatar = 'https://file-subiz.com/fiqoahedjbgwclpouoml-avatar_default_baa8a1d7.png';
|
|
30
33
|
class Widget extends _common.Com {
|
|
31
34
|
constructor(props) {
|
|
@@ -95,9 +98,12 @@ class Widget extends _common.Com {
|
|
|
95
98
|
if (noschemeurl.startsWith('widget.subiz.com.vn/orders/')) {
|
|
96
99
|
let orderid = noschemeurl.substr('widget.subiz.com.vn/orders/'.length);
|
|
97
100
|
orderid = orderid.split('/')[0];
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
+
_index.default.setTimeout(async () => {
|
|
102
|
+
if (!Order) Order = (await LoadOrder()).default;
|
|
103
|
+
this.setState({
|
|
104
|
+
showOrder: true,
|
|
105
|
+
order_id: orderid
|
|
106
|
+
});
|
|
101
107
|
});
|
|
102
108
|
e.preventDefault();
|
|
103
109
|
return;
|
|
@@ -462,14 +468,16 @@ class Widget extends _common.Com {
|
|
|
462
468
|
let $field = null;
|
|
463
469
|
var errclass = field.error ? 'input--error' : '';
|
|
464
470
|
if (field.type === 'text') {
|
|
465
|
-
if (key
|
|
471
|
+
if (key == 'question' || _index.default.get(field, 'def.multiple_line')) {
|
|
466
472
|
$field = (0, _preact.h)("textarea", {
|
|
467
473
|
class: "form-control",
|
|
468
474
|
ref: ref => {
|
|
469
475
|
this['form_' + encode(key)] = ref;
|
|
470
476
|
},
|
|
477
|
+
id: 'form_' + encode(key),
|
|
471
478
|
value: field.value || '',
|
|
472
479
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
480
|
+
onChange: e => this.onInputChange(key, e.target.value),
|
|
473
481
|
row: "4",
|
|
474
482
|
class: "form-control"
|
|
475
483
|
});
|
|
@@ -479,20 +487,9 @@ class Widget extends _common.Com {
|
|
|
479
487
|
$field = this.renderRadioField(field);
|
|
480
488
|
} else if (_index.default.get(field, 'def.select') === 'dropdown') {
|
|
481
489
|
$field = this.renderDropdownField(field);
|
|
482
|
-
} else if (_index.default.get(field, 'def.multiple_line')) {
|
|
483
|
-
$field = (0, _preact.h)("textarea", {
|
|
484
|
-
class: "form-control",
|
|
485
|
-
ref: ref => {
|
|
486
|
-
this['form_' + encode(key)] = ref;
|
|
487
|
-
},
|
|
488
|
-
value: field.value || '',
|
|
489
|
-
onInput: e => this.onInputChange(key, e.target.value),
|
|
490
|
-
onChange: e => this.onInputChange(key, e.target.value),
|
|
491
|
-
row: "4",
|
|
492
|
-
class: "form-control"
|
|
493
|
-
});
|
|
494
490
|
} else {
|
|
495
491
|
$field = (0, _preact.h)("input", {
|
|
492
|
+
id: 'form_' + encode(key),
|
|
496
493
|
value: field.value || '',
|
|
497
494
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
498
495
|
onChange: e => this.onInputChange(key, e.target.value),
|
|
@@ -505,6 +502,7 @@ class Widget extends _common.Com {
|
|
|
505
502
|
}
|
|
506
503
|
} else if (field.type === 'number') {
|
|
507
504
|
$field = (0, _preact.h)("input", {
|
|
505
|
+
id: 'form_' + encode(key),
|
|
508
506
|
value: field.value,
|
|
509
507
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
510
508
|
ref: ref => {
|
|
@@ -557,6 +555,7 @@ class Widget extends _common.Com {
|
|
|
557
555
|
$field = this.renderDropdownField(field);
|
|
558
556
|
} else if (field.type === 'datetime') {
|
|
559
557
|
$field = (0, _preact.h)("input", {
|
|
558
|
+
id: 'form_' + encode(key),
|
|
560
559
|
value: field.value,
|
|
561
560
|
onInput: e => this.onInputChange(key, e.target.value),
|
|
562
561
|
class: `form-control ${errclass}`,
|
|
@@ -576,8 +575,9 @@ class Widget extends _common.Com {
|
|
|
576
575
|
if (field.label) label = field.label;
|
|
577
576
|
return (0, _preact.h)("div", {
|
|
578
577
|
key: 'form_' + encode(key)
|
|
579
|
-
}, (0, _preact.h)("
|
|
580
|
-
class: "label"
|
|
578
|
+
}, (0, _preact.h)("label", {
|
|
579
|
+
class: "label",
|
|
580
|
+
for: 'form_' + encode(key)
|
|
581
581
|
}, label, field.is_required ? (0, _preact.h)("span", {
|
|
582
582
|
class: "ml-1 red"
|
|
583
583
|
}, "*") : ''), field.error ? (0, _preact.h)("div", {
|
|
@@ -779,7 +779,7 @@ class Widget extends _common.Com {
|
|
|
779
779
|
onRate: e => this.onRate(e),
|
|
780
780
|
cid: this.props.cid,
|
|
781
781
|
t: this.props.t
|
|
782
|
-
}), (0, _preact.h)(
|
|
782
|
+
}), (0, _preact.h)(Order, {
|
|
783
783
|
forceView: this.props.view,
|
|
784
784
|
plugin: this.props.plugin,
|
|
785
785
|
show: this.state.showOrder,
|
|
@@ -872,7 +872,7 @@ class Widget extends _common.Com {
|
|
|
872
872
|
}, (0, _preact.h)(_time.default, {
|
|
873
873
|
ago: true,
|
|
874
874
|
time: time,
|
|
875
|
-
|
|
875
|
+
t: this.props.t,
|
|
876
876
|
short: true
|
|
877
877
|
}))), (0, _preact.h)("div", {
|
|
878
878
|
class: "d-flex flex-row"
|