|
|
@@ -1,13 +1,12 @@
|
|
1
|
1
|
<template>
|
|
2
|
2
|
<ion-header>
|
|
3
|
3
|
<ion-toolbar>
|
|
4
|
|
- <ion-buttons slot="start">
|
|
5
|
|
- <ion-button color="medium" @click="cancel">Cancel</ion-button>
|
|
6
|
|
- </ion-buttons>
|
|
7
|
|
- <ion-title>Modal</ion-title>
|
|
8
|
|
- <ion-buttons slot="end">
|
|
9
|
|
- <ion-button @click="confirm">Confirm</ion-button>
|
|
10
|
|
- </ion-buttons>
|
|
|
4
|
+ <ion-buttons slot="start">
|
|
|
5
|
+ <ion-button @click="cancel">
|
|
|
6
|
+ <ion-icon :icon="arrowBack"></ion-icon>
|
|
|
7
|
+ </ion-button>
|
|
|
8
|
+ </ion-buttons>
|
|
|
9
|
+ <ion-title>รายละเอียด</ion-title>
|
|
11
|
10
|
</ion-toolbar>
|
|
12
|
11
|
</ion-header>
|
|
13
|
12
|
<ion-content class="ion-padding">
|
|
|
@@ -33,7 +32,69 @@
|
|
33
|
32
|
</ion-col>
|
|
34
|
33
|
</ion-row>
|
|
35
|
34
|
</ion-grid>
|
|
36
|
|
- <h1>{{ product.name }} {{ product.id }}</h1>
|
|
|
35
|
+
|
|
|
36
|
+ <h1>{{ product.name }}</h1>
|
|
|
37
|
+ <ion-item>
|
|
|
38
|
+ <ion-label color="danger">
|
|
|
39
|
+ <h1>{{product.price}} <s>{{product.list_price}}</s></h1>
|
|
|
40
|
+ <p><b>SKU</b> {{product.sku}} <b>Qty</b> {{product.qty}} </p>
|
|
|
41
|
+ </ion-label>
|
|
|
42
|
+ </ion-item>
|
|
|
43
|
+
|
|
|
44
|
+ <ion-grid class="ion-padding">
|
|
|
45
|
+ <ion-row id="open-vars" expand="block" @click="">
|
|
|
46
|
+ <ion-col>
|
|
|
47
|
+ <ion-label><b>ตัวเลือกสินค้า</b></ion-label>
|
|
|
48
|
+ </ion-col>
|
|
|
49
|
+ <ion-col>
|
|
|
50
|
+ <ion-label>{{varsTxt}}</ion-label>
|
|
|
51
|
+ </ion-col>
|
|
|
52
|
+ </ion-row>
|
|
|
53
|
+ <div v-for="pv in product.product_variance_options" :key='pv.id'>
|
|
|
54
|
+ <ion-row>
|
|
|
55
|
+ <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>
|
|
|
58
|
+ </ion-col>
|
|
|
59
|
+ </div>
|
|
|
60
|
+ </ion-row>
|
|
|
61
|
+ </div>
|
|
|
62
|
+ </ion-grid>
|
|
|
63
|
+
|
|
|
64
|
+ <ion-modal ref="modal" trigger="open-vars" :initial-breakpoint="0.80" :breakpoints="[0, 0.80, 0.5, 0.75]">
|
|
|
65
|
+ <ion-content class="ion-padding">
|
|
|
66
|
+
|
|
|
67
|
+ <ion-grid class="ion-padding">
|
|
|
68
|
+ <ion-row>
|
|
|
69
|
+ <ion-col size="auto">
|
|
|
70
|
+ <div style="width: 100px">
|
|
|
71
|
+ <img v-if="product.cover" :src="product.cover" />
|
|
|
72
|
+ <img v-else src="https://ionicframework.com/docs/img/demos/thumbnail.svg" />
|
|
|
73
|
+ </div>
|
|
|
74
|
+ </ion-col>
|
|
|
75
|
+
|
|
|
76
|
+ <ion-col>
|
|
|
77
|
+ <h1>{{product.price}} <s>{{product.list_price}}</s></h1>
|
|
|
78
|
+ <p><b>Qty</b> {{product.qty}} </p>
|
|
|
79
|
+ </ion-col>
|
|
|
80
|
+
|
|
|
81
|
+ </ion-row>
|
|
|
82
|
+
|
|
|
83
|
+ <div v-for="pv in product.product_variance_options" :key='pv.id'>
|
|
|
84
|
+ <ion-label>{{pv.name}}: {{pv.id}}</ion-label>
|
|
|
85
|
+ <ion-row>
|
|
|
86
|
+ <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>
|
|
|
90
|
+ </ion-col>
|
|
|
91
|
+ </div>
|
|
|
92
|
+ </ion-row>
|
|
|
93
|
+ </div>
|
|
|
94
|
+ </ion-grid>
|
|
|
95
|
+ </ion-content>
|
|
|
96
|
+ </ion-modal>
|
|
|
97
|
+
|
|
37
|
98
|
<!--
|
|
38
|
99
|
{{ readmore }} -->
|
|
39
|
100
|
<ion-text v-html="short_desc" v-if="!readmore" />
|
|
|
@@ -63,9 +124,15 @@ import {
|
|
63
|
124
|
IonText,
|
|
64
|
125
|
modalController,
|
|
65
|
126
|
onIonViewWillEnter,
|
|
66
|
|
- IonThumbnail
|
|
|
127
|
+ IonThumbnail,
|
|
|
128
|
+ IonIcon,
|
|
|
129
|
+ IonList,
|
|
|
130
|
+ IonListHeader,
|
|
|
131
|
+ IonModal,
|
|
|
132
|
+ IonAvatar,
|
|
67
|
133
|
} from '@ionic/vue';
|
|
68
|
134
|
|
|
|
135
|
+import { arrowBack } from 'ionicons/icons';
|
|
69
|
136
|
import { VueShowdown } from 'vue-showdown';
|
|
70
|
137
|
import { ReadMore } from 'vue-read-more';
|
|
71
|
138
|
import { ref, onMounted } from 'vue'
|
|
|
@@ -88,6 +155,10 @@ let description = ref(null)
|
|
88
|
155
|
let short_desc = ref(null)
|
|
89
|
156
|
let readmore = ref(false)
|
|
90
|
157
|
|
|
|
158
|
+let myItem = ref([]);
|
|
|
159
|
+let myOrder = ref(null);
|
|
|
160
|
+let varsTxt = ref("");
|
|
|
161
|
+
|
|
91
|
162
|
//console.log(pid)
|
|
92
|
163
|
|
|
93
|
164
|
let name = ref("xxx")
|
|
|
@@ -97,6 +168,49 @@ function cancel(){
|
|
97
|
168
|
function confirm(){
|
|
98
|
169
|
return modalController.dismiss(name.value, 'confirm');
|
|
99
|
170
|
}
|
|
|
171
|
+
|
|
|
172
|
+function vSelect(var_value, prod_vars){
|
|
|
173
|
+
|
|
|
174
|
+ let rs = myItem.value.findIndex(({product_variance}) => product_variance === var_value.product_variance);
|
|
|
175
|
+ if (rs >= 0){
|
|
|
176
|
+ myItem.value[rs] = { 'product_variance': var_value.product_variance, 'var_value' : var_value.value};
|
|
|
177
|
+ } else {
|
|
|
178
|
+ myItem.value.push({ 'product_variance': var_value.product_variance, 'var_value' : var_value.value});
|
|
|
179
|
+ }
|
|
|
180
|
+ console.log(rs);
|
|
|
181
|
+ let vars = myItem.value.map((e) => e.var_value);
|
|
|
182
|
+ console.log(myItem);
|
|
|
183
|
+ console.log(vars);
|
|
|
184
|
+ let stock = prod_vars.find(({values}) => JSON.stringify(values.sort()) === JSON.stringify(vars.sort()));
|
|
|
185
|
+ console.log(stock);
|
|
|
186
|
+ if(var_value.image) {
|
|
|
187
|
+ product.value['cover'] = var_value.image;
|
|
|
188
|
+ }
|
|
|
189
|
+ if(stock){
|
|
|
190
|
+ console.log('stock found');
|
|
|
191
|
+ myOrder.value = stock;
|
|
|
192
|
+ product.value['qty'] = stock.qty;
|
|
|
193
|
+ product.value['price'] = stock.price;
|
|
|
194
|
+ product.value['list_price'] = stock.list_price;
|
|
|
195
|
+ product.value['sku'] = stock.sku;
|
|
|
196
|
+ product.value['currency'] = stock.currency;
|
|
|
197
|
+ }
|
|
|
198
|
+
|
|
|
199
|
+ return "ok";
|
|
|
200
|
+}
|
|
|
201
|
+
|
|
|
202
|
+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);
|
|
|
206
|
+ if(rs >= 0) {
|
|
|
207
|
+ console.log('my found')
|
|
|
208
|
+ return 'primary';
|
|
|
209
|
+ } else {
|
|
|
210
|
+ return 'light'
|
|
|
211
|
+ }
|
|
|
212
|
+}
|
|
|
213
|
+
|
|
100
|
214
|
onMounted(async () => {
|
|
101
|
215
|
//onIonViewWillEnter(() => {
|
|
102
|
216
|
console.log("on mounted")
|
|
|
@@ -105,14 +219,20 @@ onMounted(async () => {
|
|
105
|
219
|
product.value = res.data
|
|
106
|
220
|
pid.value = props.pid
|
|
107
|
221
|
console.log("description")
|
|
108
|
|
- console.log(description)
|
|
|
222
|
+ //console.log(description)
|
|
109
|
223
|
//readmore(description)
|
|
110
|
|
- console.log(res.data)
|
|
|
224
|
+ //console.log(res.data)
|
|
111
|
225
|
description.value = marked(res.data.description)
|
|
112
|
226
|
short_desc.value = truncateMarkdown(res.data.description, { limit: 300, ellipsis: true })
|
|
113
|
227
|
let sd = truncateMarkdown(res.data.description, { limit: 300, ellipsis: true })
|
|
114
|
228
|
short_desc.value = marked(sd)
|
|
115
|
|
- console.log(description.value)
|
|
|
229
|
+
|
|
|
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());
|
|
|
233
|
+ }
|
|
|
234
|
+ console.log(varsTxt)
|
|
|
235
|
+ //console.log(description.value)
|
|
116
|
236
|
})
|
|
117
|
237
|
|
|
118
|
238
|
</script>
|