@subiz/widget-v4 4.1.71 → 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/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 +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/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 +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/lib.js
CHANGED
|
@@ -3,11 +3,11 @@ import sb from './util/index.js'
|
|
|
3
3
|
import PluginMgr from './plugin.js'
|
|
4
4
|
|
|
5
5
|
var $link = document.createElement('link')
|
|
6
|
-
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500
|
|
6
|
+
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap'
|
|
7
7
|
$link.rel = 'stylesheet'
|
|
8
8
|
document.head.append($link)
|
|
9
9
|
|
|
10
|
-
sb.preloadWebfonts(['Inter'], [400, 500
|
|
10
|
+
sb.preloadWebfonts(['Inter'], [400, 500])
|
|
11
11
|
|
|
12
12
|
class Widget {
|
|
13
13
|
constructor(ApiURL, FileURL, RealtimeURL, inmem, fake) {
|
package/src/order/icon.js
CHANGED
|
@@ -2,11 +2,11 @@ import sb from '../util/index.js'
|
|
|
2
2
|
let promiseMainCSS = (() => import(/*webpackChunkName: "main-css" */ '../chatbox/css.js'))()
|
|
3
3
|
|
|
4
4
|
var $link = document.createElement('link')
|
|
5
|
-
$link.href = 'https://fonts.googleapis.com/css2?family=
|
|
5
|
+
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap'
|
|
6
6
|
$link.rel = 'stylesheet'
|
|
7
7
|
document.head.append($link)
|
|
8
8
|
|
|
9
|
-
sb.preloadWebfonts(['
|
|
9
|
+
sb.preloadWebfonts(['Inter'], [400, 500])
|
|
10
10
|
|
|
11
11
|
import Time from '../chatbox/time.js'
|
|
12
12
|
let defaultAvatar = require('../../assets/img/default_avatar.png')
|
package/src/order/index.js
CHANGED
|
@@ -26,11 +26,11 @@ function getUrlParameter(name) {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
var $link = document.createElement('link')
|
|
29
|
-
$link.href = 'https://fonts.googleapis.com/css2?family=
|
|
29
|
+
$link.href = 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap'
|
|
30
30
|
$link.rel = 'stylesheet'
|
|
31
31
|
document.head.append($link)
|
|
32
32
|
|
|
33
|
-
sb.preloadWebfonts(['
|
|
33
|
+
sb.preloadWebfonts(['Inter'], [400, 500])
|
|
34
34
|
|
|
35
35
|
async function load() {
|
|
36
36
|
let store = new Store(config.ApiURL, config.FileURL, config.RealtimeURL, true)
|
package/src/plugin.js
CHANGED
|
@@ -2,7 +2,8 @@ import sb from './util/index.js'
|
|
|
2
2
|
import * as common from './common.js'
|
|
3
3
|
import {h, render, createRef} from 'preact'
|
|
4
4
|
|
|
5
|
-
const LoadChatbox = () => import(/*webpackChunkName: "chatbox" */ './chatbox/main.js')
|
|
5
|
+
// const LoadChatbox = () => import(/*webpackChunkName: "chatbox" */ './chatbox/main.js')
|
|
6
|
+
import Chatbox from './chatbox/main.js'
|
|
6
7
|
const LoadContact = () => import(/*webpackChunkName: "contact" */ './contact/contact.js')
|
|
7
8
|
const LoadPopup = () => import(/*webpackChunkName: "popup" */ './popup/popup.js')
|
|
8
9
|
const LoadNotif = () => import(/*webpackChunkName: "notif" */ './notif/notif.js')
|
|
@@ -54,7 +55,7 @@ function Plugin(plugin, store, $container, lib) {
|
|
|
54
55
|
|
|
55
56
|
var _ref = createRef()
|
|
56
57
|
|
|
57
|
-
let Chatbox = null
|
|
58
|
+
// let Chatbox = null
|
|
58
59
|
let Popup = null
|
|
59
60
|
let Contact = null
|
|
60
61
|
let Notif = null
|
|
@@ -70,7 +71,7 @@ function Plugin(plugin, store, $container, lib) {
|
|
|
70
71
|
if (_destroy) return
|
|
71
72
|
if (!$div) return
|
|
72
73
|
if (plugin.type === 'chatbox') {
|
|
73
|
-
if (!Chatbox) Chatbox = (await LoadChatbox()).default
|
|
74
|
+
// if (!Chatbox) Chatbox = (await LoadChatbox()).default
|
|
74
75
|
render(<Chatbox destroy={_destroy} plugin={plugin} store={store} ref={_ref} t={this.t} />, $div)
|
|
75
76
|
}
|
|
76
77
|
|
package/src/store/api.js
CHANGED
|
@@ -239,20 +239,7 @@ export default class {
|
|
|
239
239
|
|
|
240
240
|
sendTyping = (cid) => this.apireq.post(`/accounts/${this.accid}/conversations/${cid}/typing`)
|
|
241
241
|
|
|
242
|
-
sendLostFocus = (
|
|
243
|
-
this.sendEvent({
|
|
244
|
-
by: {id: this.uid, device: device},
|
|
245
|
-
type: 'presence_updated',
|
|
246
|
-
data: {
|
|
247
|
-
presence: {
|
|
248
|
-
viewing_product_sku: sku,
|
|
249
|
-
viewing_product_source_id: source_id,
|
|
250
|
-
viewing_product_id: productid,
|
|
251
|
-
pinged: sb.Date.now(),
|
|
252
|
-
is_focused: false,
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
})
|
|
242
|
+
sendLostFocus = () => this.apireq.post(`/accounts/${this.accid}/focuses/${this.uid}/delete`)
|
|
256
243
|
|
|
257
244
|
sendContentView(device, pageUrl, pageTitle, id, source_id, sku) {
|
|
258
245
|
if (!id) id = undefined // dont accept ''
|
package/src/store/store.js
CHANGED
|
@@ -364,15 +364,7 @@ export default class Store {
|
|
|
364
364
|
if (!this._track_page_view) return
|
|
365
365
|
|
|
366
366
|
let hasfocus = this.browserVisibility === 'visible' && document.hasFocus()
|
|
367
|
-
if (!hasfocus)
|
|
368
|
-
this.api.sendLostFocus(
|
|
369
|
-
this.device,
|
|
370
|
-
this._currentViewingProduct.id,
|
|
371
|
-
this._currentViewingProduct.source_id,
|
|
372
|
-
this._currentViewingProduct.sku,
|
|
373
|
-
)
|
|
374
|
-
return
|
|
375
|
-
}
|
|
367
|
+
if (!hasfocus) return this.api.sendLostFocus()
|
|
376
368
|
|
|
377
369
|
this.api.sendContentView(
|
|
378
370
|
this.device,
|
package/src/util/common.js
CHANGED
|
@@ -24,26 +24,7 @@ export var XMLHttpRequest = f.contentWindow.XMLHttpRequest
|
|
|
24
24
|
// that event is sent to
|
|
25
25
|
export function convoOfEv(ev) {
|
|
26
26
|
if (!ev) return ''
|
|
27
|
-
|
|
28
|
-
case 'conversation_state_updated':
|
|
29
|
-
case 'conversation_joined':
|
|
30
|
-
case 'conversation_invited':
|
|
31
|
-
case 'conversation_left':
|
|
32
|
-
case 'conversation_tagged':
|
|
33
|
-
case 'conversation_untagged':
|
|
34
|
-
case 'conversation_typing':
|
|
35
|
-
case 'conversation_rating_requested':
|
|
36
|
-
case 'conversation_rated':
|
|
37
|
-
return op.get(ev, 'data.conversation.id')
|
|
38
|
-
case 'message_sent':
|
|
39
|
-
case 'message_updated':
|
|
40
|
-
case 'message_pong':
|
|
41
|
-
return op.get(ev, 'data.message.conversation_id')
|
|
42
|
-
case 'ticket_updated':
|
|
43
|
-
return op.get(ev, 'data.ticket.conversation_id')
|
|
44
|
-
default:
|
|
45
|
-
return ''
|
|
46
|
-
}
|
|
27
|
+
return op.get(ev, 'data.conversation.id', op.get(ev, 'data.message.conversation_id'))
|
|
47
28
|
}
|
|
48
29
|
|
|
49
30
|
export function convoToEv(convoid, ev) {
|
|
@@ -696,21 +677,6 @@ function browserName() {
|
|
|
696
677
|
return 'unknown'
|
|
697
678
|
}
|
|
698
679
|
|
|
699
|
-
function osName() {
|
|
700
|
-
var OSName = 'Unknown'
|
|
701
|
-
if (window.navigator.userAgent.indexOf('Windows NT 10.0') != -1) OSName = 'Windows 10'
|
|
702
|
-
if (window.navigator.userAgent.indexOf('Windows NT 6.3') != -1) OSName = 'Windows 8.1'
|
|
703
|
-
if (window.navigator.userAgent.indexOf('Windows NT 6.2') != -1) OSName = 'Windows 8'
|
|
704
|
-
if (window.navigator.userAgent.indexOf('Windows NT 6.1') != -1) OSName = 'Windows 7'
|
|
705
|
-
if (window.navigator.userAgent.indexOf('Windows NT 6.0') != -1) OSName = 'Windows Vista'
|
|
706
|
-
if (window.navigator.userAgent.indexOf('Windows NT 5.1') != -1) OSName = 'Windows XP'
|
|
707
|
-
if (window.navigator.userAgent.indexOf('Windows NT 5.0') != -1) OSName = 'Windows 2000'
|
|
708
|
-
if (window.navigator.userAgent.indexOf('Mac') != -1) OSName = 'Mac/iOS'
|
|
709
|
-
if (window.navigator.userAgent.indexOf('X11') != -1) OSName = 'UNIX'
|
|
710
|
-
if (window.navigator.userAgent.indexOf('Linux') != -1) OSName = 'Linux'
|
|
711
|
-
return OSName
|
|
712
|
-
}
|
|
713
|
-
|
|
714
680
|
// frequencty
|
|
715
681
|
function check_frequently(freq, lastrun, store) {
|
|
716
682
|
if (!lastrun) return true
|
|
@@ -1023,7 +989,7 @@ export function sameDay(a, b, tzoffset) {
|
|
|
1023
989
|
}
|
|
1024
990
|
|
|
1025
991
|
// convert ms in UTC (+00:00) to short time in tz
|
|
1026
|
-
export function shortTime(utcms, tzoffset, now) {
|
|
992
|
+
export function shortTime(utcms, tzoffset, now, forcelocale) {
|
|
1027
993
|
var machineoffsetmin = -new Date().getTimezoneOffset()
|
|
1028
994
|
var offsetmin = machineoffsetmin
|
|
1029
995
|
if (tzoffset) offsetmin = offsetToMin(tzoffset)
|
|
@@ -1036,6 +1002,7 @@ export function shortTime(utcms, tzoffset, now) {
|
|
|
1036
1002
|
let tzhour = tztime.getHours()
|
|
1037
1003
|
let tzmin = tztime.getMinutes()
|
|
1038
1004
|
let locale = op.get(navigator, 'languages.0', 'en-US')
|
|
1005
|
+
if (forcelocale) locale = forcelocale
|
|
1039
1006
|
let tzdddd = tztime.toLocaleDateString(locale, {weekday: 'long'})
|
|
1040
1007
|
let tzyear = tztime.getFullYear()
|
|
1041
1008
|
let tzmonth = tztime.getMonth() + 1
|
|
@@ -1052,9 +1019,18 @@ export function shortTime(utcms, tzoffset, now) {
|
|
|
1052
1019
|
if (diffDay(time, now, tzoffset) <= 5) return tzdddd + ', ' + tzhour + ':' + tzmin
|
|
1053
1020
|
|
|
1054
1021
|
// over 5 days, same year => SEP 5, 05:44
|
|
1055
|
-
if (diffYear(time, now, tzoffset) === 0)
|
|
1022
|
+
if (diffYear(time, now, tzoffset) === 0) {
|
|
1023
|
+
if (locale === 'vi-VN') {
|
|
1024
|
+
return tzdate + ' ' + tzmonthname + ', ' + tzhour + ':' + tzmin
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
return tzmonthname + ' ' + tzdate + ', ' + tzhour + ':' + tzmin
|
|
1028
|
+
}
|
|
1056
1029
|
|
|
1057
1030
|
// difference year => 2019/13/7, 05:44
|
|
1031
|
+
if (locale === 'vi-VN') {
|
|
1032
|
+
return tzdate + '/' + tzmonth + '/' + tzyear + ', ' + tzhour + ':' + tzmin
|
|
1033
|
+
}
|
|
1058
1034
|
return tzyear + '/' + tzmonth + '/' + tzdate + ', ' + tzhour + ':' + tzmin
|
|
1059
1035
|
}
|
|
1060
1036
|
|
|
@@ -1185,186 +1161,8 @@ export function scrollIntoViewIfNeeded($ele) {
|
|
|
1185
1161
|
}
|
|
1186
1162
|
|
|
1187
1163
|
const ALL_CURRENCIES = [
|
|
1188
|
-
{code: 'AFN', symbol: '؋'}, // name: 'Afghani',
|
|
1189
|
-
{code: 'EUR', symbol: '€'}, // name: 'Euro',
|
|
1190
|
-
{code: 'ALL', symbol: 'Lek'}, // name: 'Lek',
|
|
1191
|
-
{code: 'DZD'}, // name: 'Algerian Dinar',
|
|
1192
1164
|
{code: 'USD', symbol: '$'}, // name: 'US Dollar',
|
|
1193
|
-
{code: 'AOA'}, // name: 'Kwanza',
|
|
1194
|
-
{code: 'XCD', symbol: '$'}, // name: 'East Caribbean Dollar',
|
|
1195
|
-
{code: 'ARS', symbol: '$'}, // name: 'Argentine Peso',
|
|
1196
|
-
{code: 'AMD'}, // name: 'Armenian Dram',
|
|
1197
|
-
{code: 'AWG', symbol: 'ƒ'}, // name: 'Aruban Florin',
|
|
1198
|
-
{code: 'AUD', symbol: '$'}, // name: 'Australian Dollar',
|
|
1199
|
-
{code: 'AZN', symbol: '₼'}, // name: 'Azerbaijan Manat',
|
|
1200
|
-
{code: 'BSD', symbol: '$'}, // name: 'Bahamian Dollar',
|
|
1201
|
-
{code: 'BHD'}, // name: 'Bahraini Dinar',
|
|
1202
|
-
{code: 'BDT'}, // name: 'Taka',
|
|
1203
|
-
{code: 'BBD', symbol: '$'}, // name: 'Barbados Dollar',
|
|
1204
|
-
{code: 'BYN', symbol: 'Br'}, // name: 'Belarusian Ruble',
|
|
1205
|
-
{code: 'BZD', symbol: 'BZ$'}, // name: 'Belize Dollar',
|
|
1206
|
-
{code: 'XOF'}, // name: 'CFA Franc BCEAO',
|
|
1207
|
-
{code: 'BMD', symbol: '$'}, // name: 'Bermudian Dollar',
|
|
1208
|
-
{code: 'INR', symbol: '₹'}, // name: 'Indian Rupee',
|
|
1209
|
-
{code: 'BTN'}, // name: 'Ngultrum',
|
|
1210
|
-
{code: 'BOB', symbol: '$b'}, // name: 'Boliviano',
|
|
1211
|
-
{code: 'BOV'}, // name: 'Mvdol',
|
|
1212
|
-
{code: 'BAM', symbol: 'KM'}, // name: 'Convertible Mark',
|
|
1213
|
-
{code: 'BWP', symbol: 'P'}, // name: 'Pula',
|
|
1214
|
-
{code: 'NOK', symbol: 'kr'}, // name: 'Norwegian Krone',
|
|
1215
|
-
{code: 'BRL', symbol: 'R$'}, // name: 'Brazilian Real',
|
|
1216
|
-
{code: 'BND', symbol: '$'}, // name: 'Brunei Dollar',
|
|
1217
|
-
{code: 'BGN', symbol: 'лв'}, // name: 'Bulgarian Lev',
|
|
1218
|
-
{code: 'BIF'}, // name: 'Burundi Franc',
|
|
1219
|
-
{code: 'CVE'}, // name: 'Cabo Verde Escudo',
|
|
1220
|
-
{code: 'KHR', symbol: '៛'}, // name: 'Riel',
|
|
1221
|
-
{code: 'XAF'}, // name: 'CFA Franc BEAC',
|
|
1222
|
-
{code: 'CAD', symbol: '$'}, // name: 'Canadian Dollar',
|
|
1223
|
-
{code: 'KYD', symbol: '$'}, // name: 'Cayman Islands Dollar',
|
|
1224
|
-
{code: 'CLP', symbol: '$'}, // name: 'Chilean Peso',
|
|
1225
|
-
{code: 'CLF'}, // name: 'Unidad de Fomento',
|
|
1226
|
-
{code: 'CNY', symbol: '¥'}, // name: 'Yuan Renminbi',
|
|
1227
|
-
{code: 'COP', symbol: '$'}, // name: 'Colombian Peso',
|
|
1228
|
-
{code: 'COU'}, // name: 'Unidad de Valor Real',
|
|
1229
|
-
{code: 'KMF'}, // name: 'Comorian Franc ',
|
|
1230
|
-
{code: 'CDF'}, // name: 'Congolese Franc',
|
|
1231
|
-
{code: 'NZD', symbol: '$'}, // name: 'New Zealand Dollar',
|
|
1232
|
-
{code: 'CRC', symbol: '₡'}, // name: 'Costa Rican Colon',
|
|
1233
|
-
{code: 'HRK', symbol: 'kn'}, // name: 'Kuna',
|
|
1234
|
-
{code: 'CUP', symbol: '₱'}, // name: 'Cuban Peso',
|
|
1235
|
-
{code: 'CUC'}, // name: 'Peso Convertible',
|
|
1236
|
-
{code: 'ANG', symbol: 'ƒ'}, // name: 'Netherlands Antillean Guilder',
|
|
1237
|
-
{code: 'CZK', symbol: 'Kč'}, // name: 'Czech Koruna',
|
|
1238
|
-
{code: 'DKK', symbol: 'kr'}, // name: 'Danish Krone',
|
|
1239
|
-
{code: 'DJF'}, // name: 'Djibouti Franc',
|
|
1240
|
-
{code: 'DOP', symbol: 'RD$'}, // name: 'Dominican Peso',
|
|
1241
|
-
{code: 'EGP', symbol: '£'}, // name: 'Egyptian Pound',
|
|
1242
|
-
{code: 'SVC', symbol: '$'}, // name: 'El Salvador Colon',
|
|
1243
|
-
{code: 'ERN'}, // name: 'Nakfa',
|
|
1244
|
-
{code: 'SZL'}, // name: 'Lilangeni',
|
|
1245
|
-
{code: 'ETB'}, // name: 'Ethiopian Birr',
|
|
1246
|
-
{code: 'FKP', symbol: '£'}, // name: 'Falkland Islands Pound',
|
|
1247
|
-
{code: 'FJD', symbol: '$'}, // name: 'Fiji Dollar',
|
|
1248
|
-
{code: 'XPF'}, // name: 'CFP Franc',
|
|
1249
|
-
{code: 'GMD'}, // name: 'Dalasi',
|
|
1250
|
-
{code: 'GEL'}, // name: 'Lari',
|
|
1251
|
-
{code: 'GHS', symbol: '¢'}, // name: 'Ghana Cedi',
|
|
1252
|
-
{code: 'GIP', symbol: '£'}, // name: 'Gibraltar Pound',
|
|
1253
|
-
{code: 'GTQ', symbol: 'Q'}, // name: 'Quetzal',
|
|
1254
|
-
{code: 'GBP', symbol: '£'}, // name: 'Pound Sterling',
|
|
1255
|
-
{code: 'GNF'}, // name: 'Guinean Franc',
|
|
1256
|
-
{code: 'GYD', symbol: '$'}, // name: 'Guyana Dollar',
|
|
1257
|
-
{code: 'HTG'}, // name: 'Gourde',
|
|
1258
|
-
{code: 'HNL', symbol: 'L'}, // name: 'Lempira',
|
|
1259
|
-
{code: 'HKD', symbol: '$'}, // name: 'Hong Kong Dollar',
|
|
1260
|
-
{code: 'HUF', symbol: 'Ft'}, // name: 'Forint',
|
|
1261
|
-
{code: 'ISK', symbol: 'kr'}, // name: 'Iceland Krona',
|
|
1262
|
-
{code: 'IDR', symbol: 'Rp'}, // name: 'Rupiah',
|
|
1263
|
-
{code: 'XDR'}, // name: 'SDR (Special Drawing Right)',
|
|
1264
|
-
{code: 'IRR', symbol: '﷼'}, // name: 'Iranian Rial',
|
|
1265
|
-
{code: 'IQD'}, // name: 'Iraqi Dinar',
|
|
1266
|
-
{code: 'ILS', symbol: '₪'}, // name: 'New Israeli Sheqel',
|
|
1267
|
-
{code: 'JMD', symbol: 'J$'}, // name: 'Jamaican Dollar',
|
|
1268
|
-
{code: 'JPY', symbol: '¥'}, // name: 'Yen',
|
|
1269
|
-
{code: 'JOD'}, // name: 'Jordanian Dinar',
|
|
1270
|
-
{code: 'KZT', symbol: 'лв'}, // name: 'Tenge',
|
|
1271
|
-
{code: 'KES'}, // name: 'Kenyan Shilling',
|
|
1272
|
-
{code: 'KPW', symbol: '₩'}, // name: 'North Korean Won',
|
|
1273
|
-
{code: 'KRW', symbol: '₩'}, // name: 'Won',
|
|
1274
|
-
{code: 'KWD'}, // name: 'Kuwaiti Dinar',
|
|
1275
|
-
{code: 'KGS', symbol: 'лв'}, // name: 'Som',
|
|
1276
|
-
{code: 'LAK', symbol: '₭'}, // name: 'Lao Kip',
|
|
1277
|
-
{code: 'LBP', symbol: '£'}, // name: 'Lebanese Pound',
|
|
1278
|
-
{code: 'LSL'}, // name: 'Loti',
|
|
1279
|
-
{code: 'ZAR', symbol: 'R'}, // name: 'Rand',
|
|
1280
|
-
{code: 'LRD', symbol: '$'}, // name: 'Liberian Dollar',
|
|
1281
|
-
{code: 'LYD'}, // name: 'Libyan Dinar',
|
|
1282
|
-
{code: 'CHF', symbol: 'CHF'}, // name: 'Swiss Franc',
|
|
1283
|
-
{code: 'MOP'}, // name: 'Pataca',
|
|
1284
|
-
{code: 'MKD', symbol: 'ден'}, // name: 'Denar',
|
|
1285
|
-
{code: 'MGA'}, // name: 'Malagasy Ariary',
|
|
1286
|
-
{code: 'MWK'}, // name: 'Malawi Kwacha',
|
|
1287
|
-
{code: 'MYR', symbol: 'RM'}, // name: 'Malaysian Ringgit',
|
|
1288
|
-
{code: 'MVR'}, // name: 'Rufiyaa',
|
|
1289
|
-
{code: 'MRU'}, // name: 'Ouguiya',
|
|
1290
|
-
{code: 'MUR', symbol: '₨'}, // name: 'Mauritius Rupee',
|
|
1291
|
-
{code: 'XUA'}, // name: 'ADB Unit of Account',
|
|
1292
|
-
{code: 'MXN', symbol: '$'}, // name: 'Mexican Peso',
|
|
1293
|
-
{code: 'MXV'}, // name: 'Mexican Unidad de Inversion (UDI)',
|
|
1294
|
-
{code: 'MDL'}, // name: 'Moldovan Leu',
|
|
1295
|
-
{code: 'MNT', symbol: '₮'}, // name: 'Tugrik',
|
|
1296
|
-
{code: 'MAD'}, // name: 'Moroccan Dirham',
|
|
1297
|
-
{code: 'MZN', symbol: 'MT'}, // name: 'Mozambique Metical',
|
|
1298
|
-
{code: 'MMK'}, // name: 'Kyat',
|
|
1299
|
-
{code: 'NAD', symbol: '$'}, // name: 'Namibia Dollar',
|
|
1300
|
-
{code: 'NPR', symbol: '₨'}, // name: 'Nepalese Rupee',
|
|
1301
|
-
{code: 'NIO', symbol: 'C$'}, // name: 'Cordoba Oro',
|
|
1302
|
-
{code: 'NGN', symbol: '₦'}, // name: 'Naira',
|
|
1303
|
-
{code: 'OMR', symbol: '﷼'}, // name: 'Rial Omani',
|
|
1304
|
-
{code: 'PKR', symbol: '₨'}, // name: 'Pakistan Rupee',
|
|
1305
|
-
{code: 'PAB', symbol: 'B/.'}, // name: 'Balboa',
|
|
1306
|
-
{code: 'PGK'}, // name: 'Kina',
|
|
1307
|
-
{code: 'PYG', symbol: 'Gs'}, // name: 'Guarani',
|
|
1308
|
-
{code: 'PEN', symbol: 'S/.'}, // name: 'Sol',
|
|
1309
|
-
{code: 'PHP', symbol: '₱'}, // name: 'Philippine Peso',
|
|
1310
|
-
{code: 'PLN', symbol: 'zł'}, // name: 'Zloty',
|
|
1311
|
-
{code: 'QAR', symbol: '﷼'}, // name: 'Qatari Rial',
|
|
1312
|
-
{code: 'RON', symbol: 'lei'}, // name: 'Romanian Leu',
|
|
1313
|
-
{code: 'RUB', symbol: '₽'}, // name: 'Russian Ruble',
|
|
1314
|
-
{code: 'RWF'}, // name: 'Rwanda Franc',
|
|
1315
|
-
{code: 'SHP', symbol: '£'}, // name: 'Saint Helena Pound',
|
|
1316
|
-
{code: 'WST'}, // name: 'Tala',
|
|
1317
|
-
{code: 'STN'}, // name: 'Dobra',
|
|
1318
|
-
{code: 'SAR', symbol: '﷼'}, // name: 'Saudi Riyal',
|
|
1319
|
-
{code: 'RSD', symbol: 'Дин.'}, // name: 'Serbian Dinar',
|
|
1320
|
-
{code: 'SCR', symbol: '₨'}, // name: 'Seychelles Rupee',
|
|
1321
|
-
{code: 'SLL'}, // name: 'Leone',
|
|
1322
|
-
{code: 'SGD', symbol: '$'}, // name: 'Singapore Dollar',
|
|
1323
|
-
{code: 'XSU'}, // name: 'Sucre',
|
|
1324
|
-
{code: 'SBD', symbol: '$'}, // name: 'Solomon Islands Dollar',
|
|
1325
|
-
{code: 'SOS', symbol: 'S'}, // name: 'Somali Shilling',
|
|
1326
|
-
{code: 'SSP'}, // name: 'South Sudanese Pound',
|
|
1327
|
-
{code: 'LKR', symbol: '₨'}, // name: 'Sri Lanka Rupee',
|
|
1328
|
-
{code: 'SDG'}, // name: 'Sudanese Pound',
|
|
1329
|
-
{code: 'SRD', symbol: '$'}, // name: 'Surinam Dollar',
|
|
1330
|
-
{code: 'SEK', symbol: 'kr'}, // name: 'Swedish Krona',
|
|
1331
|
-
{code: 'CHE'}, // name: 'WIR Euro',
|
|
1332
|
-
{code: 'CHW'}, // name: 'WIR Franc',
|
|
1333
|
-
{code: 'SYP', symbol: '£'}, // name: 'Syrian Pound',
|
|
1334
|
-
{code: 'TWD', symbol: 'NT$'}, // name: 'New Taiwan Dollar',
|
|
1335
|
-
{code: 'TJS'}, // name: 'Somoni',
|
|
1336
|
-
{code: 'TZS'}, // name: 'Tanzanian Shilling',
|
|
1337
|
-
{code: 'THB', symbol: '฿'}, // name: 'Baht',
|
|
1338
|
-
{code: 'TOP'}, // name: 'Pa’anga',
|
|
1339
|
-
{code: 'TTD', symbol: 'TT$'}, // name: 'Trinidad and Tobago Dollar',
|
|
1340
|
-
{code: 'TND'}, // name: 'Tunisian Dinar',
|
|
1341
|
-
{code: 'TRY', symbol: '₺'}, // name: 'Turkish Lira',
|
|
1342
|
-
{code: 'TMT'}, // name: 'Turkmenistan New Manat',
|
|
1343
|
-
{code: 'UGX'}, // name: 'Uganda Shilling',
|
|
1344
|
-
{code: 'UAH', symbol: '₴'}, // name: 'Hryvnia',
|
|
1345
|
-
{code: 'AED', symbol: ' د.إ'}, // name: 'UAE Dirham',
|
|
1346
|
-
{code: 'USN'}, // name: 'US Dollar (Next day)',
|
|
1347
|
-
{code: 'UYU', symbol: '$U'}, // name: 'Peso Uruguayo',
|
|
1348
|
-
{code: 'UYI'}, // name: 'Uruguay Peso en Unidades Indexadas (UI)',
|
|
1349
|
-
{code: 'UYW'}, // name: 'Unidad Previsional',
|
|
1350
|
-
{code: 'UZS', symbol: 'лв'}, // name: 'Uzbekistan Sum',
|
|
1351
|
-
{code: 'VUV'}, // name: 'Vatu',
|
|
1352
|
-
{code: 'VES'}, // name: 'Bolívar Soberano',
|
|
1353
|
-
{code: 'VED'}, // name: 'Bolívar Soberano',
|
|
1354
1165
|
{code: 'VND', symbol: '₫'}, // name: 'Dong',
|
|
1355
|
-
{code: 'YER', symbol: '﷼'}, // name: 'Yemeni Rial',
|
|
1356
|
-
{code: 'ZMW'}, // name: 'Zambian Kwacha',
|
|
1357
|
-
{code: 'ZWL'}, // name: 'Zimbabwe Dollar',
|
|
1358
|
-
{code: 'XBA'}, // name: 'Bond Markets Unit European Composite Unit (EURCO)',
|
|
1359
|
-
{code: 'XBB'}, // name: 'Bond Markets Unit European Monetary Unit (E.M.U.-6)',
|
|
1360
|
-
{code: 'XBC'}, // name: 'Bond Markets Unit European Unit of Account 9 (E.U.A.-9)',
|
|
1361
|
-
{code: 'XBD'}, // name: 'Bond Markets Unit European Unit of Account 17 (E.U.A.-17)',
|
|
1362
|
-
{code: 'XTS'}, // name: 'Codes specifically reserved for testing purposes',
|
|
1363
|
-
{code: 'XXX'}, // name: 'The codes assigned for transactions where no currency is involved',
|
|
1364
|
-
{code: 'XAU'}, // name: 'Gold',
|
|
1365
|
-
{code: 'XPD'}, // name: 'Palladium',
|
|
1366
|
-
{code: 'XPT'}, // name: 'Platinum',
|
|
1367
|
-
{code: 'XAG'}, // name: 'Silver',
|
|
1368
1166
|
]
|
|
1369
1167
|
|
|
1370
1168
|
// if (!Element.prototype.scrollIntoViewIfNeeded) {
|
package/src/util/index.js
CHANGED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.calcOrderTotal = calcOrderTotal;
|
|
7
|
-
exports.displayOrderShippingAddress = displayOrderShippingAddress;
|
|
8
|
-
exports.getOrderDisplayName = getOrderDisplayName;
|
|
9
|
-
exports.getProductPropName = getProductPropName;
|
|
10
|
-
const op = require('./op.js');
|
|
11
|
-
const common = require('./common');
|
|
12
|
-
op.filter = common.filter;
|
|
13
|
-
op.map = common.map;
|
|
14
|
-
op.each = common.each;
|
|
15
|
-
op.size = common.size;
|
|
16
|
-
op.find = common.find;
|
|
17
|
-
function getProductPropName(product, seperator = ' - ') {
|
|
18
|
-
let options = op.get(product, 'options', []);
|
|
19
|
-
let props = op.get(product, 'props', []);
|
|
20
|
-
let multiPropsOptions = op.filter(options, option => op.size(option.values) > 1);
|
|
21
|
-
let names = [];
|
|
22
|
-
op.each(multiPropsOptions, option => {
|
|
23
|
-
let prop = op.find(props, prop => prop.key === option.key) || {};
|
|
24
|
-
if (prop.value) names.push(prop.value);
|
|
25
|
-
});
|
|
26
|
-
return names.join(seperator);
|
|
27
|
-
}
|
|
28
|
-
function getOrderDisplayName(order = {}) {
|
|
29
|
-
return order.number || order.id || '';
|
|
30
|
-
}
|
|
31
|
-
function displayOrderShippingAddress(order, isShorten) {
|
|
32
|
-
let addr = op.get(order, 'shipping.address', {});
|
|
33
|
-
let fulladdr = [addr.address, addr.ward, addr.district, addr.province].filter(a => a).join(', ').trim();
|
|
34
|
-
if (isShorten) fulladdr = shortenAddr(fulladdr);
|
|
35
|
-
return fulladdr;
|
|
36
|
-
}
|
|
37
|
-
function shortenAddr(str) {
|
|
38
|
-
str = str || '';
|
|
39
|
-
str = str.replace(/Hà Nội/gi, 'HN');
|
|
40
|
-
str = str.replace(/Hồ Chí Minh/gi, 'HCM');
|
|
41
|
-
str = str.replace(/Thành Phố/gi, 'TP');
|
|
42
|
-
return str;
|
|
43
|
-
}
|
|
44
|
-
function calcOrderTotal(order) {
|
|
45
|
-
let subtotal = 0;
|
|
46
|
-
let beforeTaxDiscount = 0;
|
|
47
|
-
let ordervalue = 0;
|
|
48
|
-
op.map(order.items, item => {
|
|
49
|
-
if (!item.product) return 0;
|
|
50
|
-
let price = op.get(item, 'product.price', 0) * (item.quantity || 0);
|
|
51
|
-
ordervalue += price;
|
|
52
|
-
if (item.discount_type == 'percentage') {
|
|
53
|
-
if (item.discount_percentage > 0) {
|
|
54
|
-
beforeTaxDiscount += price * item.discount_percentage / 10000;
|
|
55
|
-
price = price * (1 - (item.discount_percentage || 0) / 10000);
|
|
56
|
-
}
|
|
57
|
-
} else if (item.discount_type == 'amount') {
|
|
58
|
-
if (item.discount_amount > 0) {
|
|
59
|
-
beforeTaxDiscount += item.discount_amount;
|
|
60
|
-
price = price - (item.discount_amount || 0);
|
|
61
|
-
if (price <= 0) price = 0;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
item.total = price;
|
|
65
|
-
subtotal += price;
|
|
66
|
-
});
|
|
67
|
-
let taxM = {};
|
|
68
|
-
op.map(order.items, (item, i) => {
|
|
69
|
-
if (!item.product) return;
|
|
70
|
-
let tax = item.product.tax;
|
|
71
|
-
if (!tax) return;
|
|
72
|
-
if (!tax.id) return;
|
|
73
|
-
let taxprice = item.total * tax.percentage / 10000;
|
|
74
|
-
item.total_tax = taxprice;
|
|
75
|
-
taxM[i] = {
|
|
76
|
-
tax: tax,
|
|
77
|
-
taxprice: taxprice
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
let totaltax = 0;
|
|
81
|
-
op.map(taxM, t => totaltax += t.taxprice);
|
|
82
|
-
let computed_discount = 0;
|
|
83
|
-
if (order.discount_type == 'percentage' && order.discount_percentage > 0) {
|
|
84
|
-
computed_discount = (subtotal + totaltax) * order.discount_percentage / 10000;
|
|
85
|
-
} else if (order.discount_type == 'amount') {
|
|
86
|
-
computed_discount = order.discount_amount || 0;
|
|
87
|
-
}
|
|
88
|
-
let shippingfee = op.get(order, 'shipping.nominal_fee', 0);
|
|
89
|
-
if (shippingfee > 0) {
|
|
90
|
-
if (op.get(order, 'shipping.tax.id')) {
|
|
91
|
-
let tax = order.shipping.tax;
|
|
92
|
-
let taxprice = shippingfee * (tax.percentage / 10000);
|
|
93
|
-
taxM['ship'] = {
|
|
94
|
-
tax: tax,
|
|
95
|
-
taxprice: taxprice
|
|
96
|
-
};
|
|
97
|
-
order.shipping.total_tax = taxprice;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
totaltax = 0;
|
|
101
|
-
op.map(taxM, t => totaltax += t.taxprice);
|
|
102
|
-
let total = subtotal + totaltax - computed_discount + shippingfee;
|
|
103
|
-
total += order.adjustment || 0;
|
|
104
|
-
if (total < 0) total = 0;
|
|
105
|
-
order.subtotal = subtotal;
|
|
106
|
-
order._computed_discount = computed_discount;
|
|
107
|
-
order._taxM = taxM;
|
|
108
|
-
order.total = total;
|
|
109
|
-
order.total_tax = totaltax;
|
|
110
|
-
order._discount_before_tax = beforeTaxDiscount;
|
|
111
|
-
order._order_value = ordervalue;
|
|
112
|
-
}
|