ts-glitter 14.2.9 → 14.3.0
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 +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/backend-manager/bg-recommend.js +4 -6
- package/lowcode/backend-manager/bg-recommend.ts +4 -6
- package/lowcode/cms-plugin/shopping-rebate-setting.js +21 -6
- package/lowcode/cms-plugin/shopping-rebate-setting.ts +24 -8
- package/lowcode/glitter-base/route/wallet.js +11 -0
- package/lowcode/glitter-base/route/wallet.ts +14 -2
- package/lowcode/glitterBundle/plugins/editor-elem.js +32 -11
- package/lowcode/glitterBundle/plugins/editor-elem.ts +42 -12
- package/lowcode/public-components/checkout/index.js +35 -27
- package/lowcode/public-components/checkout/index.ts +111 -106
- package/lowcode/public-components/product/product-detail.js +182 -171
- package/lowcode/public-components/product/product-detail.ts +214 -196
- package/lowcode/public-components/user-manager/um-class.js +234 -193
- package/lowcode/public-components/user-manager/um-class.ts +230 -189
- package/lowcode/public-components/user-manager/um-rebate.js +13 -8
- package/lowcode/public-components/user-manager/um-rebate.ts +17 -12
- package/lowcode/public-components/user-manager/um-voucher.js +3 -3
- package/lowcode/public-components/user-manager/um-voucher.ts +3 -3
- package/package.json +1 -1
- package/src/api-public/controllers/ai-chat.js.map +1 -1
- package/src/api-public/controllers/app-release.js.map +1 -1
- package/src/api-public/controllers/article.js.map +1 -1
- package/src/api-public/controllers/post.js.map +1 -1
- package/src/api-public/controllers/shop.js +23 -12
- package/src/api-public/controllers/shop.js.map +1 -1
- package/src/api-public/controllers/shop.ts +36 -36
- package/src/api-public/controllers/user.js.map +1 -1
- package/src/api-public/services/EcInvoice.js.map +5 -1
- package/src/api-public/services/ai-robot.js.map +1 -1
- package/src/api-public/services/financial-service.d.ts +1 -0
- package/src/api-public/services/financial-service.js.map +1 -1
- package/src/api-public/services/post.js.map +1 -1
- package/src/api-public/services/rebate.d.ts +1 -0
- package/src/api-public/services/rebate.js +15 -0
- package/src/api-public/services/rebate.js.map +1 -1
- package/src/api-public/services/rebate.ts +21 -5
- package/src/api-public/services/shopping.js +0 -3
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +0 -4
- package/src/index.js +3 -3
- package/src/index.js.map +5 -1
- package/src/services/template.js.map +1 -1
package/lowcode/Entry.js
CHANGED
|
@@ -70,7 +70,7 @@ export class Entry {
|
|
|
70
70
|
}
|
|
71
71
|
window.renderClock = (_a = window.renderClock) !== null && _a !== void 0 ? _a : clockF();
|
|
72
72
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
73
|
-
glitter.share.editerVersion = 'V_14.
|
|
73
|
+
glitter.share.editerVersion = 'V_14.3.0';
|
|
74
74
|
glitter.share.start = new Date();
|
|
75
75
|
const vm = {
|
|
76
76
|
appConfig: [],
|
package/lowcode/Entry.ts
CHANGED
|
@@ -72,7 +72,7 @@ export class Entry {
|
|
|
72
72
|
}
|
|
73
73
|
(window as any).renderClock = (window as any).renderClock ?? clockF();
|
|
74
74
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
75
|
-
glitter.share.editerVersion = 'V_14.
|
|
75
|
+
glitter.share.editerVersion = 'V_14.3.0';
|
|
76
76
|
glitter.share.start = new Date();
|
|
77
77
|
const vm: {
|
|
78
78
|
appConfig: any;
|
|
@@ -78,10 +78,7 @@ export class BgRecommend {
|
|
|
78
78
|
},
|
|
79
79
|
});
|
|
80
80
|
},
|
|
81
|
-
divCreate: {
|
|
82
|
-
class: 'mx-auto',
|
|
83
|
-
style: 'max-width: 100%; width: 960px;',
|
|
84
|
-
},
|
|
81
|
+
divCreate: {},
|
|
85
82
|
onCreate: () => {
|
|
86
83
|
if (vm.loading) {
|
|
87
84
|
new Promise((resolve) => {
|
|
@@ -133,7 +130,7 @@ export class BgRecommend {
|
|
|
133
130
|
bind: id,
|
|
134
131
|
view: () => {
|
|
135
132
|
return html `<span
|
|
136
|
-
style="color: #4D86DB;"
|
|
133
|
+
style="cursor: pointer; color: #4D86DB;"
|
|
137
134
|
onclick="${gvc.event(() => {
|
|
138
135
|
glitter.openNewTab(url);
|
|
139
136
|
})}"
|
|
@@ -142,6 +139,7 @@ export class BgRecommend {
|
|
|
142
139
|
</span>`;
|
|
143
140
|
},
|
|
144
141
|
divCreate: {
|
|
142
|
+
class: 'me-4',
|
|
145
143
|
option: [
|
|
146
144
|
{
|
|
147
145
|
key: 'onclick',
|
|
@@ -180,7 +178,7 @@ export class BgRecommend {
|
|
|
180
178
|
},
|
|
181
179
|
{
|
|
182
180
|
key: '期限',
|
|
183
|
-
value: `<div class="fs-7">${dd.content.startDate}
|
|
181
|
+
value: `<div class="fs-7">${dd.content.startDate} ~ ${(_c = dd.content.endDate) !== null && _c !== void 0 ? _c : '永不過期'}</div>`,
|
|
184
182
|
},
|
|
185
183
|
{
|
|
186
184
|
key: '狀態',
|
|
@@ -132,10 +132,7 @@ export class BgRecommend {
|
|
|
132
132
|
},
|
|
133
133
|
});
|
|
134
134
|
},
|
|
135
|
-
divCreate: {
|
|
136
|
-
class: 'mx-auto',
|
|
137
|
-
style: 'max-width: 100%; width: 960px;',
|
|
138
|
-
},
|
|
135
|
+
divCreate: {},
|
|
139
136
|
onCreate: () => {
|
|
140
137
|
if (vm.loading) {
|
|
141
138
|
new Promise<any[]>((resolve) => {
|
|
@@ -188,7 +185,7 @@ export class BgRecommend {
|
|
|
188
185
|
bind: id,
|
|
189
186
|
view: () => {
|
|
190
187
|
return html`<span
|
|
191
|
-
style="color: #4D86DB;"
|
|
188
|
+
style="cursor: pointer; color: #4D86DB;"
|
|
192
189
|
onclick="${gvc.event(() => {
|
|
193
190
|
glitter.openNewTab(url);
|
|
194
191
|
})}"
|
|
@@ -197,6 +194,7 @@ export class BgRecommend {
|
|
|
197
194
|
</span>`;
|
|
198
195
|
},
|
|
199
196
|
divCreate: {
|
|
197
|
+
class: 'me-4',
|
|
200
198
|
option: [
|
|
201
199
|
{
|
|
202
200
|
key: 'onclick',
|
|
@@ -236,7 +234,7 @@ export class BgRecommend {
|
|
|
236
234
|
},
|
|
237
235
|
{
|
|
238
236
|
key: '期限',
|
|
239
|
-
value: `<div class="fs-7">${dd.content.startDate}
|
|
237
|
+
value: `<div class="fs-7">${dd.content.startDate} ~ ${dd.content.endDate ?? '永不過期'}</div>`,
|
|
240
238
|
},
|
|
241
239
|
{
|
|
242
240
|
key: '狀態',
|
|
@@ -14,6 +14,7 @@ export class ShoppingRebateSetting {
|
|
|
14
14
|
type: 'list',
|
|
15
15
|
data: {
|
|
16
16
|
main: false,
|
|
17
|
+
title: '',
|
|
17
18
|
register: {
|
|
18
19
|
switch: false,
|
|
19
20
|
value: 100,
|
|
@@ -116,18 +117,32 @@ export class ShoppingRebateSetting {
|
|
|
116
117
|
${BgWidget.container([
|
|
117
118
|
BgWidget.container1x2({
|
|
118
119
|
html: [
|
|
119
|
-
BgWidget.mainCard(html `<div>
|
|
120
|
-
<div
|
|
120
|
+
BgWidget.mainCard(html `<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
121
|
+
<div>
|
|
121
122
|
<span class="tx_700">購物金功能</span>
|
|
122
123
|
</div>
|
|
123
|
-
<div
|
|
124
|
-
<div
|
|
125
|
-
|
|
124
|
+
<div class="gray-bottom-line-18">
|
|
125
|
+
<div style="display: flex; align-items: center; gap: 4px; margin-bottom: 8px;">
|
|
126
|
+
<div class="tx_normal">購物金功能開啟</div>
|
|
127
|
+
${BgWidget.switchButton(gvc, vm.data.main, (bool) => {
|
|
126
128
|
vm.data.main = bool;
|
|
127
129
|
gvc.notifyDataChange(vm.settingId);
|
|
128
130
|
})}
|
|
131
|
+
</div>
|
|
132
|
+
${BgWidget.grayNote('一鍵開啟或關閉整個平台的購物金功能,停用後顧客將無法獲取或使用購物金來折抵消費金額。')}
|
|
133
|
+
</div>
|
|
134
|
+
<div>
|
|
135
|
+
${BgWidget.editeInput({
|
|
136
|
+
gvc: gvc,
|
|
137
|
+
title: '購物金前台名稱',
|
|
138
|
+
default: vm.data.title,
|
|
139
|
+
callback: (text) => {
|
|
140
|
+
vm.data.title = text;
|
|
141
|
+
},
|
|
142
|
+
placeHolder: '請輸入購物金前台名稱',
|
|
143
|
+
})}
|
|
144
|
+
${BgWidget.grayNote('消費者在前台商店看到的購物金名稱,如「Lucky Point」、「樂購點」,無填寫則顯示「購物金」')}
|
|
129
145
|
</div>
|
|
130
|
-
${BgWidget.grayNote('一鍵開啟或關閉整個平台的購物金功能,停用後顧客將無法獲取或使用購物金來折抵消費金額。')}
|
|
131
146
|
</div>`),
|
|
132
147
|
gvc.bindView({
|
|
133
148
|
bind: vm.settingId,
|
|
@@ -8,6 +8,7 @@ const html = String.raw;
|
|
|
8
8
|
|
|
9
9
|
interface RebateSetting {
|
|
10
10
|
main: boolean;
|
|
11
|
+
title: string;
|
|
11
12
|
register: {
|
|
12
13
|
switch: boolean;
|
|
13
14
|
value: number;
|
|
@@ -46,6 +47,7 @@ export class ShoppingRebateSetting {
|
|
|
46
47
|
type: 'list',
|
|
47
48
|
data: {
|
|
48
49
|
main: false,
|
|
50
|
+
title: '',
|
|
49
51
|
register: {
|
|
50
52
|
switch: false,
|
|
51
53
|
value: 100,
|
|
@@ -158,18 +160,32 @@ export class ShoppingRebateSetting {
|
|
|
158
160
|
BgWidget.container1x2(
|
|
159
161
|
{
|
|
160
162
|
html: [
|
|
161
|
-
BgWidget.mainCard(html`<div>
|
|
162
|
-
<div
|
|
163
|
+
BgWidget.mainCard(html`<div style="display: flex; flex-direction: column; gap: 16px;">
|
|
164
|
+
<div>
|
|
163
165
|
<span class="tx_700">購物金功能</span>
|
|
164
166
|
</div>
|
|
165
|
-
<div
|
|
166
|
-
<div
|
|
167
|
-
|
|
168
|
-
vm.data.main
|
|
169
|
-
|
|
167
|
+
<div class="gray-bottom-line-18">
|
|
168
|
+
<div style="display: flex; align-items: center; gap: 4px; margin-bottom: 8px;">
|
|
169
|
+
<div class="tx_normal">購物金功能開啟</div>
|
|
170
|
+
${BgWidget.switchButton(gvc, vm.data.main, (bool) => {
|
|
171
|
+
vm.data.main = bool;
|
|
172
|
+
gvc.notifyDataChange(vm.settingId);
|
|
173
|
+
})}
|
|
174
|
+
</div>
|
|
175
|
+
${BgWidget.grayNote('一鍵開啟或關閉整個平台的購物金功能,停用後顧客將無法獲取或使用購物金來折抵消費金額。')}
|
|
176
|
+
</div>
|
|
177
|
+
<div>
|
|
178
|
+
${BgWidget.editeInput({
|
|
179
|
+
gvc: gvc,
|
|
180
|
+
title: '購物金前台名稱',
|
|
181
|
+
default: vm.data.title,
|
|
182
|
+
callback: (text) => {
|
|
183
|
+
vm.data.title = text;
|
|
184
|
+
},
|
|
185
|
+
placeHolder: '請輸入購物金前台名稱',
|
|
170
186
|
})}
|
|
187
|
+
${BgWidget.grayNote('消費者在前台商店看到的購物金名稱,如「Lucky Point」、「樂購點」,無填寫則顯示「購物金」')}
|
|
171
188
|
</div>
|
|
172
|
-
${BgWidget.grayNote('一鍵開啟或關閉整個平台的購物金功能,停用後顧客將無法獲取或使用購物金來折抵消費金額。')}
|
|
173
189
|
</div>`),
|
|
174
190
|
gvc.bindView({
|
|
175
191
|
bind: vm.settingId,
|
|
@@ -136,6 +136,17 @@ export class ApiWallet {
|
|
|
136
136
|
},
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
+
static getRebateConfig(json) {
|
|
140
|
+
return BaseApi.create({
|
|
141
|
+
url: getBaseUrl() + `/api-public/v1/ec/rebate/config`,
|
|
142
|
+
type: 'GET',
|
|
143
|
+
headers: {
|
|
144
|
+
'g-app': getConfig().config.appName,
|
|
145
|
+
'Content-Type': 'application/json',
|
|
146
|
+
Authorization: json.type === 'me' ? GlobalUser.token : getConfig().config.token,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
}
|
|
139
150
|
static getRebate(json) {
|
|
140
151
|
return BaseApi.create({
|
|
141
152
|
url: getBaseUrl() +
|
|
@@ -28,14 +28,14 @@ export class ApiWallet {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
public static getWallet(token?:string) {
|
|
31
|
+
public static getWallet(token?: string) {
|
|
32
32
|
return BaseApi.create({
|
|
33
33
|
url: getBaseUrl() + `/api-public/v1/wallet/sum`,
|
|
34
34
|
type: 'GET',
|
|
35
35
|
headers: {
|
|
36
36
|
'Content-Type': 'application/json',
|
|
37
37
|
'g-app': getConfig().config.appName,
|
|
38
|
-
Authorization:
|
|
38
|
+
Authorization: token || getConfig().config.token,
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -145,6 +145,18 @@ export class ApiWallet {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
public static getRebateConfig(json: { type?: 'me' | 'all' }) {
|
|
149
|
+
return BaseApi.create({
|
|
150
|
+
url: getBaseUrl() + `/api-public/v1/ec/rebate/config`,
|
|
151
|
+
type: 'GET',
|
|
152
|
+
headers: {
|
|
153
|
+
'g-app': getConfig().config.appName,
|
|
154
|
+
'Content-Type': 'application/json',
|
|
155
|
+
Authorization: json.type === 'me' ? GlobalUser.token : getConfig().config.token,
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
|
|
148
160
|
public static getRebate(json: { limit: number; page: number; search?: string; id?: string; type?: 'me' | 'all'; dataType?: 'one' | 'all' }) {
|
|
149
161
|
return BaseApi.create({
|
|
150
162
|
url:
|
|
@@ -1887,7 +1887,12 @@ ${obj.gvc.bindView(() => {
|
|
|
1887
1887
|
}
|
|
1888
1888
|
static numberInput(obj) {
|
|
1889
1889
|
const viewId = obj.gvc.glitter.getUUID();
|
|
1890
|
-
const def = () => ({
|
|
1890
|
+
const def = () => ({
|
|
1891
|
+
gvc: obj.gvc,
|
|
1892
|
+
num: obj.default,
|
|
1893
|
+
min: obj.min,
|
|
1894
|
+
max: obj.max,
|
|
1895
|
+
});
|
|
1891
1896
|
return html `${obj.title ? EditorElem.h3(obj.title) : ``}
|
|
1892
1897
|
<div class="d-flex align-items-center">
|
|
1893
1898
|
${obj.gvc.bindView({
|
|
@@ -1900,27 +1905,48 @@ ${obj.gvc.bindView(() => {
|
|
|
1900
1905
|
type="number"
|
|
1901
1906
|
placeholder="${obj.placeHolder}"
|
|
1902
1907
|
onchange="${obj.gvc.event((e) => {
|
|
1903
|
-
const n = this.
|
|
1908
|
+
const n = this.floatInterval(Object.assign(Object.assign({}, def()), { num: e.value }));
|
|
1904
1909
|
obj.default = n;
|
|
1905
1910
|
obj.callback(n);
|
|
1906
1911
|
obj.gvc.notifyDataChange(viewId);
|
|
1907
1912
|
})}"
|
|
1908
|
-
value="${obj.default !== undefined ? this.
|
|
1913
|
+
value="${obj.default !== undefined ? this.floatInterval(def()) : ''}"
|
|
1909
1914
|
${obj.readonly ? `readonly` : ``}
|
|
1910
1915
|
/>`;
|
|
1911
1916
|
},
|
|
1912
1917
|
divCreate: { class: 'w-100' },
|
|
1913
1918
|
onCreate: () => {
|
|
1914
1919
|
if (!this.checkNumberMinMax(def())) {
|
|
1915
|
-
obj.callback(this.
|
|
1920
|
+
obj.callback(this.floatInterval(def()));
|
|
1916
1921
|
}
|
|
1917
1922
|
},
|
|
1918
1923
|
})}
|
|
1919
1924
|
${obj.unit ? html ` <div class="p-2">${obj.unit}</div>` : ''}
|
|
1920
1925
|
</div> `;
|
|
1921
1926
|
}
|
|
1927
|
+
static floatInterval(obj) {
|
|
1928
|
+
const dialog = new ShareDialog(obj.gvc.glitter);
|
|
1929
|
+
let n = parseFloat(`${obj.num}`);
|
|
1930
|
+
if (isNaN(n)) {
|
|
1931
|
+
dialog.errorMessage({ text: '請輸入數字' });
|
|
1932
|
+
}
|
|
1933
|
+
if (obj.precision !== undefined && obj.precision >= 0) {
|
|
1934
|
+
n = parseFloat(n.toFixed(obj.precision));
|
|
1935
|
+
}
|
|
1936
|
+
if (obj.max !== undefined && n > obj.max) {
|
|
1937
|
+
return obj.max;
|
|
1938
|
+
}
|
|
1939
|
+
if (obj.min !== undefined && n < obj.min) {
|
|
1940
|
+
return obj.min;
|
|
1941
|
+
}
|
|
1942
|
+
return n;
|
|
1943
|
+
}
|
|
1922
1944
|
static numberInterval(obj) {
|
|
1945
|
+
const dialog = new ShareDialog(obj.gvc.glitter);
|
|
1923
1946
|
const n = parseInt(`${obj.num}`, 10);
|
|
1947
|
+
if (isNaN(n)) {
|
|
1948
|
+
dialog.errorMessage({ text: '請輸入數字' });
|
|
1949
|
+
}
|
|
1924
1950
|
if (obj.max !== undefined && n > obj.max) {
|
|
1925
1951
|
return obj.max;
|
|
1926
1952
|
}
|
|
@@ -2245,17 +2271,12 @@ ${obj.gvc.bindView(() => {
|
|
|
2245
2271
|
static editerDialog(par) {
|
|
2246
2272
|
return html ` <button
|
|
2247
2273
|
type="button"
|
|
2248
|
-
class="btn btn-primary-c
|
|
2249
|
-
style=""
|
|
2274
|
+
class="btn btn-primary-c w-100"
|
|
2250
2275
|
onclick="${par.gvc.event(() => {
|
|
2251
2276
|
const gvc = par.gvc;
|
|
2252
2277
|
NormalPageEditor.toggle({
|
|
2253
2278
|
visible: true,
|
|
2254
|
-
view: `
|
|
2255
|
-
<div class="p-2"
|
|
2256
|
-
style="overflow-y:auto;">
|
|
2257
|
-
${par.dialog(gvc)}
|
|
2258
|
-
</div>`,
|
|
2279
|
+
view: html ` <div class="p-2" style="overflow-y:auto;">${par.dialog(gvc)}</div>`,
|
|
2259
2280
|
title: par.editTitle || '',
|
|
2260
2281
|
});
|
|
2261
2282
|
par.callback && (NormalPageEditor.closeEvent = par.callback);
|
|
@@ -2059,7 +2059,12 @@ ${obj.gvc.bindView(() => {
|
|
|
2059
2059
|
readonly?: boolean;
|
|
2060
2060
|
}) {
|
|
2061
2061
|
const viewId = obj.gvc.glitter.getUUID();
|
|
2062
|
-
const def = () => ({
|
|
2062
|
+
const def = () => ({
|
|
2063
|
+
gvc: obj.gvc,
|
|
2064
|
+
num: obj.default,
|
|
2065
|
+
min: obj.min,
|
|
2066
|
+
max: obj.max,
|
|
2067
|
+
});
|
|
2063
2068
|
return html`${obj.title ? EditorElem.h3(obj.title) : ``}
|
|
2064
2069
|
<div class="d-flex align-items-center">
|
|
2065
2070
|
${obj.gvc.bindView({
|
|
@@ -2071,7 +2076,7 @@ ${obj.gvc.bindView(() => {
|
|
|
2071
2076
|
type="number"
|
|
2072
2077
|
placeholder="${obj.placeHolder}"
|
|
2073
2078
|
onchange="${obj.gvc.event((e) => {
|
|
2074
|
-
const n = this.
|
|
2079
|
+
const n = this.floatInterval({
|
|
2075
2080
|
...def(),
|
|
2076
2081
|
num: e.value,
|
|
2077
2082
|
});
|
|
@@ -2079,14 +2084,14 @@ ${obj.gvc.bindView(() => {
|
|
|
2079
2084
|
obj.callback(n);
|
|
2080
2085
|
obj.gvc.notifyDataChange(viewId);
|
|
2081
2086
|
})}"
|
|
2082
|
-
value="${obj.default !== undefined ? this.
|
|
2087
|
+
value="${obj.default !== undefined ? this.floatInterval(def()) : ''}"
|
|
2083
2088
|
${obj.readonly ? `readonly` : ``}
|
|
2084
2089
|
/>`;
|
|
2085
2090
|
},
|
|
2086
2091
|
divCreate: { class: 'w-100' },
|
|
2087
2092
|
onCreate: () => {
|
|
2088
2093
|
if (!this.checkNumberMinMax(def())) {
|
|
2089
|
-
obj.callback(this.
|
|
2094
|
+
obj.callback(this.floatInterval(def()));
|
|
2090
2095
|
}
|
|
2091
2096
|
},
|
|
2092
2097
|
})}
|
|
@@ -2094,8 +2099,38 @@ ${obj.gvc.bindView(() => {
|
|
|
2094
2099
|
</div> `;
|
|
2095
2100
|
}
|
|
2096
2101
|
|
|
2097
|
-
public static
|
|
2102
|
+
public static floatInterval(obj: { gvc: GVC; num: number | string; min?: number; max?: number; precision?: number }): number {
|
|
2103
|
+
const dialog = new ShareDialog(obj.gvc.glitter);
|
|
2104
|
+
let n = parseFloat(`${obj.num}`);
|
|
2105
|
+
|
|
2106
|
+
// 驗證是否為有效數字
|
|
2107
|
+
if (isNaN(n)) {
|
|
2108
|
+
dialog.errorMessage({ text: '請輸入數字' });
|
|
2109
|
+
}
|
|
2110
|
+
|
|
2111
|
+
// 限制小數位數(如果指定了 precision)
|
|
2112
|
+
if (obj.precision !== undefined && obj.precision >= 0) {
|
|
2113
|
+
n = parseFloat(n.toFixed(obj.precision));
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
// 檢查範圍
|
|
2117
|
+
if (obj.max !== undefined && n > obj.max) {
|
|
2118
|
+
return obj.max;
|
|
2119
|
+
}
|
|
2120
|
+
if (obj.min !== undefined && n < obj.min) {
|
|
2121
|
+
return obj.min;
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
return n;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
public static numberInterval(obj: { gvc: GVC; num: number | string; min?: number; max?: number }): number {
|
|
2128
|
+
const dialog = new ShareDialog(obj.gvc.glitter);
|
|
2098
2129
|
const n = parseInt(`${obj.num}`, 10);
|
|
2130
|
+
|
|
2131
|
+
if (isNaN(n)) {
|
|
2132
|
+
dialog.errorMessage({ text: '請輸入數字' });
|
|
2133
|
+
}
|
|
2099
2134
|
if (obj.max !== undefined && n > obj.max) {
|
|
2100
2135
|
return obj.max;
|
|
2101
2136
|
}
|
|
@@ -2453,17 +2488,12 @@ ${obj.gvc.bindView(() => {
|
|
|
2453
2488
|
public static editerDialog(par: { gvc: GVC; dialog: (gvc: GVC) => string; width?: string; editTitle?: string; callback?: () => void }) {
|
|
2454
2489
|
return html` <button
|
|
2455
2490
|
type="button"
|
|
2456
|
-
class="btn btn-primary-c
|
|
2457
|
-
style=""
|
|
2491
|
+
class="btn btn-primary-c w-100"
|
|
2458
2492
|
onclick="${par.gvc.event(() => {
|
|
2459
2493
|
const gvc = par.gvc;
|
|
2460
2494
|
NormalPageEditor.toggle({
|
|
2461
2495
|
visible: true,
|
|
2462
|
-
view: `
|
|
2463
|
-
<div class="p-2"
|
|
2464
|
-
style="overflow-y:auto;">
|
|
2465
|
-
${par.dialog(gvc)}
|
|
2466
|
-
</div>`,
|
|
2496
|
+
view: html` <div class="p-2" style="overflow-y:auto;">${par.dialog(gvc)}</div>`,
|
|
2467
2497
|
title: par.editTitle || '',
|
|
2468
2498
|
});
|
|
2469
2499
|
par.callback && (NormalPageEditor.closeEvent = par.callback);
|
|
@@ -18,6 +18,7 @@ import { FormWidget } from "../../official_view_component/official/form.js";
|
|
|
18
18
|
import { ShareDialog } from "../../glitterBundle/dialog/ShareDialog.js";
|
|
19
19
|
import { PdClass } from "../product/pd-class.js";
|
|
20
20
|
import { Ad } from "../public/ad.js";
|
|
21
|
+
import { ApiWallet } from '../../glitter-base/route/wallet.js';
|
|
21
22
|
const html = String.raw;
|
|
22
23
|
const css = String.raw;
|
|
23
24
|
export class CheckoutIndex {
|
|
@@ -952,6 +953,9 @@ export class CheckoutIndex {
|
|
|
952
953
|
"bank_user": "陳女士",
|
|
953
954
|
"bank_account": "888800004567"
|
|
954
955
|
}
|
|
956
|
+
},
|
|
957
|
+
rebateConfig: {
|
|
958
|
+
title: '購物金'
|
|
955
959
|
}
|
|
956
960
|
};
|
|
957
961
|
const noImageURL = 'https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722936949034-default_image.jpg';
|
|
@@ -1392,16 +1396,22 @@ export class CheckoutIndex {
|
|
|
1392
1396
|
}));
|
|
1393
1397
|
})).then((data) => {
|
|
1394
1398
|
vm.cartData = data;
|
|
1395
|
-
|
|
1396
|
-
{
|
|
1397
|
-
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1399
|
+
ApiWallet.getRebateConfig({ type: 'me' }).then((res) => __awaiter(this, void 0, void 0, function* () {
|
|
1400
|
+
if (res.result && res.response.data) {
|
|
1401
|
+
vm.rebateConfig = res.response.data;
|
|
1402
|
+
}
|
|
1403
|
+
vm.rebateConfig.title = CheckInput.isEmpty(vm.rebateConfig.title) ? '購物金' : vm.rebateConfig.title;
|
|
1404
|
+
gvc.addMtScript([
|
|
1405
|
+
{
|
|
1406
|
+
src: `https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js`,
|
|
1407
|
+
},
|
|
1408
|
+
], () => {
|
|
1409
|
+
loadings.page = false;
|
|
1410
|
+
dialog.dataLoading({ visible: false });
|
|
1411
|
+
gvc.notifyDataChange(['js-cart-count', ids.page]);
|
|
1412
|
+
}, () => {
|
|
1413
|
+
});
|
|
1414
|
+
}));
|
|
1405
1415
|
});
|
|
1406
1416
|
}
|
|
1407
1417
|
else {
|
|
@@ -1900,7 +1910,7 @@ export class CheckoutIndex {
|
|
|
1900
1910
|
let tempRebate = 0;
|
|
1901
1911
|
const dialog = new ShareDialog(gvc.glitter);
|
|
1902
1912
|
return `<div class="${gClass(['price-row', 'text-2'])}">
|
|
1903
|
-
|
|
1913
|
+
<div>${vm.rebateConfig.title}折抵</div>
|
|
1904
1914
|
<div>- NT. ${vm.cartData.use_rebate.toLocaleString()}</div>
|
|
1905
1915
|
</div>
|
|
1906
1916
|
|
|
@@ -1914,7 +1924,7 @@ export class CheckoutIndex {
|
|
|
1914
1924
|
>
|
|
1915
1925
|
<input
|
|
1916
1926
|
class="flex-fill ${gClass('group-input')}"
|
|
1917
|
-
placeholder="
|
|
1927
|
+
placeholder="請輸入${vm.rebateConfig.title}"
|
|
1918
1928
|
style="${document.body.clientWidth < 800 ? `width:calc(100% - 150px) !important;` : ``}"
|
|
1919
1929
|
value="${vm.cartData.use_rebate || ''}"
|
|
1920
1930
|
onchange="${gvc.event((e, event) => {
|
|
@@ -1941,20 +1951,18 @@ export class CheckoutIndex {
|
|
|
1941
1951
|
}));
|
|
1942
1952
|
});
|
|
1943
1953
|
const limit = vm.cartData.total - vm.cartData.shipment_fee + vm.cartData.use_rebate;
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
});
|
|
1954
|
+
if (sum === 0) {
|
|
1955
|
+
dialog.errorMessage({ text: `您的 ${vm.rebateConfig.title} 為 0 點,無法折抵` });
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1949
1958
|
if (tempRebate > Math.min(sum, limit)) {
|
|
1950
1959
|
dialog.errorMessage({ text: `請輸入 0 到 ${Math.min(sum, limit)} 的數值` });
|
|
1960
|
+
return;
|
|
1951
1961
|
}
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
});
|
|
1957
|
-
}
|
|
1962
|
+
ApiCart.setCart((cartItem) => {
|
|
1963
|
+
cartItem.use_rebate = tempRebate;
|
|
1964
|
+
refreshCartData();
|
|
1965
|
+
});
|
|
1958
1966
|
}))}">
|
|
1959
1967
|
套用
|
|
1960
1968
|
</div>
|
|
@@ -1984,13 +1992,13 @@ export class CheckoutIndex {
|
|
|
1984
1992
|
}
|
|
1985
1993
|
const info = vm.cartData.useRebateInfo;
|
|
1986
1994
|
if (info.condition) {
|
|
1987
|
-
return `還差$ ${info.condition.toLocaleString()}
|
|
1995
|
+
return `還差$ ${info.condition.toLocaleString()} 即可使用 ${vm.rebateConfig.title} 折抵`;
|
|
1988
1996
|
}
|
|
1989
1997
|
if (info.limit) {
|
|
1990
|
-
return `您目前剩餘 ${sum || 0}
|
|
1998
|
+
return `您目前剩餘 ${sum || 0} 點 ${vm.rebateConfig.title}<br />此份訂單最多可折抵 ${info.limit.toLocaleString()} 點 ${vm.rebateConfig.title}`;
|
|
1991
1999
|
}
|
|
1992
2000
|
else {
|
|
1993
|
-
return `您目前剩餘 ${sum || 0}
|
|
2001
|
+
return `您目前剩餘 ${sum || 0} 點 ${vm.rebateConfig.title}`;
|
|
1994
2002
|
}
|
|
1995
2003
|
})
|
|
1996
2004
|
};
|
|
@@ -2417,7 +2425,7 @@ export class CheckoutIndex {
|
|
|
2417
2425
|
].join('');
|
|
2418
2426
|
}
|
|
2419
2427
|
catch (e) {
|
|
2420
|
-
console.
|
|
2428
|
+
console.error(e);
|
|
2421
2429
|
return ``;
|
|
2422
2430
|
}
|
|
2423
2431
|
})()}
|