ts-glitter 14.3.9 → 14.4.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.
Files changed (51) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-product.js +22 -20
  4. package/lowcode/backend-manager/bg-product.ts +85 -73
  5. package/lowcode/backend-manager/bg-recommend.js +31 -28
  6. package/lowcode/backend-manager/bg-recommend.ts +31 -28
  7. package/lowcode/cms-plugin/ai-message.ts +2 -1
  8. package/lowcode/cms-plugin/filter-options.js +6 -4
  9. package/lowcode/cms-plugin/filter-options.ts +8 -6
  10. package/lowcode/cms-plugin/module/product-excel.js +35 -14
  11. package/lowcode/cms-plugin/module/product-excel.ts +40 -15
  12. package/lowcode/cms-plugin/shopping-discount-setting.js +1 -1
  13. package/lowcode/cms-plugin/shopping-discount-setting.ts +5 -2
  14. package/lowcode/cms-plugin/shopping-invoice-manager.js +0 -1
  15. package/lowcode/cms-plugin/shopping-invoice-manager.ts +0 -1
  16. package/lowcode/cms-plugin/shopping-product-setting.js +265 -160
  17. package/lowcode/cms-plugin/shopping-product-setting.ts +295 -297
  18. package/lowcode/cms-plugin/shopping-product-stock.js +12 -16
  19. package/lowcode/cms-plugin/shopping-product-stock.ts +29 -35
  20. package/lowcode/glitter-base/route/shopping.js +25 -4
  21. package/lowcode/glitter-base/route/shopping.ts +52 -44
  22. package/lowcode/glitterBundle/html-component/widget.js +0 -3
  23. package/lowcode/glitterBundle/html-component/widget.ts +3 -3
  24. package/lowcode/public-components/blogs/blogs-01.js +138 -1
  25. package/lowcode/public-components/blogs/blogs-01.ts +142 -2
  26. package/lowcode/public-components/checkout/index.js +3 -2
  27. package/lowcode/public-components/checkout/index.ts +16 -3
  28. package/lowcode/public-components/product/product-detail.js +1 -0
  29. package/lowcode/public-components/product/product-detail.ts +1 -0
  30. package/lowcode/public-components/product/product-list.js +1 -0
  31. package/lowcode/public-components/product/product-list.ts +1 -0
  32. package/lowcode/public-components/user-manager/um-class.js +2 -2
  33. package/lowcode/public-components/user-manager/um-class.ts +2 -2
  34. package/lowcode/public-components/user-manager/um-rebate.js +18 -18
  35. package/lowcode/public-components/user-manager/um-rebate.ts +39 -38
  36. package/package.json +1 -1
  37. package/src/api-public/controllers/shop.js +18 -0
  38. package/src/api-public/controllers/shop.js.map +1 -1
  39. package/src/api-public/controllers/shop.ts +17 -1
  40. package/src/api-public/services/financial-service.d.ts +16 -0
  41. package/src/api-public/services/financial-service.js +70 -3
  42. package/src/api-public/services/financial-service.js.map +1 -1
  43. package/src/api-public/services/financial-service.ts +89 -4
  44. package/src/api-public/services/recommend.js +14 -0
  45. package/src/api-public/services/recommend.js.map +1 -1
  46. package/src/api-public/services/recommend.ts +15 -0
  47. package/src/api-public/services/shopping.d.ts +35 -0
  48. package/src/api-public/services/shopping.js +97 -9
  49. package/src/api-public/services/shopping.js.map +1 -1
  50. package/src/api-public/services/shopping.ts +136 -20
  51. package/src/services/template.js.map +1 -1
@@ -12,7 +12,7 @@ export class StockList {
12
12
  title: '庫存管理',
13
13
  select_data: [],
14
14
  select_mode: false,
15
- filter_variants: []
15
+ filter_variants: [],
16
16
  }, productType = 'all') {
17
17
  const glitter = gvc.glitter;
18
18
  const vm = {
@@ -219,20 +219,15 @@ export class StockList {
219
219
  searchType: vm.queryType || 'title',
220
220
  orderBy: vm.orderString || undefined,
221
221
  status: (() => {
222
- if (vm.filter.status && vm.filter.status.length === 1) {
223
- switch (vm.filter.status[0]) {
224
- case 'active':
225
- return 'active';
226
- case 'draft':
227
- return 'draft';
228
- }
222
+ if (vm.filter.status && vm.filter.status.length > 0) {
223
+ return vm.filter.status.join(',');
229
224
  }
230
225
  return undefined;
231
226
  })(),
232
227
  collection: vm.filter.collection,
233
228
  stockCount: vm.filter.count,
234
229
  accurate_search_collection: true,
235
- productType: productType
230
+ productType: productType,
236
231
  }).then((data) => {
237
232
  data.response.data = data.response.data.filter((dd) => {
238
233
  return !option.filter_variants.includes([dd.product_id].concat(dd.variant_content.spec).join('-'));
@@ -256,7 +251,7 @@ export class StockList {
256
251
  if (b.checked) {
257
252
  option.select_data.push({
258
253
  variant: b.variant_content,
259
- product_id: b.product_id
254
+ product_id: b.product_id,
260
255
  });
261
256
  }
262
257
  }
@@ -273,13 +268,14 @@ export class StockList {
273
268
  vm.replaceData = product;
274
269
  vm.type = 'editSpec';
275
270
  },
276
- filter: (option.select_mode) ? [
277
- {
278
- name: '選擇項目',
279
- event: (checkedData) => {
271
+ filter: option.select_mode
272
+ ? [
273
+ {
274
+ name: '選擇項目',
275
+ event: (checkedData) => { },
280
276
  },
281
- },
282
- ] : [],
277
+ ]
278
+ : [],
283
279
  });
284
280
  }
285
281
  catch (e) {
@@ -34,15 +34,15 @@ export class StockList {
34
34
  option: {
35
35
  title: string;
36
36
  select_mode: boolean;
37
- select_data: { variant:any,product_id:string }[];
37
+ select_data: { variant: any; product_id: string }[];
38
38
  filter_variants: string[];
39
39
  } = {
40
40
  title: '庫存管理',
41
41
  select_data: [],
42
42
  select_mode: false,
43
- filter_variants: []
43
+ filter_variants: [],
44
44
  },
45
- productType:'product' | 'addProduct' | 'giveaway' | 'hidden' | 'all' ='all'
45
+ productType: 'product' | 'addProduct' | 'giveaway' | 'hidden' | 'all' = 'all'
46
46
  ) {
47
47
  const glitter = gvc.glitter;
48
48
 
@@ -274,24 +274,19 @@ export class StockList {
274
274
  searchType: vm.queryType || 'title',
275
275
  orderBy: vm.orderString || undefined,
276
276
  status: (() => {
277
- if (vm.filter.status && vm.filter.status.length === 1) {
278
- switch (vm.filter.status[0]) {
279
- case 'active':
280
- return 'active';
281
- case 'draft':
282
- return 'draft';
283
- }
277
+ if (vm.filter.status && vm.filter.status.length > 0) {
278
+ return vm.filter.status.join(',');
284
279
  }
285
280
  return undefined;
286
281
  })(),
287
282
  collection: vm.filter.collection,
288
283
  stockCount: vm.filter.count,
289
284
  accurate_search_collection: true,
290
- productType:productType
285
+ productType: productType,
291
286
  }).then((data) => {
292
- data.response.data=data.response.data.filter((dd:any)=>{
293
- return !option.filter_variants.includes([dd.product_id].concat(dd.variant_content.spec).join('-'))
294
- })
287
+ data.response.data = data.response.data.filter((dd: any) => {
288
+ return !option.filter_variants.includes([dd.product_id].concat(dd.variant_content.spec).join('-'));
289
+ });
295
290
  vm.dataList = data.response.data;
296
291
  vmi.pageSize = Math.ceil(data.response.total / limit);
297
292
  vmi.originalData = vm.dataList;
@@ -302,17 +297,17 @@ export class StockList {
302
297
  vmi.callback();
303
298
  });
304
299
  },
305
- item_select:()=>{
306
- console.log(vm.dataList)
300
+ item_select: () => {
301
+ console.log(vm.dataList);
307
302
  while (option.select_data.length > 0) {
308
303
  option.select_data.shift();
309
304
  }
310
- for (const b of vm.dataList){
311
- if(b.checked){
305
+ for (const b of vm.dataList) {
306
+ if (b.checked) {
312
307
  option.select_data.push({
313
- variant:b.variant_content,
314
- product_id:b.product_id
315
- })
308
+ variant: b.variant_content,
309
+ product_id: b.product_id,
310
+ });
316
311
  }
317
312
  }
318
313
  // if(vm.dataList[index].checked){
@@ -327,8 +322,8 @@ export class StockList {
327
322
  // gvc.notifyDataChange(vm.filterId);
328
323
  },
329
324
  rowClick: (data, index) => {
330
- if(option.select_mode){
331
- return
325
+ if (option.select_mode) {
326
+ return;
332
327
  }
333
328
  const product = vm.dataList[index].product_content;
334
329
  const variant = vm.dataList[index].variant_content;
@@ -338,20 +333,19 @@ export class StockList {
338
333
  vm.replaceData = product;
339
334
  vm.type = 'editSpec';
340
335
  },
341
- filter:(option.select_mode) ? [
342
- {
343
- name: '選擇項目',
344
- event: (checkedData) => {
345
-
346
- },
347
- },
348
- ]:[],
336
+ filter: option.select_mode
337
+ ? [
338
+ {
339
+ name: '選擇項目',
340
+ event: (checkedData) => {},
341
+ },
342
+ ]
343
+ : [],
349
344
  });
350
- }catch (e) {
351
- console.log(e)
352
- return `${e}`
345
+ } catch (e) {
346
+ console.log(e);
347
+ return `${e}`;
353
348
  }
354
-
355
349
  },
356
350
  }),
357
351
  ].join('')
@@ -300,6 +300,9 @@ export class ApiShop {
300
300
  json.maxPrice && par.push(`max_price=${json.maxPrice}`);
301
301
  json.minPrice && par.push(`min_price=${json.minPrice}`);
302
302
  json.status && par.push(`status=${json.status}`);
303
+ if (json.schedule === true || json.schedule === false) {
304
+ par.push(`schedule=${json.schedule}`);
305
+ }
303
306
  json.orderBy && par.push(`order_by=${json.orderBy}`);
304
307
  json.id_list && par.push(`id_list=${json.id_list}`);
305
308
  json.productType && par.push(`productType=${json.productType}`);
@@ -323,6 +326,24 @@ export class ApiShop {
323
326
  },
324
327
  });
325
328
  }
329
+ static getProductDomain(json) {
330
+ return BaseApi.create({
331
+ url: getBaseUrl() +
332
+ `/api-public/v1/ec/product/domain?${(() => {
333
+ let par = [];
334
+ json.id && par.push(`id=${json.id}`);
335
+ json.search && par.push(`search=${json.search}`);
336
+ json.domain && par.push(`domain=${json.domain}`);
337
+ return par.join('&');
338
+ })()}`,
339
+ type: 'GET',
340
+ headers: {
341
+ 'Content-Type': 'application/json',
342
+ 'g-app': json.app_name || (window.glitter.getUrlParameter('type') === 'find_idea' ? window.appName : encodeURIComponent(getConfig().config.appName)),
343
+ Authorization: (window.parent.glitter.getUrlParameter('type') === 'editor' && getConfig().config.token) || GlobalUser.token,
344
+ },
345
+ });
346
+ }
326
347
  static orderListFilterString(obj) {
327
348
  if (!obj)
328
349
  return [];
@@ -564,7 +585,7 @@ export class ApiShop {
564
585
  });
565
586
  }
566
587
  static getInvoice(json) {
567
- console.log("json.filter -- ", json);
588
+ console.log('json.filter -- ', json);
568
589
  let filterString = this.invoiceListFilterString(json.filter);
569
590
  return BaseApi.create({
570
591
  url: getBaseUrl() +
@@ -776,8 +797,8 @@ export class ApiShop {
776
797
  data: JSON.stringify({
777
798
  base64: {
778
799
  app_name: app_name,
779
- "receipt-data": receipt
780
- }
800
+ 'receipt-data': receipt,
801
+ },
781
802
  }),
782
803
  });
783
804
  }
@@ -884,7 +905,7 @@ export class ApiShop {
884
905
  const passData = {
885
906
  invoiceNo: invoiceNo,
886
907
  voidReason: voidReason,
887
- createDate: createDate
908
+ createDate: createDate,
888
909
  };
889
910
  return BaseApi.create({
890
911
  url: getBaseUrl() + `/api-public/v1/ec/void_invoice`,
@@ -311,13 +311,14 @@ export class ApiShop {
311
311
  maxPrice?: string;
312
312
  minPrice?: string;
313
313
  status?: string;
314
+ schedule?: boolean;
314
315
  orderBy?: string;
315
316
  id_list?: string;
316
317
  with_hide_index?: string;
317
318
  productType?: string;
318
319
  filter_visible?: string;
319
320
  app_name?: string;
320
- show_hidden?:boolean
321
+ show_hidden?: boolean;
321
322
  }) {
322
323
  return BaseApi.create({
323
324
  url:
@@ -333,6 +334,9 @@ export class ApiShop {
333
334
  json.maxPrice && par.push(`max_price=${json.maxPrice}`);
334
335
  json.minPrice && par.push(`min_price=${json.minPrice}`);
335
336
  json.status && par.push(`status=${json.status}`);
337
+ if(json.schedule === true || json.schedule === false){
338
+ par.push(`schedule=${json.schedule}`)
339
+ }
336
340
  json.orderBy && par.push(`order_by=${json.orderBy}`);
337
341
  json.id_list && par.push(`id_list=${json.id_list}`);
338
342
  json.productType && par.push(`productType=${json.productType}`);
@@ -340,9 +344,9 @@ export class ApiShop {
340
344
  json.searchType && par.push(`searchType=${json.searchType}`);
341
345
  json.filter_visible && par.push(`filter_visible=${json.filter_visible}`);
342
346
  json.show_hidden && par.push(`show_hidden=${json.show_hidden}`);
343
- if(location.pathname.includes('/hidden/')) {
347
+ if (location.pathname.includes('/hidden/')) {
344
348
  par.push(`filter_visible=false`);
345
- }else if ( (window as any).glitter.getUrlParameter('function')==='user-editor') {
349
+ } else if ((window as any).glitter.getUrlParameter('function') === 'user-editor') {
346
350
  par.push(`filter_visible=true`);
347
351
  }
348
352
  return par.join('&');
@@ -356,6 +360,26 @@ export class ApiShop {
356
360
  });
357
361
  }
358
362
 
363
+ static getProductDomain(json: { id?: string; search?: string; domain?: string; app_name?: string }) {
364
+ return BaseApi.create({
365
+ url:
366
+ getBaseUrl() +
367
+ `/api-public/v1/ec/product/domain?${(() => {
368
+ let par = [];
369
+ json.id && par.push(`id=${json.id}`);
370
+ json.search && par.push(`search=${json.search}`);
371
+ json.domain && par.push(`domain=${json.domain}`);
372
+ return par.join('&');
373
+ })()}`,
374
+ type: 'GET',
375
+ headers: {
376
+ 'Content-Type': 'application/json',
377
+ 'g-app': json.app_name || ((window as any).glitter.getUrlParameter('type') === 'find_idea' ? (window as any).appName : encodeURIComponent(getConfig().config.appName)),
378
+ Authorization: ((window.parent as any).glitter.getUrlParameter('type') === 'editor' && getConfig().config.token) || GlobalUser.token,
379
+ },
380
+ });
381
+ }
382
+
359
383
  static orderListFilterString(obj: any): string[] {
360
384
  if (!obj) return [];
361
385
  let list = [] as string[];
@@ -644,16 +668,9 @@ export class ApiShop {
644
668
  });
645
669
  });
646
670
  }
647
- static getInvoice(json: {
648
- limit: number;
649
- page: number;
650
- search?: string;
651
- searchType?: string;
652
- orderString?: string;
653
- filter?: any;
654
- }) {
655
- console.log("json.filter -- " , json)
656
- let filterString = this.invoiceListFilterString(json.filter)
671
+ static getInvoice(json: { limit: number; page: number; search?: string; searchType?: string; orderString?: string; filter?: any }) {
672
+ console.log('json.filter -- ', json);
673
+ let filterString = this.invoiceListFilterString(json.filter);
657
674
  // const filterString = this.orderListFilterString(json.filter);
658
675
  // filterString.length > 0 && par.push(filterString.join('&'));
659
676
  return BaseApi.create({
@@ -676,16 +693,8 @@ export class ApiShop {
676
693
  },
677
694
  });
678
695
  }
679
- static getAllowance(json: {
680
- limit: number;
681
- page: number;
682
- search?: string;
683
- searchType?: string;
684
- orderString?: string;
685
- filter?: any;
686
- }) {
687
-
688
- let filterString = this.allowanceListFilterString(json.filter)
696
+ static getAllowance(json: { limit: number; page: number; search?: string; searchType?: string; orderString?: string; filter?: any }) {
697
+ let filterString = this.allowanceListFilterString(json.filter);
689
698
  // const filterString = this.orderListFilterString(json.filter);
690
699
  // filterString.length > 0 && par.push(filterString.join('&'));
691
700
  return BaseApi.create({
@@ -924,7 +933,7 @@ export class ApiShop {
924
933
  });
925
934
  }
926
935
 
927
- public static app_subscription(receipt:string,app_name:string){
936
+ public static app_subscription(receipt: string, app_name: string) {
928
937
  return BaseApi.create({
929
938
  url: getBaseUrl() + `/api-public/v1/ec/apple-webhook`,
930
939
  type: 'POST',
@@ -934,9 +943,10 @@ export class ApiShop {
934
943
  Authorization: getConfig().config.token,
935
944
  },
936
945
  data: JSON.stringify({
937
- base64:{
938
- app_name:app_name,
939
- "receipt-data": receipt }
946
+ base64: {
947
+ app_name: app_name,
948
+ 'receipt-data': receipt,
949
+ },
940
950
  }),
941
951
  });
942
952
  }
@@ -1045,7 +1055,7 @@ export class ApiShop {
1045
1055
  orderBy?: string;
1046
1056
  status?: string;
1047
1057
  stockCount?: { key: string; value: string };
1048
- productType?:'product' | 'addProduct' | 'giveaway' | 'hidden' | 'all'
1058
+ productType?: 'product' | 'addProduct' | 'giveaway' | 'hidden' | 'all';
1049
1059
  }) {
1050
1060
  return BaseApi.create({
1051
1061
  url:
@@ -1118,25 +1128,24 @@ export class ApiShop {
1118
1128
  headers: {
1119
1129
  'Content-Type': 'application/json',
1120
1130
  'g-app': getConfig().config.appName,
1121
- Authorization: getConfig().config.token,
1131
+ Authorization: getConfig().config.token,
1122
1132
  },
1123
1133
  data: JSON.stringify(passData),
1124
1134
  });
1125
1135
  }
1126
- static voidInvoice(invoiceNo:string , voidReason:string ,createDate:string
1127
- ) {
1136
+ static voidInvoice(invoiceNo: string, voidReason: string, createDate: string) {
1128
1137
  const passData = {
1129
- invoiceNo:invoiceNo,
1130
- voidReason:voidReason,
1131
- createDate:createDate
1132
- }
1138
+ invoiceNo: invoiceNo,
1139
+ voidReason: voidReason,
1140
+ createDate: createDate,
1141
+ };
1133
1142
  return BaseApi.create({
1134
1143
  url: getBaseUrl() + `/api-public/v1/ec/void_invoice`,
1135
1144
  type: 'POST',
1136
1145
  headers: {
1137
1146
  'Content-Type': 'application/json',
1138
1147
  'g-app': getConfig().config.appName,
1139
- Authorization: getConfig().config.token,
1148
+ Authorization: getConfig().config.token,
1140
1149
  },
1141
1150
  data: JSON.stringify(passData),
1142
1151
  });
@@ -1148,25 +1157,24 @@ export class ApiShop {
1148
1157
  headers: {
1149
1158
  'Content-Type': 'application/json',
1150
1159
  'g-app': getConfig().config.appName,
1151
- Authorization: getConfig().config.token,
1160
+ Authorization: getConfig().config.token,
1152
1161
  },
1153
1162
  data: JSON.stringify(passData),
1154
1163
  });
1155
1164
  }
1156
- static voidAllowance(invoiceNo:string , allowanceNo:string , voidReason:string
1157
- ) {
1165
+ static voidAllowance(invoiceNo: string, allowanceNo: string, voidReason: string) {
1158
1166
  const passData = {
1159
- invoiceNo:invoiceNo,
1160
- allowanceNo:allowanceNo,
1161
- voidReason:voidReason,
1162
- }
1167
+ invoiceNo: invoiceNo,
1168
+ allowanceNo: allowanceNo,
1169
+ voidReason: voidReason,
1170
+ };
1163
1171
  return BaseApi.create({
1164
1172
  url: getBaseUrl() + `/api-public/v1/ec/void_allowance`,
1165
1173
  type: 'POST',
1166
1174
  headers: {
1167
1175
  'Content-Type': 'application/json',
1168
1176
  'g-app': getConfig().config.appName,
1169
- Authorization: getConfig().config.token,
1177
+ Authorization: getConfig().config.token,
1170
1178
  },
1171
1179
  data: JSON.stringify(passData),
1172
1180
  });
@@ -383,8 +383,6 @@ export const widgetComponent = {
383
383
  resolve(true);
384
384
  }
385
385
  });
386
- console.log(`widget.data.key=>`, widget.data.key);
387
- console.log(oWidget);
388
386
  if (widget.data.selectType === 'api') {
389
387
  resolve(vm.data.map((dd) => {
390
388
  var _a;
@@ -445,7 +443,6 @@ export const widgetComponent = {
445
443
  view.push(innerText);
446
444
  break;
447
445
  }
448
- console.log(`htmlGenerate.root`, htmlGenerate.root);
449
446
  return view.join('');
450
447
  },
451
448
  divCreate: getCreateOption,
@@ -388,8 +388,8 @@ export const widgetComponent = {
388
388
  resolve(true)
389
389
  }
390
390
  })
391
- console.log(`widget.data.key=>`,widget.data.key)
392
- console.log(oWidget)
391
+ // console.log(`widget.data.key=>`,widget.data.key)
392
+ // console.log(oWidget)
393
393
  if (widget.data.selectType === 'api') {
394
394
  resolve(vm.data.map((dd: any) => {
395
395
  formData[widget.data.key] = formData[widget.data.key] ?? dd.value
@@ -448,7 +448,7 @@ export const widgetComponent = {
448
448
  break
449
449
 
450
450
  }
451
- console.log(`htmlGenerate.root`, htmlGenerate.root)
451
+ // console.log(`htmlGenerate.root`, htmlGenerate.root)
452
452
  // if ((window.parent as any).editerData !== undefined && htmlGenerate.root && widget.data.elem !== 'textArea') {
453
453
  // view.push(glitter.htmlGenerate.getEditorSelectSection({
454
454
  // id: widget.id,
@@ -1,4 +1,141 @@
1
+ import { ShareDialog } from "../../glitterBundle/dialog/ShareDialog.js";
2
+ import { UmClass } from "../user-manager/um-class.js";
1
3
  export class Blogs01 {
2
- static main() {
4
+ static main(gvc, subData) {
5
+ if (subData.content.generator !== 'page_editor') {
6
+ return subData.content.text;
7
+ }
8
+ else {
9
+ console.log(`subData.content==>`, subData.content.show_auth);
10
+ function startRender() {
11
+ if (subData.content.relative_data && ["shopping", "hidden"].includes(subData.content.page_type) && (localStorage.getItem('block-refresh-cart') !== 'true')) {
12
+ subData.content.relative_data.map((dd) => {
13
+ const key = [dd.product_id].concat(dd.variant.spec).join('-');
14
+ const cart = gvc.glitter.share.ApiCart.cart;
15
+ const line_item = cart.line_items.find((dd) => {
16
+ return `${dd.id}-${dd.spec.join('-')}` === key;
17
+ });
18
+ let cle = [];
19
+ cart.line_items.map((dd) => {
20
+ if (!cle.find((d1) => {
21
+ return `${dd.id}-${dd.spec.join('-')}` === `${d1.id}-${d1.spec.join('-')}`;
22
+ })) {
23
+ cle.push(dd);
24
+ }
25
+ });
26
+ cart.line_items = cle;
27
+ if (!line_item) {
28
+ cart.line_items.push({
29
+ id: dd.product_id,
30
+ spec: dd.variant.spec,
31
+ count: 1
32
+ });
33
+ }
34
+ gvc.glitter.share.ApiCart.cart = cart;
35
+ });
36
+ }
37
+ else {
38
+ localStorage.setItem('block-refresh-cart', 'false');
39
+ }
40
+ return new gvc.glitter.htmlGenerate(subData.content.config, [], subData.content).render(gvc, {
41
+ class: `w-100`,
42
+ style: `position:relative;`,
43
+ containerID: gvc.glitter.getUUID(),
44
+ tag: gvc.glitter.getUUID(),
45
+ jsFinish: () => {
46
+ },
47
+ onCreate: () => {
48
+ },
49
+ document: document
50
+ }, {});
51
+ }
52
+ if (subData.content.page_type === 'hidden') {
53
+ if (subData.content.show_auth.auth === 'all') {
54
+ return startRender();
55
+ }
56
+ else if (subData.content.show_auth.auth === "password") {
57
+ if (localStorage.getItem('password_to_see_' + subData.content.tag) === subData.content.show_auth.value) {
58
+ return startRender();
59
+ }
60
+ return gvc.bindView(() => {
61
+ const rid = gvc.glitter.getUUID();
62
+ return {
63
+ bind: rid,
64
+ view: () => {
65
+ return ``;
66
+ },
67
+ divCreate: {
68
+ option: [
69
+ { key: 'id', value: rid }
70
+ ]
71
+ },
72
+ onCreate: () => {
73
+ function checkPwd() {
74
+ const pwd = window.prompt('請輸入網站密碼', '');
75
+ localStorage.setItem('password_to_see_' + subData.content.tag, pwd !== null && pwd !== void 0 ? pwd : '');
76
+ if (subData.content.show_auth.value === pwd) {
77
+ document.querySelector(`#${rid}`).outerHTML = startRender();
78
+ }
79
+ else {
80
+ const dialog = new ShareDialog(gvc.glitter);
81
+ dialog.checkYesOrNot({
82
+ text: '網站密碼輸入錯誤', callback: () => {
83
+ gvc.glitter.closeDiaLog();
84
+ checkPwd();
85
+ }
86
+ });
87
+ }
88
+ }
89
+ checkPwd();
90
+ }
91
+ };
92
+ });
93
+ }
94
+ else if (subData.content.show_auth.auth === "member_type") {
95
+ return gvc.bindView(() => {
96
+ const rid = gvc.glitter.getUUID();
97
+ return {
98
+ bind: rid,
99
+ view: () => {
100
+ return ``;
101
+ },
102
+ divCreate: {
103
+ option: [
104
+ { key: 'id', value: rid }
105
+ ]
106
+ },
107
+ onCreate: () => {
108
+ const dialog = new ShareDialog(gvc.glitter);
109
+ UmClass.getUserData(gvc).then((resp) => {
110
+ try {
111
+ const mem = resp.member.find((d) => {
112
+ return d.trigger;
113
+ });
114
+ if (subData.content.show_auth.value.includes(mem.id)) {
115
+ document.querySelector(`#${rid}`).outerHTML = startRender();
116
+ }
117
+ else {
118
+ dialog.errorMessage({ text: '無訪問權限' });
119
+ gvc.glitter.href = '/index';
120
+ }
121
+ }
122
+ catch (e) {
123
+ dialog.errorMessage({ text: '無訪問權限' });
124
+ gvc.glitter.href = '/index';
125
+ }
126
+ });
127
+ }
128
+ };
129
+ });
130
+ }
131
+ else {
132
+ return startRender();
133
+ }
134
+ }
135
+ else {
136
+ return startRender();
137
+ }
138
+ }
3
139
  }
4
140
  }
141
+ window.glitter.setModule(import.meta.url, Blogs01);