@wikala/spmkt 2.31.1 → 3.0.0-beta.0
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/MIGRATION_GUIDE.md +261 -0
- package/api/product.js +1 -0
- package/api/request.js +9 -4
- package/api/user.js +1 -1
- package/components/Account/AccountDashboard.vue +101 -101
- package/components/Account/AccountStore.js +57 -31
- package/components/Account/AffiliateReport.vue +56 -60
- package/components/Account/{OrderDetail.vue → Orders/OrderDetail.vue} +44 -30
- package/components/Account/Orders/Orders.vue +124 -0
- package/components/Account/{AccountSettings.vue → Settings/AccountSettings.vue} +4 -4
- package/components/Account/Settings/ChangeEmail.vue +136 -0
- package/components/Account/Settings/ChangeName.vue +82 -0
- package/components/Account/Settings/ChangePassword.vue +91 -0
- package/components/Address/Address.vue +38 -57
- package/components/Address/AddressBook.vue +77 -57
- package/components/Address/AddressSelect.vue +94 -87
- package/components/Address/Edit.vue +253 -265
- package/components/Address/PostalCode.vue +22 -21
- package/components/AgeGate.vue +11 -5
- package/components/Auth/Login.vue +62 -44
- package/components/Auth/Register.vue +82 -60
- package/components/Auth/ResetPassword.vue +45 -30
- package/components/Cart/AgeVerification/AgeChecker.vue +3 -3
- package/components/Cart/CartBadge.vue +15 -4
- package/components/Cart/CartBox.vue +19 -11
- package/components/Cart/CartItem.vue +3 -3
- package/components/Cart/CartMode.vue +6 -5
- package/components/Cart/CartPreview.vue +24 -18
- package/components/Cart/CreditCard/Everyware.vue +10 -10
- package/components/Cart/CreditCard/ExtendedCreditCard.vue +5 -5
- package/components/Cart/CreditCard/SquarePay.vue +18 -16
- package/components/Cart/CreditCard/StandardCreditCard.vue +9 -9
- package/components/Cart/Delivery/Delivery.vue +16 -12
- package/components/Cart/Delivery/DeliveryAddress.vue +1 -1
- package/components/Cart/Delivery/DeliveryMethods.vue +1 -1
- package/components/Cart/Delivery/DeliveryOptions.vue +15 -9
- package/components/Cart/Delivery/DeliveryTypes.vue +8 -5
- package/components/Cart/Delivery/ReservationSlots.vue +14 -8
- package/components/Cart/Disclaimer.vue +1 -1
- package/components/Cart/OrderConfirmation.vue +1 -1
- package/components/Cart/Payment/Payment.vue +37 -33
- package/components/Cart/Payment/PaymentMethods.vue +6 -4
- package/components/Cart/ReviewAndSubmit.vue +9 -7
- package/components/Cart/ShoppingCart.vue +42 -31
- package/components/Cart/Store/actions.js +1 -1
- package/components/Cart/Store/getters.js +2 -1
- package/components/Cart/Store/index.js +1 -1
- package/components/Cart/Store/mutations.js +7 -5
- package/components/Cart/UserIdentity.vue +1 -1
- package/components/Category/CategoryFilter.vue +128 -114
- package/components/Category/CategorySort.vue +44 -32
- package/components/Category/LoadMore.vue +39 -23
- package/components/DeliverTo.vue +10 -15
- package/components/DeliveryNotice.vue +72 -68
- package/components/DobInput.vue +23 -23
- package/components/Gmaps/GmapsAutocomplete.vue +139 -78
- package/components/Gmaps/GmapsLocations.vue +1 -1
- package/components/Gmaps/GmapsSingleLocation.vue +121 -87
- package/components/ModalContainer/ModalContainer.vue +12 -9
- package/components/ModalContainer/index.js +61 -18
- package/components/Product/AddToCart.vue +237 -221
- package/components/Product/BoxAddToCart.vue +114 -86
- package/components/Product/Compare.vue +68 -48
- package/components/Product/CompareBox.vue +128 -123
- package/components/Product/Lookup.vue +92 -65
- package/components/Product/Photo.vue +105 -66
- package/components/Product/Price.vue +64 -43
- package/components/Product/ProductAutocomplete.vue +52 -57
- package/components/Product/ProductBox.vue +61 -38
- package/components/Product/ProductImages.vue +83 -86
- package/components/Product/Quantity.vue +115 -53
- package/components/Product/QuickView.vue +52 -45
- package/components/Product/RelatedProducts.vue +88 -23
- package/components/Product/SKU.vue +27 -8
- package/components/Product/Variants.vue +335 -341
- package/components/Product/reviews-questions/ProductQuestions.vue +226 -198
- package/components/Product/reviews-questions/ProductReviews.vue +122 -107
- package/components/Product/reviews-questions/Review.vue +54 -59
- package/components/Product/reviews-questions/ReviewForm.vue +222 -170
- package/components/Product/reviews-questions/ReviewImages.vue +197 -216
- package/components/Product/reviews-questions/Vote.vue +83 -57
- package/components/QuantityInput.vue +18 -8
- package/components/RangeInput.vue +15 -8
- package/components/Recaptcha.vue +8 -1
- package/components/SelectShippingCountry.vue +81 -62
- package/components/TimedOffer.vue +59 -74
- package/composables/globals.js +53 -0
- package/config.js +5 -2
- package/index.js +41 -10
- package/install.js +75 -0
- package/locales/en.json +2 -1
- package/locales/sr.json +2 -1
- package/package.json +43 -30
- package/utils/directives.js +28 -45
- package/utils/event-bus.js +56 -0
- package/utils/filters.js +24 -7
- package/utils/{gmaps.js → google/gmaps.js} +43 -10
- package/utils/{google-analytics-eec.js → google/google-analytics-eec.js} +7 -7
- package/babel.config.js +0 -5
- package/components/Account/ChangeEmail.vue +0 -133
- package/components/Account/ChangeName.vue +0 -92
- package/components/Account/ChangePassword.vue +0 -94
- package/components/Account/CreditCards.vue +0 -18
- package/components/Account/Orders.vue +0 -110
- package/components/Account/Settings.vue +0 -18
- package/components/Cart/Delivery/DeliveryAddressGuest.spec.js +0 -128
- package/components/Cart/Delivery/DeliveryTypes.spec.js +0 -83
- package/components/Cart/PCIBadge/SecurityMetrics.vue +0 -11
- package/components/Instagram.vue +0 -49
- package/components/ProductImageModal.vue +0 -41
- package/jest.config.js +0 -16
- package/test/e2e/.babelrc.js +0 -8
- package/test/e2e/.eslintrc.js +0 -11
- package/test/e2e/accAuth.spec.js +0 -64
- package/test/e2e/ageGate.spec.js +0 -26
- package/test/e2e/checkout.spec.js +0 -106
- package/test/e2e/compare.spec.js +0 -52
- package/test/e2e/config/data.js +0 -21
- package/test/e2e/config/routes.js +0 -11
- package/test/e2e/region.spec.js +0 -46
- package/test/e2e/search.spec.js +0 -32
- package/tests/vueBuefy.js +0 -4
- package/tsconfig.json +0 -8
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
@typing="getAsyncData"
|
|
11
11
|
@select="select($event)"
|
|
12
12
|
>
|
|
13
|
-
<template
|
|
13
|
+
<template #default="props">
|
|
14
14
|
<div class="media">
|
|
15
15
|
<div class="media-left">
|
|
16
16
|
<img width="32" :src="props.option.image" />
|
|
@@ -25,81 +25,108 @@
|
|
|
25
25
|
</div>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
|
-
<script>
|
|
28
|
+
<script setup>
|
|
29
|
+
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
|
30
|
+
import { useBuefy, useBus } from '../../composables/globals'
|
|
29
31
|
import _ from 'underscore'
|
|
30
32
|
import { request } from '../../api'
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
name: 'ProductLookup',
|
|
34
|
-
props: ['position', 'productOnPosition', 'label', 'attTemplateId'],
|
|
35
|
-
data() {
|
|
36
|
-
return {
|
|
37
|
-
data: [],
|
|
38
|
-
selected: null,
|
|
39
|
-
isFetching: false,
|
|
40
|
-
selectedIds: []
|
|
41
|
-
}
|
|
42
|
-
},
|
|
34
|
+
defineOptions({ name: 'ProductLookup' })
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
const props = defineProps({
|
|
37
|
+
position: {
|
|
38
|
+
type: [Number, String],
|
|
39
|
+
default: -1
|
|
40
|
+
},
|
|
41
|
+
productOnPosition: {
|
|
42
|
+
type: [Number, String],
|
|
43
|
+
default: null
|
|
44
|
+
},
|
|
45
|
+
label: {
|
|
46
|
+
type: String,
|
|
47
|
+
default: ''
|
|
48
|
+
},
|
|
49
|
+
attTemplateId: {
|
|
50
|
+
type: [Number, String],
|
|
51
|
+
default: null
|
|
52
|
+
}
|
|
53
|
+
})
|
|
50
54
|
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
// Get global properties and injections
|
|
56
|
+
const $bus = useBus()
|
|
57
|
+
const $buefy = useBuefy()
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
.then((response) => {
|
|
60
|
-
console.log('response: ', response)
|
|
61
|
-
this.data = response.data.slice(0, 6)
|
|
62
|
-
this.isFetching = false
|
|
63
|
-
})
|
|
64
|
-
.catch((error) => {
|
|
65
|
-
console.log(error)
|
|
66
|
-
this.isFetching = false
|
|
67
|
-
})
|
|
68
|
-
}, 500),
|
|
59
|
+
// Reactive state
|
|
60
|
+
const data = ref([])
|
|
61
|
+
const selected = ref(null)
|
|
62
|
+
const isFetching = ref(false)
|
|
63
|
+
const selectedIds = ref([])
|
|
69
64
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
this.selectedIds[this.position] = option.id
|
|
77
|
-
} else {
|
|
78
|
-
this.selectedIds.push(option.id.toString())
|
|
79
|
-
}
|
|
80
|
-
window.location.href = '/compare-products?products=' + this.selectedIds.join(',')
|
|
81
|
-
} else {
|
|
82
|
-
this.$buefy.dialog.alert({
|
|
83
|
-
title: '',
|
|
84
|
-
message: "You've already selected " + option.name,
|
|
85
|
-
confirmText: 'OK'
|
|
86
|
-
})
|
|
87
|
-
}
|
|
88
|
-
},
|
|
65
|
+
// Methods
|
|
66
|
+
const getAsyncData = _.debounce(function (query) {
|
|
67
|
+
if (!query.length) {
|
|
68
|
+
data.value = []
|
|
69
|
+
return
|
|
70
|
+
}
|
|
89
71
|
|
|
90
|
-
|
|
91
|
-
this.selectedIds.splice(position, 1)
|
|
92
|
-
window.location.href = '/compare-products?products=' + this.selectedIds.join(',')
|
|
93
|
-
}
|
|
94
|
-
},
|
|
72
|
+
isFetching.value = true
|
|
95
73
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
74
|
+
return request({
|
|
75
|
+
baseURL: '',
|
|
76
|
+
url: '/products/lookup?q=' + query + '&tid=' + props.attTemplateId,
|
|
77
|
+
method: 'get'
|
|
78
|
+
})
|
|
79
|
+
.then((response) => {
|
|
80
|
+
console.log('response: ', response)
|
|
81
|
+
data.value = response.data.slice(0, 6)
|
|
82
|
+
isFetching.value = false
|
|
83
|
+
})
|
|
84
|
+
.catch((error) => {
|
|
85
|
+
console.log(error)
|
|
86
|
+
isFetching.value = false
|
|
87
|
+
})
|
|
88
|
+
}, 500)
|
|
99
89
|
|
|
100
|
-
|
|
101
|
-
|
|
90
|
+
const select = (option) => {
|
|
91
|
+
if (!option) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
if (selectedIds.value.indexOf(option.id.toString()) === -1) {
|
|
95
|
+
if (parseInt(props.position) >= 0) {
|
|
96
|
+
selectedIds.value[props.position] = option.id
|
|
97
|
+
} else {
|
|
98
|
+
selectedIds.value.push(option.id.toString())
|
|
99
|
+
}
|
|
100
|
+
window.location.href = '/compare-products?products=' + selectedIds.value.join(',')
|
|
101
|
+
} else {
|
|
102
|
+
$buefy.dialog.alert({
|
|
103
|
+
title: '',
|
|
104
|
+
message: "You've already selected " + option.name,
|
|
105
|
+
confirmText: 'OK'
|
|
102
106
|
})
|
|
103
107
|
}
|
|
104
108
|
}
|
|
109
|
+
|
|
110
|
+
const remove = (position) => {
|
|
111
|
+
selectedIds.value.splice(position, 1)
|
|
112
|
+
window.location.href = '/compare-products?products=' + selectedIds.value.join(',')
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const onRemoveFromCompare = (position) => {
|
|
116
|
+
remove(position)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Lifecycle hooks
|
|
120
|
+
onMounted(() => {
|
|
121
|
+
const urlParams = new URL(window.location.href).searchParams.get('products')
|
|
122
|
+
if (urlParams) {
|
|
123
|
+
selectedIds.value = urlParams.split(',')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
$bus.on('removeFromCompare', onRemoveFromCompare)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
onBeforeUnmount(() => {
|
|
130
|
+
$bus.off('removeFromCompare', onRemoveFromCompare)
|
|
131
|
+
})
|
|
105
132
|
</script>
|
|
@@ -1,76 +1,115 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="photo-container">
|
|
2
|
+
<div ref="container" class="photo-container">
|
|
3
3
|
<figure class="zoom" @mousemove="zoom($event)" :style="{ backgroundImage: `url('${photoSrc}')` }">
|
|
4
4
|
<img ref="img" :src="src" :alt="alt" />
|
|
5
5
|
</figure>
|
|
6
6
|
</div>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
|
-
<script>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
9
|
+
<script setup>
|
|
10
|
+
import { ref, onMounted, onBeforeUnmount } from 'vue'
|
|
11
|
+
import { useBuefy } from '../../composables/globals'
|
|
12
|
+
import { eventBus } from '../../utils/event-bus'
|
|
13
|
+
|
|
14
|
+
defineOptions({ name: 'Photo' })
|
|
15
|
+
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
src: String,
|
|
18
|
+
alt: String
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
// Get global properties
|
|
22
|
+
const $buefy = useBuefy()
|
|
23
|
+
|
|
24
|
+
// Template refs
|
|
25
|
+
const img = ref(null)
|
|
26
|
+
const container = ref(null)
|
|
27
|
+
|
|
28
|
+
// Reactive state
|
|
29
|
+
const photoSrc = ref('')
|
|
30
|
+
|
|
31
|
+
// Methods
|
|
32
|
+
const swapSrc = (src = '') => {
|
|
33
|
+
if (src) {
|
|
34
|
+
photoSrc.value = src
|
|
35
|
+
} else {
|
|
36
|
+
photoSrc.value = props.src
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const image = img.value
|
|
40
|
+
const downloadingImage = new Image()
|
|
41
|
+
|
|
42
|
+
let photoLoading = null
|
|
43
|
+
|
|
44
|
+
downloadingImage.onload = () => {
|
|
45
|
+
image.src = photoSrc.value
|
|
46
|
+
photoLoading.close()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
photoLoading = $buefy.loading.open({ container: container.value })
|
|
50
|
+
downloadingImage.src = photoSrc.value
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const zoom = (e) => {
|
|
54
|
+
const zoomer = e.currentTarget
|
|
55
|
+
let offsetX
|
|
56
|
+
let offsetY
|
|
57
|
+
let x
|
|
58
|
+
let y
|
|
59
|
+
|
|
60
|
+
if (e.offsetX && e.offsetY) {
|
|
61
|
+
offsetX = e.offsetX
|
|
62
|
+
offsetY = e.offsetY
|
|
63
|
+
} else if (e.touches && e.touches[0]) {
|
|
64
|
+
offsetX = e.touches[0].pageX
|
|
65
|
+
offsetY = e.touches[0].pageY
|
|
66
|
+
}
|
|
67
|
+
x = (offsetX / zoomer.offsetWidth) * 100
|
|
68
|
+
y = (offsetY / zoomer.offsetHeight) * 100
|
|
69
|
+
zoomer.style.backgroundPosition = x + '% ' + y + '%'
|
|
70
|
+
e.preventDefault()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const handleChangePhoto = (src) => {
|
|
74
|
+
if (!src) {
|
|
75
|
+
return false
|
|
74
76
|
}
|
|
77
|
+
swapSrc(src)
|
|
75
78
|
}
|
|
79
|
+
|
|
80
|
+
// Lifecycle hooks
|
|
81
|
+
onMounted(() => {
|
|
82
|
+
swapSrc()
|
|
83
|
+
eventBus.on('changePhoto', handleChangePhoto)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
onBeforeUnmount(() => {
|
|
87
|
+
eventBus.off('changePhoto', handleChangePhoto)
|
|
88
|
+
})
|
|
76
89
|
</script>
|
|
90
|
+
|
|
91
|
+
<style scoped>
|
|
92
|
+
.photo-container {
|
|
93
|
+
display: flex;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
figure.zoom {
|
|
98
|
+
background-position: 50% 50%;
|
|
99
|
+
background-size: 200%;
|
|
100
|
+
position: relative;
|
|
101
|
+
overflow: hidden;
|
|
102
|
+
cursor: zoom-in;
|
|
103
|
+
margin: 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
figure.zoom img {
|
|
107
|
+
display: block;
|
|
108
|
+
width: 100%;
|
|
109
|
+
transition: opacity 0.3s;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
figure.zoom:hover img {
|
|
113
|
+
opacity: 0;
|
|
114
|
+
}
|
|
115
|
+
</style>
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script>
|
|
9
|
+
import { ref, onMounted, onUnmounted } from 'vue'
|
|
9
10
|
import { formatMoney } from '../../utils/filters'
|
|
11
|
+
import { eventBus } from '../../utils/event-bus'
|
|
10
12
|
|
|
11
13
|
export default {
|
|
12
14
|
name: 'Price',
|
|
@@ -19,67 +21,86 @@ export default {
|
|
|
19
21
|
}
|
|
20
22
|
},
|
|
21
23
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
discountPercent: 0
|
|
28
|
-
}
|
|
29
|
-
},
|
|
24
|
+
setup(props) {
|
|
25
|
+
const comparePrice = ref(0)
|
|
26
|
+
const price = ref(0)
|
|
27
|
+
const from = ref('')
|
|
28
|
+
const discountPercent = ref(0)
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
formatMoney,
|
|
33
|
-
refresh(value, compareValue) {
|
|
30
|
+
const refresh = (value, compareValue) => {
|
|
34
31
|
if (typeof value === 'object' && value.min) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
from.value = 'from'
|
|
33
|
+
price.value = value.min
|
|
34
|
+
comparePrice.value = compareValue.min
|
|
38
35
|
} else {
|
|
39
|
-
|
|
36
|
+
comparePrice.value = value
|
|
40
37
|
if (compareValue === undefined) {
|
|
41
|
-
|
|
38
|
+
price.value = value * (1 - discountPercent.value)
|
|
42
39
|
} else {
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
price.value = parseFloat(value)
|
|
41
|
+
comparePrice.value = parseFloat(compareValue)
|
|
45
42
|
}
|
|
46
43
|
}
|
|
47
44
|
}
|
|
48
|
-
},
|
|
49
45
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
const handleUpdatePrice = (value, compareValue) => {
|
|
47
|
+
if (!value && !compareValue) {
|
|
48
|
+
return
|
|
49
|
+
}
|
|
50
|
+
if (!props.updatable) {
|
|
51
|
+
return false
|
|
52
|
+
}
|
|
53
|
+
refresh(value, compareValue)
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
56
|
+
onMounted(() => {
|
|
57
|
+
if (typeof props.value !== 'object') {
|
|
58
|
+
price.value = parseFloat(props.value)
|
|
59
|
+
comparePrice.value = parseFloat(props.compareValue)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (typeof props.value === 'object') {
|
|
63
|
+
if (Object.entries(props.value).length === 0) {
|
|
64
|
+
console.log('Price empty value', props.value)
|
|
65
|
+
price.value = NaN
|
|
66
|
+
comparePrice.value = NaN
|
|
64
67
|
} else {
|
|
65
|
-
|
|
68
|
+
if (typeof props.value === 'object') {
|
|
69
|
+
discountPercent.value = Math.abs(props.value.min - props.compareValue.min) / props.compareValue.min
|
|
70
|
+
} else {
|
|
71
|
+
discountPercent.value = Math.abs(props.value - props.compareValue) / props.compareValue
|
|
72
|
+
}
|
|
66
73
|
}
|
|
67
74
|
}
|
|
68
|
-
}
|
|
69
75
|
|
|
70
|
-
|
|
76
|
+
refresh(props.value, props.compareValue)
|
|
71
77
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return false
|
|
78
|
-
}
|
|
79
|
-
this.refresh(value, compareValue)
|
|
78
|
+
eventBus.on('updatePrice', handleUpdatePrice)
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
onUnmounted(() => {
|
|
82
|
+
eventBus.off('updatePrice', handleUpdatePrice)
|
|
80
83
|
})
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
comparePrice,
|
|
87
|
+
price,
|
|
88
|
+
from,
|
|
89
|
+
discountPercent,
|
|
90
|
+
formatMoney
|
|
91
|
+
}
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
94
|
</script>
|
|
84
95
|
|
|
85
|
-
<style scoped
|
|
96
|
+
<style scoped>
|
|
97
|
+
.price-old {
|
|
98
|
+
text-decoration: line-through;
|
|
99
|
+
margin-right: 0.5rem;
|
|
100
|
+
opacity: 0.7;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.price {
|
|
104
|
+
font-weight: 600;
|
|
105
|
+
}
|
|
106
|
+
</style>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
name="productSearchForm"
|
|
5
5
|
action="/search"
|
|
6
6
|
method="get"
|
|
7
|
-
:class="{ active: active
|
|
7
|
+
:class="{ active: active === 1 }"
|
|
8
8
|
@mouseover="active = 1"
|
|
9
9
|
@mouseout="active = 0"
|
|
10
10
|
>
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
field="name"
|
|
16
16
|
icon-pack="fas"
|
|
17
17
|
:data="data"
|
|
18
|
-
|
|
18
|
+
v-model="searchQuery"
|
|
19
19
|
:icon="isFetching ? '' : 'search'"
|
|
20
20
|
:loading="isFetching"
|
|
21
21
|
@typing="searchProducts"
|
|
22
22
|
@select="onSelected"
|
|
23
|
-
@keydown.
|
|
23
|
+
@keydown.enter="onEnter"
|
|
24
24
|
>
|
|
25
25
|
<template v-slot="props">
|
|
26
26
|
<div class="media">
|
|
@@ -37,72 +37,67 @@
|
|
|
37
37
|
</div>
|
|
38
38
|
</form>
|
|
39
39
|
</template>
|
|
40
|
-
<script>
|
|
40
|
+
<script setup>
|
|
41
|
+
import { ref, inject, onMounted } from 'vue'
|
|
41
42
|
import _ from 'underscore'
|
|
42
43
|
import liveAddEventListener from '../../utils/native-dom'
|
|
43
|
-
|
|
44
44
|
import { Product } from '../../api'
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
name: 'ProductAutocomplete',
|
|
48
|
-
|
|
49
|
-
props: {
|
|
50
|
-
q: {
|
|
51
|
-
type: String,
|
|
52
|
-
required: true
|
|
53
|
-
},
|
|
54
|
-
searchLimit: {
|
|
55
|
-
type: String,
|
|
56
|
-
required: true
|
|
57
|
-
}
|
|
58
|
-
},
|
|
46
|
+
defineOptions({ name: 'ProductAutocomplete' })
|
|
59
47
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
isFetching: false,
|
|
65
|
-
enter: true,
|
|
66
|
-
active: 0
|
|
67
|
-
}
|
|
48
|
+
const props = defineProps({
|
|
49
|
+
q: {
|
|
50
|
+
type: String,
|
|
51
|
+
required: true
|
|
68
52
|
},
|
|
53
|
+
searchLimit: {
|
|
54
|
+
type: String,
|
|
55
|
+
required: true
|
|
56
|
+
}
|
|
57
|
+
})
|
|
69
58
|
|
|
70
|
-
|
|
71
|
-
searchProducts: _.debounce(function (query_string) {
|
|
72
|
-
if (!query_string.length) {
|
|
73
|
-
this.data = []
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.isFetching = true
|
|
59
|
+
const navigate = inject('navigate', (url) => { window.location.href = url })
|
|
78
60
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
.finally(() => {
|
|
86
|
-
this.isFetching = false
|
|
87
|
-
})
|
|
88
|
-
}, 250),
|
|
61
|
+
const productSearchForm = ref(null)
|
|
62
|
+
const searchQuery = ref(props.q || '')
|
|
63
|
+
const data = ref([])
|
|
64
|
+
const isFetching = ref(false)
|
|
65
|
+
const enter = ref(true)
|
|
66
|
+
const active = ref(0)
|
|
89
67
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
const searchProducts = _.debounce((query_string) => {
|
|
69
|
+
if (!query_string.length) {
|
|
70
|
+
data.value = []
|
|
71
|
+
return
|
|
72
|
+
}
|
|
95
73
|
|
|
96
|
-
|
|
97
|
-
this.enter = false
|
|
98
|
-
window.location.href = product.url
|
|
99
|
-
}
|
|
100
|
-
},
|
|
74
|
+
isFetching.value = true
|
|
101
75
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
76
|
+
Product.search(query_string)
|
|
77
|
+
.then((response) => {
|
|
78
|
+
let products = response.data.slice(0, props.searchLimit)
|
|
79
|
+
data.value = []
|
|
80
|
+
products.forEach((item) => data.value.push(item))
|
|
81
|
+
})
|
|
82
|
+
.finally(() => {
|
|
83
|
+
isFetching.value = false
|
|
105
84
|
})
|
|
85
|
+
}, 250)
|
|
86
|
+
|
|
87
|
+
const onEnter = () => {
|
|
88
|
+
if (enter.value) {
|
|
89
|
+
productSearchForm.value.submit()
|
|
106
90
|
}
|
|
107
91
|
}
|
|
92
|
+
|
|
93
|
+
const onSelected = (product) => {
|
|
94
|
+
enter.value = false
|
|
95
|
+
navigate(product?.url)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
onMounted(() => {
|
|
99
|
+
liveAddEventListener('.search-box .icon', 'click', () => {
|
|
100
|
+
document.forms.productSearchForm.submit()
|
|
101
|
+
})
|
|
102
|
+
})
|
|
108
103
|
</script>
|