@subiz/widget-v4 4.1.70 → 4.1.72
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/AgentsAvatar.js +102 -108
- package/compiled_src/chatbox/AudioAttachments.js +25 -32
- package/compiled_src/chatbox/ButtonAttachments.js +16 -23
- package/compiled_src/chatbox/Buttons.js +36 -43
- package/compiled_src/chatbox/ChatButton.js +5 -1
- 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/Rating.js +1 -1
- 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 +1 -4
- 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/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/AgentsAvatar.js +118 -134
- package/src/chatbox/AudioAttachments.js +19 -26
- package/src/chatbox/ButtonAttachments.js +13 -20
- package/src/chatbox/Buttons.js +29 -37
- package/src/chatbox/ChatButton.js +6 -1
- 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/Rating.js +1 -1
- 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 +1 -9
- 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/src/util/order.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
const op = require('./op.js')
|
|
2
|
-
const common = require('./common')
|
|
3
|
-
op.filter = common.filter
|
|
4
|
-
op.map = common.map
|
|
5
|
-
op.each = common.each
|
|
6
|
-
op.size = common.size
|
|
7
|
-
op.find = common.find
|
|
8
|
-
|
|
9
|
-
export function getProductPropName(product, seperator = ' - ') {
|
|
10
|
-
let options = op.get(product, 'options', [])
|
|
11
|
-
let props = op.get(product, 'props', [])
|
|
12
|
-
let multiPropsOptions = op.filter(options, (option) => op.size(option.values) > 1)
|
|
13
|
-
let names = []
|
|
14
|
-
op.each(multiPropsOptions, (option) => {
|
|
15
|
-
let prop = op.find(props, (prop) => prop.key === option.key) || {}
|
|
16
|
-
if (prop.value) names.push(prop.value)
|
|
17
|
-
})
|
|
18
|
-
return names.join(seperator)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getOrderDisplayName(order = {}) {
|
|
22
|
-
return order.number || order.id || ''
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function displayOrderShippingAddress(order, isShorten) {
|
|
26
|
-
let addr = op.get(order, 'shipping.address', {})
|
|
27
|
-
let fulladdr = [addr.address, addr.ward, addr.district, addr.province]
|
|
28
|
-
.filter((a) => a)
|
|
29
|
-
.join(', ')
|
|
30
|
-
.trim()
|
|
31
|
-
if (isShorten) fulladdr = shortenAddr(fulladdr)
|
|
32
|
-
return fulladdr
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function shortenAddr(str) {
|
|
36
|
-
str = str || ''
|
|
37
|
-
str = str.replace(/Hà Nội/gi, 'HN')
|
|
38
|
-
str = str.replace(/Hồ Chí Minh/gi, 'HCM')
|
|
39
|
-
str = str.replace(/Thành Phố/gi, 'TP')
|
|
40
|
-
|
|
41
|
-
return str
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function calcOrderTotal(order) {
|
|
45
|
-
// compute subtotal first, since it doesn't depend on tax or gloal discount
|
|
46
|
-
let subtotal = 0
|
|
47
|
-
let beforeTaxDiscount = 0
|
|
48
|
-
let ordervalue = 0
|
|
49
|
-
op.map(order.items, (item) => {
|
|
50
|
-
if (!item.product) return 0
|
|
51
|
-
let price = op.get(item, 'product.price', 0) * (item.quantity || 0)
|
|
52
|
-
ordervalue += price
|
|
53
|
-
|
|
54
|
-
// some products that are discounted before tax
|
|
55
|
-
// the discount amount is calculated in product price for
|
|
56
|
-
// simpler calucation in future
|
|
57
|
-
if (item.discount_type == 'percentage') {
|
|
58
|
-
if (item.discount_percentage > 0) {
|
|
59
|
-
beforeTaxDiscount += (price * item.discount_percentage) / 10000
|
|
60
|
-
price = price * (1 - (item.discount_percentage || 0) / 10000)
|
|
61
|
-
}
|
|
62
|
-
} else if (item.discount_type == 'amount') {
|
|
63
|
-
if (item.discount_amount > 0) {
|
|
64
|
-
beforeTaxDiscount += item.discount_amount
|
|
65
|
-
price = price - (item.discount_amount || 0)
|
|
66
|
-
if (price <= 0) price = 0
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
item.total = price
|
|
70
|
-
subtotal += price
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
// TAX
|
|
74
|
-
let taxM = {}
|
|
75
|
-
op.map(order.items, (item, i) => {
|
|
76
|
-
if (!item.product) return
|
|
77
|
-
let tax = item.product.tax
|
|
78
|
-
if (!tax) return
|
|
79
|
-
if (!tax.id) return
|
|
80
|
-
let taxprice = (item.total * tax.percentage) / 10000
|
|
81
|
-
item.total_tax = taxprice
|
|
82
|
-
taxM[i] = {tax: tax, taxprice: taxprice}
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
let totaltax = 0
|
|
86
|
-
op.map(taxM, (t) => (totaltax += t.taxprice))
|
|
87
|
-
|
|
88
|
-
let computed_discount = 0
|
|
89
|
-
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
90
|
-
computed_discount = ((subtotal + totaltax) * order.discount_percentage) / 10000
|
|
91
|
-
} else if (order.discount_type == 'amount') {
|
|
92
|
-
computed_discount = order.discount_amount || 0
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// SHIP
|
|
96
|
-
let shippingfee = op.get(order, 'shipping.nominal_fee', 0)
|
|
97
|
-
if (shippingfee > 0) {
|
|
98
|
-
if (op.get(order, 'shipping.tax.id')) {
|
|
99
|
-
let tax = order.shipping.tax
|
|
100
|
-
let taxprice = shippingfee * (tax.percentage / 10000)
|
|
101
|
-
taxM['ship'] = {tax: tax, taxprice: taxprice}
|
|
102
|
-
order.shipping.total_tax = taxprice
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
totaltax = 0
|
|
107
|
-
op.map(taxM, (t) => (totaltax += t.taxprice))
|
|
108
|
-
let total = subtotal + totaltax - computed_discount + shippingfee
|
|
109
|
-
|
|
110
|
-
// add adjustment
|
|
111
|
-
total += order.adjustment || 0
|
|
112
|
-
if (total < 0) total = 0
|
|
113
|
-
order.subtotal = subtotal
|
|
114
|
-
order._computed_discount = computed_discount
|
|
115
|
-
order._taxM = taxM
|
|
116
|
-
order.total = total
|
|
117
|
-
order.total_tax = totaltax
|
|
118
|
-
order._discount_before_tax = beforeTaxDiscount
|
|
119
|
-
order._order_value = ordervalue
|
|
120
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|