ts-glitter 21.7.0 → 21.7.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/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.7.0';
149
+ glitter.share.editerVersion = 'V_21.7.2';
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.7.0';
153
+ glitter.share.editerVersion = 'V_21.7.2';
154
154
  glitter.share.start = new Date();
155
155
  const vm = { appConfig: [] };
156
156
  (window as any).saasConfig = {
@@ -238,6 +238,14 @@ export class Language {
238
238
  { key: 'discount', tw: '折抵', cn: '折抵', en: 'Discount' },
239
239
  { key: 'remaining_balance', tw: '您目前剩餘', cn: '您目前剩余', en: 'Your remaining balance' },
240
240
  { key: 'point', tw: '點', cn: '点', en: '' },
241
+ { key: 'recipient', tw: '收件人', cn: '收件人', en: 'Recipient' },
242
+ { key: 'add_recipient', tw: '新增收件人', cn: '新增收件人', en: 'Add Recipient' },
243
+ {
244
+ key: 'recipient_limit',
245
+ tw: '最多限制儲存 _max_ 名收件人',
246
+ cn: '最多限制保存 _max_ 名收件人',
247
+ en: 'You can save up to _max_ recipients',
248
+ },
241
249
  {
242
250
  key: 'max_discount_order',
243
251
  tw: '此份訂單最多可折抵',
@@ -247,6 +247,14 @@ export class Language {
247
247
  { key: 'discount', tw: '折抵', cn: '折抵', en: 'Discount' },
248
248
  { key: 'remaining_balance', tw: '您目前剩餘', cn: '您目前剩余', en: 'Your remaining balance' },
249
249
  { key: 'point', tw: '點', cn: '点', en: '' },
250
+ { key: 'recipient', tw: '收件人', cn: '收件人', en: 'Recipient' },
251
+ { key: 'add_recipient', tw: '新增收件人', cn: '新增收件人', en: 'Add Recipient' },
252
+ {
253
+ key: 'recipient_limit',
254
+ tw: '最多限制儲存 _max_ 名收件人',
255
+ cn: '最多限制保存 _max_ 名收件人',
256
+ en: 'You can save up to _max_ recipients',
257
+ },
250
258
  {
251
259
  key: 'max_discount_order',
252
260
  tw: '此份訂單最多可折抵',
@@ -901,6 +901,7 @@ export const component = Plugin.createComponent(import.meta.url, (glitter, editM
901
901
  return {
902
902
  bind: vm.id,
903
903
  view: () => __awaiter(this, void 0, void 0, function* () {
904
+ var _a;
904
905
  let refer_form = getReferForm(widget, type);
905
906
  function refresh(widget, device) {
906
907
  if (widget.data.refer_app) {
@@ -972,6 +973,8 @@ export const component = Plugin.createComponent(import.meta.url, (glitter, editM
972
973
  subData.editor_updated_callback(oWidget);
973
974
  }
974
975
  glitter.share.refer_form = refer_form;
976
+ glitter.share.refer_form_ = (_a = glitter.share.refer_form_) !== null && _a !== void 0 ? _a : {};
977
+ glitter.share.refer_form_[oWidget.data.tag] = refer_form;
975
978
  glitter.share.refresh_global = (() => {
976
979
  refresh(widget, type);
977
980
  });
@@ -1078,6 +1078,8 @@ export const component = Plugin.createComponent(import.meta.url, (glitter: Glitt
1078
1078
  subData.editor_updated_callback(oWidget);
1079
1079
  }
1080
1080
  glitter.share.refer_form=refer_form
1081
+ glitter.share.refer_form_=glitter.share.refer_form_ ?? {}
1082
+ glitter.share.refer_form_[oWidget.data.tag]=refer_form
1081
1083
  glitter.share.refresh_global=(()=>{
1082
1084
  refresh(widget,type)
1083
1085
  })
@@ -154,12 +154,11 @@ export class CheckoutIndex {
154
154
  })());
155
155
  }
156
156
  function resetShipmentSelected() {
157
- const findGroup = vm.logisticsGroup.find(item => item.key === localStorage.getItem('logistics-group'));
158
- if (findGroup) {
159
- const list = findGroup.list;
160
- const def = localStorage.getItem('shipment-select');
161
- if (!def || !list.includes(def)) {
162
- localStorage.setItem('shipment-select', list[0]);
157
+ const findGroup = vm.logisticsGroup.flatMap(item => item.list);
158
+ if (Array.isArray(findGroup) && findGroup.length > 0) {
159
+ const defaultShipment = localStorage.getItem('shipment-select');
160
+ if (!defaultShipment || !findGroup.includes(defaultShipment)) {
161
+ localStorage.setItem('shipment-select', findGroup[0]);
163
162
  }
164
163
  }
165
164
  }
@@ -1637,7 +1636,7 @@ export class CheckoutIndex {
1637
1636
  return html ` <option
1638
1637
  value="${dd.value}"
1639
1638
  ${vm.cartData.user_info.shipment === dd.value
1640
- ? `selected`
1639
+ ? 'selected'
1641
1640
  : ''}
1642
1641
  >
1643
1642
  ${Language.text(`ship_${dd.value}`) ||
@@ -2222,7 +2221,7 @@ export class CheckoutIndex {
2222
2221
  class="d-flex justify-content-between align-items-center p-1 w-100 gap-2"
2223
2222
  >
2224
2223
  <div class="d-flex flex-column">
2225
- <h5>收件人 ${index + 1}</h5>
2224
+ <h5>${Language.text('recipient')} ${index + 1}</h5>
2226
2225
  ${['name', 'email', 'phone']
2227
2226
  .filter(key => data[key])
2228
2227
  .map(key => {
@@ -3182,9 +3181,7 @@ export class CheckoutIndex {
3182
3181
  }
3183
3182
  let pass = true;
3184
3183
  if (subData.shipment === 'none') {
3185
- dialog.errorMessage({
3186
- text: Language.text('select_shipping_method'),
3187
- });
3184
+ dialog.errorMessage({ text: Language.text('select_shipping_method') });
3188
3185
  return false;
3189
3186
  }
3190
3187
  if (ShipmentConfig.supermarketList.includes(subData['shipment'])) {
@@ -201,12 +201,13 @@ export class CheckoutIndex {
201
201
  }
202
202
 
203
203
  function resetShipmentSelected() {
204
- const findGroup = vm.logisticsGroup.find(item => item.key === localStorage.getItem('logistics-group'));
205
- if (findGroup) {
206
- const list = findGroup.list;
207
- const def = localStorage.getItem('shipment-select');
208
- if (!def || !list.includes(def)) {
209
- localStorage.setItem('shipment-select', list[0]);
204
+ const findGroup = vm.logisticsGroup.flatMap(item => item.list);
205
+
206
+ if (Array.isArray(findGroup) && findGroup.length > 0) {
207
+ const defaultShipment = localStorage.getItem('shipment-select');
208
+
209
+ if (!defaultShipment || !findGroup.includes(defaultShipment)) {
210
+ localStorage.setItem('shipment-select', findGroup[0]);
210
211
  }
211
212
  }
212
213
  }
@@ -1786,6 +1787,7 @@ export class CheckoutIndex {
1786
1787
  return '';
1787
1788
  }
1788
1789
  };
1790
+
1789
1791
  return html` <div class="d-flex flex-column gap-1">
1790
1792
  <select
1791
1793
  class="w-100 ${gClass('select')}"
@@ -1813,7 +1815,7 @@ export class CheckoutIndex {
1813
1815
  return html` <option
1814
1816
  value="${dd.value}"
1815
1817
  ${vm.cartData.user_info.shipment === dd.value
1816
- ? `selected`
1818
+ ? 'selected'
1817
1819
  : ''}
1818
1820
  >
1819
1821
  ${Language.text(`ship_${dd.value}`) ||
@@ -2445,7 +2447,7 @@ export class CheckoutIndex {
2445
2447
  class="d-flex justify-content-between align-items-center p-1 w-100 gap-2"
2446
2448
  >
2447
2449
  <div class="d-flex flex-column">
2448
- <h5>收件人 ${index + 1}</h5>
2450
+ <h5>${Language.text('recipient')} ${index + 1}</h5>
2449
2451
  ${['name', 'email', 'phone']
2450
2452
  .filter(key => data[key])
2451
2453
  .map(key => {
@@ -3487,9 +3489,7 @@ export class CheckoutIndex {
3487
3489
 
3488
3490
  // 驗證有無配送方式
3489
3491
  if (subData.shipment === 'none') {
3490
- dialog.errorMessage({
3491
- text: Language.text('select_shipping_method'),
3492
- });
3492
+ dialog.errorMessage({ text: Language.text('select_shipping_method') });
3493
3493
  return false;
3494
3494
  }
3495
3495
 
@@ -82,7 +82,6 @@ export class CartModule {
82
82
  }
83
83
  }
84
84
  }
85
- const hasFullCart = vm.shippings.some(ship => ship.cartLength === cart.line_items.length);
86
85
  for (const item of cart.line_items) {
87
86
  const product = products.find((p) => `${p.id}` === `${item.id}`);
88
87
  if (product) {
@@ -113,17 +112,9 @@ export class CartModule {
113
112
  data.cart.push(lineItem);
114
113
  continue;
115
114
  }
116
- if (hasFullCart) {
117
- const filterGroup = vm.logisticsGroup.filter(group => productLogi.group.includes(group.key));
118
- for (const group of filterGroup) {
119
- if (group && group.list.includes(data.logistic)) {
120
- data.cart.push(lineItem);
121
- }
122
- }
123
- }
124
- else {
125
- const findGroup = vm.logisticsGroup.find(group => productLogi.group.includes(group.key));
126
- if (findGroup && findGroup.list.includes(data.logistic)) {
115
+ const filterGroup = vm.logisticsGroup.filter(group => productLogi.group.includes(group.key));
116
+ for (const group of filterGroup) {
117
+ if (group && group.list.includes(data.logistic)) {
127
118
  data.cart.push(lineItem);
128
119
  }
129
120
  }
@@ -126,7 +126,7 @@ export class CartModule {
126
126
  }
127
127
 
128
128
  // 是否有單一物流結果
129
- const hasFullCart = vm.shippings.some(ship => ship.cartLength === cart.line_items.length);
129
+ // const hasFullCart = vm.shippings.some(ship => ship.cartLength === cart.line_items.length);
130
130
 
131
131
  // 遍歷購物車商品,並加入所有物流群組
132
132
  for (const item of cart.line_items) {
@@ -163,17 +163,10 @@ export class CartModule {
163
163
  continue;
164
164
  }
165
165
 
166
- if (hasFullCart) {
167
- const filterGroup = vm.logisticsGroup.filter(group => productLogi.group.includes(group.key));
166
+ const filterGroup = vm.logisticsGroup.filter(group => productLogi.group.includes(group.key));
168
167
 
169
- for (const group of filterGroup) {
170
- if (group && group.list.includes(data.logistic)) {
171
- data.cart.push(lineItem);
172
- }
173
- }
174
- } else {
175
- const findGroup = vm.logisticsGroup.find(group => productLogi.group.includes(group.key));
176
- if (findGroup && findGroup.list.includes(data.logistic)) {
168
+ for (const group of filterGroup) {
169
+ if (group && group.list.includes(data.logistic)) {
177
170
  data.cart.push(lineItem);
178
171
  }
179
172
  }
@@ -28,6 +28,7 @@ export class UMReceive {
28
28
  dataList: [],
29
29
  dataKeys: [],
30
30
  };
31
+ const receive_list_max_length = 100;
31
32
  let changePage = (index, type, subData) => { };
32
33
  gvc.glitter.getModule(new URL('./official_event/page/change-page.js', gvc.glitter.root_path).href, cl => {
33
34
  changePage = cl.changePage;
@@ -38,6 +39,93 @@ export class UMReceive {
38
39
  if (vm.loading) {
39
40
  return UmClass.spinner();
40
41
  }
42
+ function saveView() {
43
+ return html `<div class="d-flex justify-content-end">
44
+ <div
45
+ class="um-nav-btn um-nav-btn-active d-flex align-items-center justify-content-center fw-bold"
46
+ onclick="${gvc.event(() => {
47
+ vm.userData.receive_list = vm.dataList
48
+ .map((data) => {
49
+ const temp = {};
50
+ vm.dataKeys.map(key => {
51
+ temp[key] = data[key];
52
+ });
53
+ return temp;
54
+ })
55
+ .filter((data) => {
56
+ return Object.values(data).some(Boolean);
57
+ });
58
+ ApiUser.updateUserData({
59
+ userData: vm.userData,
60
+ }).then(res => {
61
+ dialog.dataLoading({ visible: false });
62
+ if (!res.result && res.response.data.msg === 'email-verify-false') {
63
+ dialog.errorMessage({ text: Language.text('email_verification_code_incorrect') });
64
+ }
65
+ else if (!res.result && res.response.data.msg === 'phone-verify-false') {
66
+ dialog.errorMessage({ text: Language.text('sms_verification_code_incorrect') });
67
+ }
68
+ else if (!res.result && res.response.data.msg === 'phone-exists') {
69
+ dialog.errorMessage({ text: Language.text('phone_number_already_exists') });
70
+ }
71
+ else if (!res.result && res.response.data.msg === 'email-exists') {
72
+ dialog.errorMessage({ text: Language.text('email_already_exists') });
73
+ }
74
+ else if (!res.result) {
75
+ dialog.errorMessage({ text: Language.text('update_exception') });
76
+ }
77
+ else {
78
+ dialog.successMessage({ text: Language.text('change_success') });
79
+ gvc.recreateView();
80
+ }
81
+ });
82
+ })}"
83
+ >
84
+ ${Language.text('confirm')}
85
+ </div>
86
+ </div>`;
87
+ }
88
+ function recipientView() {
89
+ return html ` <div class="col-12" style="min-height: 500px;">
90
+ ${vm.dataList
91
+ .map((data, index) => {
92
+ const cloneForm = JSON.parse(JSON.stringify(vm.funnyForm));
93
+ return html `<div class="px-0 py-2 px-md-2 py-md-4 mb-3">
94
+ <h5>${Language.text('recipient')} ${index + 1}</h5>
95
+ ${FormWidget.editorView({
96
+ gvc: gvc,
97
+ array: cloneForm.map((dd, index) => {
98
+ dd.col = '6';
99
+ if (index === cloneForm.length - 1) {
100
+ dd.col = '12';
101
+ }
102
+ return dd;
103
+ }),
104
+ refresh: () => {
105
+ gvc.notifyDataChange(vm.id);
106
+ },
107
+ formData: data,
108
+ })}
109
+ </div>`;
110
+ })
111
+ .join('')}
112
+ </div>`;
113
+ }
114
+ function plusButton() {
115
+ return html `<div
116
+ class="w-100 d-flex justify-content-center align-items-center gap-2"
117
+ style="color: #3366BB; cursor: pointer"
118
+ onclick="${gvc.event(() => {
119
+ vm.dataList.push({});
120
+ gvc.notifyDataChange(vm.id);
121
+ })}"
122
+ >
123
+ <div style="font-size: 16px; font-weight: 400; word-wrap: break-word">
124
+ ${Language.text('add_recipient')}
125
+ </div>
126
+ <i class="fa-solid fa-plus"></i>
127
+ </div>`;
128
+ }
41
129
  return html `
42
130
  <div class="row mx-auto p-0">
43
131
  <div class="w-100 align-items-center d-flex py-3 pb-lg-3 pt-lg-0" style="gap:10px;">
@@ -63,74 +151,9 @@ export class UMReceive {
63
151
  </div>
64
152
  <div class="um-info-title fw-bold" style="font-size: 24px;">${Language.text('recipient_info')}</div>
65
153
  </div>
66
- <div class="col-12" style="min-height: 500px;">
67
- ${vm.dataList
68
- .map((data, index) => {
69
- const cloneForm = JSON.parse(JSON.stringify(vm.funnyForm));
70
- return html `<div class="px-0 py-2 px-md-2 py-md-4 mb-3">
71
- <h5>收件人 ${index + 1}</h5>
72
- ${FormWidget.editorView({
73
- gvc: gvc,
74
- array: cloneForm.map((dd, index) => {
75
- dd.col = '6';
76
- if (index === cloneForm.length - 1) {
77
- dd.col = '12';
78
- }
79
- return dd;
80
- }),
81
- refresh: () => {
82
- gvc.notifyDataChange(vm.id);
83
- },
84
- formData: data,
85
- })}
86
- </div>`;
87
- })
88
- .join('')}
89
- <div class="d-flex justify-content-end">
90
- <div
91
- class="um-nav-btn um-nav-btn-active d-flex align-items-center justify-content-center fw-bold"
92
- onclick="${gvc.event(() => {
93
- vm.userData.receive_list = vm.dataList
94
- .map((data) => {
95
- const temp = {};
96
- vm.dataKeys.map(key => {
97
- temp[key] = data[key];
98
- });
99
- return temp;
100
- })
101
- .filter((data) => {
102
- return Object.values(data).some(Boolean);
103
- });
104
- ApiUser.updateUserData({
105
- userData: vm.userData,
106
- }).then(res => {
107
- dialog.dataLoading({ visible: false });
108
- if (!res.result && res.response.data.msg === 'email-verify-false') {
109
- dialog.errorMessage({ text: Language.text('email_verification_code_incorrect') });
110
- }
111
- else if (!res.result && res.response.data.msg === 'phone-verify-false') {
112
- dialog.errorMessage({ text: Language.text('sms_verification_code_incorrect') });
113
- }
114
- else if (!res.result && res.response.data.msg === 'phone-exists') {
115
- dialog.errorMessage({ text: Language.text('phone_number_already_exists') });
116
- }
117
- else if (!res.result && res.response.data.msg === 'email-exists') {
118
- dialog.errorMessage({ text: Language.text('email_already_exists') });
119
- }
120
- else if (!res.result) {
121
- dialog.errorMessage({ text: Language.text('update_exception') });
122
- }
123
- else {
124
- dialog.successMessage({ text: Language.text('change_success') });
125
- gvc.recreateView();
126
- }
127
- });
128
- })}"
129
- >
130
- ${Language.text('confirm')}
131
- </div>
132
- </div>
133
- </div>
154
+ ${vm.dataList.length > 0 ? [saveView(), recipientView()].join('') : ''}
155
+ <div class="w-100 my-3" style="background: white;height: 1px;"></div>
156
+ ${receive_list_max_length > vm.dataList.length ? plusButton() : ''}
134
157
  </div>
135
158
  `;
136
159
  }),
@@ -139,12 +162,9 @@ export class UMReceive {
139
162
  const classPrefix = 'cart-prefix';
140
163
  CartModule.addStyle(gvc, classPrefix);
141
164
  Promise.all([ApiUser.getUserData(GlobalUser.token, 'me'), this.funnyQuickFormFrame(classPrefix)]).then(dataArray => {
142
- var _a;
143
165
  vm.userData = dataArray[0].response.userData;
144
- vm.userData.receive_list = (_a = vm.userData.receive_list) !== null && _a !== void 0 ? _a : [];
145
- if (vm.userData.receive_list) {
146
- vm.dataList = [...vm.userData.receive_list, ...new Array(3 - vm.userData.receive_list.length).fill({})];
147
- }
166
+ vm.userData.receive_list = Array.isArray(vm.userData.receive_list) ? vm.userData.receive_list : [];
167
+ vm.dataList = vm.userData.receive_list;
148
168
  vm.funnyForm = dataArray[1];
149
169
  vm.dataKeys = vm.funnyForm.map((item) => item.key).filter(Boolean);
150
170
  vm.loading = false;
@@ -22,6 +22,7 @@ export class UMReceive {
22
22
  dataList: [] as any,
23
23
  dataKeys: [] as string[],
24
24
  };
25
+ const receive_list_max_length = 100;
25
26
 
26
27
  let changePage = (index: string, type: 'page' | 'home', subData: any) => {};
27
28
  gvc.glitter.getModule(new URL('./official_event/page/change-page.js', gvc.glitter.root_path).href, cl => {
@@ -35,6 +36,91 @@ export class UMReceive {
35
36
  return UmClass.spinner();
36
37
  }
37
38
 
39
+ function saveView() {
40
+ return html`<div class="d-flex justify-content-end">
41
+ <div
42
+ class="um-nav-btn um-nav-btn-active d-flex align-items-center justify-content-center fw-bold"
43
+ onclick="${gvc.event(() => {
44
+ vm.userData.receive_list = vm.dataList
45
+ .map((data: any) => {
46
+ const temp = {} as any;
47
+ vm.dataKeys.map(key => {
48
+ temp[key] = data[key];
49
+ });
50
+ return temp;
51
+ })
52
+ .filter((data: any) => {
53
+ return Object.values(data).some(Boolean);
54
+ });
55
+ ApiUser.updateUserData({
56
+ userData: vm.userData,
57
+ }).then(res => {
58
+ dialog.dataLoading({ visible: false });
59
+ if (!res.result && res.response.data.msg === 'email-verify-false') {
60
+ dialog.errorMessage({ text: Language.text('email_verification_code_incorrect') });
61
+ } else if (!res.result && res.response.data.msg === 'phone-verify-false') {
62
+ dialog.errorMessage({ text: Language.text('sms_verification_code_incorrect') });
63
+ } else if (!res.result && res.response.data.msg === 'phone-exists') {
64
+ dialog.errorMessage({ text: Language.text('phone_number_already_exists') });
65
+ } else if (!res.result && res.response.data.msg === 'email-exists') {
66
+ dialog.errorMessage({ text: Language.text('email_already_exists') });
67
+ } else if (!res.result) {
68
+ dialog.errorMessage({ text: Language.text('update_exception') });
69
+ } else {
70
+ dialog.successMessage({ text: Language.text('change_success') });
71
+ gvc.recreateView();
72
+ }
73
+ });
74
+ })}"
75
+ >
76
+ ${Language.text('confirm')}
77
+ </div>
78
+ </div>`;
79
+ }
80
+
81
+ function recipientView() {
82
+ return html` <div class="col-12" style="min-height: 500px;">
83
+ ${vm.dataList
84
+ .map((data: any, index: number) => {
85
+ const cloneForm = JSON.parse(JSON.stringify(vm.funnyForm));
86
+ return html`<div class="px-0 py-2 px-md-2 py-md-4 mb-3">
87
+ <h5>${Language.text('recipient')} ${index + 1}</h5>
88
+ ${FormWidget.editorView({
89
+ gvc: gvc,
90
+ array: cloneForm.map((dd: any, index: number) => {
91
+ dd.col = '6';
92
+ if (index === cloneForm.length - 1) {
93
+ dd.col = '12';
94
+ }
95
+ return dd;
96
+ }),
97
+ refresh: () => {
98
+ gvc.notifyDataChange(vm.id);
99
+ },
100
+ formData: data,
101
+ })}
102
+ </div>`;
103
+ })
104
+ .join('')}
105
+ </div>`;
106
+ }
107
+
108
+ function plusButton() {
109
+ return html`<div
110
+ class="w-100 d-flex justify-content-center align-items-center gap-2"
111
+ style="color: #3366BB; cursor: pointer"
112
+ onclick="${gvc.event(() => {
113
+ vm.dataList.push({});
114
+ gvc.notifyDataChange(vm.id);
115
+ })}"
116
+ >
117
+ <div style="font-size: 16px; font-weight: 400; word-wrap: break-word">
118
+ ${Language.text('add_recipient')}
119
+ </div>
120
+ <i class="fa-solid fa-plus"></i>
121
+ </div>`;
122
+ }
123
+
38
124
  return html`
39
125
  <div class="row mx-auto p-0">
40
126
  <div class="w-100 align-items-center d-flex py-3 pb-lg-3 pt-lg-0" style="gap:10px;">
@@ -66,69 +152,9 @@ export class UMReceive {
66
152
  </div>
67
153
  <div class="um-info-title fw-bold" style="font-size: 24px;">${Language.text('recipient_info')}</div>
68
154
  </div>
69
- <div class="col-12" style="min-height: 500px;">
70
- ${vm.dataList
71
- .map((data: any, index: number) => {
72
- const cloneForm = JSON.parse(JSON.stringify(vm.funnyForm));
73
- return html`<div class="px-0 py-2 px-md-2 py-md-4 mb-3">
74
- <h5>收件人 ${index + 1}</h5>
75
- ${FormWidget.editorView({
76
- gvc: gvc,
77
- array: cloneForm.map((dd: any, index: number) => {
78
- dd.col = '6';
79
- if (index === cloneForm.length - 1) {
80
- dd.col = '12';
81
- }
82
- return dd;
83
- }),
84
- refresh: () => {
85
- gvc.notifyDataChange(vm.id);
86
- },
87
- formData: data,
88
- })}
89
- </div>`;
90
- })
91
- .join('')}
92
- <div class="d-flex justify-content-end">
93
- <div
94
- class="um-nav-btn um-nav-btn-active d-flex align-items-center justify-content-center fw-bold"
95
- onclick="${gvc.event(() => {
96
- vm.userData.receive_list = vm.dataList
97
- .map((data: any) => {
98
- const temp = {} as any;
99
- vm.dataKeys.map(key => {
100
- temp[key] = data[key];
101
- });
102
- return temp;
103
- })
104
- .filter((data: any) => {
105
- return Object.values(data).some(Boolean);
106
- });
107
- ApiUser.updateUserData({
108
- userData: vm.userData,
109
- }).then(res => {
110
- dialog.dataLoading({ visible: false });
111
- if (!res.result && res.response.data.msg === 'email-verify-false') {
112
- dialog.errorMessage({ text: Language.text('email_verification_code_incorrect') });
113
- } else if (!res.result && res.response.data.msg === 'phone-verify-false') {
114
- dialog.errorMessage({ text: Language.text('sms_verification_code_incorrect') });
115
- } else if (!res.result && res.response.data.msg === 'phone-exists') {
116
- dialog.errorMessage({ text: Language.text('phone_number_already_exists') });
117
- } else if (!res.result && res.response.data.msg === 'email-exists') {
118
- dialog.errorMessage({ text: Language.text('email_already_exists') });
119
- } else if (!res.result) {
120
- dialog.errorMessage({ text: Language.text('update_exception') });
121
- } else {
122
- dialog.successMessage({ text: Language.text('change_success') });
123
- gvc.recreateView();
124
- }
125
- });
126
- })}"
127
- >
128
- ${Language.text('confirm')}
129
- </div>
130
- </div>
131
- </div>
155
+ ${vm.dataList.length > 0 ? [saveView(), recipientView()].join('') : ''}
156
+ <div class="w-100 my-3" style="background: white;height: 1px;"></div>
157
+ ${receive_list_max_length > vm.dataList.length ? plusButton() : ''}
132
158
  </div>
133
159
  `;
134
160
  },
@@ -140,10 +166,9 @@ export class UMReceive {
140
166
  dataArray => {
141
167
  // dataArray[0] => userData
142
168
  vm.userData = dataArray[0].response.userData;
143
- vm.userData.receive_list=vm.userData.receive_list ?? []
144
- if (vm.userData.receive_list) {
145
- vm.dataList = [...vm.userData.receive_list, ...new Array(3 - vm.userData.receive_list.length).fill({})];
146
- }
169
+ vm.userData.receive_list = Array.isArray(vm.userData.receive_list) ? vm.userData.receive_list : [];
170
+
171
+ vm.dataList = vm.userData.receive_list;
147
172
 
148
173
  // dataArray[1] => funnyForm
149
174
  vm.funnyForm = dataArray[1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-glitter",
3
- "version": "21.7.0",
3
+ "version": "21.7.2",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {