|
1 | 1 | import { mask } from './stores/useMask' |
| 2 | +import { computed } from 'vue' |
2 | 3 |
|
3 | 4 | document.addEventListener('vue:loaded', function (event) { |
4 | | - event.detail.vue.mixin({ |
5 | | - methods: { |
6 | | - async asyncForEach(array, callback) { |
7 | | - for (let index = 0; index < array.length; index++) { |
8 | | - await callback(array[index], index, array) |
9 | | - } |
10 | | - }, |
| 5 | + event.detail.vue.config.globalProperties.asyncForEach = async (array, callback) => { |
| 6 | + for (let index = 0; index < array.length; index++) { |
| 7 | + await callback(array[index], index, array) |
| 8 | + } |
| 9 | + } |
11 | 10 |
|
12 | | - async magentoCart(method, endpoint, data) { |
13 | | - if (window.app.config.globalProperties.loggedIn.value) { |
14 | | - return await window.magentoAPI(method, 'carts/mine/' + endpoint, data) |
15 | | - } else { |
16 | | - return await window.magentoAPI(method, 'guest-carts/' + mask.value + '/' + endpoint, data) |
17 | | - } |
18 | | - }, |
19 | | - }, |
| 11 | + event.detail.vue.config.globalProperties.magentoCart = async (method, endpoint, data) => { |
| 12 | + if (window.app.config.globalProperties.loggedIn.value) { |
| 13 | + return await window.magentoAPI(method, 'carts/mine/' + endpoint, data) |
| 14 | + } else { |
| 15 | + return await window.magentoAPI(method, 'guest-carts/' + mask.value + '/' + endpoint, data) |
| 16 | + } |
| 17 | + } |
20 | 18 |
|
21 | | - computed: { |
22 | | - currencySymbolLocation() { |
23 | | - return new Intl.NumberFormat(config.locale.replace('_', '-'), { |
24 | | - style: 'currency', |
25 | | - currency: config.currency, |
26 | | - }).formatToParts(1)?.[0]?.type === 'currency' |
27 | | - ? 'left' |
28 | | - : 'right' |
29 | | - }, |
| 19 | + event.detail.vue.config.globalProperties.currencySymbolLocation = computed(() => { |
| 20 | + return new Intl.NumberFormat(config.locale.replace('_', '-'), { |
| 21 | + style: 'currency', |
| 22 | + currency: config.currency, |
| 23 | + }).formatToParts(1)?.[0]?.type === 'currency' |
| 24 | + ? 'left' |
| 25 | + : 'right' |
| 26 | + }) |
30 | 27 |
|
31 | | - currencySymbol() { |
32 | | - return new Intl.NumberFormat(config.locale.replace('_', '-'), { |
33 | | - style: 'currency', |
34 | | - currency: config.currency, |
35 | | - maximumFractionDigits: 0, |
36 | | - }) |
37 | | - .format(0) |
38 | | - .replace(/\d/g, '') |
39 | | - .trim() |
40 | | - }, |
41 | | - }, |
| 28 | + event.detail.vue.config.globalProperties.currencySymbol = computed(() => { |
| 29 | + return new Intl.NumberFormat(config.locale.replace('_', '-'), { |
| 30 | + style: 'currency', |
| 31 | + currency: config.currency, |
| 32 | + maximumFractionDigits: 0, |
| 33 | + }) |
| 34 | + .format(0) |
| 35 | + .replace(/\d/g, '') |
| 36 | + .trim() |
42 | 37 | }) |
43 | 38 | }) |
0 commit comments