ts-glitter 17.2.0 → 17.2.2
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/ed8x60j4nn.json +1 -0
- package/gkh2p2jhta.json +1 -0
- package/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/cms-plugin/pos-pages/models.js +18 -15
- package/lowcode/cms-plugin/pos-pages/models.ts +30 -25
- package/lowcode/cms-plugin/pos-pages/payment-function.js +53 -57
- package/lowcode/cms-plugin/pos-pages/payment-function.ts +92 -100
- package/lowcode/form-view/editor/image-selector.js +7 -3
- package/lowcode/form-view/editor/image-selector.ts +75 -69
- package/lowcode/glitter-base/route/shopping.js +2 -0
- package/lowcode/glitter-base/route/shopping.ts +6 -4
- package/lowcode/official_view_component/official/component.js +1 -3
- package/lowcode/official_view_component/official/component.ts +3 -4
- package/lowcode/public-components/footer/footer-01.js +1 -1
- package/lowcode/public-components/footer/footer-01.ts +1 -1
- package/lowcode/public-components/footer/footer-02.js +1 -1
- package/lowcode/public-components/footer/footer-02.ts +1 -1
- package/lowcode/public-components/footer/footer-03.js +1 -1
- package/lowcode/public-components/footer/footer-03.ts +1 -1
- package/lowcode/public-components/product/pd-card-01.js +22 -11
- package/lowcode/public-components/product/pd-card-01.ts +23 -11
- package/lowcode/public-components/product/pd-card-02.js +22 -11
- package/lowcode/public-components/product/pd-card-02.ts +22 -11
- package/lowcode/public-components/product/pd-card-03.js +22 -11
- package/lowcode/public-components/product/pd-card-03.ts +23 -11
- package/lowcode/public-components/product/product-detail.js +7 -0
- package/lowcode/public-components/product/product-detail.ts +5 -1
- package/lowcode/public-components/user-manager/um-voucher.ts +1 -0
- package/package.json +1 -1
- package/src/api-public/controllers/shop.js +44 -33
- package/src/api-public/controllers/shop.js.map +1 -1
- package/src/api-public/controllers/shop.ts +54 -35
- package/src/api-public/services/shopping.d.ts +2 -1
- package/src/api-public/services/shopping.js +110 -109
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +174 -117
- package/src/index.js +1 -0
- package/src/index.js.map +1 -1
- package/src/index.ts +1 -0
- package/src/seo-config.d.ts +1 -0
- package/src/seo-config.js +40 -1
- package/src/seo-config.js.map +1 -1
- package/src/seo-config.ts +46 -3
- package/src/services/page.ts +0 -1
|
@@ -152,9 +152,9 @@ export const component = Plugin.createComponent(import.meta.url, (glitter: Glitt
|
|
|
152
152
|
|
|
153
153
|
function updatePageConfig(formData: any, type: any, oWidget: any) {
|
|
154
154
|
oWidget && (widget = oWidget);
|
|
155
|
-
const ref=(widget.data.refer_app) ? (widget.data.refer_form_data || data.page_config.formData) : data.page_config.formData
|
|
156
|
-
viewConfig.formData = getFormData(ref);
|
|
155
|
+
const ref=(widget.data.refer_app) ? (widget.data.refer_form_data || data.page_config.formData) : data.page_config.formData;
|
|
157
156
|
(window.parent as any).glitter.share.updated_form_data[`${page_request_config.appName}_${tag}`]=ref;
|
|
157
|
+
viewConfig.formData = getFormData(ref);
|
|
158
158
|
const view = getView();
|
|
159
159
|
(window.parent as any).glitter.share.loading_dialog.dataLoading({visible: true})
|
|
160
160
|
setTimeout(() => {
|
|
@@ -859,7 +859,6 @@ export const component = Plugin.createComponent(import.meta.url, (glitter: Glitt
|
|
|
859
859
|
})
|
|
860
860
|
});
|
|
861
861
|
try {
|
|
862
|
-
console.log(`getPageData-${parent_array.tag}`, parent_array);
|
|
863
862
|
(window as any).glitterInitialHelper.share[`getPageData-${(window as any).appName}-${parent_array.tag}`].data.response.result[0].config = parent_array;
|
|
864
863
|
} catch (error) {
|
|
865
864
|
console.log(`error->`, error)
|
|
@@ -903,6 +902,7 @@ export const component = Plugin.createComponent(import.meta.url, (glitter: Glitt
|
|
|
903
902
|
|
|
904
903
|
}
|
|
905
904
|
}
|
|
905
|
+
|
|
906
906
|
subData.editor_updated_callback && subData.editor_updated_callback(oWidget);
|
|
907
907
|
}
|
|
908
908
|
|
|
@@ -1348,7 +1348,6 @@ font-weight: 700;" onclick="${gvc.event(() => {
|
|
|
1348
1348
|
if (!pageData.template_config || !pageData.template_config.tag || (!pageData.template_config.tag.find((dd: any) => {
|
|
1349
1349
|
return dd === "商品卡片"
|
|
1350
1350
|
}))) {
|
|
1351
|
-
console.log(`pageData.template_config.tag`, pageData.template_config.tag)
|
|
1352
1351
|
if ((gvc.glitter.getUrlParameter('device') === 'mobile') && pageData.template_config.tag.includes('標頭元件')) {
|
|
1353
1352
|
|
|
1354
1353
|
} else if ((gvc.glitter.getUrlParameter('device') !== 'mobile') && pageData.template_config.tag.includes('APP-Header')) {
|
|
@@ -151,6 +151,18 @@ export class ProductCard01 {
|
|
|
151
151
|
}
|
|
152
152
|
`);
|
|
153
153
|
const labelID = glitter.getUUID();
|
|
154
|
+
function getImgSrc(index) {
|
|
155
|
+
const innerText = prod.preview_image[index] || prod.preview_image[0] || ProductCard01.noImageURL;
|
|
156
|
+
let rela_link = innerText;
|
|
157
|
+
if (innerText.includes('size1440_s*px$_')) {
|
|
158
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
159
|
+
if (document.body.clientWidth < dd) {
|
|
160
|
+
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return rela_link;
|
|
165
|
+
}
|
|
154
166
|
return html ` <div
|
|
155
167
|
class="card mb-7 card-border"
|
|
156
168
|
onclick="${gvc.event(() => {
|
|
@@ -192,18 +204,17 @@ export class ProductCard01 {
|
|
|
192
204
|
})}
|
|
193
205
|
<img
|
|
194
206
|
class="card-image-fit-center "
|
|
195
|
-
src="${(
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
200
|
-
if (document.body.clientWidth < dd) {
|
|
201
|
-
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
207
|
+
src="${getImgSrc(0)}"
|
|
208
|
+
onmouseover="${gvc.event((e, event) => {
|
|
209
|
+
if (widget.formData.show_second === 'true') {
|
|
210
|
+
e.src = getImgSrc(1);
|
|
204
211
|
}
|
|
205
|
-
|
|
206
|
-
|
|
212
|
+
})}"
|
|
213
|
+
onmouseleave="${gvc.event((e, event) => {
|
|
214
|
+
if (widget.formData.show_second === 'true') {
|
|
215
|
+
e.src = getImgSrc(0);
|
|
216
|
+
}
|
|
217
|
+
})}"
|
|
207
218
|
/>
|
|
208
219
|
<div class="child add-cart-child">
|
|
209
220
|
<div
|
|
@@ -154,7 +154,20 @@ export class ProductCard01 {
|
|
|
154
154
|
letter-spacing: -0.98px;
|
|
155
155
|
}
|
|
156
156
|
`);
|
|
157
|
+
|
|
157
158
|
const labelID = glitter.getUUID();
|
|
159
|
+
function getImgSrc(index:number){
|
|
160
|
+
const innerText = prod.preview_image[index] || prod.preview_image[0] || ProductCard01.noImageURL;
|
|
161
|
+
let rela_link = innerText;
|
|
162
|
+
if (innerText.includes('size1440_s*px$_')) {
|
|
163
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
164
|
+
if (document.body.clientWidth < dd) {
|
|
165
|
+
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return rela_link;
|
|
170
|
+
}
|
|
158
171
|
return html` <div
|
|
159
172
|
class="card mb-7 card-border"
|
|
160
173
|
onclick="${gvc.event(() => {
|
|
@@ -196,18 +209,17 @@ export class ProductCard01 {
|
|
|
196
209
|
})}
|
|
197
210
|
<img
|
|
198
211
|
class="card-image-fit-center "
|
|
199
|
-
src="${(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
212
|
+
src="${getImgSrc(0)}"
|
|
213
|
+
onmouseover="${gvc.event((e,event)=>{
|
|
214
|
+
if(widget.formData.show_second==='true'){
|
|
215
|
+
e.src=getImgSrc(1)
|
|
216
|
+
}
|
|
217
|
+
})}"
|
|
218
|
+
onmouseleave="${gvc.event((e,event)=>{
|
|
219
|
+
if(widget.formData.show_second==='true'){
|
|
220
|
+
e.src=getImgSrc(0)
|
|
208
221
|
}
|
|
209
|
-
|
|
210
|
-
})()}"
|
|
222
|
+
})}"
|
|
211
223
|
/>
|
|
212
224
|
<div class="child add-cart-child">
|
|
213
225
|
<div
|
|
@@ -141,6 +141,18 @@ export class ProductCard02 {
|
|
|
141
141
|
}
|
|
142
142
|
`);
|
|
143
143
|
const labelID = glitter.getUUID();
|
|
144
|
+
function getImgSrc(index) {
|
|
145
|
+
const innerText = prod.preview_image[index] || prod.preview_image[0] || ProductCard02.noImageURL;
|
|
146
|
+
let rela_link = innerText;
|
|
147
|
+
if (innerText.includes('size1440_s*px$_')) {
|
|
148
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
149
|
+
if (document.body.clientWidth < dd) {
|
|
150
|
+
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
return rela_link;
|
|
155
|
+
}
|
|
144
156
|
return html `<div
|
|
145
157
|
class="card mb-7 card-border"
|
|
146
158
|
style="cursor: pointer"
|
|
@@ -183,18 +195,17 @@ export class ProductCard02 {
|
|
|
183
195
|
})}
|
|
184
196
|
<img
|
|
185
197
|
class="card-image-fit-center"
|
|
186
|
-
src="${(
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
191
|
-
if (document.body.clientWidth < dd) {
|
|
192
|
-
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
193
|
-
}
|
|
194
|
-
});
|
|
198
|
+
src="${getImgSrc(0)}"
|
|
199
|
+
onmouseover="${gvc.event((e, event) => {
|
|
200
|
+
if (widget.formData.show_second === 'true') {
|
|
201
|
+
e.src = getImgSrc(1);
|
|
195
202
|
}
|
|
196
|
-
|
|
197
|
-
|
|
203
|
+
})}"
|
|
204
|
+
onmouseleave="${gvc.event((e, event) => {
|
|
205
|
+
if (widget.formData.show_second === 'true') {
|
|
206
|
+
e.src = getImgSrc(0);
|
|
207
|
+
}
|
|
208
|
+
})}"
|
|
198
209
|
/>
|
|
199
210
|
</div>
|
|
200
211
|
<div
|
|
@@ -144,6 +144,18 @@ export class ProductCard02 {
|
|
|
144
144
|
}
|
|
145
145
|
`);
|
|
146
146
|
const labelID = glitter.getUUID();
|
|
147
|
+
function getImgSrc(index:number){
|
|
148
|
+
const innerText = prod.preview_image[index] || prod.preview_image[0] || ProductCard02.noImageURL;
|
|
149
|
+
let rela_link = innerText;
|
|
150
|
+
if (innerText.includes('size1440_s*px$_')) {
|
|
151
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
152
|
+
if (document.body.clientWidth < dd) {
|
|
153
|
+
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
return rela_link;
|
|
158
|
+
}
|
|
147
159
|
return html`<div
|
|
148
160
|
class="card mb-7 card-border"
|
|
149
161
|
style="cursor: pointer"
|
|
@@ -187,18 +199,17 @@ export class ProductCard02 {
|
|
|
187
199
|
})}
|
|
188
200
|
<img
|
|
189
201
|
class="card-image-fit-center"
|
|
190
|
-
src="${(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
202
|
+
src="${getImgSrc(0)}"
|
|
203
|
+
onmouseover="${gvc.event((e,event)=>{
|
|
204
|
+
if(widget.formData.show_second==='true'){
|
|
205
|
+
e.src=getImgSrc(1)
|
|
206
|
+
}
|
|
207
|
+
})}"
|
|
208
|
+
onmouseleave="${gvc.event((e,event)=>{
|
|
209
|
+
if(widget.formData.show_second==='true'){
|
|
210
|
+
e.src=getImgSrc(0)
|
|
199
211
|
}
|
|
200
|
-
|
|
201
|
-
})()}"
|
|
212
|
+
})}"
|
|
202
213
|
/>
|
|
203
214
|
</div>
|
|
204
215
|
<div
|
|
@@ -145,6 +145,18 @@ export class ProductCard03 {
|
|
|
145
145
|
}
|
|
146
146
|
`);
|
|
147
147
|
const labelID = glitter.getUUID();
|
|
148
|
+
function getImgSrc(index) {
|
|
149
|
+
const innerText = prod.preview_image[index] || prod.preview_image[0] || ProductCard03.noImageURL;
|
|
150
|
+
let rela_link = innerText;
|
|
151
|
+
if (innerText.includes('size1440_s*px$_')) {
|
|
152
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
153
|
+
if (document.body.clientWidth < dd) {
|
|
154
|
+
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return rela_link;
|
|
159
|
+
}
|
|
148
160
|
return html `
|
|
149
161
|
<div
|
|
150
162
|
class="card mb-7 card-border"
|
|
@@ -190,18 +202,17 @@ export class ProductCard03 {
|
|
|
190
202
|
})}
|
|
191
203
|
<img
|
|
192
204
|
class="card-image-fit-center"
|
|
193
|
-
src="${(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
198
|
-
if (document.body.clientWidth < dd) {
|
|
199
|
-
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
205
|
+
src="${getImgSrc(0)}"
|
|
206
|
+
onmouseover="${gvc.event((e, event) => {
|
|
207
|
+
if (widget.formData.show_second === 'true') {
|
|
208
|
+
e.src = getImgSrc(1);
|
|
202
209
|
}
|
|
203
|
-
|
|
204
|
-
|
|
210
|
+
})}"
|
|
211
|
+
onmouseleave="${gvc.event((e, event) => {
|
|
212
|
+
if (widget.formData.show_second === 'true') {
|
|
213
|
+
e.src = getImgSrc(0);
|
|
214
|
+
}
|
|
215
|
+
})}"
|
|
205
216
|
/>
|
|
206
217
|
</div>
|
|
207
218
|
<div
|
|
@@ -150,6 +150,19 @@ export class ProductCard03 {
|
|
|
150
150
|
`);
|
|
151
151
|
|
|
152
152
|
const labelID = glitter.getUUID();
|
|
153
|
+
|
|
154
|
+
function getImgSrc(index:number){
|
|
155
|
+
const innerText = prod.preview_image[index] || prod.preview_image[0] || ProductCard03.noImageURL;
|
|
156
|
+
let rela_link = innerText;
|
|
157
|
+
if (innerText.includes('size1440_s*px$_')) {
|
|
158
|
+
[150, 600, 1200, 1440].reverse().map((dd) => {
|
|
159
|
+
if (document.body.clientWidth < dd) {
|
|
160
|
+
rela_link = innerText.replace('size1440_s*px$_', `size${dd}_s*px$_`);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
return rela_link;
|
|
165
|
+
}
|
|
153
166
|
return html`
|
|
154
167
|
<div
|
|
155
168
|
class="card mb-7 card-border"
|
|
@@ -197,18 +210,17 @@ export class ProductCard03 {
|
|
|
197
210
|
})}
|
|
198
211
|
<img
|
|
199
212
|
class="card-image-fit-center"
|
|
200
|
-
src="${(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
213
|
+
src="${getImgSrc(0)}"
|
|
214
|
+
onmouseover="${gvc.event((e,event)=>{
|
|
215
|
+
if(widget.formData.show_second==='true'){
|
|
216
|
+
e.src=getImgSrc(1)
|
|
217
|
+
}
|
|
218
|
+
})}"
|
|
219
|
+
onmouseleave="${gvc.event((e,event)=>{
|
|
220
|
+
if(widget.formData.show_second==='true'){
|
|
221
|
+
e.src=getImgSrc(0)
|
|
209
222
|
}
|
|
210
|
-
|
|
211
|
-
})()}"
|
|
223
|
+
})}"
|
|
212
224
|
/>
|
|
213
225
|
</div>
|
|
214
226
|
<div
|
|
@@ -395,6 +395,13 @@ export class ProductDetail {
|
|
|
395
395
|
(vm.data.content.seo.domain || vm.data.content.title),
|
|
396
396
|
(_b = window.home_seo.title_suffix) !== null && _b !== void 0 ? _b : "",
|
|
397
397
|
].join(''));
|
|
398
|
+
const json_ld = document.querySelector('script[type="application/ld+json"]');
|
|
399
|
+
if (json_ld) {
|
|
400
|
+
json_ld.remove();
|
|
401
|
+
}
|
|
402
|
+
;
|
|
403
|
+
document.querySelector('head').innerHTML += vm.data.json_ld;
|
|
404
|
+
console.log(`(vm.data as any).json_ld=>`, vm.data.json_ld);
|
|
398
405
|
}
|
|
399
406
|
catch (e) {
|
|
400
407
|
vm.data = {};
|
|
@@ -445,7 +445,11 @@ export class ProductDetail {
|
|
|
445
445
|
(vm.data.content.seo.domain || vm.data.content.title),
|
|
446
446
|
(window as any).home_seo.title_suffix ?? "",
|
|
447
447
|
].join(''));
|
|
448
|
-
|
|
448
|
+
//如有原先的JSON LD
|
|
449
|
+
const json_ld=document.querySelector('script[type="application/ld+json"]');
|
|
450
|
+
if(json_ld){json_ld.remove()};
|
|
451
|
+
(document.querySelector('head') as any).innerHTML+=(vm.data as any).json_ld;
|
|
452
|
+
console.log(`(vm.data as any).json_ld=>`,(vm.data as any).json_ld)
|
|
449
453
|
} catch (e) {
|
|
450
454
|
(vm.data as any) = {};
|
|
451
455
|
}
|
package/package.json
CHANGED
|
@@ -460,48 +460,57 @@ router.post('/returnOrder', async (req, resp) => {
|
|
|
460
460
|
}
|
|
461
461
|
});
|
|
462
462
|
router.get('/voucher', async (req, resp) => {
|
|
463
|
-
var _a, _b;
|
|
464
463
|
try {
|
|
465
464
|
let query = [`(content->>'$.type'='voucher')`];
|
|
466
|
-
req.query.search
|
|
465
|
+
if (req.query.search) {
|
|
466
|
+
query.push(`(UPPER(JSON_UNQUOTE(JSON_EXTRACT(content, '$.title'))) LIKE UPPER('%${req.query.search}%'))`);
|
|
467
|
+
}
|
|
467
468
|
if (req.query.voucher_type) {
|
|
468
469
|
query.push(`(content->>'$.reBackType'='${req.query.voucher_type}')`);
|
|
469
470
|
}
|
|
470
|
-
const
|
|
471
|
-
|
|
472
|
-
|
|
471
|
+
const shopping = new shopping_1.Shopping(req.get('g-app'), req.body.token);
|
|
472
|
+
const vouchers = await shopping.querySql(query, {
|
|
473
|
+
page: Number(req.query.page) || 0,
|
|
474
|
+
limit: Number(req.query.limit) || 50,
|
|
473
475
|
id: req.query.id,
|
|
474
476
|
});
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
if (dd.target === 'levels') {
|
|
485
|
-
if (userLevels[0]) {
|
|
486
|
-
return dd.targetList.includes(userLevels[0].data.id);
|
|
487
|
-
}
|
|
488
|
-
return false;
|
|
489
|
-
}
|
|
490
|
-
if (dd.target === 'group') {
|
|
491
|
-
if (!groupList.result) {
|
|
492
|
-
return false;
|
|
493
|
-
}
|
|
494
|
-
let pass = false;
|
|
495
|
-
for (const group of groupList.data.filter((item) => dd.targetList.includes(item.type))) {
|
|
496
|
-
if (!pass && group.users.some((item) => item.userID === req.body.token.userID)) {
|
|
497
|
-
pass = true;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
return pass;
|
|
501
|
-
}
|
|
502
|
-
return true;
|
|
477
|
+
const isManager = await ut_permission_1.UtPermission.isManager(req);
|
|
478
|
+
if (isManager && !req.query.user_email) {
|
|
479
|
+
return response_1.default.succ(resp, vouchers);
|
|
480
|
+
}
|
|
481
|
+
if (req.query.date_confirm === 'true') {
|
|
482
|
+
vouchers.data = vouchers.data.filter((voucher) => {
|
|
483
|
+
const { start_ISO_Date, end_ISO_Date } = voucher.content;
|
|
484
|
+
const now = new Date().getTime();
|
|
485
|
+
return new Date(start_ISO_Date).getTime() < now && (!end_ISO_Date || new Date(end_ISO_Date).getTime() > now);
|
|
503
486
|
});
|
|
504
487
|
}
|
|
488
|
+
const userClass = new user_js_1.User(req.get('g-app'));
|
|
489
|
+
const groupList = await userClass.getUserGroups();
|
|
490
|
+
const userID = await (async () => {
|
|
491
|
+
if (!isManager)
|
|
492
|
+
return req.body.token.userID;
|
|
493
|
+
if (req.query.user_email === 'guest')
|
|
494
|
+
return -1;
|
|
495
|
+
const userData = await userClass.getUserData(req.query.user_email, 'email_or_phone');
|
|
496
|
+
return userData.userID;
|
|
497
|
+
})();
|
|
498
|
+
const userLevels = await userClass.getUserLevel([{ userId: userID }]);
|
|
499
|
+
vouchers.data = vouchers.data.filter((voucher) => {
|
|
500
|
+
const { target, targetList } = voucher.content;
|
|
501
|
+
switch (target) {
|
|
502
|
+
case 'customer':
|
|
503
|
+
return targetList.includes(userID);
|
|
504
|
+
case 'levels':
|
|
505
|
+
return userLevels[0] ? targetList.includes(userLevels[0].data.id) : false;
|
|
506
|
+
case 'group':
|
|
507
|
+
if (!groupList.result)
|
|
508
|
+
return false;
|
|
509
|
+
return groupList.data.some((group) => targetList.includes(group.type) && group.users.some((user) => user.userID === userID));
|
|
510
|
+
default:
|
|
511
|
+
return true;
|
|
512
|
+
}
|
|
513
|
+
});
|
|
505
514
|
return response_1.default.succ(resp, vouchers);
|
|
506
515
|
}
|
|
507
516
|
catch (err) {
|
|
@@ -999,12 +1008,14 @@ router.post('/pos/checkout', async (req, resp) => {
|
|
|
999
1008
|
customer_info: req.body.customer_info,
|
|
1000
1009
|
discount: req.body.discount,
|
|
1001
1010
|
total: req.body.total,
|
|
1011
|
+
use_rebate: req.body.use_rebate,
|
|
1002
1012
|
pay_status: req.body.pay_status,
|
|
1003
1013
|
code_array: req.body.code_array,
|
|
1004
1014
|
pos_info: req.body.pos_info,
|
|
1005
1015
|
pos_store: req.body.pos_store,
|
|
1006
1016
|
invoice_select: req.body.invoice_select,
|
|
1007
1017
|
pre_order: req.body.pre_order,
|
|
1018
|
+
voucherList: req.body.voucherList,
|
|
1008
1019
|
}, 'POS'));
|
|
1009
1020
|
}
|
|
1010
1021
|
try {
|