@subiz/widget-v4 4.0.52 → 4.0.57
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/cloudflare_worker.js +1 -1
- package/compiled_src/chatbox/OrderAttachments.js +1 -4
- package/compiled_src/notif/notif.js +7 -3
- package/compiled_src/plugin.js +1 -1
- package/compiled_src/store/store.js +0 -140
- package/compiled_src/util/campaign.js +7 -2
- package/dist/178.js +406 -0
- package/dist/{17d517e44e2.178.js → 17d83c40640.178.js} +0 -0
- package/dist/{17d517e44e2.213.js → 17d83c40640.213.js} +0 -0
- package/dist/{17d517e44e2.362.js → 17d83c40640.362.js} +0 -0
- package/dist/17d83c40640.441.js +1 -0
- package/dist/17d83c40640.605.js +1 -0
- package/dist/{17d517e44e2.619.js → 17d83c40640.619.js} +1 -1
- package/dist/{17d517e44e2.678.js → 17d83c40640.678.js} +0 -0
- package/dist/17d83c40640.74.js +1 -0
- package/dist/{17d517e44e2.782.js → 17d83c40640.782.js} +0 -0
- package/dist/17d83c40640.app.js +1 -0
- package/dist/{17d517e44e2.index.html → 17d83c40640.index.html} +1 -1
- package/dist/{17d517e44e2.library.html → 17d83c40640.library.html} +1 -1
- package/dist/17d83c40640.library.js +1 -0
- package/dist/{17d517e44e2.preview.html → 17d83c40640.preview.html} +1 -1
- package/dist/17d83c40640.preview.js +1 -0
- package/dist/17d83c40640.screenshoot.js +1 -0
- package/dist/213.js +3223 -0
- package/dist/362.js +107 -0
- package/dist/441.js +2706 -0
- package/dist/605.js +391 -0
- package/dist/619.js +777 -0
- package/dist/678.js +107 -0
- package/dist/74.js +4732 -0
- package/dist/782.js +107 -0
- package/dist/HASH +1 -1
- package/dist/screenshoot.html +7 -0
- package/dist/screenshoot.js +5747 -0
- package/package.json +11 -11
- package/screenshoot.html +15 -0
- package/screenshoot.js +59 -0
- package/src/chatbox/OrderAttachments.js +1 -3
- package/src/notif/notif.js +37 -28
- package/src/plugin.js +12 -5
- package/src/store/store.js +0 -129
- package/src/util/campaign.js +16 -12
- package/take.js +36 -0
- package/webpack.dev.js +7 -0
- package/webpack.prod.js +12 -2
- package/webpack.screenshoot.js +20 -0
- package/dist/17d517e44e2.441.js +0 -1
- package/dist/17d517e44e2.605.js +0 -1
- package/dist/17d517e44e2.74.js +0 -1
- package/dist/17d517e44e2.app.js +0 -1
- package/dist/17d517e44e2.library.js +0 -1
- package/dist/17d517e44e2.preview.js +0 -1
package/cloudflare_worker.js
CHANGED
|
@@ -16,7 +16,7 @@ document.body.appendChild(tag)`
|
|
|
16
16
|
|
|
17
17
|
return new Response(body, {
|
|
18
18
|
headers: {
|
|
19
|
-
'Cache-Control': 'public, max-age=
|
|
19
|
+
'Cache-Control': 'public, max-age=300, must-revalidate, s-maxage=300, no-transform',
|
|
20
20
|
'Content-Type': 'text/javascript',
|
|
21
21
|
},
|
|
22
22
|
status: 200,
|
|
@@ -61,12 +61,9 @@ class ProductAttachments extends _common.Com {
|
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
let {
|
|
65
|
-
total
|
|
66
|
-
} = this.props.store.getOrderTotal(order);
|
|
67
64
|
let $total = (0, _preact.h)("div", {
|
|
68
65
|
class: "order_attachment__footer"
|
|
69
|
-
}, (0, _preact.h)("div", null, this.props.t('total')), ' ', (0, _preact.h)("div", null, (0, _preact.h)("b", null, _index.default.formatCurrency(total))));
|
|
66
|
+
}, (0, _preact.h)("div", null, this.props.t('total')), ' ', (0, _preact.h)("div", null, (0, _preact.h)("b", null, _index.default.formatCurrency(order.total))));
|
|
70
67
|
|
|
71
68
|
let addr = _index.default.get(order, 'shipping.address', {});
|
|
72
69
|
|
|
@@ -132,7 +132,7 @@ class Notif extends _common.Com {
|
|
|
132
132
|
|
|
133
133
|
let profiles = _index.default.get(this.props, 'plugin.notification.profiles', []);
|
|
134
134
|
|
|
135
|
-
let user = profiles[Math.floor(Math.random() * _index.default.size(profiles))];
|
|
135
|
+
let user = profiles[Math.floor(Math.random() * _index.default.size(profiles))] || {};
|
|
136
136
|
|
|
137
137
|
if (user.avatar_url && user.avatar_url.startsWith('http')) {
|
|
138
138
|
await _index.default.preloadImg(user.avatar_url);
|
|
@@ -154,6 +154,10 @@ class Notif extends _common.Com {
|
|
|
154
154
|
|
|
155
155
|
let i18n_message = i18n_messages[Math.floor(Math.random() * _index.default.size(i18n_messages))];
|
|
156
156
|
|
|
157
|
+
let fallbackmsgs = _index.default.get(this.props, 'plugin.notification.message_quill_deltas', []);
|
|
158
|
+
|
|
159
|
+
let fallbackmessage = fallbackmsgs[Math.floor(Math.random() * _index.default.size(fallbackmsgs))];
|
|
160
|
+
|
|
157
161
|
let i18n_title = _index.default.get(this.props, 'plugin.notification.i18n_title_quill_delta');
|
|
158
162
|
|
|
159
163
|
return this.setState({
|
|
@@ -161,8 +165,8 @@ class Notif extends _common.Com {
|
|
|
161
165
|
last_show: _index.default.Date.now(),
|
|
162
166
|
timestamp: timestamp,
|
|
163
167
|
user: user,
|
|
164
|
-
title: this.props.t.i18n(i18n_title),
|
|
165
|
-
message: this.props.t.i18n(i18n_message)
|
|
168
|
+
title: this.props.t.i18n(i18n_title) || _index.default.get(this.props, 'plugin.notification.title_quill_delta'),
|
|
169
|
+
message: this.props.t.i18n(i18n_message) || fallbackmessage
|
|
166
170
|
});
|
|
167
171
|
}
|
|
168
172
|
|
package/compiled_src/plugin.js
CHANGED
|
@@ -411,7 +411,7 @@ const getLocale = (plugin, loc) => {
|
|
|
411
411
|
|
|
412
412
|
let found = _index.default.find(plugin.locales, l => l.toLowerCase().trim() === loc.toLowerCase().trim());
|
|
413
413
|
|
|
414
|
-
if (found) return
|
|
414
|
+
if (found) return found;
|
|
415
415
|
found = _index.default.find(plugin.locales, l => {
|
|
416
416
|
l = l.replace('-', '_').split('_')[0].trim().toLowerCase();
|
|
417
417
|
let compareloc = loc.replace('-', '_').split('_')[0].trim().toLowerCase();
|
|
@@ -1015,146 +1015,6 @@ class Store {
|
|
|
1015
1015
|
setTimeout(() => this.loopTime(), 60000);
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
|
-
getOrderTotal(order) {
|
|
1019
|
-
let subtotal = 0;
|
|
1020
|
-
|
|
1021
|
-
_index.default.map(order.items, item => {
|
|
1022
|
-
if (!item.product) return 0;
|
|
1023
|
-
let price = item.product.price * item.quantity;
|
|
1024
|
-
|
|
1025
|
-
if (item.discount_type) {
|
|
1026
|
-
if (item.discount_type == 'percentage') {
|
|
1027
|
-
if (item.discount_before_tax && item.discount_percentage > 0) {
|
|
1028
|
-
price = price * (1 - item.discount_percentage / 10000);
|
|
1029
|
-
}
|
|
1030
|
-
} else if (item.discount_type == 'amount') {
|
|
1031
|
-
let computed_discount = item.discount;
|
|
1032
|
-
|
|
1033
|
-
if (item.discount_before_tax && computed_discount > 0) {
|
|
1034
|
-
price = price - computed_discount;
|
|
1035
|
-
if (price <= 0) price = 0;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
subtotal += price;
|
|
1041
|
-
});
|
|
1042
|
-
|
|
1043
|
-
let computed_discount = 0;
|
|
1044
|
-
|
|
1045
|
-
_index.default.map(order.items, item => {
|
|
1046
|
-
if (!item.discount_type) return;
|
|
1047
|
-
if (!item.product) return 0;
|
|
1048
|
-
let price = item.product.price * item.quantity;
|
|
1049
|
-
let tax = item.product.tax;
|
|
1050
|
-
let taxprice = 0;
|
|
1051
|
-
if (tax && tax.id) taxprice = price * tax.percentage / 10000;
|
|
1052
|
-
|
|
1053
|
-
if (item.discount_type == 'percentage' && !item.discount_before_tax && item.discount_percentage > 0) {
|
|
1054
|
-
computed_discount += (price + taxprice) * item.discount_percentage / 10000;
|
|
1055
|
-
} else if (item.discount_type == 'amount') {
|
|
1056
|
-
let itemdiscount = item.discount;
|
|
1057
|
-
|
|
1058
|
-
if (!item.discount_before_tax && itemdiscount > 0) {
|
|
1059
|
-
if (itemdiscount > price + taxprice) itemdiscount = price + taxprice;
|
|
1060
|
-
computed_discount += itemdiscount;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
});
|
|
1064
|
-
|
|
1065
|
-
let totaltax = 0;
|
|
1066
|
-
let taxM = {};
|
|
1067
|
-
|
|
1068
|
-
_index.default.map(order.items, (item, i) => {
|
|
1069
|
-
if (!item.product) return;
|
|
1070
|
-
let tax = item.product.tax;
|
|
1071
|
-
if (!tax) return;
|
|
1072
|
-
if (!tax.id) return;
|
|
1073
|
-
let price = item.product.price * item.quantity;
|
|
1074
|
-
|
|
1075
|
-
if (item.discount_type) {
|
|
1076
|
-
if (item.discount_type == 'percentage') {
|
|
1077
|
-
if (item.discount_before_tax && item.discount_percentage > 0) {
|
|
1078
|
-
price = price * (1 - item.discount_percentage / 10000);
|
|
1079
|
-
}
|
|
1080
|
-
} else if (item.discount_type == 'amount') {
|
|
1081
|
-
let computed_discount = item.discount;
|
|
1082
|
-
|
|
1083
|
-
if (item.discount_before_tax && computed_discount > 0) {
|
|
1084
|
-
price = price - computed_discount;
|
|
1085
|
-
if (price <= 0) price = 0;
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
let taxprice = price * tax.percentage / 10000;
|
|
1091
|
-
taxM[i] = {
|
|
1092
|
-
tax: tax,
|
|
1093
|
-
taxprice: taxprice
|
|
1094
|
-
};
|
|
1095
|
-
});
|
|
1096
|
-
|
|
1097
|
-
if (order.discount_before_tax) {
|
|
1098
|
-
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
1099
|
-
_index.default.map(taxM, t => {
|
|
1100
|
-
t.taxprice = t.taxprice * (1 - order.discount_percentage / 10000);
|
|
1101
|
-
});
|
|
1102
|
-
|
|
1103
|
-
computed_discount += subtotal * order.discount_percentage / 10000;
|
|
1104
|
-
} else if (order.discount_type == 'amount') {
|
|
1105
|
-
let discount = order.discount;
|
|
1106
|
-
|
|
1107
|
-
if (subtotal > 0) {
|
|
1108
|
-
_index.default.map(taxM, t => {
|
|
1109
|
-
if (discount > subtotal) discount = subtotal;
|
|
1110
|
-
t.taxprice = t.taxprice * (1 - discount / subtotal);
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
computed_discount += discount;
|
|
1115
|
-
}
|
|
1116
|
-
} else {
|
|
1117
|
-
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
1118
|
-
let taxprice = 0;
|
|
1119
|
-
|
|
1120
|
-
_index.default.map(taxM, t => taxprice += t.taxprice);
|
|
1121
|
-
|
|
1122
|
-
computed_discount += (subtotal + taxprice) * order.discount_percentage / 10000;
|
|
1123
|
-
} else if (order.discount_type == 'amount') {
|
|
1124
|
-
let discount = order.discount;
|
|
1125
|
-
computed_discount += discount;
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
let shippingfee = lo.get(order, 'shipping.fee');
|
|
1130
|
-
|
|
1131
|
-
if (shippingfee > 0) {
|
|
1132
|
-
if (_index.default.get(order, 'shipping.tax.id')) {
|
|
1133
|
-
let tax = order.shipping.tax;
|
|
1134
|
-
let taxprice = shippingfee * tax.percentage / 10000;
|
|
1135
|
-
taxM['ship'] = {
|
|
1136
|
-
tax: tax,
|
|
1137
|
-
taxprice: taxprice
|
|
1138
|
-
};
|
|
1139
|
-
}
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
let taxprice = 0;
|
|
1143
|
-
|
|
1144
|
-
_index.default.map(taxM, t => taxprice += t.taxprice);
|
|
1145
|
-
|
|
1146
|
-
let total = subtotal + taxprice - computed_discount + shippingfee;
|
|
1147
|
-
let adj = order.adjustment;
|
|
1148
|
-
total += adj;
|
|
1149
|
-
if (total < 0) total = 0;
|
|
1150
|
-
return {
|
|
1151
|
-
subtotal,
|
|
1152
|
-
computed_discount,
|
|
1153
|
-
taxM,
|
|
1154
|
-
total
|
|
1155
|
-
};
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
1018
|
replaceFileUrl(src) {
|
|
1159
1019
|
if (!src) return '';
|
|
1160
1020
|
if (_index.default.startsWith(src, '/')) return src;
|
|
@@ -26,7 +26,7 @@ function trackScrollingPercentage(percent, cb) {
|
|
|
26
26
|
let scrollTop = e.srcElement.scrollingElement ? e.srcElement.scrollingElement.scrollTop : e.srcElement.scrollTop;
|
|
27
27
|
let scrollHeight = e.srcElement.scrollingElement ? e.srcElement.scrollingElement.scrollHeight : e.srcElement.scrollHeight;
|
|
28
28
|
|
|
29
|
-
if (scrollTop > 0 && scrollHeight > 0 && scrollTop / scrollHeight >= percent) {
|
|
29
|
+
if (scrollTop > 0 && scrollHeight > 0 && (scrollTop + window.innerHeight) / scrollHeight >= percent) {
|
|
30
30
|
if (cb) cb();
|
|
31
31
|
window.removeEventListener('scroll', handleScroll, false);
|
|
32
32
|
}
|
|
@@ -41,7 +41,12 @@ function trackAreaClicked(selector, cb) {
|
|
|
41
41
|
common.map(selector.split('\n'), selector => {
|
|
42
42
|
selector = common.trim(selector);
|
|
43
43
|
if (!selector) return;
|
|
44
|
-
let doms =
|
|
44
|
+
let doms = [];
|
|
45
|
+
|
|
46
|
+
try {
|
|
47
|
+
doms = document.querySelectorAll(selector);
|
|
48
|
+
} catch (e) {}
|
|
49
|
+
|
|
45
50
|
common.map(doms, dom => {
|
|
46
51
|
if (!dom) return;
|
|
47
52
|
dom.addEventListener('click', cb, false);
|