ts-glitter 21.6.5 → 21.6.7

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/lowcode/Entry.js CHANGED
@@ -146,7 +146,7 @@ export class Entry {
146
146
  }
147
147
  window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : createClock();
148
148
  console.log(`Entry-time:`, window.renderClock.stop());
149
- glitter.share.editerVersion = 'V_21.6.5';
149
+ glitter.share.editerVersion = 'V_21.6.7';
150
150
  glitter.share.start = new Date();
151
151
  const vm = { appConfig: [] };
152
152
  window.saasConfig = {
package/lowcode/Entry.ts CHANGED
@@ -150,7 +150,7 @@ export class Entry {
150
150
  }
151
151
  (window as any).renderClock = (window as any).renderClock ?? createClock();
152
152
  console.log(`Entry-time:`, (window as any).renderClock.stop());
153
- glitter.share.editerVersion = 'V_21.6.5';
153
+ glitter.share.editerVersion = 'V_21.6.7';
154
154
  glitter.share.start = new Date();
155
155
  const vm = { appConfig: [] };
156
156
  (window as any).saasConfig = {
@@ -346,7 +346,7 @@ export class AccountInfo {
346
346
  };
347
347
  }),
348
348
  ` <div style="height:${glitter.share.bottom_inset || 0}px;"></div>`,
349
- ];
349
+ ].join('');
350
350
  }
351
351
  }
352
352
  window.glitter.setModule(import.meta.url, AccountInfo);
@@ -366,7 +366,7 @@ export class AccountInfo {
366
366
  };
367
367
  }),
368
368
  ` <div style="height:${glitter.share.bottom_inset || 0}px;"></div>`,
369
- ];
369
+ ].join('');
370
370
  }
371
371
  }
372
372
 
@@ -851,7 +851,7 @@ export class ShoppingDiscountSetting {
851
851
  voucherData.reBackType === 'shipment_free' ? selectShipment() : '',
852
852
  ]
853
853
  .filter(Boolean)
854
- .map(str => html `<div>${str}</div>`)
854
+ .map(str => html ` <div>${str}</div>`)
855
855
  .join(BgWidget.horizontalLine())),
856
856
  ...(['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)
857
857
  ? []
@@ -1526,7 +1526,7 @@ export class ShoppingDiscountSetting {
1526
1526
  function rebateEndDay() {
1527
1527
  var _b, _c;
1528
1528
  return [
1529
- html `<div class="tx_700">購物金有效天數</div>`,
1529
+ html ` <div class="tx_700">購物金有效天數</div>`,
1530
1530
  BgWidget.multiCheckboxContainer(gvc, [
1531
1531
  {
1532
1532
  key: 'noEnd',
@@ -1563,7 +1563,7 @@ export class ShoppingDiscountSetting {
1563
1563
  voucherData.rebateEndDay = '0';
1564
1564
  }
1565
1565
  }, { single: true }),
1566
- ].join(html `<div class="my-2"></div>`);
1566
+ ].join(html ` <div class="my-2"></div>`);
1567
1567
  }
1568
1568
  return [
1569
1569
  storeUseTimeLimit(),
@@ -1702,7 +1702,7 @@ export class ShoppingDiscountSetting {
1702
1702
  };
1703
1703
  const voucherData = Object.assign(Object.assign({}, this.emptyVoucher(obj.reBackType)), vm.data);
1704
1704
  const cloneForKey = (key) => JSON.parse(JSON.stringify(key));
1705
- const setTitle = (title) => html `<div class="tx_700">${title}</div>`;
1705
+ const setTitle = (title) => html ` <div class="tx_700">${title}</div>`;
1706
1706
  const voucherSettingCard = (array) => BgWidget.mainCard(array
1707
1707
  .map(stringArray => stringArray.filter(Boolean))
1708
1708
  .filter(stringArray => stringArray.length > 0)
@@ -1734,7 +1734,7 @@ export class ShoppingDiscountSetting {
1734
1734
  manager_tag: cloneForKey(voucherData.forKey),
1735
1735
  };
1736
1736
  function status() {
1737
- return html `<div class="d-flex gap-1">
1737
+ return html ` <div class="d-flex gap-1">
1738
1738
  <div class="tx_normal">活動啟用</div>
1739
1739
  ${BgWidget.switchTextButton(gvc, voucherData.status === 1, {}, bool => {
1740
1740
  voucherData.status = bool ? 1 : 0;
@@ -2116,18 +2116,22 @@ export class ShoppingDiscountSetting {
2116
2116
  }
2117
2117
  function setVoucherFor() {
2118
2118
  var _b;
2119
- return EditorElem.radio({
2120
- gvc: gvc,
2121
- title: '',
2122
- def: (_b = voucherData.for) !== null && _b !== void 0 ? _b : 'all',
2123
- array: ShoppingDiscountSetting.productForList,
2124
- callback: text => {
2125
- voucherData.forKey = defKeys[text];
2126
- voucherData.for = text;
2127
- gvc.notifyDataChange(pageVM.viewID);
2128
- },
2129
- oneLine: true,
2130
- });
2119
+ let view = [EditorElem.radio({
2120
+ gvc: gvc,
2121
+ title: '',
2122
+ def: (_b = voucherData.for) !== null && _b !== void 0 ? _b : 'all',
2123
+ array: ShoppingDiscountSetting.productForList,
2124
+ callback: text => {
2125
+ voucherData.forKey = defKeys[text];
2126
+ voucherData.for = text;
2127
+ gvc.notifyDataChange(pageVM.viewID);
2128
+ },
2129
+ oneLine: true,
2130
+ })];
2131
+ if (['add_on_items', 'giveaway'].includes(voucherData.reBackType)) {
2132
+ view.push(`<div class="mx-n2">${selectProduct()}</div>`);
2133
+ }
2134
+ return view.join('');
2131
2135
  }
2132
2136
  function selectProduct() {
2133
2137
  if (voucherData.trigger === 'distribution') {
@@ -2256,49 +2260,55 @@ export class ShoppingDiscountSetting {
2256
2260
  return {
2257
2261
  bind: subVM.id,
2258
2262
  view: () => {
2259
- if (subVM.loading) {
2260
- return BgWidget.spinner();
2261
- }
2262
- return html `
2263
- <div class="d-flex flex-column p-2" style="gap: 18px;">
2264
- <div
2265
- class="d-flex align-items-center gray-bottom-line-18"
2266
- style="gap: 24px; justify-content: space-between;"
2267
- >
2268
- <div class="form-check-label c_updown_label">
2269
- <div class="tx_normal">商品列表</div>
2263
+ try {
2264
+ if (subVM.loading) {
2265
+ return BgWidget.spinner();
2266
+ }
2267
+ return html `
2268
+ <div class="d-flex flex-column p-2" style="gap: 18px;">
2269
+ <div
2270
+ class="d-flex align-items-center gray-bottom-line-18"
2271
+ style="gap: 24px; justify-content: space-between;"
2272
+ >
2273
+ <div class="form-check-label c_updown_label">
2274
+ <div class="tx_normal">商品列表</div>
2275
+ </div>
2276
+ ${BgWidget.grayButton('選擇商品', gvc.event(() => {
2277
+ var _b;
2278
+ BgProduct.productsDialog({
2279
+ gvc: gvc,
2280
+ default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
2281
+ callback: (value) => __awaiter(this, void 0, void 0, function* () {
2282
+ voucherData.forKey = value;
2283
+ defKeys.product = value;
2284
+ subVM.dataList = yield BgProduct.getProductOpts(voucherData.forKey);
2285
+ subVM.loading = true;
2286
+ gvc.notifyDataChange(subVM.id);
2287
+ }),
2288
+ });
2289
+ }), { textStyle: 'font-weight: 400;' })}
2270
2290
  </div>
2271
- ${BgWidget.grayButton('選擇商品', gvc.event(() => {
2272
- var _b;
2273
- BgProduct.productsDialog({
2274
- gvc: gvc,
2275
- default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
2276
- callback: (value) => __awaiter(this, void 0, void 0, function* () {
2277
- voucherData.forKey = value;
2278
- defKeys.product = value;
2279
- subVM.dataList = yield BgProduct.getProductOpts(voucherData.forKey);
2280
- subVM.loading = true;
2281
- gvc.notifyDataChange(subVM.id);
2282
- }),
2283
- });
2284
- }), { textStyle: 'font-weight: 400;' })}
2291
+ ${subVM.dataList
2292
+ .map((opt, index) => {
2293
+ return html ` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
2294
+ <span class="tx_normal">${index + 1}.</span>
2295
+ ${BgWidget.validImageBox({
2296
+ gvc: gvc,
2297
+ image: opt.image,
2298
+ width: 40,
2299
+ })}
2300
+ <div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
2301
+ ${opt.note ? html ` <div class="tx_gray_12">${opt.note}</div> ` : ''}
2302
+ </div>`;
2303
+ })
2304
+ .join(``)}
2285
2305
  </div>
2286
- ${subVM.dataList
2287
- .map((opt, index) => {
2288
- return html ` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
2289
- <span class="tx_normal">${index + 1}.</span>
2290
- ${BgWidget.validImageBox({
2291
- gvc: gvc,
2292
- image: opt.image,
2293
- width: 40,
2294
- })}
2295
- <div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
2296
- ${opt.note ? html ` <div class="tx_gray_12">${opt.note}</div> ` : ''}
2297
- </div>`;
2298
- })
2299
- .join(``)}
2300
- </div>
2301
- `;
2306
+ `;
2307
+ }
2308
+ catch (e) {
2309
+ console.error(e);
2310
+ return `${e}`;
2311
+ }
2302
2312
  },
2303
2313
  onCreate: () => {
2304
2314
  if (subVM.loading) {
@@ -2310,9 +2320,9 @@ export class ShoppingDiscountSetting {
2310
2320
  }, 200);
2311
2321
  }
2312
2322
  else {
2313
- new Promise(resolve => {
2314
- resolve(BgProduct.getProductOpts(voucherData.forKey));
2315
- }).then(data => {
2323
+ new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
2324
+ resolve(yield BgProduct.getProductOpts(voucherData.forKey));
2325
+ })).then(data => {
2316
2326
  subVM.dataList = data;
2317
2327
  subVM.loading = false;
2318
2328
  gvc.notifyDataChange(subVM.id);
@@ -2796,8 +2806,8 @@ export class ShoppingDiscountSetting {
2796
2806
  rebate: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
2797
2807
  discount: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
2798
2808
  shipment_free: { title: '活動商品', html: '' },
2799
- add_on_items: { title: '加購品項', html: addProductView() },
2800
- giveaway: { title: '贈品品項', html: addProductView() },
2809
+ add_on_items: { title: '加購品項', html: [addProductView()].join('') },
2810
+ giveaway: { title: '贈品品項', html: [addProductView()].join('') },
2801
2811
  };
2802
2812
  const viewList = [
2803
2813
  [
@@ -2863,13 +2873,13 @@ export class ShoppingDiscountSetting {
2863
2873
  const getSummary = this.summaryTextList(voucherData)
2864
2874
  .map(text => {
2865
2875
  const className = text.length > 0 ? 'tx_normal' : 'gray-top-bottom-line-6';
2866
- return html `<div class="${className}">${text}</div>`;
2876
+ return html ` <div class="${className}">${text}</div>`;
2867
2877
  })
2868
2878
  .join('');
2869
2879
  return BgWidget.mainCard([
2870
2880
  setTitle('摘要'),
2871
2881
  BgWidget.mbContainer(18),
2872
- html `<div style="display: flex; gap: 12px; flex-direction: column;">${getSummary}</div>`,
2882
+ html ` <div style="display: flex; gap: 12px; flex-direction: column;">${getSummary}</div>`,
2873
2883
  ].join(''));
2874
2884
  },
2875
2885
  divCreate: {
@@ -1050,7 +1050,7 @@ export class ShoppingDiscountSetting {
1050
1050
  voucherData.reBackType === 'shipment_free' ? selectShipment() : '',
1051
1051
  ]
1052
1052
  .filter(Boolean)
1053
- .map(str => html`<div>${str}</div>`)
1053
+ .map(str => html` <div>${str}</div>`)
1054
1054
  .join(BgWidget.horizontalLine())
1055
1055
  ),
1056
1056
  ...(['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)
@@ -1840,7 +1840,7 @@ export class ShoppingDiscountSetting {
1840
1840
 
1841
1841
  function rebateEndDay() {
1842
1842
  return [
1843
- html`<div class="tx_700">購物金有效天數</div>`,
1843
+ html` <div class="tx_700">購物金有效天數</div>`,
1844
1844
  BgWidget.multiCheckboxContainer(
1845
1845
  gvc,
1846
1846
  [
@@ -1883,7 +1883,7 @@ export class ShoppingDiscountSetting {
1883
1883
  },
1884
1884
  { single: true }
1885
1885
  ),
1886
- ].join(html`<div class="my-2"></div>`);
1886
+ ].join(html` <div class="my-2"></div>`);
1887
1887
  }
1888
1888
 
1889
1889
  return [
@@ -2053,7 +2053,7 @@ export class ShoppingDiscountSetting {
2053
2053
 
2054
2054
  const cloneForKey = <T>(key: T): T => JSON.parse(JSON.stringify(key));
2055
2055
 
2056
- const setTitle = (title: string) => html`<div class="tx_700">${title}</div>`;
2056
+ const setTitle = (title: string) => html` <div class="tx_700">${title}</div>`;
2057
2057
 
2058
2058
  const voucherSettingCard = (array: string[][]) =>
2059
2059
  BgWidget.mainCard(
@@ -2102,7 +2102,7 @@ export class ShoppingDiscountSetting {
2102
2102
 
2103
2103
  // 活動啟用
2104
2104
  function status() {
2105
- return html`<div class="d-flex gap-1">
2105
+ return html` <div class="d-flex gap-1">
2106
2106
  <div class="tx_normal">活動啟用</div>
2107
2107
  ${BgWidget.switchTextButton(gvc, voucherData.status === 1, {}, bool => {
2108
2108
  voucherData.status = bool ? 1 : 0;
@@ -2530,7 +2530,7 @@ export class ShoppingDiscountSetting {
2530
2530
 
2531
2531
  // 優惠套用至
2532
2532
  function setVoucherFor() {
2533
- return EditorElem.radio({
2533
+ let view=[EditorElem.radio({
2534
2534
  gvc: gvc,
2535
2535
  title: '',
2536
2536
  def: voucherData.for ?? 'all',
@@ -2541,7 +2541,14 @@ export class ShoppingDiscountSetting {
2541
2541
  gvc.notifyDataChange(pageVM.viewID);
2542
2542
  },
2543
2543
  oneLine: true,
2544
- });
2544
+ })]
2545
+ if( ['add_on_items','giveaway'].includes(voucherData.reBackType)){
2546
+ view.push(`<div class="mx-n2">${selectProduct()}</div>`)
2547
+ }
2548
+ // [
2549
+ // selectProduct()
2550
+ // ]
2551
+ return view.join('');
2545
2552
  }
2546
2553
 
2547
2554
  // 活動商品
@@ -2549,7 +2556,6 @@ export class ShoppingDiscountSetting {
2549
2556
  if (voucherData.trigger === 'distribution') {
2550
2557
  return '';
2551
2558
  }
2552
-
2553
2559
  switch (voucherData.for) {
2554
2560
  case 'manager_tag':
2555
2561
  return gvc.bindView(() => {
@@ -2685,52 +2691,57 @@ export class ShoppingDiscountSetting {
2685
2691
  return {
2686
2692
  bind: subVM.id,
2687
2693
  view: () => {
2688
- if (subVM.loading) {
2689
- return BgWidget.spinner();
2690
- }
2691
- return html`
2692
- <div class="d-flex flex-column p-2" style="gap: 18px;">
2693
- <div
2694
- class="d-flex align-items-center gray-bottom-line-18"
2695
- style="gap: 24px; justify-content: space-between;"
2696
- >
2697
- <div class="form-check-label c_updown_label">
2698
- <div class="tx_normal">商品列表</div>
2694
+ try {
2695
+ if (subVM.loading) {
2696
+ return BgWidget.spinner();
2697
+ }
2698
+ return html`
2699
+ <div class="d-flex flex-column p-2" style="gap: 18px;">
2700
+ <div
2701
+ class="d-flex align-items-center gray-bottom-line-18"
2702
+ style="gap: 24px; justify-content: space-between;"
2703
+ >
2704
+ <div class="form-check-label c_updown_label">
2705
+ <div class="tx_normal">商品列表</div>
2706
+ </div>
2707
+ ${BgWidget.grayButton(
2708
+ '選擇商品',
2709
+ gvc.event(() => {
2710
+ BgProduct.productsDialog({
2711
+ gvc: gvc,
2712
+ default: voucherData.forKey ?? [],
2713
+ callback: async value => {
2714
+ voucherData.forKey = value;
2715
+ defKeys.product = value;
2716
+ subVM.dataList = await BgProduct.getProductOpts(voucherData.forKey);
2717
+ subVM.loading = true;
2718
+ gvc.notifyDataChange(subVM.id);
2719
+ },
2720
+ });
2721
+ }),
2722
+ { textStyle: 'font-weight: 400;' }
2723
+ )}
2699
2724
  </div>
2700
- ${BgWidget.grayButton(
2701
- '選擇商品',
2702
- gvc.event(() => {
2703
- BgProduct.productsDialog({
2704
- gvc: gvc,
2705
- default: voucherData.forKey ?? [],
2706
- callback: async value => {
2707
- voucherData.forKey = value;
2708
- defKeys.product = value;
2709
- subVM.dataList = await BgProduct.getProductOpts(voucherData.forKey);
2710
- subVM.loading = true;
2711
- gvc.notifyDataChange(subVM.id);
2712
- },
2713
- });
2714
- }),
2715
- { textStyle: 'font-weight: 400;' }
2716
- )}
2725
+ ${subVM.dataList
2726
+ .map((opt: OptionsItem, index) => {
2727
+ return html` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
2728
+ <span class="tx_normal">${index + 1}.</span>
2729
+ ${BgWidget.validImageBox({
2730
+ gvc: gvc,
2731
+ image: opt.image,
2732
+ width: 40,
2733
+ })}
2734
+ <div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
2735
+ ${opt.note ? html` <div class="tx_gray_12">${opt.note}</div> ` : ''}
2736
+ </div>`;
2737
+ })
2738
+ .join(``)}
2717
2739
  </div>
2718
- ${subVM.dataList
2719
- .map((opt: OptionsItem, index) => {
2720
- return html` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
2721
- <span class="tx_normal">${index + 1}.</span>
2722
- ${BgWidget.validImageBox({
2723
- gvc: gvc,
2724
- image: opt.image,
2725
- width: 40,
2726
- })}
2727
- <div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
2728
- ${opt.note ? html` <div class="tx_gray_12">${opt.note}</div> ` : ''}
2729
- </div>`;
2730
- })
2731
- .join(``)}
2732
- </div>
2733
- `;
2740
+ `;
2741
+ } catch (e) {
2742
+ console.error(e);
2743
+ return `${e}`;
2744
+ }
2734
2745
  },
2735
2746
  onCreate: () => {
2736
2747
  if (subVM.loading) {
@@ -2741,11 +2752,12 @@ export class ShoppingDiscountSetting {
2741
2752
  gvc.notifyDataChange(subVM.id);
2742
2753
  }, 200);
2743
2754
  } else {
2744
- new Promise<OptionsItem[]>(resolve => {
2745
- resolve(BgProduct.getProductOpts(voucherData.forKey));
2755
+ new Promise<OptionsItem[]>(async resolve => {
2756
+ resolve(await BgProduct.getProductOpts(voucherData.forKey));
2746
2757
  }).then(data => {
2747
2758
  subVM.dataList = data;
2748
2759
  subVM.loading = false;
2760
+
2749
2761
  gvc.notifyDataChange(subVM.id);
2750
2762
  });
2751
2763
  }
@@ -3349,10 +3361,9 @@ export class ShoppingDiscountSetting {
3349
3361
  rebate: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
3350
3362
  discount: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
3351
3363
  shipment_free: { title: '活動商品', html: '' },
3352
- add_on_items: { title: '加購品項', html: addProductView() },
3353
- giveaway: { title: '贈品品項', html: addProductView() },
3364
+ add_on_items: { title: '加購品項', html: [addProductView()].join('') },
3365
+ giveaway: { title: '贈品品項', html: [addProductView()].join('') },
3354
3366
  };
3355
-
3356
3367
  // 優惠券設定 Layout Data
3357
3368
  const viewList: { title: string; html: string | string[] }[][] = [
3358
3369
  [
@@ -3429,7 +3440,7 @@ export class ShoppingDiscountSetting {
3429
3440
  const getSummary = this.summaryTextList(voucherData)
3430
3441
  .map(text => {
3431
3442
  const className = text.length > 0 ? 'tx_normal' : 'gray-top-bottom-line-6';
3432
- return html`<div class="${className}">${text}</div>`;
3443
+ return html` <div class="${className}">${text}</div>`;
3433
3444
  })
3434
3445
  .join('');
3435
3446
 
@@ -3437,7 +3448,7 @@ export class ShoppingDiscountSetting {
3437
3448
  [
3438
3449
  setTitle('摘要'),
3439
3450
  BgWidget.mbContainer(18),
3440
- html`<div style="display: flex; gap: 12px; flex-direction: column;">${getSummary}</div>`,
3451
+ html` <div style="display: flex; gap: 12px; flex-direction: column;">${getSummary}</div>`,
3441
3452
  ].join('')
3442
3453
  );
3443
3454
  },
@@ -139,7 +139,9 @@ export class UMReceive {
139
139
  const classPrefix = 'cart-prefix';
140
140
  CartModule.addStyle(gvc, classPrefix);
141
141
  Promise.all([ApiUser.getUserData(GlobalUser.token, 'me'), this.funnyQuickFormFrame(classPrefix)]).then(dataArray => {
142
+ var _a;
142
143
  vm.userData = dataArray[0].response.userData;
144
+ vm.userData.receive_list = (_a = vm.userData.receive_list) !== null && _a !== void 0 ? _a : [];
143
145
  if (vm.userData.receive_list) {
144
146
  vm.dataList = [...vm.userData.receive_list, ...new Array(3 - vm.userData.receive_list.length).fill({})];
145
147
  }
@@ -104,7 +104,6 @@ export class UMReceive {
104
104
  .filter((data: any) => {
105
105
  return Object.values(data).some(Boolean);
106
106
  });
107
-
108
107
  ApiUser.updateUserData({
109
108
  userData: vm.userData,
110
109
  }).then(res => {
@@ -141,7 +140,7 @@ export class UMReceive {
141
140
  dataArray => {
142
141
  // dataArray[0] => userData
143
142
  vm.userData = dataArray[0].response.userData;
144
-
143
+ vm.userData.receive_list=vm.userData.receive_list ?? []
145
144
  if (vm.userData.receive_list) {
146
145
  vm.dataList = [...vm.userData.receive_list, ...new Array(3 - vm.userData.receive_list.length).fill({})];
147
146
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-glitter",
3
- "version": "21.6.5",
3
+ "version": "21.6.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {