|
|
@@ -1,22 +1,20 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<ion-header>
|
|
3
|
3
|
<ion-toolbar>
|
|
4
|
|
- <ion-buttons slot="start">
|
|
|
4
|
+ <ion-buttons>
|
|
5
|
5
|
<ion-button @click="cancel">
|
|
6
|
6
|
<ion-icon :icon="arrowBack"></ion-icon>
|
|
7
|
7
|
</ion-button>
|
|
8
|
|
- </ion-buttons>
|
|
9
|
8
|
<ion-title>รายละเอียด</ion-title>
|
|
|
9
|
+ <ion-button slot="end" id='cartBtn' @click="cancel" router-link="/cart">
|
|
|
10
|
+ <ion-icon :icon="cart" slot='start'></ion-icon>
|
|
|
11
|
+ <ion-badge slot="end" id='bd'>22</ion-badge>
|
|
|
12
|
+ </ion-button>
|
|
|
13
|
+ </ion-buttons>
|
|
10
|
14
|
</ion-toolbar>
|
|
11
|
15
|
</ion-header>
|
|
12
|
16
|
<ion-content class="ion-padding">
|
|
13
|
|
- <!--<ion-item>-->
|
|
14
|
|
- <!--<ion-label position="stacked">Your name</ion-label>-->
|
|
15
|
|
- <!--{{ name }}-->
|
|
16
|
17
|
|
|
17
|
|
- <!--<strong>{{ pid }}</strong>-->
|
|
18
|
|
- <!--<ion-input v-model="name" placeholder="Your name" label='xx'></ion-input>-->
|
|
19
|
|
- <!--</ion-item>-->
|
|
20
|
18
|
<template v-if="product">
|
|
21
|
19
|
<swiper>
|
|
22
|
20
|
<swiper-slide v-for="p in product.product_photos">
|
|
|
@@ -40,27 +38,33 @@
|
|
40
|
38
|
<p><b>SKU</b> {{product.sku}} <b>Qty</b> {{product.qty}} </p>
|
|
41
|
39
|
</ion-label>
|
|
42
|
40
|
</ion-item>
|
|
43
|
|
-
|
|
44
|
|
- <ion-grid class="ion-padding">
|
|
45
|
|
- <ion-row id="open-vars" expand="block" @click="">
|
|
|
41
|
+ <ion-grid class="ion-padding" id="open-vars" expand="block" @click="">
|
|
|
42
|
+ <ion-row >
|
|
46
|
43
|
<ion-col>
|
|
47
|
44
|
<ion-label><b>ตัวเลือกสินค้า</b></ion-label>
|
|
48
|
45
|
</ion-col>
|
|
49
|
46
|
<ion-col>
|
|
50
|
|
- <ion-label>{{varsTxt}}</ion-label>
|
|
|
47
|
+ <ion-label v-if="myOrder"><p v-for="(m, i) in myOrder.values">{{myOrder.keys[i]}}: {{m}}</p></ion-label>
|
|
|
48
|
+ <ion-label v-else>{{varsTxt}}</ion-label>
|
|
51
|
49
|
</ion-col>
|
|
52
|
50
|
</ion-row>
|
|
53
|
51
|
<div v-for="pv in product.product_variance_options" :key='pv.id'>
|
|
54
|
52
|
<ion-row>
|
|
55
|
53
|
<div v-for="(var_value, idx) in pv.var_values">
|
|
56
|
|
- <ion-col>
|
|
57
|
|
- <ion-img v-if="var_value.image" :src="var_value.image" style="height:40px" class="ion-padding-end" @click="vSelect(var_value, product.prod_vars)"></ion-img>
|
|
|
54
|
+ <ion-col size="6">
|
|
|
55
|
+ <ion-img v-if="var_value.image" :src="var_value.image" style="height:40px;"
|
|
|
56
|
+ class="ion-padding-end"
|
|
|
57
|
+ :class="isSelect(var_value) ? 'img-active' : ''"
|
|
|
58
|
+ @click=""
|
|
|
59
|
+ ></ion-img>
|
|
58
|
60
|
</ion-col>
|
|
59
|
61
|
</div>
|
|
60
|
62
|
</ion-row>
|
|
61
|
63
|
</div>
|
|
62
|
64
|
</ion-grid>
|
|
63
|
65
|
|
|
|
66
|
+
|
|
|
67
|
+
|
|
64
|
68
|
<ion-modal ref="modal" trigger="open-vars" :initial-breakpoint="0.80" :breakpoints="[0, 0.80, 0.5, 0.75]">
|
|
65
|
69
|
<ion-content class="ion-padding">
|
|
66
|
70
|
|
|
|
@@ -75,22 +79,42 @@
|
|
75
|
79
|
|
|
76
|
80
|
<ion-col>
|
|
77
|
81
|
<h1>{{product.price}} <s>{{product.list_price}}</s></h1>
|
|
78
|
|
- <p><b>Qty</b> {{product.qty}} </p>
|
|
|
82
|
+ <p v-if="product.qty"><b>Qty</b> {{product.qty}} </p>
|
|
79
|
83
|
</ion-col>
|
|
80
|
84
|
|
|
81
|
85
|
</ion-row>
|
|
82
|
86
|
|
|
83
|
87
|
<div v-for="pv in product.product_variance_options" :key='pv.id'>
|
|
84
|
|
- <ion-label>{{pv.name}}: {{pv.id}}</ion-label>
|
|
|
88
|
+ <ion-label>{{pv.name}}</ion-label>
|
|
85
|
89
|
<ion-row>
|
|
86
|
90
|
<div v-for="(var_value, idx) in pv.var_values">
|
|
87
|
|
- <ion-col>
|
|
88
|
|
- <ion-img v-if="var_value.image" :src="var_value.image" style="height:40px" class="ion-padding-end" @click="vSelect(var_value, product.prod_vars)"></ion-img>
|
|
89
|
|
- <ion-button v-else :color="isSelect(var_value)" @click="vSelect(var_value, product.prod_vars)">{{var_value.value}}</ion-button>
|
|
|
91
|
+ <ion-col size="6">
|
|
|
92
|
+ <ion-img v-if="var_value.image" :src="var_value.image" style="height:40px;" :class="isSelect(var_value) ? 'img-active' : ''" class="ion-padding-end" @click="vSelect(var_value, product.prod_vars)"></ion-img>
|
|
|
93
|
+ <ion-button v-else :color=" isSelect(var_value) ? 'primary' : 'light' " @click="vSelect(var_value, product.prod_vars)">{{var_value.value}}</ion-button>
|
|
90
|
94
|
</ion-col>
|
|
91
|
95
|
</div>
|
|
92
|
96
|
</ion-row>
|
|
93
|
97
|
</div>
|
|
|
98
|
+ <hr/>
|
|
|
99
|
+ <ion-item lines="none">
|
|
|
100
|
+ <ion-label>จำนวน</ion-label>
|
|
|
101
|
+ <ion-button slot="end" @click="stepQty(false)">
|
|
|
102
|
+ <ion-icon slot="icon-only" :icon="removeOutline"></ion-icon>
|
|
|
103
|
+ </ion-button>
|
|
|
104
|
+ <ion-input
|
|
|
105
|
+ slot="end"
|
|
|
106
|
+ aria-label=""
|
|
|
107
|
+ class="custom"
|
|
|
108
|
+ :maxlength="3"
|
|
|
109
|
+ v-model="qty"
|
|
|
110
|
+ ></ion-input>
|
|
|
111
|
+ <ion-button slot="end" @click="stepQty(true)">
|
|
|
112
|
+ <ion-icon slot="icon-only" :icon="addOutline"></ion-icon>
|
|
|
113
|
+ </ion-button>
|
|
|
114
|
+ </ion-item>
|
|
|
115
|
+ <ion-item lines="none">
|
|
|
116
|
+ <ion-button color="danger">Add to cart</ion-button>
|
|
|
117
|
+ </ion-item>
|
|
94
|
118
|
</ion-grid>
|
|
95
|
119
|
</ion-content>
|
|
96
|
120
|
</ion-modal>
|
|
|
@@ -130,9 +154,10 @@ import {
|
|
130
|
154
|
IonListHeader,
|
|
131
|
155
|
IonModal,
|
|
132
|
156
|
IonAvatar,
|
|
|
157
|
+ IonBadge
|
|
133
|
158
|
} from '@ionic/vue';
|
|
134
|
159
|
|
|
135
|
|
-import { arrowBack } from 'ionicons/icons';
|
|
|
160
|
+import { arrowBack, removeOutline, addOutline, cart } from 'ionicons/icons';
|
|
136
|
161
|
import { VueShowdown } from 'vue-showdown';
|
|
137
|
162
|
import { ReadMore } from 'vue-read-more';
|
|
138
|
163
|
import { ref, onMounted } from 'vue'
|
|
|
@@ -159,6 +184,8 @@ let myItem = ref([]);
|
|
159
|
184
|
let myOrder = ref(null);
|
|
160
|
185
|
let varsTxt = ref("");
|
|
161
|
186
|
|
|
|
187
|
+const qty = ref(0)
|
|
|
188
|
+
|
|
162
|
189
|
//console.log(pid)
|
|
163
|
190
|
|
|
164
|
191
|
let name = ref("xxx")
|
|
|
@@ -200,17 +227,37 @@ function vSelect(var_value, prod_vars){
|
|
200
|
227
|
}
|
|
201
|
228
|
|
|
202
|
229
|
function isSelect(v){
|
|
203
|
|
- console.log('SSSSSS',myItem.value);
|
|
204
|
|
- console.log(v);
|
|
205
|
|
- let rs = myItem.value.findIndex(({var_value}) => var_value === v.value);
|
|
|
230
|
+ //console.log('SSSSSS',myItem.value);
|
|
|
231
|
+ //console.log('vvvv',v);
|
|
|
232
|
+ let rs = myItem.value.findIndex((el) => el.var_value === v.value && el.product_variance === v.product_variance);
|
|
206
|
233
|
if(rs >= 0) {
|
|
207
|
234
|
console.log('my found')
|
|
208
|
|
- return 'primary';
|
|
|
235
|
+ return true;
|
|
209
|
236
|
} else {
|
|
210
|
|
- return 'light'
|
|
|
237
|
+ return false;
|
|
211
|
238
|
}
|
|
212
|
239
|
}
|
|
213
|
240
|
|
|
|
241
|
+function stepQty(isUp) {
|
|
|
242
|
+
|
|
|
243
|
+ if(isUp && product.value['qty'] && qty.value < product.value['qty']) {
|
|
|
244
|
+ qty.value++
|
|
|
245
|
+ console.log('step up')
|
|
|
246
|
+ }
|
|
|
247
|
+
|
|
|
248
|
+ if(!isUp && qty.value > 0 ) {
|
|
|
249
|
+ qty.value--
|
|
|
250
|
+ }
|
|
|
251
|
+ console.log('step down')
|
|
|
252
|
+}
|
|
|
253
|
+
|
|
|
254
|
+function addCart() {
|
|
|
255
|
+}
|
|
|
256
|
+
|
|
|
257
|
+function goCartPage() {
|
|
|
258
|
+}
|
|
|
259
|
+
|
|
|
260
|
+
|
|
214
|
261
|
onMounted(async () => {
|
|
215
|
262
|
//onIonViewWillEnter(() => {
|
|
216
|
263
|
console.log("on mounted")
|
|
|
@@ -227,12 +274,48 @@ onMounted(async () => {
|
|
227
|
274
|
let sd = truncateMarkdown(res.data.description, { limit: 300, ellipsis: true })
|
|
228
|
275
|
short_desc.value = marked(sd)
|
|
229
|
276
|
|
|
230
|
|
- for(let pv of product.value.product_variance_options){
|
|
231
|
|
- varsTxt.value = varsTxt.value + ' ' + pv.var_values.length + ' ' + pv.name;
|
|
232
|
|
- console.log(pv.name.toString());
|
|
|
277
|
+ let i = 0
|
|
|
278
|
+ for( let pv of product.value.product_variance_options ){
|
|
|
279
|
+ if(i == 0){
|
|
|
280
|
+ myItem.value.push({ 'product_variance': pv.var_values[0].product_variance, 'var_value' : pv.var_values[0].value});
|
|
|
281
|
+ product.value['cover'] = pv.var_values[0].image;
|
|
|
282
|
+ console.log('img = ',pv.var_values[0].image)
|
|
|
283
|
+ console.log(pv);
|
|
|
284
|
+ }
|
|
|
285
|
+ i++
|
|
|
286
|
+ varsTxt.value = varsTxt.value + ' ' + pv.var_values.length + ' ' + pv.name;
|
|
|
287
|
+ console.log(pv.name.toString());
|
|
233
|
288
|
}
|
|
|
289
|
+
|
|
234
|
290
|
console.log(varsTxt)
|
|
235
|
291
|
//console.log(description.value)
|
|
236
|
292
|
})
|
|
237
|
293
|
|
|
238
|
294
|
</script>
|
|
|
295
|
+
|
|
|
296
|
+
|
|
|
297
|
+<style>
|
|
|
298
|
+ .img-active {
|
|
|
299
|
+ border: 2px solid red;
|
|
|
300
|
+ }
|
|
|
301
|
+
|
|
|
302
|
+ hr {
|
|
|
303
|
+ margin-top: 1rem;
|
|
|
304
|
+ margin-bottom: 1rem;
|
|
|
305
|
+ border: 0;
|
|
|
306
|
+ border-top: 1px solid rgba(0, 0, 0, 0.1);
|
|
|
307
|
+ }
|
|
|
308
|
+
|
|
|
309
|
+ ion-input.custom {
|
|
|
310
|
+
|
|
|
311
|
+ background: #d9d9d9;
|
|
|
312
|
+ color: #000;
|
|
|
313
|
+ width: 50px;
|
|
|
314
|
+ height: 50px;
|
|
|
315
|
+ text-align: center;
|
|
|
316
|
+ padding-bottom: 1px;
|
|
|
317
|
+ padding-end: 1px;
|
|
|
318
|
+ padding-start: 1px;
|
|
|
319
|
+ padding-top: 1px;
|
|
|
320
|
+ }
|
|
|
321
|
+</style>
|