@subiz/widget-v4 4.0.51 → 4.0.56
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/OrderAttachments.js +4 -8
- package/compiled_src/chatbox/ProductAttachments.js +4 -4
- package/compiled_src/notif/notif.js +7 -3
- package/compiled_src/plugin.js +1 -1
- package/compiled_src/store/api.js +1 -0
- package/compiled_src/store/store.js +0 -150
- package/compiled_src/util/campaign.js +6 -1
- package/dist/{17d02a15859.178.js → 17d7f3360b5.178.js} +1 -1
- package/dist/{17d02a15859.213.js → 17d7f3360b5.213.js} +0 -0
- package/dist/{17d02a15859.362.js → 17d7f3360b5.362.js} +1 -1
- package/dist/17d7f3360b5.441.js +1 -0
- package/dist/17d7f3360b5.605.js +1 -0
- package/dist/{17d02a15859.619.js → 17d7f3360b5.619.js} +1 -1
- package/dist/{17d02a15859.678.js → 17d7f3360b5.678.js} +0 -0
- package/dist/17d7f3360b5.74.js +1 -0
- package/dist/{17d02a15859.782.js → 17d7f3360b5.782.js} +1 -1
- package/dist/17d7f3360b5.app.js +1 -0
- package/dist/{17d02a15859.index.html → 17d7f3360b5.index.html} +1 -1
- package/dist/{17d02a15859.library.html → 17d7f3360b5.library.html} +1 -1
- package/dist/17d7f3360b5.library.js +1 -0
- package/dist/{17d02a15859.preview.html → 17d7f3360b5.preview.html} +1 -1
- package/dist/17d7f3360b5.preview.js +1 -0
- package/dist/17d7f3360b5.screenshoot.js +1 -0
- package/dist/17d7f338b23.178.js +406 -0
- package/dist/17d7f338b23.213.js +3223 -0
- package/dist/17d7f338b23.362.js +107 -0
- package/dist/17d7f338b23.441.js +2706 -0
- package/dist/17d7f338b23.605.js +391 -0
- package/dist/17d7f338b23.619.js +777 -0
- package/dist/17d7f338b23.678.js +107 -0
- package/dist/17d7f338b23.74.js +4732 -0
- package/dist/17d7f338b23.782.js +107 -0
- package/dist/17d7f338b23.screenshoot.js +5747 -0
- package/dist/HASH +1 -1
- package/dist/assets/img/default.06e6ee0.jpg +0 -0
- package/dist/screenshoot.html +7 -0
- package/package.json +11 -11
- package/screenshoot.html +15 -0
- package/screenshoot.js +59 -0
- package/src/chatbox/OrderAttachments.js +4 -9
- package/src/chatbox/ProductAttachments.js +4 -4
- package/src/notif/notif.js +37 -28
- package/src/plugin.js +12 -5
- package/src/store/api.js +2 -5
- package/src/store/store.js +0 -137
- package/src/util/campaign.js +14 -11
- package/take.js +36 -0
- package/webpack.dev.js +7 -0
- package/webpack.prod.js +12 -2
- package/webpack.screenshoot.js +28 -0
- package/dist/17d02a15859.441.js +0 -1
- package/dist/17d02a15859.605.js +0 -1
- package/dist/17d02a15859.712.js +0 -1
- package/dist/17d02a15859.app.js +0 -1
- package/dist/17d02a15859.library.js +0 -1
- package/dist/17d02a15859.preview.js +0 -1
|
@@ -44,7 +44,6 @@ class ProductAttachments extends _common.Com {
|
|
|
44
44
|
class: "order_attachment__label"
|
|
45
45
|
}, this.props.t('product')), _index.default.map(order.items, item => {
|
|
46
46
|
let product = item.product || {};
|
|
47
|
-
let price = this.props.store.getPrice(product, 'price', order.currency);
|
|
48
47
|
return (0, _preact.h)("div", {
|
|
49
48
|
class: "order_attachment__product"
|
|
50
49
|
}, (0, _preact.h)("img", {
|
|
@@ -54,20 +53,17 @@ class ProductAttachments extends _common.Com {
|
|
|
54
53
|
style: "overflow: hidden !important;"
|
|
55
54
|
}, (0, _preact.h)("div", {
|
|
56
55
|
class: "order_attachment__product_name"
|
|
57
|
-
},
|
|
56
|
+
}, product.name), (0, _preact.h)("div", {
|
|
58
57
|
class: "order_attachment__product_desc"
|
|
59
|
-
},
|
|
58
|
+
}, product.description || product.long_description), (0, _preact.h)("div", {
|
|
60
59
|
class: "order_attachment__product_desc"
|
|
61
|
-
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(price))));
|
|
60
|
+
}, this.props.t('qty'), " ", item.quantity, "\xA0\xB7\xA0", _index.default.formatCurrency(product.price))));
|
|
62
61
|
}));
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
let {
|
|
66
|
-
total
|
|
67
|
-
} = this.props.store.getOrderTotal(order);
|
|
68
64
|
let $total = (0, _preact.h)("div", {
|
|
69
65
|
class: "order_attachment__footer"
|
|
70
|
-
}, (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))));
|
|
71
67
|
|
|
72
68
|
let addr = _index.default.get(order, 'shipping.address', {});
|
|
73
69
|
|
|
@@ -44,9 +44,9 @@ class ProductAttachments extends _common.Com {
|
|
|
44
44
|
href: url,
|
|
45
45
|
class: "product_attachment__title",
|
|
46
46
|
target: "_blank"
|
|
47
|
-
},
|
|
47
|
+
}, product.name);
|
|
48
48
|
let $subtitle = null;
|
|
49
|
-
let desc =
|
|
49
|
+
let desc = product.description || product.long_description;
|
|
50
50
|
if (desc) $subtitle = (0, _preact.h)("div", {
|
|
51
51
|
class: "product_attachment__subtitle"
|
|
52
52
|
}, desc);
|
|
@@ -61,11 +61,11 @@ class ProductAttachments extends _common.Com {
|
|
|
61
61
|
return (0, _preact.h)("div", {
|
|
62
62
|
class: 'product_attachment product_attachment__' + byType
|
|
63
63
|
}, (0, _preact.h)("div", null, (0, _preact.h)("a", {
|
|
64
|
-
href: this.props.store.replaceFileUrl(product.
|
|
64
|
+
href: this.props.store.replaceFileUrl(product.image),
|
|
65
65
|
target: "_blank"
|
|
66
66
|
}, (0, _preact.h)("img", {
|
|
67
67
|
class: "product_attachment__img",
|
|
68
|
-
src: this.props.store.replaceFileUrl(product.
|
|
68
|
+
src: this.props.store.replaceFileUrl(product.image)
|
|
69
69
|
}))), $title, $subtitle, $price, (0, _preact.h)("div", {
|
|
70
70
|
class: "product_attachment__btns"
|
|
71
71
|
}, $detailbtn));
|
|
@@ -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,156 +1015,6 @@ class Store {
|
|
|
1015
1015
|
setTimeout(() => this.loopTime(), 60000);
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
|
-
getPrice(obj, field, currency) {
|
|
1019
|
-
if (!obj) return 0;
|
|
1020
|
-
if (!currency) return obj[field] || 0;
|
|
1021
|
-
|
|
1022
|
-
let defcur = _index.default.get(this.matchAccount(), 'currency');
|
|
1023
|
-
|
|
1024
|
-
if (currency != defcur) return _index.default.get(obj, [field + '_locale', currency], 0);
|
|
1025
|
-
return obj[field] || 0;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
getOrderTotal(order) {
|
|
1029
|
-
let subtotal = 0;
|
|
1030
|
-
|
|
1031
|
-
_index.default.map(order.items, item => {
|
|
1032
|
-
if (!item.product) return 0;
|
|
1033
|
-
let price = this.getPrice(item.product, 'price', order.currency) * item.quantity;
|
|
1034
|
-
|
|
1035
|
-
if (item.discount_type) {
|
|
1036
|
-
if (item.discount_type == 'percentage') {
|
|
1037
|
-
if (item.discount_before_tax && item.discount_percentage > 0) {
|
|
1038
|
-
price = price * (1 - item.discount_percentage / 10000);
|
|
1039
|
-
}
|
|
1040
|
-
} else if (item.discount_type == 'amount') {
|
|
1041
|
-
let computed_discount = this.getPrice(item, 'discount', order.currency);
|
|
1042
|
-
|
|
1043
|
-
if (item.discount_before_tax && computed_discount > 0) {
|
|
1044
|
-
price = price - computed_discount;
|
|
1045
|
-
if (price <= 0) price = 0;
|
|
1046
|
-
}
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
subtotal += price;
|
|
1051
|
-
});
|
|
1052
|
-
|
|
1053
|
-
let computed_discount = 0;
|
|
1054
|
-
|
|
1055
|
-
_index.default.map(order.items, item => {
|
|
1056
|
-
if (!item.discount_type) return;
|
|
1057
|
-
if (!item.product) return 0;
|
|
1058
|
-
let price = this.getPrice(item.product, 'price', order.currency) * item.quantity;
|
|
1059
|
-
let tax = item.product.tax;
|
|
1060
|
-
let taxprice = 0;
|
|
1061
|
-
if (tax && tax.id) taxprice = price * tax.percentage / 10000;
|
|
1062
|
-
|
|
1063
|
-
if (item.discount_type == 'percentage' && !item.discount_before_tax && item.discount_percentage > 0) {
|
|
1064
|
-
computed_discount += (price + taxprice) * item.discount_percentage / 10000;
|
|
1065
|
-
} else if (item.discount_type == 'amount') {
|
|
1066
|
-
let itemdiscount = this.getPrice(item, 'discount', order.currency);
|
|
1067
|
-
|
|
1068
|
-
if (!item.discount_before_tax && itemdiscount > 0) {
|
|
1069
|
-
if (itemdiscount > price + taxprice) itemdiscount = price + taxprice;
|
|
1070
|
-
computed_discount += itemdiscount;
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
});
|
|
1074
|
-
|
|
1075
|
-
let totaltax = 0;
|
|
1076
|
-
let taxM = {};
|
|
1077
|
-
|
|
1078
|
-
_index.default.map(order.items, (item, i) => {
|
|
1079
|
-
if (!item.product) return;
|
|
1080
|
-
let tax = item.product.tax;
|
|
1081
|
-
if (!tax) return;
|
|
1082
|
-
if (!tax.id) return;
|
|
1083
|
-
let price = this.getPrice(item.product, 'price', order.currency) * item.quantity;
|
|
1084
|
-
|
|
1085
|
-
if (item.discount_type) {
|
|
1086
|
-
if (item.discount_type == 'percentage') {
|
|
1087
|
-
if (item.discount_before_tax && item.discount_percentage > 0) {
|
|
1088
|
-
price = price * (1 - item.discount_percentage / 10000);
|
|
1089
|
-
}
|
|
1090
|
-
} else if (item.discount_type == 'amount') {
|
|
1091
|
-
let computed_discount = this.getPrice(item, 'discount', order.currency);
|
|
1092
|
-
|
|
1093
|
-
if (item.discount_before_tax && computed_discount > 0) {
|
|
1094
|
-
price = price - computed_discount;
|
|
1095
|
-
if (price <= 0) price = 0;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
let taxprice = price * tax.percentage / 10000;
|
|
1101
|
-
taxM[i] = {
|
|
1102
|
-
tax: tax,
|
|
1103
|
-
taxprice: taxprice
|
|
1104
|
-
};
|
|
1105
|
-
});
|
|
1106
|
-
|
|
1107
|
-
if (order.discount_before_tax) {
|
|
1108
|
-
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
1109
|
-
_index.default.map(taxM, t => {
|
|
1110
|
-
t.taxprice = t.taxprice * (1 - order.discount_percentage / 10000);
|
|
1111
|
-
});
|
|
1112
|
-
|
|
1113
|
-
computed_discount += subtotal * order.discount_percentage / 10000;
|
|
1114
|
-
} else if (order.discount_type == 'amount') {
|
|
1115
|
-
let discount = this.getPrice(order, 'discount', order.currency);
|
|
1116
|
-
|
|
1117
|
-
if (subtotal > 0) {
|
|
1118
|
-
_index.default.map(taxM, t => {
|
|
1119
|
-
if (discount > subtotal) discount = subtotal;
|
|
1120
|
-
t.taxprice = t.taxprice * (1 - discount / subtotal);
|
|
1121
|
-
});
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
computed_discount += discount;
|
|
1125
|
-
}
|
|
1126
|
-
} else {
|
|
1127
|
-
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
1128
|
-
let taxprice = 0;
|
|
1129
|
-
|
|
1130
|
-
_index.default.map(taxM, t => taxprice += t.taxprice);
|
|
1131
|
-
|
|
1132
|
-
computed_discount += (subtotal + taxprice) * order.discount_percentage / 10000;
|
|
1133
|
-
} else if (order.discount_type == 'amount') {
|
|
1134
|
-
let discount = this.getPrice(order, 'discount', order.currency);
|
|
1135
|
-
computed_discount += discount;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
let shippingfee = this.getPrice(order.shipping, 'fee', order.currency);
|
|
1140
|
-
|
|
1141
|
-
if (shippingfee > 0) {
|
|
1142
|
-
if (_index.default.get(order, 'shipping.tax.id')) {
|
|
1143
|
-
let tax = order.shipping.tax;
|
|
1144
|
-
let taxprice = shippingfee * tax.percentage / 10000;
|
|
1145
|
-
taxM['ship'] = {
|
|
1146
|
-
tax: tax,
|
|
1147
|
-
taxprice: taxprice
|
|
1148
|
-
};
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
let taxprice = 0;
|
|
1153
|
-
|
|
1154
|
-
_index.default.map(taxM, t => taxprice += t.taxprice);
|
|
1155
|
-
|
|
1156
|
-
let total = subtotal + taxprice - computed_discount + shippingfee;
|
|
1157
|
-
let adj = this.getPrice(order, 'adjustment', order.currency);
|
|
1158
|
-
total += adj;
|
|
1159
|
-
if (total < 0) total = 0;
|
|
1160
|
-
return {
|
|
1161
|
-
subtotal,
|
|
1162
|
-
computed_discount,
|
|
1163
|
-
taxM,
|
|
1164
|
-
total
|
|
1165
|
-
};
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
1018
|
replaceFileUrl(src) {
|
|
1169
1019
|
if (!src) return '';
|
|
1170
1020
|
if (_index.default.startsWith(src, '/')) return src;
|
|
@@ -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);
|