ts-glitter 21.8.3 → 21.8.4
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-dialog.js +342 -100
- package/lowcode/backend-manager/bg-dialog.ts +432 -145
- package/lowcode/backend-manager/bg-widget.js +4 -4
- package/lowcode/backend-manager/bg-widget.ts +5 -5
- package/lowcode/cms-plugin/shopping-discount-setting.js +148 -92
- package/lowcode/cms-plugin/shopping-discount-setting.ts +162 -111
- package/lowcode/cms-plugin/shopping-product-stock.js +58 -45
- package/lowcode/cms-plugin/shopping-product-stock.ts +66 -49
- package/lowcode/css/editor.css +8 -9
- package/lowcode/editor/basic-component.js +0 -10
- package/lowcode/editor/basic-component.ts +1 -11
- package/lowcode/glitter-base/route/article.js +50 -51
- package/lowcode/glitter-base/route/article.ts +102 -103
- package/lowcode/glitter-base/route/recommend.js +1 -0
- package/lowcode/glitter-base/route/recommend.ts +141 -123
- package/lowcode/glitterBundle/plugins/html-render.js +2 -0
- package/lowcode/glitterBundle/plugins/html-render.ts +1 -0
- package/lowcode/jspage/function-page/tool-setting.js +0 -1
- package/lowcode/jspage/function-page/tool-setting.ts +0 -1
- package/lowcode/jspage/main.js +6 -1
- package/lowcode/jspage/main.ts +6 -1
- package/lowcode/modules/image-library-clone.ts +2 -0
- package/lowcode/modules/image-library.js +118 -155
- package/lowcode/modules/image-library.ts +134 -197
- package/lowcode/official_view_component/official/component.js +1 -1
- package/lowcode/official_view_component/official/component.ts +1 -1
- package/lowcode/public-components/banner/first-banner.js +85 -50
- package/lowcode/public-components/banner/first-banner.ts +96 -59
- package/lowcode/public-components/layout-plugin/social-links-01.js +23 -44
- package/lowcode/public-components/layout-plugin/social-links-01.ts +23 -48
- package/package.json +1 -1
- package/src/api-public/controllers/article.js +11 -0
- package/src/api-public/controllers/article.js.map +1 -1
- package/src/api-public/controllers/article.ts +13 -0
- package/src/api-public/controllers/recommend.js +1 -0
- package/src/api-public/controllers/recommend.js.map +1 -1
- package/src/api-public/controllers/recommend.ts +99 -89
- package/src/api-public/services/checkout-event.js +4 -3
- package/src/api-public/services/checkout-event.js.map +1 -1
- package/src/api-public/services/checkout-event.ts +11 -7
- package/src/api-public/services/post.js +7 -17
- package/src/api-public/services/post.js.map +1 -1
- package/src/api-public/services/recommend.d.ts +1 -0
- package/src/api-public/services/recommend.js +12 -2
- package/src/api-public/services/recommend.js.map +1 -1
- package/src/api-public/services/recommend.ts +375 -354
- package/src/api-public/services/shopping.d.ts +1 -0
- package/src/api-public/services/shopping.js +4 -2
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +7 -2
|
@@ -1023,7 +1023,7 @@ ${obj.default ?? ''}</textarea
|
|
|
1023
1023
|
</div>`;
|
|
1024
1024
|
}
|
|
1025
1025
|
|
|
1026
|
-
static searchPlace(event: string,
|
|
1026
|
+
static searchPlace(event: string, value: string, placeholder: string, margin?: string, padding?: string) {
|
|
1027
1027
|
const defMargin = document.body.clientWidth > 768 ? '16px 0' : '8px 0';
|
|
1028
1028
|
const defPadding = document.body.clientWidth > 768 ? '0 16px' : '0';
|
|
1029
1029
|
return html`
|
|
@@ -1039,7 +1039,7 @@ ${obj.default ?? ''}</textarea
|
|
|
1039
1039
|
style="border-radius: 10px; border: 1px solid #DDD; padding-left: 50px;"
|
|
1040
1040
|
placeholder="${placeholder}"
|
|
1041
1041
|
onchange="${event}"
|
|
1042
|
-
value="${
|
|
1042
|
+
value="${value}"
|
|
1043
1043
|
/>
|
|
1044
1044
|
</div>
|
|
1045
1045
|
</div>
|
|
@@ -2088,7 +2088,7 @@ ${obj.default ?? ''}</textarea
|
|
|
2088
2088
|
gvc: GVC;
|
|
2089
2089
|
filter: TableV3Filter[]; // 批量編輯與刪除物件陣列
|
|
2090
2090
|
getData: (vm: TableV3) => void; // 非同步取得資料陣列事件
|
|
2091
|
-
rowClick: (data: any, index: number) => void; // row 點擊事件
|
|
2091
|
+
rowClick: (data: any, index: number, element: any, event: any) => void; // row 點擊事件
|
|
2092
2092
|
hiddenPageSplit?: boolean; // 表格頁面導覽列
|
|
2093
2093
|
defPage?: number; // 預設顯示第幾頁
|
|
2094
2094
|
itemSelect?: () => void;
|
|
@@ -2451,8 +2451,8 @@ ${obj.default ?? ''}</textarea
|
|
|
2451
2451
|
class="${trIndex === 0 ? ids.tr : ''} ${dd.find(d3 => d3.tooltip)
|
|
2452
2452
|
? 'tr-tooltip-container'
|
|
2453
2453
|
: ''}"
|
|
2454
|
-
onclick="${gvc.event(() => {
|
|
2455
|
-
obj.rowClick && obj.rowClick(dd, trIndex);
|
|
2454
|
+
onclick="${gvc.event((e, event) => {
|
|
2455
|
+
obj.rowClick && obj.rowClick(dd, trIndex, e, event);
|
|
2456
2456
|
})}"
|
|
2457
2457
|
onmouseover="${gvc.event(() => {
|
|
2458
2458
|
$(`#${ids.pencil}${trIndex}`).removeClass('d-none');
|
|
@@ -18,6 +18,8 @@ import { FilterOptions } from './filter-options.js';
|
|
|
18
18
|
import { Tool } from '../modules/tool.js';
|
|
19
19
|
import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
|
|
20
20
|
import { BgDialog } from '../backend-manager/bg-dialog.js';
|
|
21
|
+
import { Article } from '../glitter-base/route/article.js';
|
|
22
|
+
import { ApiRecommend } from '../glitter-base/route/recommend.js';
|
|
21
23
|
const html = String.raw;
|
|
22
24
|
export class ShoppingDiscountSetting {
|
|
23
25
|
static main(gvc, voucher_type) {
|
|
@@ -63,7 +65,7 @@ export class ShoppingDiscountSetting {
|
|
|
63
65
|
const triggerLabels = {
|
|
64
66
|
auto: '自動',
|
|
65
67
|
code: '輸入代碼',
|
|
66
|
-
distribution: '
|
|
68
|
+
distribution: '特定賣場',
|
|
67
69
|
};
|
|
68
70
|
function getDatalist() {
|
|
69
71
|
return data.response.data.map((dd) => {
|
|
@@ -199,7 +201,7 @@ export class ShoppingDiscountSetting {
|
|
|
199
201
|
if (voucherData.trigger === 'auto')
|
|
200
202
|
return '自動折扣';
|
|
201
203
|
if (voucherData.trigger === 'distribution')
|
|
202
|
-
return '
|
|
204
|
+
return '特定賣場使用';
|
|
203
205
|
if (voucherData.trigger === 'code')
|
|
204
206
|
return `優惠代碼「${(_b = voucherData.code) !== null && _b !== void 0 ? _b : ''}」`;
|
|
205
207
|
return '';
|
|
@@ -263,6 +265,7 @@ export class ShoppingDiscountSetting {
|
|
|
263
265
|
const vm = obj.vm;
|
|
264
266
|
const glitter = gvc.glitter;
|
|
265
267
|
const dialog = new ShareDialog(glitter);
|
|
268
|
+
const bgDialog = new BgDialog(gvc);
|
|
266
269
|
const getUUID = glitter.getUUID;
|
|
267
270
|
const pageVM = {
|
|
268
271
|
viewID: getUUID(),
|
|
@@ -369,7 +372,7 @@ export class ShoppingDiscountSetting {
|
|
|
369
372
|
{
|
|
370
373
|
key: 'distribution',
|
|
371
374
|
name: '供特定賣場優惠使用',
|
|
372
|
-
innerHtml: BgWidget.grayNote('僅限於隱形賣場 / 一頁商店 /
|
|
375
|
+
innerHtml: BgWidget.grayNote('僅限於隱形賣場 / 一頁商店 / 分銷連結使用'),
|
|
373
376
|
},
|
|
374
377
|
], [voucherData.trigger], text => {
|
|
375
378
|
if (text[0] === 'auto') {
|
|
@@ -1386,28 +1389,12 @@ export class ShoppingDiscountSetting {
|
|
|
1386
1389
|
if (voucherData.trigger !== 'distribution') {
|
|
1387
1390
|
return '';
|
|
1388
1391
|
}
|
|
1392
|
+
const id = 'apply_shop_view';
|
|
1389
1393
|
const prefix = Tool.randomString(6);
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
icon: html `<i class="fa-regular fa-puzzle-piece ${prefix}_icon"></i>`,
|
|
1393
|
-
title: '拼團賣場',
|
|
1394
|
-
},
|
|
1395
|
-
recommend: {
|
|
1396
|
-
icon: html `<i class="fa-regular fa-share-nodes ${prefix}_icon"></i>`,
|
|
1397
|
-
title: '分銷連結',
|
|
1398
|
-
},
|
|
1399
|
-
hidden: {
|
|
1400
|
-
icon: html `<i class="fa-solid fa-face-dotted ${prefix}_icon"></i>`,
|
|
1401
|
-
title: '隱形賣場',
|
|
1402
|
-
},
|
|
1403
|
-
onepage: {
|
|
1404
|
-
icon: html `<i class="fa-regular fa-file ${prefix}_icon"></i>`,
|
|
1405
|
-
title: '一頁商店',
|
|
1406
|
-
},
|
|
1407
|
-
};
|
|
1394
|
+
let loading = true;
|
|
1395
|
+
let dataList = [];
|
|
1408
1396
|
gvc.addStyle(`
|
|
1409
1397
|
.${prefix}_container {
|
|
1410
|
-
max-width: 800px;
|
|
1411
1398
|
margin: 0 auto;
|
|
1412
1399
|
background-color: #fff;
|
|
1413
1400
|
border-radius: 8px;
|
|
@@ -1417,9 +1404,9 @@ export class ShoppingDiscountSetting {
|
|
|
1417
1404
|
.${prefix}_table {
|
|
1418
1405
|
width: 100%;
|
|
1419
1406
|
border-collapse: collapse;
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1407
|
+
overflow-x: auto;
|
|
1408
|
+
white-space: nowrap;
|
|
1409
|
+
${bgDialog.isMobile ? 'display: block;' : ''}
|
|
1423
1410
|
}
|
|
1424
1411
|
|
|
1425
1412
|
.${prefix}_th {
|
|
@@ -1473,13 +1460,21 @@ export class ShoppingDiscountSetting {
|
|
|
1473
1460
|
.${prefix}_expend:hover {
|
|
1474
1461
|
background-color: #f9fafb;
|
|
1475
1462
|
}
|
|
1463
|
+
|
|
1464
|
+
.${prefix}_none_text {
|
|
1465
|
+
text-align: center;
|
|
1466
|
+
padding: 18px 0;
|
|
1467
|
+
}
|
|
1476
1468
|
`);
|
|
1477
1469
|
return gvc.bindView({
|
|
1478
|
-
bind:
|
|
1470
|
+
bind: id,
|
|
1479
1471
|
view: () => {
|
|
1472
|
+
if (loading) {
|
|
1473
|
+
return BgWidget.spinner();
|
|
1474
|
+
}
|
|
1480
1475
|
return html `<div class="${prefix}_container">
|
|
1481
|
-
<table id="
|
|
1482
|
-
<thead
|
|
1476
|
+
<table id="apply-shop-table" class="${prefix}_table">
|
|
1477
|
+
<thead>
|
|
1483
1478
|
<tr class="${prefix}_tr">
|
|
1484
1479
|
<th class="${prefix}_th">賣場類型</th>
|
|
1485
1480
|
<th class="${prefix}_th">賣場名稱</th>
|
|
@@ -1490,86 +1485,139 @@ export class ShoppingDiscountSetting {
|
|
|
1490
1485
|
<!-- 資料將由 JavaScript 動態填入 -->
|
|
1491
1486
|
</tbody>
|
|
1492
1487
|
</table>
|
|
1493
|
-
<div id="
|
|
1488
|
+
<div id="apply-shop-div">
|
|
1494
1489
|
<!-- 資料將由 JavaScript 動態填入 -->
|
|
1495
1490
|
</div>
|
|
1496
1491
|
</div>`;
|
|
1497
1492
|
},
|
|
1498
|
-
divCreate: {},
|
|
1499
1493
|
onCreate: () => {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
},
|
|
1506
|
-
{
|
|
1507
|
-
type: 'recommend',
|
|
1508
|
-
name: '與Sandy的貓跳台合作,給貓咪最好的跳台!',
|
|
1509
|
-
referrer: 'YT貓皇',
|
|
1510
|
-
},
|
|
1511
|
-
{
|
|
1512
|
-
type: 'hidden',
|
|
1513
|
-
name: '毛孩防寒任三件8折,一起溫暖過冬!',
|
|
1514
|
-
referrer: 'Sandy',
|
|
1515
|
-
},
|
|
1516
|
-
{
|
|
1517
|
-
type: 'onepage',
|
|
1518
|
-
name: '毛孩玩具聯名,買三件折扣8折!',
|
|
1519
|
-
referrer: '-',
|
|
1520
|
-
},
|
|
1521
|
-
];
|
|
1522
|
-
const tableBody = document.querySelector('#beauty-salon-table tbody');
|
|
1523
|
-
const tableDiv = document.querySelector('#beauty-salon-div');
|
|
1524
|
-
if (!tableBody || !tableDiv) {
|
|
1525
|
-
return;
|
|
1526
|
-
}
|
|
1527
|
-
salons.forEach(salon => {
|
|
1528
|
-
const data = shopTypeRecord[salon.type];
|
|
1529
|
-
const row = document.createElement('tr');
|
|
1530
|
-
row.className = `${prefix}_tr`;
|
|
1531
|
-
const typeCell = document.createElement('td');
|
|
1532
|
-
typeCell.className = `${prefix}_td ${prefix}_type_cell`;
|
|
1533
|
-
typeCell.innerHTML = `${data.icon} ${data.title}`;
|
|
1534
|
-
row.appendChild(typeCell);
|
|
1535
|
-
const nameCell = document.createElement('td');
|
|
1536
|
-
nameCell.className = `${prefix}_td`;
|
|
1537
|
-
nameCell.textContent = salon.name;
|
|
1538
|
-
row.appendChild(nameCell);
|
|
1539
|
-
const referrerCell = document.createElement('td');
|
|
1540
|
-
referrerCell.className = `${prefix}_td`;
|
|
1541
|
-
if (salon.referrer) {
|
|
1542
|
-
referrerCell.textContent = salon.referrer;
|
|
1494
|
+
function render() {
|
|
1495
|
+
const tableBody = document.querySelector('#apply-shop-table tbody');
|
|
1496
|
+
const tableDiv = document.querySelector('#apply-shop-div');
|
|
1497
|
+
if (!tableBody || !tableDiv) {
|
|
1498
|
+
return;
|
|
1543
1499
|
}
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1500
|
+
tableBody.innerHTML = '';
|
|
1501
|
+
if (voucherData.distribution_shop.length === 0) {
|
|
1502
|
+
const row = document.createElement('tr');
|
|
1503
|
+
row.className = `${prefix}_tr`;
|
|
1504
|
+
row.innerHTML = html `<td colspan="3" class="${prefix}_none_text">尚未選擇賣場</td>`;
|
|
1505
|
+
tableBody.appendChild(row);
|
|
1506
|
+
return;
|
|
1547
1507
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1508
|
+
const shopTypeRecord = bgDialog.shopTypeRecord();
|
|
1509
|
+
dataList.forEach(data => {
|
|
1510
|
+
const shopData = shopTypeRecord[data.type];
|
|
1511
|
+
const row = document.createElement('tr');
|
|
1512
|
+
row.className = `${prefix}_tr`;
|
|
1513
|
+
const referrerText = data.referrer ? data.referrer : '-';
|
|
1514
|
+
const referrerClass = data.referrer ? '' : `${prefix}_empty_referrer`;
|
|
1515
|
+
row.innerHTML = html `
|
|
1516
|
+
<td class="${prefix}_td ${prefix}_type_cell">${shopData.icon} ${shopData.title}</td>
|
|
1517
|
+
<td class="${prefix}_td">${data.name}</td>
|
|
1518
|
+
<td class="${prefix}_td ${referrerClass}">${referrerText}</td>
|
|
1519
|
+
`;
|
|
1520
|
+
tableBody.appendChild(row);
|
|
1521
|
+
});
|
|
1522
|
+
}
|
|
1523
|
+
if (loading) {
|
|
1524
|
+
if (voucherData.distribution_shop.length === 0) {
|
|
1525
|
+
loading = false;
|
|
1526
|
+
setTimeout(() => gvc.notifyDataChange(id), 100);
|
|
1527
|
+
return;
|
|
1528
|
+
}
|
|
1529
|
+
dataList = [];
|
|
1530
|
+
const articleIds = [];
|
|
1531
|
+
const recommendIds = [];
|
|
1532
|
+
voucherData.distribution_shop.map(item => {
|
|
1533
|
+
const [pageType, id] = item.split('-');
|
|
1534
|
+
pageType === 'recommend' ? recommendIds.push(id) : articleIds.push(id);
|
|
1535
|
+
});
|
|
1536
|
+
Promise.all([
|
|
1537
|
+
articleIds.length > 0
|
|
1538
|
+
? Article.get({
|
|
1539
|
+
page: 0,
|
|
1540
|
+
limit: 9999,
|
|
1541
|
+
search: vm.search || undefined,
|
|
1542
|
+
status: '0,1',
|
|
1543
|
+
id_list: articleIds.join(','),
|
|
1544
|
+
}).then(data => {
|
|
1545
|
+
var _b;
|
|
1546
|
+
return Array.isArray((_b = data.response) === null || _b === void 0 ? void 0 : _b.data) ? data.response.data : [];
|
|
1547
|
+
})
|
|
1548
|
+
: [],
|
|
1549
|
+
recommendIds.length > 0
|
|
1550
|
+
? ApiRecommend.getList({
|
|
1551
|
+
data: {},
|
|
1552
|
+
limit: 9999,
|
|
1553
|
+
page: 0,
|
|
1554
|
+
token: window.parent.config.token,
|
|
1555
|
+
id_list: recommendIds.join(','),
|
|
1556
|
+
}).then(data => {
|
|
1557
|
+
var _b;
|
|
1558
|
+
return Array.isArray((_b = data.response) === null || _b === void 0 ? void 0 : _b.data) ? data.response.data : [];
|
|
1559
|
+
})
|
|
1560
|
+
: [],
|
|
1561
|
+
]).then(dataArray => {
|
|
1562
|
+
const [article, recommend] = dataArray;
|
|
1563
|
+
article.map((item) => {
|
|
1564
|
+
dataList.push({
|
|
1565
|
+
type: item.content.page_type === 'hidden' ? 'hidden' : 'onepage',
|
|
1566
|
+
name: item.content.name,
|
|
1567
|
+
referrer: '-',
|
|
1568
|
+
});
|
|
1569
|
+
});
|
|
1570
|
+
recommend.map((item) => {
|
|
1571
|
+
var _b, _c;
|
|
1572
|
+
dataList.push({
|
|
1573
|
+
type: 'recommend',
|
|
1574
|
+
name: item.content.title,
|
|
1575
|
+
referrer: (_c = (_b = item.content.recommend_user) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '-',
|
|
1576
|
+
});
|
|
1577
|
+
});
|
|
1578
|
+
loading = false;
|
|
1579
|
+
gvc.notifyDataChange(id);
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
else {
|
|
1583
|
+
render();
|
|
1584
|
+
}
|
|
1557
1585
|
},
|
|
1558
1586
|
});
|
|
1559
1587
|
}
|
|
1560
1588
|
const reBackProductView = {
|
|
1561
|
-
rebate: {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1589
|
+
rebate: {
|
|
1590
|
+
title: '活動商品',
|
|
1591
|
+
html: voucherData.for === 'all' ? '' : selectProduct(),
|
|
1592
|
+
},
|
|
1593
|
+
discount: {
|
|
1594
|
+
title: '活動商品',
|
|
1595
|
+
html: voucherData.for === 'all' ? '' : selectProduct(),
|
|
1596
|
+
},
|
|
1597
|
+
shipment_free: {
|
|
1598
|
+
title: '活動商品',
|
|
1599
|
+
html: '',
|
|
1600
|
+
},
|
|
1601
|
+
add_on_items: {
|
|
1602
|
+
title: '加購品項',
|
|
1603
|
+
html: [addProductView()].join(''),
|
|
1604
|
+
},
|
|
1605
|
+
giveaway: {
|
|
1606
|
+
title: '贈品品項',
|
|
1607
|
+
html: [addProductView()].join(''),
|
|
1608
|
+
},
|
|
1566
1609
|
};
|
|
1567
1610
|
const applyShopButton = BgWidget.customButton({
|
|
1568
1611
|
button: { color: 'gray', size: 'md' },
|
|
1569
1612
|
text: { name: '選擇賣場' },
|
|
1570
1613
|
event: gvc.event(() => {
|
|
1571
|
-
|
|
1572
|
-
|
|
1614
|
+
bgDialog.marketShop({
|
|
1615
|
+
def: voucherData.distribution_shop.slice(),
|
|
1616
|
+
callback: postData => {
|
|
1617
|
+
voucherData.distribution_shop = postData;
|
|
1618
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
1619
|
+
},
|
|
1620
|
+
});
|
|
1573
1621
|
}),
|
|
1574
1622
|
});
|
|
1575
1623
|
const viewList = [
|
|
@@ -1578,6 +1626,13 @@ export class ShoppingDiscountSetting {
|
|
|
1578
1626
|
{ title: '折扣方式', html: trigger() },
|
|
1579
1627
|
{ title: '適用訂單類型', html: device() },
|
|
1580
1628
|
],
|
|
1629
|
+
[
|
|
1630
|
+
{
|
|
1631
|
+
title: '套用賣場',
|
|
1632
|
+
button: applyShopButton,
|
|
1633
|
+
html: applyShop(),
|
|
1634
|
+
},
|
|
1635
|
+
],
|
|
1581
1636
|
[
|
|
1582
1637
|
{ title: '折扣設定', html: method() },
|
|
1583
1638
|
{ title: '使用條件', html: rule() },
|
|
@@ -1772,6 +1827,7 @@ ShoppingDiscountSetting.emptyVoucher = (reBackType) => {
|
|
|
1772
1827
|
includeDiscount: 'before',
|
|
1773
1828
|
productOffStart: 'price_desc',
|
|
1774
1829
|
selectShipment: { type: 'all', list: [] },
|
|
1830
|
+
distribution_shop: [],
|
|
1775
1831
|
};
|
|
1776
1832
|
};
|
|
1777
1833
|
window.glitter.setModule(import.meta.url, ShoppingDiscountSetting);
|