ts-glitter 22.5.1 → 22.5.3
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/collection.json +398 -0
- package/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/backend-manager/bg-product.js +3 -0
- package/lowcode/backend-manager/bg-product.ts +3 -0
- package/lowcode/cms-plugin/shopping-collections.js +851 -831
- package/lowcode/cms-plugin/shopping-collections.ts +909 -1156
- package/lowcode/cms-plugin/shopping-setting-basic.js +1 -0
- package/lowcode/cms-plugin/shopping-setting-basic.ts +1 -0
- package/lowcode/glitter-base/route/public-config.js +1 -1
- package/lowcode/glitter-base/route/public-config.ts +1 -1
- package/lowcode/public-components/product/pd-card-03.ts +1 -0
- package/lowcode/public-components/product/product-list.js +8 -4
- package/lowcode/public-components/product/product-list.ts +6 -5
- package/package.json +1 -1
- package/src/api-public/services/collection.d.ts +3 -0
- package/src/api-public/services/collection.js +100 -0
- package/src/api-public/services/collection.js.map +1 -0
- package/src/api-public/services/collection.ts +98 -0
- package/src/api-public/services/data-analyze.d.ts +1 -1
- package/src/api-public/services/manager.d.ts +2 -1
- package/src/api-public/services/manager.js +67 -13
- package/src/api-public/services/manager.js.map +1 -1
- package/src/api-public/services/manager.ts +86 -14
- package/src/api-public/services/public-table-check.js +14 -1
- package/src/api-public/services/public-table-check.js.map +1 -1
- package/src/api-public/services/public-table-check.ts +14 -1
- package/src/api-public/services/shopping.js +16 -8
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +19 -10
- package/src/api-public/services/updated-table-checked.js +43 -0
- package/src/api-public/services/updated-table-checked.js.map +1 -1
- package/src/api-public/services/updated-table-checked.ts +49 -0
- package/src/seo-config.js +1 -1
- package/src/seo-config.js.map +1 -1
- package/src/seo-config.ts +1 -1
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { BgWidget } from '../backend-manager/bg-widget.js';
|
|
2
11
|
import { BgProduct } from '../backend-manager/bg-product.js';
|
|
3
12
|
import { ApiShop } from '../glitter-base/route/shopping.js';
|
|
@@ -5,6 +14,7 @@ import { EditorElem } from '../glitterBundle/plugins/editor-elem.js';
|
|
|
5
14
|
import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
|
|
6
15
|
import { CheckInput } from '../modules/checkInput.js';
|
|
7
16
|
import { Language } from '../glitter-base/global/language.js';
|
|
17
|
+
import { PublicConfig } from '../glitter-base/route/public-config.js';
|
|
8
18
|
const html = String.raw;
|
|
9
19
|
function getEmptyLanguageData() {
|
|
10
20
|
return {
|
|
@@ -72,7 +82,7 @@ export class ShoppingCollections {
|
|
|
72
82
|
let flattened = [];
|
|
73
83
|
collections.forEach(col => {
|
|
74
84
|
const { title, array, product_id } = col;
|
|
75
|
-
const flattenedCol = Object.assign(Object.assign({}, col), { array: [], product_id: product_id !== null && product_id !== void 0 ? product_id : [], checked: false, parentTitles: parentTitles.length ? [...parentTitles] : [], allCollections: parentTitles.length ? [...topLevelCollections] : [], subCollections: array.map(subCol => subCol.title), hidden: Boolean(col.hidden) });
|
|
85
|
+
const flattenedCol = Object.assign(Object.assign({}, col), { array: [], product_id: product_id !== null && product_id !== void 0 ? product_id : [], checked: false, parentTitles: parentTitles.length ? [...parentTitles] : [], allCollections: parentTitles.length ? [...topLevelCollections] : [], subCollections: (array !== null && array !== void 0 ? array : []).map(subCol => subCol.title), hidden: Boolean(col.hidden) });
|
|
76
86
|
if (flattenedCol.title.includes(vm.query) ||
|
|
77
87
|
flattenedCol.parentTitles.find(title => {
|
|
78
88
|
return title.includes(vm.query);
|
|
@@ -105,6 +115,33 @@ export class ShoppingCollections {
|
|
|
105
115
|
const topLevelCollections = data.collections.map(col => col.title);
|
|
106
116
|
return flattenCollections(data.collections, [], topLevelCollections);
|
|
107
117
|
};
|
|
118
|
+
function saveEvent() {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
function checkPass(array) {
|
|
122
|
+
if (Array.from(new Set((array !== null && array !== void 0 ? array : []).map((dd) => { return dd.title; }))).length !== array.length) {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
return !array.find((dd) => {
|
|
126
|
+
return dd.array && !checkPass(dd.array);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const data = getSaveData();
|
|
130
|
+
if (!checkPass(data)) {
|
|
131
|
+
dialog.errorMessage({ text: "同層級不可以有相同的分類標籤!!" });
|
|
132
|
+
resolve(false);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
dialog.dataLoading({ visible: true });
|
|
136
|
+
yield PublicConfig.set('collection', data);
|
|
137
|
+
dialog.dataLoading({ visible: false });
|
|
138
|
+
dialog.successMessage({ text: '儲存成功' });
|
|
139
|
+
gvc.recreateView();
|
|
140
|
+
resolve(true);
|
|
141
|
+
}));
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
let getSaveData = () => { };
|
|
108
145
|
return gvc.bindView(() => {
|
|
109
146
|
return {
|
|
110
147
|
bind: vm.id,
|
|
@@ -116,319 +153,516 @@ export class ShoppingCollections {
|
|
|
116
153
|
<div class="title-container">
|
|
117
154
|
${BgWidget.title('商品分類')}
|
|
118
155
|
<div class="flex-fill"></div>
|
|
119
|
-
<div class="d-flex gap-2">
|
|
120
|
-
${BgWidget.grayButton('編輯順序', gvc.event(() => {
|
|
121
|
-
const cloneCollectionList = vm.collectionList.slice();
|
|
122
|
-
return BgWidget.settingDialog({
|
|
123
|
-
gvc,
|
|
124
|
-
title: '編輯順序',
|
|
125
|
-
width: 700,
|
|
126
|
-
innerHTML: (iGVC) => {
|
|
127
|
-
const id = glitter.getUUID();
|
|
128
|
-
let loading = true;
|
|
129
|
-
this.addStyle(iGVC);
|
|
130
|
-
return iGVC.bindView({
|
|
131
|
-
bind: id,
|
|
132
|
-
view: () => {
|
|
133
|
-
if (loading) {
|
|
134
|
-
return BgWidget.spinner();
|
|
135
|
-
}
|
|
136
|
-
return html `
|
|
137
|
-
<div class="p-2">
|
|
138
|
-
${BgWidget.grayNote('提示:左鍵拖曳可排列順序,點擊可顯示向下一層分類')}
|
|
139
|
-
<div class="d-flex justify-content-start mt-3">
|
|
140
|
-
<div class="layer-container">
|
|
141
|
-
${[0, 1, 2]
|
|
142
|
-
.map(depth => {
|
|
143
|
-
const title = ['第一層分類', '第二層分類', '第三層分類'][depth];
|
|
144
|
-
return html ` <div class="flex-1 layer-block">
|
|
145
|
-
<div class="tx_700 fs-4 text-center mb-2">${title}</div>
|
|
146
|
-
<ul class="ul-style" id="layer-list-${depth}"></ul>
|
|
147
|
-
</div>`;
|
|
148
|
-
})
|
|
149
|
-
.join('')}
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
</div>
|
|
153
|
-
`;
|
|
154
|
-
},
|
|
155
|
-
onCreate: () => {
|
|
156
|
-
var _a;
|
|
157
|
-
if (loading) {
|
|
158
|
-
iGVC.addMtScript([{ src: 'https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js' }], () => {
|
|
159
|
-
const si = setInterval(() => {
|
|
160
|
-
if (window.parent.Sortable !== undefined) {
|
|
161
|
-
loading = false;
|
|
162
|
-
clearInterval(si);
|
|
163
|
-
iGVC.notifyDataChange(id);
|
|
164
|
-
}
|
|
165
|
-
}, 300);
|
|
166
|
-
}, () => { });
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
const document = window.parent.document;
|
|
170
|
-
function createListItem(item, index) {
|
|
171
|
-
var _a;
|
|
172
|
-
const li = document.createElement('li');
|
|
173
|
-
li.className = 'li-style';
|
|
174
|
-
li.setAttribute('data-index', index.toString());
|
|
175
|
-
li.setAttribute('data-path', [...((_a = item.parentTitles) !== null && _a !== void 0 ? _a : []), item.title].join(' / '));
|
|
176
|
-
li.innerHTML = `<span class="drag-icon"></span><span class="tx_normal">${item.title}</span>`;
|
|
177
|
-
li.addEventListener('click', (e) => {
|
|
178
|
-
var _a;
|
|
179
|
-
const target = e.currentTarget;
|
|
180
|
-
const ul = target.closest('ul');
|
|
181
|
-
if (ul) {
|
|
182
|
-
Array.from(ul.children).forEach((element) => {
|
|
183
|
-
element.style.backgroundColor = '#dddddd';
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
target.style.backgroundColor = '#d8ecda';
|
|
187
|
-
loadChildLayer([...((_a = item.parentTitles) !== null && _a !== void 0 ? _a : []), item.title]);
|
|
188
|
-
});
|
|
189
|
-
return li;
|
|
190
|
-
}
|
|
191
|
-
function initSortable(containerId) {
|
|
192
|
-
const el = document.getElementById(containerId);
|
|
193
|
-
window.parent.Sortable.create(el, {
|
|
194
|
-
animation: 200,
|
|
195
|
-
scroll: true,
|
|
196
|
-
onEnd: () => {
|
|
197
|
-
const items = [...el.children].map(child => { var _a; return (_a = vm.dataList) === null || _a === void 0 ? void 0 : _a[parseInt(child.getAttribute('data-index'))]; });
|
|
198
|
-
vm.collectionList = ShoppingCollections.sortedCollectionConfig(vm.collectionList, items);
|
|
199
|
-
},
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
function loadChildLayer(parentPath) {
|
|
203
|
-
var _a;
|
|
204
|
-
const nextDepth = parentPath.length;
|
|
205
|
-
const nextId = `layer-list-${nextDepth}`;
|
|
206
|
-
for (let i = nextDepth; i < 3; i++) {
|
|
207
|
-
const el = document.getElementById(`layer-list-${i}`);
|
|
208
|
-
if (el)
|
|
209
|
-
el.innerHTML = '';
|
|
210
|
-
}
|
|
211
|
-
const container = document.getElementById(nextId);
|
|
212
|
-
container.innerHTML = '';
|
|
213
|
-
(_a = vm.dataList) === null || _a === void 0 ? void 0 : _a.forEach((item, index) => {
|
|
214
|
-
var _a;
|
|
215
|
-
const path = (_a = item.parentTitles) !== null && _a !== void 0 ? _a : [];
|
|
216
|
-
if (path.length === parentPath.length &&
|
|
217
|
-
path.every((p, i) => p === parentPath[i])) {
|
|
218
|
-
container.appendChild(createListItem(item, index));
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
initSortable(nextId);
|
|
222
|
-
}
|
|
223
|
-
const root = document.getElementById('layer-list-0');
|
|
224
|
-
root.innerHTML = '';
|
|
225
|
-
(_a = vm.dataList) === null || _a === void 0 ? void 0 : _a.forEach((item, index) => {
|
|
226
|
-
var _a;
|
|
227
|
-
if (((_a = item.parentTitles) !== null && _a !== void 0 ? _a : []).length === 0) {
|
|
228
|
-
root.appendChild(createListItem(item, index));
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
initSortable('layer-list-0');
|
|
232
|
-
}
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
},
|
|
236
|
-
footer_html: (fGVC) => {
|
|
237
|
-
return [
|
|
238
|
-
BgWidget.cancel(fGVC.event(() => {
|
|
239
|
-
vm.collectionList = cloneCollectionList;
|
|
240
|
-
fGVC.closeDialog();
|
|
241
|
-
})),
|
|
242
|
-
BgWidget.save(fGVC.event(() => {
|
|
243
|
-
dialog.dataLoading({ visible: true });
|
|
244
|
-
ApiShop.sortCollections({
|
|
245
|
-
data: { list: vm.collectionList },
|
|
246
|
-
token: window.parent.config.token,
|
|
247
|
-
}).then(res => {
|
|
248
|
-
dialog.dataLoading({ visible: false });
|
|
249
|
-
if (res.result && !res.response) {
|
|
250
|
-
dialog.errorMessage({ text: '更改順序失敗' });
|
|
251
|
-
}
|
|
252
|
-
else {
|
|
253
|
-
dialog.successMessage({ text: '更改順序成功' });
|
|
254
|
-
fGVC.closeDialog();
|
|
255
|
-
gvc.notifyDataChange(vm.id);
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
})),
|
|
259
|
-
].join('');
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
}))}
|
|
263
|
-
${BgWidget.darkButton('新增', gvc.event(() => {
|
|
264
|
-
vm.data = {
|
|
265
|
-
title: '',
|
|
266
|
-
array: [],
|
|
267
|
-
product_id: [],
|
|
268
|
-
parentTitles: [],
|
|
269
|
-
subCollections: [],
|
|
270
|
-
checked: false,
|
|
271
|
-
seo_title: '',
|
|
272
|
-
seo_content: '',
|
|
273
|
-
language_data: {
|
|
274
|
-
'zh-CN': getEmptyLanguageData(),
|
|
275
|
-
'zh-TW': getEmptyLanguageData(),
|
|
276
|
-
'en-US': getEmptyLanguageData(),
|
|
277
|
-
},
|
|
278
|
-
seo_image: '',
|
|
279
|
-
code: '',
|
|
280
|
-
allCollections: vm.allParents,
|
|
281
|
-
};
|
|
282
|
-
vm.type = 'add';
|
|
283
|
-
}))}
|
|
284
|
-
</div>
|
|
285
156
|
</div>
|
|
286
157
|
${BgWidget.container(BgWidget.mainCard([
|
|
287
158
|
BgWidget.searchPlace(gvc.event(e => {
|
|
288
159
|
vm.query = e.value;
|
|
289
160
|
gvc.notifyDataChange(vm.id);
|
|
290
161
|
}), vm.query || '', '搜尋分類'),
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
162
|
+
gvc.bindView(() => {
|
|
163
|
+
const vm_2 = {
|
|
164
|
+
id: gvc.glitter.getUUID(),
|
|
165
|
+
loading: true,
|
|
166
|
+
data: [],
|
|
167
|
+
};
|
|
168
|
+
function loading() {
|
|
169
|
+
var _a;
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const collection = yield ApiShop.getCollection();
|
|
172
|
+
vm_2.data = (_a = collection.response.value) !== null && _a !== void 0 ? _a : [];
|
|
173
|
+
vm_2.loading = false;
|
|
174
|
+
gvc.notifyDataChange(vm_2.id);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
const sharedData = {};
|
|
178
|
+
loading();
|
|
179
|
+
function refresh() {
|
|
180
|
+
gvc.notifyDataChange(vm_2.id);
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
bind: vm_2.id,
|
|
184
|
+
view: () => {
|
|
185
|
+
if (vm_2.loading) {
|
|
186
|
+
return BgWidget.spinner();
|
|
187
|
+
}
|
|
188
|
+
function loop(root, array, og_path) {
|
|
189
|
+
function plus(array2 = array) {
|
|
190
|
+
const refer = {
|
|
191
|
+
title: '',
|
|
192
|
+
array: [],
|
|
193
|
+
product_id: [],
|
|
194
|
+
parentTitles: [],
|
|
195
|
+
subCollections: [],
|
|
196
|
+
checked: false,
|
|
197
|
+
seo_title: '',
|
|
198
|
+
seo_content: '',
|
|
199
|
+
language_data: {
|
|
200
|
+
'zh-CN': getEmptyLanguageData(),
|
|
201
|
+
'zh-TW': getEmptyLanguageData(),
|
|
202
|
+
'en-US': getEmptyLanguageData(),
|
|
203
|
+
},
|
|
204
|
+
seo_image: '',
|
|
205
|
+
code: '',
|
|
206
|
+
allCollections: vm.allParents,
|
|
207
|
+
};
|
|
208
|
+
BgWidget.settingDialog({
|
|
209
|
+
gvc: gvc,
|
|
210
|
+
title: html ` <div class="d-flex align-items-center" style="gap:10px;">
|
|
211
|
+
新增分類
|
|
212
|
+
<div id="language_btn_place" class=""></div>
|
|
213
|
+
</div>`,
|
|
214
|
+
width: 720,
|
|
215
|
+
height: 720,
|
|
216
|
+
innerHTML: gvc => {
|
|
217
|
+
return ShoppingCollections.editorDetail({
|
|
218
|
+
vm: {
|
|
219
|
+
data: refer,
|
|
220
|
+
},
|
|
221
|
+
type: 'add',
|
|
222
|
+
gvc: gvc,
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
footer_html: gvc => {
|
|
226
|
+
return html ` <div class="d-flex align-items-center w-100">
|
|
227
|
+
<div class="flex-fill"></div>
|
|
228
|
+
${[
|
|
229
|
+
BgWidget.cancel(gvc.event(() => {
|
|
230
|
+
gvc.closeDialog();
|
|
231
|
+
})),
|
|
232
|
+
BgWidget.save(gvc.event(() => {
|
|
233
|
+
console.log(JSON.stringify(refer));
|
|
234
|
+
if (array2.find(dd => dd.title === refer.title)) {
|
|
235
|
+
dialog.errorMessage({ text: '此分類標籤已存在' });
|
|
236
|
+
}
|
|
237
|
+
else if (!refer.title) {
|
|
238
|
+
dialog.errorMessage({ text: '請輸入分類標籤' });
|
|
333
239
|
}
|
|
334
240
|
else {
|
|
335
|
-
|
|
336
|
-
|
|
241
|
+
array2.push(refer);
|
|
242
|
+
refresh();
|
|
243
|
+
gvc.closeDialog();
|
|
244
|
+
}
|
|
245
|
+
})),
|
|
246
|
+
].join('<div class="mx-2"></div>')}
|
|
247
|
+
</div>`;
|
|
248
|
+
},
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
return html `
|
|
252
|
+
<ol class="dd-list">
|
|
253
|
+
${array
|
|
254
|
+
.map((dd, index) => {
|
|
255
|
+
dd.og_path = [og_path, dd.title]
|
|
256
|
+
.filter(dd => {
|
|
257
|
+
return dd;
|
|
258
|
+
})
|
|
259
|
+
.join(' / ');
|
|
260
|
+
const id = gvc.glitter.getUUID();
|
|
261
|
+
sharedData[id] = dd;
|
|
262
|
+
return html ` <li class="dd-item" data-id="${id}" id="${id}">
|
|
263
|
+
${gvc.bindView(() => {
|
|
264
|
+
const c_vm = {
|
|
265
|
+
id: gvc.glitter.getUUID(),
|
|
266
|
+
};
|
|
267
|
+
function refresh() {
|
|
268
|
+
gvc.notifyDataChange(c_vm.id);
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
bind: c_vm.id,
|
|
272
|
+
view: () => {
|
|
273
|
+
return ` ${dd.title}
|
|
274
|
+
<div class="flex-fill"></div>
|
|
275
|
+
${[
|
|
276
|
+
(() => {
|
|
277
|
+
if (dd.og_path.split(' / ').length === 3) {
|
|
278
|
+
return ``;
|
|
279
|
+
}
|
|
280
|
+
return `<div
|
|
281
|
+
style="cursor: pointer;"
|
|
282
|
+
class="border d-flex align-items-center justify-content-center rounded-3 p-2"
|
|
283
|
+
onclick="${gvc.event((e, event) => {
|
|
284
|
+
event.stopPropagation();
|
|
285
|
+
event.preventDefault();
|
|
286
|
+
dd.array = dd.array || [];
|
|
287
|
+
plus(dd.array);
|
|
288
|
+
})}"
|
|
289
|
+
onmousedown="${gvc.event((e, event) => {
|
|
290
|
+
event.stopPropagation();
|
|
291
|
+
event.preventDefault();
|
|
292
|
+
})}"
|
|
293
|
+
ontouchstart="${gvc.event((e, event) => {
|
|
294
|
+
event.stopPropagation();
|
|
295
|
+
event.preventDefault();
|
|
296
|
+
dd.array = dd.array || [];
|
|
297
|
+
plus(dd.array);
|
|
298
|
+
})}"
|
|
299
|
+
>
|
|
300
|
+
<i class="fa-regular fa-circle-plus fs-6"></i>
|
|
301
|
+
</div>`;
|
|
302
|
+
})(),
|
|
303
|
+
(() => {
|
|
304
|
+
function next() {
|
|
305
|
+
const refer = JSON.parse(JSON.stringify(dd));
|
|
306
|
+
BgWidget.settingDialog({
|
|
307
|
+
gvc: gvc,
|
|
308
|
+
title: html ` <div class="d-flex align-items-center" style="gap:10px;">
|
|
309
|
+
編輯分類
|
|
310
|
+
<div id="language_btn_place" class=""></div>
|
|
311
|
+
</div>`,
|
|
312
|
+
width: 720,
|
|
313
|
+
height: 720,
|
|
314
|
+
innerHTML: gvc => {
|
|
315
|
+
return ShoppingCollections.editorDetail({
|
|
316
|
+
vm: {
|
|
317
|
+
data: refer,
|
|
318
|
+
},
|
|
319
|
+
type: 'replace',
|
|
320
|
+
gvc: gvc,
|
|
321
|
+
});
|
|
322
|
+
},
|
|
323
|
+
footer_html: gvc => {
|
|
324
|
+
return html ` <div class="d-flex align-items-center w-100">
|
|
325
|
+
<div class="flex-fill"></div>
|
|
326
|
+
${[
|
|
327
|
+
BgWidget.cancel(gvc.event(() => {
|
|
328
|
+
gvc.closeDialog();
|
|
329
|
+
})),
|
|
330
|
+
BgWidget.save(gvc.event(() => {
|
|
331
|
+
if (array.find(dd => dd.title === refer.title)) {
|
|
332
|
+
dialog.errorMessage({ text: '此分類標籤已存在' });
|
|
333
|
+
}
|
|
334
|
+
else if (!refer.title) {
|
|
335
|
+
dialog.errorMessage({ text: '請輸入分類標籤' });
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
array[index] = refer;
|
|
339
|
+
sharedData[id] = refer;
|
|
340
|
+
dd = refer;
|
|
341
|
+
saveEvent().then((res) => {
|
|
342
|
+
if (res) {
|
|
343
|
+
gvc.closeDialog();
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
})),
|
|
348
|
+
].join('<div class="mx-2"></div>')}
|
|
349
|
+
</div>`;
|
|
350
|
+
},
|
|
351
|
+
});
|
|
337
352
|
}
|
|
338
|
-
|
|
353
|
+
return `<div
|
|
354
|
+
style="cursor: pointer;"
|
|
355
|
+
class="border d-flex align-items-center justify-content-center rounded-3 p-2"
|
|
356
|
+
onclick="${gvc.event((e, event) => {
|
|
357
|
+
event.stopPropagation();
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
next();
|
|
360
|
+
})}"
|
|
361
|
+
onmousedown="${gvc.event((e, event) => {
|
|
362
|
+
event.stopPropagation();
|
|
363
|
+
event.preventDefault();
|
|
364
|
+
})}"
|
|
365
|
+
ontouchstart="${gvc.event((e, event) => {
|
|
366
|
+
event.stopPropagation();
|
|
367
|
+
event.preventDefault();
|
|
368
|
+
next();
|
|
369
|
+
})}"
|
|
370
|
+
>
|
|
371
|
+
<i class="fa-solid fa-pencil fs-6 "></i>
|
|
372
|
+
</div>`;
|
|
373
|
+
})(),
|
|
374
|
+
gvc.bindView(() => {
|
|
375
|
+
const b_id = gvc.glitter.getUUID();
|
|
376
|
+
function next() {
|
|
377
|
+
dd.hidden = !dd.hidden;
|
|
378
|
+
gvc.notifyDataChange(b_id);
|
|
379
|
+
}
|
|
380
|
+
return {
|
|
381
|
+
bind: b_id,
|
|
382
|
+
view: () => {
|
|
383
|
+
return ` <i class="${dd.hidden ? 'fa-solid fa-eye-slash' : 'fa-solid fa-eye'} fs-6 "></i>`;
|
|
384
|
+
},
|
|
385
|
+
divCreate: {
|
|
386
|
+
style: `cursor: pointer;`,
|
|
387
|
+
class: `border d-flex align-items-center justify-content-center rounded-3 p-2`,
|
|
388
|
+
option: [
|
|
389
|
+
{
|
|
390
|
+
key: 'onclick',
|
|
391
|
+
value: gvc.event((e, event) => {
|
|
392
|
+
event.stopPropagation();
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
next();
|
|
395
|
+
}),
|
|
396
|
+
},
|
|
397
|
+
{
|
|
398
|
+
key: 'onmousedown',
|
|
399
|
+
value: gvc.event((e, event) => {
|
|
400
|
+
event.stopPropagation();
|
|
401
|
+
event.preventDefault();
|
|
402
|
+
}),
|
|
403
|
+
},
|
|
404
|
+
{
|
|
405
|
+
key: 'ontouchstart',
|
|
406
|
+
value: gvc.event((e, event) => {
|
|
407
|
+
event.stopPropagation();
|
|
408
|
+
event.preventDefault();
|
|
409
|
+
next();
|
|
410
|
+
}),
|
|
411
|
+
},
|
|
412
|
+
],
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
}),
|
|
416
|
+
(() => {
|
|
417
|
+
function next() {
|
|
339
418
|
dialog.checkYesOrNot({
|
|
340
|
-
text: '
|
|
341
|
-
callback:
|
|
419
|
+
text: '是否確認刪除分類?',
|
|
420
|
+
callback: response => {
|
|
421
|
+
if (response) {
|
|
422
|
+
dd.deleted = true;
|
|
423
|
+
document.getElementById(`${id}`).classList.add(`d-none`);
|
|
424
|
+
saveEvent();
|
|
425
|
+
}
|
|
426
|
+
},
|
|
342
427
|
});
|
|
343
428
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
429
|
+
return ` <div
|
|
430
|
+
style="cursor: pointer;"
|
|
431
|
+
class="border d-flex align-items-center justify-content-center rounded-3 p-2"
|
|
432
|
+
onclick="${gvc.event((e, event) => {
|
|
433
|
+
event.stopPropagation();
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
next();
|
|
436
|
+
})}"
|
|
437
|
+
onmousedown="${gvc.event((e, event) => {
|
|
438
|
+
event.stopPropagation();
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
})}"
|
|
441
|
+
ontouchstart="${gvc.event((e, event) => {
|
|
442
|
+
event.stopPropagation();
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
next();
|
|
445
|
+
})}"
|
|
446
|
+
>
|
|
447
|
+
<i class="fa-regular fa-trash fs-6 text-black-50"></i>
|
|
448
|
+
</div>`;
|
|
449
|
+
})(),
|
|
450
|
+
].filter((dd) => {
|
|
451
|
+
return dd;
|
|
452
|
+
}).join(` <div class="mx-1"></div>`)}`;
|
|
453
|
+
},
|
|
454
|
+
divCreate: {
|
|
455
|
+
class: `dd-handle d-flex align-items-center`,
|
|
456
|
+
},
|
|
457
|
+
};
|
|
458
|
+
})}
|
|
459
|
+
${dd.array && dd.array.length ? loop(false, dd.array, `${dd.og_path}`) : []}
|
|
460
|
+
</li>`;
|
|
461
|
+
})
|
|
462
|
+
.join('')}
|
|
463
|
+
<div
|
|
464
|
+
class="${root ? `` : `d-none`}"
|
|
465
|
+
style="cursor:pointer;align-self: stretch; height: 50px; flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 10px; display: flex"
|
|
466
|
+
onclick="${gvc.event(() => {
|
|
467
|
+
plus();
|
|
468
|
+
})}"
|
|
469
|
+
>
|
|
470
|
+
<div
|
|
471
|
+
style="align-self: stretch; height: 40px; border-radius: 2px; border: 1px #DDDDDD solid; justify-content: center; align-items: center; gap: 6px; display: inline-flex"
|
|
472
|
+
>
|
|
473
|
+
<i class="fa-solid fa-plus" style="color: #3366BB;font-size: 16px; "></i>
|
|
474
|
+
<div
|
|
475
|
+
style="color: #3366BB; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
|
|
476
|
+
>
|
|
477
|
+
新增主分類
|
|
478
|
+
</div>
|
|
479
|
+
</div>
|
|
480
|
+
</div>
|
|
481
|
+
</ol>
|
|
482
|
+
`;
|
|
391
483
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
484
|
+
return html ` <div class="dd" id="nestable">${loop(true, vm_2.data, '')}</div>`;
|
|
485
|
+
},
|
|
486
|
+
divCreate: {
|
|
487
|
+
class: `px-lg-3 px-1`,
|
|
488
|
+
},
|
|
489
|
+
onCreate: () => {
|
|
490
|
+
gvc.glitter.addStyle(`
|
|
491
|
+
.cf:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
|
|
492
|
+
*:first-child+html .cf { zoom: 1; }
|
|
493
|
+
|
|
494
|
+
h1 { font-size: 1.75em; margin: 0 0 0.6em 0; }
|
|
495
|
+
|
|
496
|
+
a { color: #2996cc; }
|
|
497
|
+
a:hover { text-decoration: none; }
|
|
498
|
+
|
|
499
|
+
p { line-height: 1.5em; }
|
|
500
|
+
.small { color: #666; font-size: 0.875em; }
|
|
501
|
+
.large { font-size: 1.25em; }
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* Nestable
|
|
505
|
+
*/
|
|
506
|
+
|
|
507
|
+
.dd { position: relative; display: block; margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 20px; }
|
|
508
|
+
|
|
509
|
+
.dd-list { display: block; position: relative; margin: 0; padding: 0; list-style: none; }
|
|
510
|
+
.dd-list .dd-list { padding-left: 30px; }
|
|
511
|
+
.dd-collapsed .dd-list { display: none; }
|
|
512
|
+
|
|
513
|
+
.dd-item,
|
|
514
|
+
.dd-empty,
|
|
515
|
+
.dd-placeholder { display: block; position: relative; margin: 0; padding: 0; min-height: 20px; font-size: 13px; line-height: 20px; }
|
|
516
|
+
|
|
517
|
+
.dd-handle { display: block; height: 40px; margin: 5px 0; padding: 5px 10px; color: #333; text-decoration: none; font-weight: bold; border: 1px solid #ccc;
|
|
518
|
+
background: #fafafa;
|
|
519
|
+
background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
|
|
520
|
+
background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
|
|
521
|
+
background: linear-gradient(top, #fafafa 0%, #eee 100%);
|
|
522
|
+
-webkit-border-radius: 3px;
|
|
523
|
+
border-radius: 3px;
|
|
524
|
+
box-sizing: border-box; -moz-box-sizing: border-box;
|
|
525
|
+
}
|
|
526
|
+
.dd-handle:hover { color: #2ea8e5; background: #fff; }
|
|
527
|
+
|
|
528
|
+
.dd-item > button { display: block; position: relative; cursor: pointer; float: left; width: 25px; height: 30px; margin: 5px 0; padding: 0; text-indent: 100%; white-space: nowrap; overflow: hidden; border: 0; background: transparent; font-size: 20px; line-height: 1; text-align: center; font-weight: bold; }
|
|
529
|
+
.dd-item > button:before { content: '+'; display: block; position: absolute; width: 100%; text-align: center; text-indent: 0; }
|
|
530
|
+
.dd-item > button[data-action="collapse"]:before { content: '-'; }
|
|
531
|
+
|
|
532
|
+
.dd-placeholder,
|
|
533
|
+
.dd-empty { margin: 5px 0; padding: 0; min-height: 30px; background: #f2fbff; border: 1px dashed #b6bcbf; box-sizing: border-box; -moz-box-sizing: border-box; }
|
|
534
|
+
.dd-empty { border: 1px dashed #bbb; min-height: 100px; background-color: #e5e5e5;
|
|
535
|
+
background-image: -webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
|
|
536
|
+
-webkit-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
|
537
|
+
background-image: -moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
|
|
538
|
+
-moz-linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
|
539
|
+
background-image: linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff),
|
|
540
|
+
linear-gradient(45deg, #fff 25%, transparent 25%, transparent 75%, #fff 75%, #fff);
|
|
541
|
+
background-size: 60px 60px;
|
|
542
|
+
background-position: 0 0, 30px 30px;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
.dd-dragel { position: absolute; pointer-events: none; z-index: 9999; }
|
|
546
|
+
.dd-dragel > .dd-item .dd-handle { margin-top: 0; }
|
|
547
|
+
.dd-dragel .dd-handle {
|
|
548
|
+
-webkit-box-shadow: 2px 4px 6px 0 rgba(0,0,0,.1);
|
|
549
|
+
box-shadow: 2px 4px 6px 0 rgba(0,0,0,.1);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* Nestable Extras
|
|
554
|
+
*/
|
|
555
|
+
|
|
556
|
+
.nestable-lists { display: block; clear: both; padding: 30px 0; width: 100%; border: 0; border-top: 2px solid #ddd; border-bottom: 2px solid #ddd; }
|
|
557
|
+
|
|
558
|
+
#nestable-menu { padding: 0; margin: 20px 0; }
|
|
559
|
+
|
|
560
|
+
#nestable-output,
|
|
561
|
+
#nestable2-output { width: 100%; height: 7em; font-size: 0.75em; line-height: 1.333333em; font-family: Consolas, monospace; padding: 5px; box-sizing: border-box; -moz-box-sizing: border-box; }
|
|
562
|
+
|
|
563
|
+
#nestable2 .dd-handle {
|
|
564
|
+
color: #fff;
|
|
565
|
+
border: 1px solid #999;
|
|
566
|
+
background: #bbb;
|
|
567
|
+
background: -webkit-linear-gradient(top, #bbb 0%, #999 100%);
|
|
568
|
+
background: -moz-linear-gradient(top, #bbb 0%, #999 100%);
|
|
569
|
+
background: linear-gradient(top, #bbb 0%, #999 100%);
|
|
570
|
+
}
|
|
571
|
+
#nestable2 .dd-handle:hover { background: #bbb; }
|
|
572
|
+
#nestable2 .dd-item > button:before { color: #fff; }
|
|
573
|
+
|
|
574
|
+
@media only screen and (min-width: 700px) {
|
|
575
|
+
|
|
576
|
+
.dd { width: 100%; }
|
|
577
|
+
.dd + .dd { margin-left: 2%; }
|
|
578
|
+
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
.dd-hover > .dd-handle { background: #2ea8e5 !important; }
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* Nestable Draggable Handles
|
|
585
|
+
*/
|
|
586
|
+
|
|
587
|
+
.dd3-content { display: block; height: 30px; margin: 5px 0; padding: 5px 10px 5px 40px; color: #333; text-decoration: none; font-weight: bold; border: 1px solid #ccc;
|
|
588
|
+
background: #fafafa;
|
|
589
|
+
background: -webkit-linear-gradient(top, #fafafa 0%, #eee 100%);
|
|
590
|
+
background: -moz-linear-gradient(top, #fafafa 0%, #eee 100%);
|
|
591
|
+
background: linear-gradient(top, #fafafa 0%, #eee 100%);
|
|
592
|
+
-webkit-border-radius: 3px;
|
|
593
|
+
border-radius: 3px;
|
|
594
|
+
box-sizing: border-box; -moz-box-sizing: border-box;
|
|
595
|
+
}
|
|
596
|
+
.dd3-content:hover { color: #2ea8e5; background: #fff; }
|
|
597
|
+
|
|
598
|
+
.dd-dragel > .dd3-item > .dd3-content { margin: 0; }
|
|
599
|
+
|
|
600
|
+
.dd3-item > button { margin-left: 30px; }
|
|
601
|
+
|
|
602
|
+
.dd3-handle { position: absolute; margin: 0; left: 0; top: 0; cursor: pointer; width: 30px; text-indent: 100%; white-space: nowrap; overflow: hidden;
|
|
603
|
+
border: 1px solid #aaa;
|
|
604
|
+
background: #ddd;
|
|
605
|
+
background: -webkit-linear-gradient(top, #ddd 0%, #bbb 100%);
|
|
606
|
+
background: -moz-linear-gradient(top, #ddd 0%, #bbb 100%);
|
|
607
|
+
background: linear-gradient(top, #ddd 0%, #bbb 100%);
|
|
608
|
+
border-top-right-radius: 0;
|
|
609
|
+
border-bottom-right-radius: 0;
|
|
610
|
+
}
|
|
611
|
+
.dd3-handle:before { content: '≡'; display: block; position: absolute; left: 0; top: 3px; width: 100%; text-align: center; text-indent: 0; color: #fff; font-size: 20px; font-weight: normal; }
|
|
612
|
+
.dd3-handle:hover { background: #ddd; }
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Socialite
|
|
616
|
+
*/
|
|
617
|
+
|
|
618
|
+
.socialite { display: block; float: left; height: 35px; }
|
|
619
|
+
`);
|
|
620
|
+
gvc.glitter.addMtScript([`${gvc.glitter.root_path}/jslib/nestable/jquery.nestable.js`], () => {
|
|
621
|
+
const updateOutput = function () {
|
|
622
|
+
const outPutJson = $('#nestable').nestable('serialize');
|
|
623
|
+
function loop(array, new_path) {
|
|
624
|
+
return (array !== null && array !== void 0 ? array : []).map(dd => {
|
|
625
|
+
const og = sharedData[dd.id];
|
|
626
|
+
og.new_path = [new_path, og.title]
|
|
627
|
+
.filter(dd => {
|
|
628
|
+
return dd;
|
|
629
|
+
})
|
|
630
|
+
.join(' / ');
|
|
631
|
+
if (dd.children) {
|
|
632
|
+
dd.children = loop(dd.children, og.new_path);
|
|
633
|
+
}
|
|
634
|
+
og.array = dd.children;
|
|
635
|
+
return og;
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
const op = loop(outPutJson, '');
|
|
639
|
+
console.log(`output-data`, op);
|
|
640
|
+
return op;
|
|
641
|
+
};
|
|
642
|
+
getSaveData = updateOutput;
|
|
643
|
+
$('#nestable')
|
|
644
|
+
.nestable({
|
|
645
|
+
group: 1,
|
|
646
|
+
maxDepth: 3
|
|
647
|
+
})
|
|
648
|
+
.on('change', updateOutput);
|
|
649
|
+
}, () => { });
|
|
428
650
|
},
|
|
429
|
-
|
|
430
|
-
hiddenPageSplit: true,
|
|
651
|
+
};
|
|
431
652
|
}),
|
|
653
|
+
`<div class="update-bar-container">
|
|
654
|
+
${BgWidget.save(gvc.event(() => {
|
|
655
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
656
|
+
dialog.checkYesOrNot({
|
|
657
|
+
text: '是否確認儲存?',
|
|
658
|
+
callback: (response) => __awaiter(this, void 0, void 0, function* () {
|
|
659
|
+
if (response) {
|
|
660
|
+
yield saveEvent();
|
|
661
|
+
}
|
|
662
|
+
}),
|
|
663
|
+
});
|
|
664
|
+
}))}
|
|
665
|
+
</div>`,
|
|
432
666
|
].join('')))}
|
|
433
667
|
${BgWidget.mbContainer(120)}
|
|
434
668
|
`);
|
|
@@ -544,7 +778,7 @@ export class ShoppingCollections {
|
|
|
544
778
|
return {
|
|
545
779
|
bind: viewID,
|
|
546
780
|
view: () => {
|
|
547
|
-
var _a, _b, _c, _d;
|
|
781
|
+
var _a, _b, _c, _d, _e;
|
|
548
782
|
if (obj.type === 'replace') {
|
|
549
783
|
vm.data.language_data = (_a = vm.data.language_data) !== null && _a !== void 0 ? _a : {
|
|
550
784
|
'zh-TW': {
|
|
@@ -559,556 +793,342 @@ export class ShoppingCollections {
|
|
|
559
793
|
'en-US': getEmptyLanguageData(),
|
|
560
794
|
};
|
|
561
795
|
}
|
|
796
|
+
vm.data.product_id = ((_b = vm.data.product_id) !== null && _b !== void 0 ? _b : []).map((dd) => {
|
|
797
|
+
return parseInt(dd, 10);
|
|
798
|
+
});
|
|
562
799
|
const language_data = vm.data.language_data[select_lan];
|
|
563
800
|
const prefixURL = `https://${window.parent.glitter.share.editorViewModel.domain}/${Language.getLanguageLinkPrefix(true, select_lan)}collections/`;
|
|
801
|
+
setTimeout(() => {
|
|
802
|
+
window.parent.document.querySelector('#language_btn_place').innerHTML =
|
|
803
|
+
`<div class="title-container">
|
|
804
|
+
<div class="flex-fill"></div>
|
|
805
|
+
<div class="d-flex align-items-center gap-2">
|
|
806
|
+
${BgWidget.grayButton(html ` <div class="d-flex align-items-center gap-2">
|
|
807
|
+
<i class="fa-duotone fa-solid fa-earth-americas"></i>${Language.getLanguageText({
|
|
808
|
+
local: true,
|
|
809
|
+
compare: select_lan,
|
|
810
|
+
})}
|
|
811
|
+
</div>`, gvc.event(() => {
|
|
812
|
+
BgWidget.settingDialog({
|
|
813
|
+
gvc: gvc,
|
|
814
|
+
innerHTML: (gvc) => {
|
|
815
|
+
return gvc.bindView((() => {
|
|
816
|
+
const id = gvc.glitter.getUUID();
|
|
817
|
+
return {
|
|
818
|
+
bind: id,
|
|
819
|
+
view: () => {
|
|
820
|
+
return html ` <div
|
|
821
|
+
style="position: relative; word-break: break-all; white-space: normal;"
|
|
822
|
+
>
|
|
823
|
+
${BgWidget.grayNote('前往商店設定->商店訊息中,設定支援的語言。')}
|
|
824
|
+
${gvc.bindView(() => {
|
|
825
|
+
return {
|
|
826
|
+
bind: glitter.getUUID(),
|
|
827
|
+
view: () => {
|
|
828
|
+
const sup = [
|
|
829
|
+
{
|
|
830
|
+
key: 'en-US',
|
|
831
|
+
value: '英文',
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
key: 'zh-CN',
|
|
835
|
+
value: '簡體中文',
|
|
836
|
+
},
|
|
837
|
+
{
|
|
838
|
+
key: 'zh-TW',
|
|
839
|
+
value: '繁體中文',
|
|
840
|
+
},
|
|
841
|
+
]
|
|
842
|
+
.filter(dd => {
|
|
843
|
+
return window.parent.store_info.language_setting.support.includes(dd.key);
|
|
844
|
+
})
|
|
845
|
+
.sort(dd => {
|
|
846
|
+
return dd.key === select_lan ? -1 : 1;
|
|
847
|
+
});
|
|
848
|
+
return html ` <div
|
|
849
|
+
class="d-flex mt-3 flex-wrap align-items-center justify-content-center"
|
|
850
|
+
style="gap:15px;"
|
|
851
|
+
>
|
|
852
|
+
${sup
|
|
853
|
+
.map(dd => {
|
|
854
|
+
return html `
|
|
855
|
+
<div
|
|
856
|
+
class="px-3 py-1 text-white position-relative d-flex align-items-center justify-content-center"
|
|
857
|
+
style="border-radius: 20px;background: #393939;cursor: pointer;width:100px;"
|
|
858
|
+
onclick="${gvc.event(() => {
|
|
859
|
+
select_lan = dd.key;
|
|
860
|
+
gvc.closeDialog();
|
|
861
|
+
refresh();
|
|
862
|
+
})}"
|
|
863
|
+
>
|
|
864
|
+
${dd.value}
|
|
865
|
+
<div
|
|
866
|
+
class="position-absolute text-white rounded-2 px-2 d-flex align-items-center rounded-3 ${dd.key !==
|
|
867
|
+
select_lan
|
|
868
|
+
? 'd-none'
|
|
869
|
+
: ''}"
|
|
870
|
+
style="top: -12px;right: -10px; height:20px;font-size: 11px;background: #ff6c02;"
|
|
871
|
+
>
|
|
872
|
+
已選擇
|
|
873
|
+
</div>
|
|
874
|
+
</div>
|
|
875
|
+
`;
|
|
876
|
+
})
|
|
877
|
+
.join('')}
|
|
878
|
+
</div>`;
|
|
879
|
+
},
|
|
880
|
+
};
|
|
881
|
+
})}
|
|
882
|
+
</div>`;
|
|
883
|
+
},
|
|
884
|
+
};
|
|
885
|
+
})());
|
|
886
|
+
},
|
|
887
|
+
title: '切換語系',
|
|
888
|
+
footer_html: gvc => {
|
|
889
|
+
return '';
|
|
890
|
+
},
|
|
891
|
+
width: 300,
|
|
892
|
+
});
|
|
893
|
+
}))}
|
|
894
|
+
${vm.type === 'add'
|
|
895
|
+
? BgWidget.grayButton('代入現有分類', gvc.event(() => {
|
|
896
|
+
BgProduct.collectionsDialog({
|
|
897
|
+
gvc: gvc,
|
|
898
|
+
default: [],
|
|
899
|
+
callback: value => {
|
|
900
|
+
var _a;
|
|
901
|
+
const data = (_a = vm.dataList) === null || _a === void 0 ? void 0 : _a.find(item => [...item.parentTitles, item.title].join(' / ') === value[0]);
|
|
902
|
+
if (data) {
|
|
903
|
+
vm.data = data;
|
|
904
|
+
vm.cloneTarget = structuredClone(data);
|
|
905
|
+
}
|
|
906
|
+
gvc.notifyDataChange(viewID);
|
|
907
|
+
},
|
|
908
|
+
single: true,
|
|
909
|
+
});
|
|
910
|
+
}))
|
|
911
|
+
: ''}
|
|
912
|
+
</div>
|
|
913
|
+
</div>`;
|
|
914
|
+
}, 100);
|
|
564
915
|
return BgWidget.container([
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
}))}
|
|
569
|
-
${BgWidget.title(obj.type === 'add' ? '新增分類' : '編輯分類')}
|
|
570
|
-
<div class="flex-fill"></div>
|
|
571
|
-
<div class="d-flex align-items-center gap-2">
|
|
572
|
-
${BgWidget.grayButton(html ` <div class="d-flex align-items-center gap-2">
|
|
573
|
-
<i class="fa-duotone fa-solid fa-earth-americas"></i>${Language.getLanguageText({
|
|
574
|
-
local: true,
|
|
575
|
-
compare: select_lan,
|
|
576
|
-
})}
|
|
577
|
-
</div>`, gvc.event(() => {
|
|
578
|
-
BgWidget.settingDialog({
|
|
916
|
+
[
|
|
917
|
+
html ` <div class="tx_700" style="margin-bottom: 12px">分類標籤 ${BgWidget.requiredStar()}</div>
|
|
918
|
+
${EditorElem.editeInput({
|
|
579
919
|
gvc: gvc,
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
view: () => {
|
|
586
|
-
return html ` <div
|
|
587
|
-
style="position: relative; word-break: break-all; white-space: normal;"
|
|
588
|
-
>
|
|
589
|
-
${BgWidget.grayNote('前往商店設定->商店訊息中,設定支援的語言。')}
|
|
590
|
-
${gvc.bindView(() => {
|
|
591
|
-
return {
|
|
592
|
-
bind: glitter.getUUID(),
|
|
593
|
-
view: () => {
|
|
594
|
-
const sup = [
|
|
595
|
-
{
|
|
596
|
-
key: 'en-US',
|
|
597
|
-
value: '英文',
|
|
598
|
-
},
|
|
599
|
-
{
|
|
600
|
-
key: 'zh-CN',
|
|
601
|
-
value: '簡體中文',
|
|
602
|
-
},
|
|
603
|
-
{
|
|
604
|
-
key: 'zh-TW',
|
|
605
|
-
value: '繁體中文',
|
|
606
|
-
},
|
|
607
|
-
]
|
|
608
|
-
.filter(dd => {
|
|
609
|
-
return window.parent.store_info.language_setting.support.includes(dd.key);
|
|
610
|
-
})
|
|
611
|
-
.sort(dd => {
|
|
612
|
-
return dd.key === select_lan ? -1 : 1;
|
|
613
|
-
});
|
|
614
|
-
return html ` <div
|
|
615
|
-
class="d-flex mt-3 flex-wrap align-items-center justify-content-center"
|
|
616
|
-
style="gap:15px;"
|
|
617
|
-
>
|
|
618
|
-
${sup
|
|
619
|
-
.map(dd => {
|
|
620
|
-
return html `
|
|
621
|
-
<div
|
|
622
|
-
class="px-3 py-1 text-white position-relative d-flex align-items-center justify-content-center"
|
|
623
|
-
style="border-radius: 20px;background: #393939;cursor: pointer;width:100px;"
|
|
624
|
-
onclick="${gvc.event(() => {
|
|
625
|
-
select_lan = dd.key;
|
|
626
|
-
gvc.closeDialog();
|
|
627
|
-
refresh();
|
|
628
|
-
})}"
|
|
629
|
-
>
|
|
630
|
-
${dd.value}
|
|
631
|
-
<div
|
|
632
|
-
class="position-absolute text-white rounded-2 px-2 d-flex align-items-center rounded-3 ${dd.key !==
|
|
633
|
-
select_lan
|
|
634
|
-
? 'd-none'
|
|
635
|
-
: ''}"
|
|
636
|
-
style="top: -12px;right: -10px; height:20px;font-size: 11px;background: #ff6c02;"
|
|
637
|
-
>
|
|
638
|
-
已選擇
|
|
639
|
-
</div>
|
|
640
|
-
</div>
|
|
641
|
-
`;
|
|
642
|
-
})
|
|
643
|
-
.join('')}
|
|
644
|
-
</div>`;
|
|
645
|
-
},
|
|
646
|
-
};
|
|
647
|
-
})}
|
|
648
|
-
</div>`;
|
|
649
|
-
},
|
|
650
|
-
};
|
|
651
|
-
})());
|
|
920
|
+
title: '',
|
|
921
|
+
default: vm.data.title,
|
|
922
|
+
placeHolder: '請輸入分類標籤',
|
|
923
|
+
callback: text => {
|
|
924
|
+
vm.data.title = text;
|
|
652
925
|
},
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
926
|
+
})}`,
|
|
927
|
+
html ` <div class="d-flex flex-column" style="margin-bottom: 12px; gap:5px;">
|
|
928
|
+
<div class="tx_700">前台分類顯示名稱 ${BgWidget.languageInsignia(select_lan)}</div>
|
|
929
|
+
${BgWidget.grayNote('未設定則參照分類標籤顯示')}
|
|
930
|
+
</div>
|
|
931
|
+
${EditorElem.editeInput({
|
|
932
|
+
gvc: gvc,
|
|
933
|
+
title: '',
|
|
934
|
+
default: language_data.title,
|
|
935
|
+
placeHolder: vm.data.title || '預設為「分類標籤」輸入值',
|
|
936
|
+
callback: text => {
|
|
937
|
+
language_data.title = text;
|
|
938
|
+
if (language_data.seo.domain === '') {
|
|
939
|
+
language_data.seo.domain = language_data.title;
|
|
940
|
+
gvc.notifyDataChange(domainID);
|
|
941
|
+
}
|
|
656
942
|
},
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
943
|
+
})}`,
|
|
944
|
+
gvc.bindView(() => {
|
|
945
|
+
const viewID = gvc.glitter.getUUID();
|
|
946
|
+
return {
|
|
947
|
+
bind: viewID,
|
|
948
|
+
view: () => {
|
|
949
|
+
return [
|
|
950
|
+
html ` <div class="tx_700 mb-2">
|
|
951
|
+
連結網址 ${BgWidget.requiredStar()} ${BgWidget.languageInsignia(select_lan)}
|
|
952
|
+
</div>`,
|
|
953
|
+
gvc.bindView({
|
|
954
|
+
bind: domainID,
|
|
955
|
+
view: () => {
|
|
956
|
+
return html ` <div
|
|
957
|
+
class="${document.body.clientWidth < 800
|
|
958
|
+
? 'w-100'
|
|
959
|
+
: ''} justify-content-start justify-content-lg-center"
|
|
960
|
+
style="padding: 9px 18px;background: #EAEAEA; justify-content: center; align-items: center; gap: 5px; display: flex"
|
|
961
|
+
>
|
|
962
|
+
<div
|
|
963
|
+
style="text-align: right; color: #393939; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
|
|
964
|
+
>
|
|
965
|
+
${prefixURL}
|
|
966
|
+
</div>
|
|
967
|
+
</div>
|
|
968
|
+
<input
|
|
969
|
+
class="flex-fill ${document.body.clientWidth < 800 ? `w-100` : ``}"
|
|
970
|
+
style="border:none;background:none;text-align: start; color: #393939; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word; ${document
|
|
971
|
+
.body.clientWidth > 768
|
|
972
|
+
? ''
|
|
973
|
+
: 'padding: 9px 18px;'}"
|
|
974
|
+
placeholder="請輸入連結網址"
|
|
975
|
+
value="${language_data.seo.domain || ''}"
|
|
976
|
+
onchange="${gvc.event(e => {
|
|
977
|
+
let text = e.value;
|
|
978
|
+
if (text.length > 0 && !CheckInput.isChineseEnglishNumberHyphen(text)) {
|
|
979
|
+
dialog.infoMessage({ text: '連結僅限使用中英文數字與連接號' });
|
|
980
|
+
}
|
|
981
|
+
else {
|
|
982
|
+
language_data.seo.domain = text;
|
|
983
|
+
}
|
|
984
|
+
gvc.notifyDataChange(viewID);
|
|
985
|
+
})}"
|
|
986
|
+
/>`;
|
|
987
|
+
},
|
|
988
|
+
divCreate: {
|
|
989
|
+
style: `width: 100%; justify-content: flex-start; align-items: center; display: inline-flex;border:1px solid #EAEAEA;border-radius: 10px;overflow: hidden; ${document.body.clientWidth > 768 ? 'gap: 18px;' : 'flex-direction: column; gap: 0px;'}`,
|
|
990
|
+
},
|
|
991
|
+
}),
|
|
992
|
+
html ` <div class="mt-2 mb-1">
|
|
993
|
+
<span class="tx_normal me-1">網址預覽</span>
|
|
994
|
+
${BgWidget.greenNote(prefixURL + language_data.seo.domain, gvc.event(() => {
|
|
995
|
+
var _a;
|
|
996
|
+
gvc.glitter.openNewTab(prefixURL + ((_a = language_data.seo.domain) !== null && _a !== void 0 ? _a : ''));
|
|
997
|
+
}))}
|
|
998
|
+
</div>`,
|
|
999
|
+
].join(BgWidget.mbContainer(12));
|
|
690
1000
|
},
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
<div class="tx_700">前台分類顯示名稱 ${BgWidget.languageInsignia(select_lan)}</div>
|
|
694
|
-
${BgWidget.grayNote('未設定則參照分類標籤顯示')}
|
|
695
|
-
</div>
|
|
696
|
-
${EditorElem.editeInput({
|
|
697
|
-
gvc: gvc,
|
|
698
|
-
title: '',
|
|
699
|
-
default: language_data.title,
|
|
700
|
-
placeHolder: vm.data.title || '預設為「分類標籤」輸入值',
|
|
701
|
-
callback: text => {
|
|
702
|
-
language_data.title = text;
|
|
703
|
-
if (language_data.seo.domain === '') {
|
|
704
|
-
language_data.seo.domain = language_data.title;
|
|
705
|
-
gvc.notifyDataChange(domainID);
|
|
706
|
-
}
|
|
1001
|
+
divCreate: {
|
|
1002
|
+
class: `${gvc.glitter.ut.frSize({ sm: '' }, 'p-0')}`,
|
|
707
1003
|
},
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
? 'w-100'
|
|
724
|
-
: ''} justify-content-start justify-content-lg-center"
|
|
725
|
-
style="padding: 9px 18px;background: #EAEAEA; justify-content: center; align-items: center; gap: 5px; display: flex"
|
|
726
|
-
>
|
|
727
|
-
<div
|
|
728
|
-
style="text-align: right; color: #393939; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
|
|
729
|
-
>
|
|
730
|
-
${prefixURL}
|
|
731
|
-
</div>
|
|
732
|
-
</div>
|
|
733
|
-
<input
|
|
734
|
-
class="flex-fill ${document.body.clientWidth < 800 ? `w-100` : ``}"
|
|
735
|
-
style="border:none;background:none;text-align: start; color: #393939; font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word; ${document
|
|
736
|
-
.body.clientWidth > 768
|
|
737
|
-
? ''
|
|
738
|
-
: 'padding: 9px 18px;'}"
|
|
739
|
-
placeholder="請輸入連結網址"
|
|
740
|
-
value="${language_data.seo.domain || ''}"
|
|
741
|
-
onchange="${gvc.event(e => {
|
|
742
|
-
let text = e.value;
|
|
743
|
-
if (text.length > 0 && !CheckInput.isChineseEnglishNumberHyphen(text)) {
|
|
744
|
-
dialog.infoMessage({ text: '連結僅限使用中英文數字與連接號' });
|
|
745
|
-
}
|
|
746
|
-
else {
|
|
747
|
-
language_data.seo.domain = text;
|
|
748
|
-
}
|
|
749
|
-
gvc.notifyDataChange(viewID);
|
|
750
|
-
})}"
|
|
751
|
-
/>`;
|
|
752
|
-
},
|
|
753
|
-
divCreate: {
|
|
754
|
-
style: `width: 100%; justify-content: flex-start; align-items: center; display: inline-flex;border:1px solid #EAEAEA;border-radius: 10px;overflow: hidden; ${document.body.clientWidth > 768 ? 'gap: 18px;' : 'flex-direction: column; gap: 0px;'}`,
|
|
755
|
-
},
|
|
756
|
-
}),
|
|
757
|
-
html ` <div class="mt-2 mb-1">
|
|
758
|
-
<span class="tx_normal me-1">網址預覽</span>
|
|
759
|
-
${BgWidget.greenNote(prefixURL + language_data.seo.domain, gvc.event(() => {
|
|
760
|
-
var _a;
|
|
761
|
-
gvc.glitter.openNewTab(prefixURL + ((_a = language_data.seo.domain) !== null && _a !== void 0 ? _a : ''));
|
|
762
|
-
}))}
|
|
763
|
-
</div>`,
|
|
764
|
-
].join(BgWidget.mbContainer(12)));
|
|
765
|
-
},
|
|
766
|
-
divCreate: {
|
|
767
|
-
class: `${gvc.glitter.ut.frSize({ sm: '' }, 'p-0')}`,
|
|
768
|
-
},
|
|
769
|
-
};
|
|
770
|
-
}),
|
|
771
|
-
BgWidget.mainCard((() => {
|
|
772
|
-
const pvm = {
|
|
773
|
-
id: gvc.glitter.getUUID(),
|
|
774
|
-
loading: true,
|
|
775
|
-
dataList: vm.data.product_id,
|
|
776
|
-
productList: [],
|
|
777
|
-
};
|
|
778
|
-
return html `
|
|
779
|
-
<div class="d-flex flex-column">
|
|
780
|
-
<div class="d-flex align-items-center" style="justify-content: space-between;">
|
|
781
|
-
<div class="tx_700" style="margin-bottom: 12px">商品</div>
|
|
782
|
-
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
783
|
-
BgProduct.productsDialog({
|
|
784
|
-
gvc: gvc,
|
|
785
|
-
default: vm.data.product_id,
|
|
786
|
-
callback: value => {
|
|
787
|
-
pvm.dataList = value;
|
|
788
|
-
vm.data.product_id = value;
|
|
789
|
-
pvm.loading = true;
|
|
790
|
-
gvc.notifyDataChange(pvm.id);
|
|
791
|
-
},
|
|
792
|
-
});
|
|
793
|
-
}))}
|
|
794
|
-
</div>
|
|
795
|
-
${gvc.bindView({
|
|
796
|
-
bind: pvm.id,
|
|
797
|
-
view: () => {
|
|
798
|
-
if (pvm.loading) {
|
|
799
|
-
return '資料載入中';
|
|
800
|
-
}
|
|
801
|
-
if (pvm.productList.length === 0) {
|
|
802
|
-
return '目前無選取任何商品';
|
|
803
|
-
}
|
|
804
|
-
return gvc.map(pvm.productList.map((opt, index) => {
|
|
805
|
-
return html ` <div
|
|
806
|
-
class="form-check-label c_updown_label"
|
|
807
|
-
style="display: flex; align-items: center; min-height: 60px; gap: 8px;"
|
|
808
|
-
>
|
|
809
|
-
<span class="tx_normal" style="min-width: 30px;">${index + 1}.</span>
|
|
810
|
-
${BgWidget.validImageBox({ gvc, image: opt.image, width: 40 })}
|
|
811
|
-
<span class="tx_normal">${opt.value}</span>
|
|
812
|
-
${opt.note ? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> ` : ''}
|
|
813
|
-
</div>`;
|
|
814
|
-
}));
|
|
815
|
-
},
|
|
816
|
-
onCreate: () => {
|
|
817
|
-
if (pvm.loading) {
|
|
818
|
-
if (pvm.dataList.length === 0) {
|
|
819
|
-
pvm.productList = [];
|
|
820
|
-
pvm.loading = false;
|
|
821
|
-
setTimeout(() => gvc.notifyDataChange(pvm.id), 100);
|
|
822
|
-
}
|
|
823
|
-
else {
|
|
824
|
-
ApiShop.getProduct({
|
|
825
|
-
page: 0,
|
|
826
|
-
limit: 99999,
|
|
827
|
-
id_list: pvm.dataList.join(','),
|
|
828
|
-
}).then(data => {
|
|
829
|
-
pvm.productList = data.response.data.map((product) => {
|
|
830
|
-
var _a;
|
|
831
|
-
return {
|
|
832
|
-
key: product.content.id,
|
|
833
|
-
value: product.content.title,
|
|
834
|
-
image: (_a = product.content.preview_image[0]) !== null && _a !== void 0 ? _a : BgWidget.noImageURL,
|
|
835
|
-
};
|
|
836
|
-
});
|
|
837
|
-
pvm.loading = false;
|
|
838
|
-
gvc.notifyDataChange(pvm.id);
|
|
839
|
-
});
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
},
|
|
843
|
-
})}
|
|
844
|
-
</div>
|
|
845
|
-
`;
|
|
846
|
-
})()),
|
|
847
|
-
BgWidget.mainCard([
|
|
848
|
-
html ` <div style="font-weight: 700;" class="mb-3">
|
|
849
|
-
搜尋引擎列表 ${BgWidget.languageInsignia(select_lan, 'margin-left:5px;')}
|
|
850
|
-
</div>
|
|
851
|
-
<div class="tx_normal fw-normal" style="margin: 18px 0 8px;">SEO 標題</div>
|
|
852
|
-
${EditorElem.editeInput({
|
|
853
|
-
gvc: gvc,
|
|
854
|
-
title: '',
|
|
855
|
-
default: (_b = language_data.seo.title) !== null && _b !== void 0 ? _b : '',
|
|
856
|
-
placeHolder: '請輸入 SEO 標題',
|
|
857
|
-
callback: text => {
|
|
858
|
-
language_data.seo.title = text;
|
|
859
|
-
},
|
|
860
|
-
})}`,
|
|
861
|
-
,
|
|
862
|
-
html ` <div class="tx_normal fw-normal">SEO 描述</div>
|
|
863
|
-
${EditorElem.editeText({
|
|
864
|
-
gvc: gvc,
|
|
865
|
-
title: '',
|
|
866
|
-
default: (_c = language_data.seo.content) !== null && _c !== void 0 ? _c : '',
|
|
867
|
-
placeHolder: '請輸入 SEO 描述',
|
|
868
|
-
callback: text => {
|
|
869
|
-
language_data.seo.content = text;
|
|
870
|
-
},
|
|
871
|
-
})}`,
|
|
872
|
-
,
|
|
873
|
-
html ` <div class="tx_normal fw-normal">SEO 圖片</div>
|
|
874
|
-
${EditorElem.uploadImageContainer({
|
|
1004
|
+
};
|
|
1005
|
+
}),
|
|
1006
|
+
(() => {
|
|
1007
|
+
const pvm = {
|
|
1008
|
+
id: gvc.glitter.getUUID(),
|
|
1009
|
+
loading: true,
|
|
1010
|
+
dataList: vm.data.product_id,
|
|
1011
|
+
productList: [],
|
|
1012
|
+
};
|
|
1013
|
+
return html `
|
|
1014
|
+
<div class="d-flex flex-column">
|
|
1015
|
+
<div class="d-flex align-items-center" style="justify-content: space-between;">
|
|
1016
|
+
<div class="tx_700" style="margin-bottom: 12px">商品</div>
|
|
1017
|
+
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
1018
|
+
BgProduct.productsDialog({
|
|
875
1019
|
gvc: gvc,
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
vm.data.
|
|
1020
|
+
default: pvm.dataList,
|
|
1021
|
+
callback: value => {
|
|
1022
|
+
pvm.dataList = value;
|
|
1023
|
+
vm.data.product_id = value;
|
|
1024
|
+
pvm.loading = true;
|
|
1025
|
+
gvc.notifyDataChange(pvm.id);
|
|
880
1026
|
},
|
|
881
|
-
})
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
}, {
|
|
887
|
-
html: gvc.bindView((() => {
|
|
888
|
-
const summaryId = glitter.getUUID();
|
|
889
|
-
return {
|
|
890
|
-
bind: summaryId,
|
|
1027
|
+
});
|
|
1028
|
+
}))}
|
|
1029
|
+
</div>
|
|
1030
|
+
${gvc.bindView({
|
|
1031
|
+
bind: pvm.id,
|
|
891
1032
|
view: () => {
|
|
892
|
-
|
|
893
|
-
return
|
|
894
|
-
}
|
|
895
|
-
function firstParentView() {
|
|
896
|
-
var _a;
|
|
897
|
-
return [
|
|
898
|
-
html ` <div class="tx_700">第一層</div>`,
|
|
899
|
-
vm.type === 'add' && isUndefinedOption(vm.data.parentTitles[0])
|
|
900
|
-
? BgWidget.grayNote('若未選取項目,則為第一層分類')
|
|
901
|
-
: '',
|
|
902
|
-
BgWidget.select({
|
|
903
|
-
gvc: gvc,
|
|
904
|
-
callback: text => {
|
|
905
|
-
vm.data.parentTitles[0] = text;
|
|
906
|
-
gvc.notifyDataChange(summaryId);
|
|
907
|
-
},
|
|
908
|
-
default: (_a = vm.data.parentTitles[0]) !== null && _a !== void 0 ? _a : '',
|
|
909
|
-
options: vm.data.allCollections.map((item) => {
|
|
910
|
-
return { key: item, value: item };
|
|
911
|
-
}),
|
|
912
|
-
style: 'margin: 8px 0;',
|
|
913
|
-
readonly: vm.type === 'replace',
|
|
914
|
-
}),
|
|
915
|
-
BgWidget.mbContainer(12),
|
|
916
|
-
].join('');
|
|
1033
|
+
if (pvm.loading && pvm.dataList && pvm.dataList.length) {
|
|
1034
|
+
return '資料載入中';
|
|
917
1035
|
}
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
return [
|
|
921
|
-
html ` <div class="tx_700">第二層</div>`,
|
|
922
|
-
vm.type === 'add' && isUndefinedOption(vm.data.parentTitles[1])
|
|
923
|
-
? BgWidget.grayNote('若未選取項目,則為第二層分類')
|
|
924
|
-
: '',
|
|
925
|
-
BgWidget.select({
|
|
926
|
-
gvc: gvc,
|
|
927
|
-
callback: text => {
|
|
928
|
-
vm.data.parentTitles[1] = text;
|
|
929
|
-
gvc.notifyDataChange(summaryId);
|
|
930
|
-
},
|
|
931
|
-
default: (_a = vm.data.parentTitles[1]) !== null && _a !== void 0 ? _a : '',
|
|
932
|
-
options: [ShoppingCollections.undefinedOption, ...subs].map((item) => {
|
|
933
|
-
return { key: item, value: item };
|
|
934
|
-
}),
|
|
935
|
-
style: 'margin: 8px 0;',
|
|
936
|
-
readonly: vm.type === 'replace',
|
|
937
|
-
}),
|
|
938
|
-
].join('');
|
|
1036
|
+
if (pvm.productList.length === 0 || !pvm.dataList.length) {
|
|
1037
|
+
return '目前無選取任何商品';
|
|
939
1038
|
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
onclick="${gvc.event(() => {
|
|
959
|
-
vm.data.subCollections = vm.data.subCollections.filter((sub) => item !== sub);
|
|
960
|
-
gvc.notifyDataChange(id);
|
|
961
|
-
})}"
|
|
962
|
-
></i>
|
|
963
|
-
</div>`;
|
|
964
|
-
})
|
|
965
|
-
.join(''),
|
|
966
|
-
}),
|
|
967
|
-
].join('');
|
|
968
|
-
}
|
|
969
|
-
function levelSetting() {
|
|
970
|
-
var _a;
|
|
971
|
-
const parentTitles = Array.isArray(vm.data.parentTitles) ? vm.data.parentTitles : [];
|
|
972
|
-
const parentTab = (_a = vm.dataList) === null || _a === void 0 ? void 0 : _a.find(item => item.title === parentTitles[0]);
|
|
973
|
-
const parentSubs = parentTab && Array.isArray(parentTab.subCollections) ? parentTab.subCollections : [];
|
|
974
|
-
if (vm.type === 'add') {
|
|
975
|
-
return [
|
|
976
|
-
firstParentView(),
|
|
977
|
-
parentSubs.length > 0
|
|
978
|
-
? secondParentView(parentSubs.filter((item) => item !== vm.data.title))
|
|
979
|
-
: '',
|
|
980
|
-
].join('');
|
|
1039
|
+
return gvc.map(pvm.productList.map((opt, index) => {
|
|
1040
|
+
return html ` <div
|
|
1041
|
+
class="form-check-label c_updown_label"
|
|
1042
|
+
style="display: flex; align-items: center; min-height: 60px; gap: 8px;"
|
|
1043
|
+
>
|
|
1044
|
+
<span class="tx_normal" style="min-width: 30px;">${index + 1}.</span>
|
|
1045
|
+
${BgWidget.validImageBox({ gvc, image: opt.image, width: 40 })}
|
|
1046
|
+
<span class="tx_normal">${opt.value}</span>
|
|
1047
|
+
${opt.note ? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> ` : ''}
|
|
1048
|
+
</div>`;
|
|
1049
|
+
}));
|
|
1050
|
+
},
|
|
1051
|
+
onCreate: () => {
|
|
1052
|
+
if (pvm.loading) {
|
|
1053
|
+
if (pvm.dataList.length === 0) {
|
|
1054
|
+
pvm.productList = [];
|
|
1055
|
+
pvm.loading = false;
|
|
1056
|
+
gvc.notifyDataChange(pvm.id);
|
|
981
1057
|
}
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1058
|
+
else {
|
|
1059
|
+
ApiShop.getProduct({
|
|
1060
|
+
page: 0,
|
|
1061
|
+
limit: 99999,
|
|
1062
|
+
id_list: pvm.dataList.join(','),
|
|
1063
|
+
}).then(data => {
|
|
1064
|
+
pvm.productList = data.response.data.map((product) => {
|
|
1065
|
+
var _a;
|
|
1066
|
+
return {
|
|
1067
|
+
key: product.content.id,
|
|
1068
|
+
value: product.content.title,
|
|
1069
|
+
image: (_a = product.content.preview_image[0]) !== null && _a !== void 0 ? _a : BgWidget.noImageURL,
|
|
1070
|
+
};
|
|
1071
|
+
});
|
|
1072
|
+
pvm.loading = false;
|
|
1073
|
+
gvc.notifyDataChange(pvm.id);
|
|
1074
|
+
});
|
|
988
1075
|
}
|
|
989
|
-
return editSubCollection();
|
|
990
1076
|
}
|
|
991
|
-
return [BgWidget.summaryCard(levelSetting())].join(BgWidget.mbContainer(24));
|
|
992
1077
|
},
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
}),
|
|
997
|
-
BgWidget.mbContainer(240),
|
|
998
|
-
html ` <div class="update-bar-container">
|
|
999
|
-
${obj.type === 'replace'
|
|
1000
|
-
? BgWidget.redButton('刪除分類', gvc.event(() => {
|
|
1001
|
-
dialog.checkYesOrNot({
|
|
1002
|
-
text: '確定要刪除商品分類嗎?<br/>(若包含子分類,也將一併刪除)',
|
|
1003
|
-
callback: bool => {
|
|
1004
|
-
if (bool) {
|
|
1005
|
-
dialog.dataLoading({ visible: true });
|
|
1006
|
-
ApiShop.deleteCollections({
|
|
1007
|
-
data: { data: [vm.data] },
|
|
1008
|
-
token: window.parent.config.token,
|
|
1009
|
-
}).then(res => {
|
|
1010
|
-
dialog.dataLoading({ visible: false });
|
|
1011
|
-
if (res.result) {
|
|
1012
|
-
vm.type = 'list';
|
|
1013
|
-
dialog.successMessage({ text: '更新成功' });
|
|
1014
|
-
}
|
|
1015
|
-
else {
|
|
1016
|
-
dialog.errorMessage({ text: '更新失敗' });
|
|
1017
|
-
}
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1078
|
+
divCreate: {
|
|
1079
|
+
class: `w-100`,
|
|
1080
|
+
style: `overflow-x:hidden;`,
|
|
1020
1081
|
},
|
|
1021
|
-
})
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
if (somePath) {
|
|
1038
|
-
dialog.infoMessage({ text: '此「分類標籤」已存在' });
|
|
1039
|
-
return;
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
const forbiddenRegex = /[,/\\]/;
|
|
1043
|
-
if (forbiddenRegex.test(vm.data.title)) {
|
|
1044
|
-
dialog.infoMessage({ text: '標題不可包含空白格與以下符號:<br />「 , 」「 / 」「 \\ 」' });
|
|
1045
|
-
return;
|
|
1046
|
-
}
|
|
1047
|
-
const no_fill_language = window.parent.store_info.language_setting.support.find((dd) => !vm.data.language_data[dd].seo.domain);
|
|
1048
|
-
if (no_fill_language) {
|
|
1049
|
-
select_lan = no_fill_language;
|
|
1050
|
-
refresh();
|
|
1051
|
-
dialog.infoMessage({ text: '請重新填寫「連結網址」' });
|
|
1052
|
-
return;
|
|
1053
|
-
}
|
|
1054
|
-
if (window.parent.store_info.language_setting.support.find((dd) => {
|
|
1055
|
-
if (CheckInput.isChineseEnglishNumberHyphen(vm.data.language_data[dd].seo.domain)) {
|
|
1056
|
-
return false;
|
|
1057
|
-
}
|
|
1058
|
-
select_lan = dd;
|
|
1059
|
-
return true;
|
|
1060
|
-
})) {
|
|
1061
|
-
refresh();
|
|
1062
|
-
dialog.infoMessage({ text: '連結僅限使用中英文數字與連接號' });
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
const validLangDomain = getValidLangDomain();
|
|
1066
|
-
if (!validLangDomain.result) {
|
|
1067
|
-
refresh();
|
|
1068
|
-
dialog.infoMessage({ text: validLangDomain.text });
|
|
1069
|
-
return;
|
|
1070
|
-
}
|
|
1071
|
-
function putEvent() {
|
|
1072
|
-
dialog.dataLoading({ visible: true });
|
|
1073
|
-
ApiShop.putCollections({
|
|
1074
|
-
data: { replace: vm.data, original },
|
|
1075
|
-
token: window.parent.config.token,
|
|
1076
|
-
}).then(res => {
|
|
1077
|
-
dialog.dataLoading({ visible: false });
|
|
1078
|
-
if (res.result) {
|
|
1079
|
-
if (res.response.result) {
|
|
1080
|
-
vm.type = 'list';
|
|
1081
|
-
dialog.successMessage({ text: '更新成功' });
|
|
1082
|
-
}
|
|
1083
|
-
else {
|
|
1084
|
-
dialog.errorMessage({ text: res.response.message });
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
else {
|
|
1088
|
-
dialog.errorMessage({ text: '更新失敗' });
|
|
1089
|
-
}
|
|
1090
|
-
});
|
|
1091
|
-
}
|
|
1092
|
-
if (vm.cloneTarget && vm.cloneTarget.title === vm.data.title) {
|
|
1093
|
-
dialog.checkYesOrNot({
|
|
1094
|
-
text: ['若移動當前商品分類,<b>附帶的子分類將不會保留</b>,', '確定要執行嗎?'].join('<br/>'),
|
|
1095
|
-
callback: bool => {
|
|
1096
|
-
if (bool && vm.cloneTarget) {
|
|
1097
|
-
ApiShop.deleteCollections({
|
|
1098
|
-
data: { data: [vm.cloneTarget] },
|
|
1099
|
-
token: window.parent.config.token,
|
|
1100
|
-
}).then(() => {
|
|
1101
|
-
putEvent();
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1082
|
+
})}
|
|
1083
|
+
</div>
|
|
1084
|
+
`;
|
|
1085
|
+
})(),
|
|
1086
|
+
[
|
|
1087
|
+
html ` <div style="font-weight: 700;" class="mb-3">
|
|
1088
|
+
搜尋引擎列表 ${BgWidget.languageInsignia(select_lan, 'margin-left:5px;')}
|
|
1089
|
+
</div>
|
|
1090
|
+
<div class="tx_normal fw-normal" style="margin: 18px 0 8px;">SEO 標題</div>
|
|
1091
|
+
${EditorElem.editeInput({
|
|
1092
|
+
gvc: gvc,
|
|
1093
|
+
title: '',
|
|
1094
|
+
default: (_c = language_data.seo.title) !== null && _c !== void 0 ? _c : '',
|
|
1095
|
+
placeHolder: '請輸入 SEO 標題',
|
|
1096
|
+
callback: text => {
|
|
1097
|
+
language_data.seo.title = text;
|
|
1104
1098
|
},
|
|
1105
|
-
})
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1099
|
+
})}`,
|
|
1100
|
+
,
|
|
1101
|
+
html ` <div class="tx_normal fw-normal">SEO 描述</div>
|
|
1102
|
+
${EditorElem.editeText({
|
|
1103
|
+
gvc: gvc,
|
|
1104
|
+
title: '',
|
|
1105
|
+
default: (_d = language_data.seo.content) !== null && _d !== void 0 ? _d : '',
|
|
1106
|
+
placeHolder: '請輸入 SEO 描述',
|
|
1107
|
+
callback: text => {
|
|
1108
|
+
language_data.seo.content = text;
|
|
1109
|
+
},
|
|
1110
|
+
})}`,
|
|
1111
|
+
,
|
|
1112
|
+
html ` <div class="tx_normal fw-normal">SEO 圖片</div>
|
|
1113
|
+
${EditorElem.uploadImageContainer({
|
|
1114
|
+
gvc: gvc,
|
|
1115
|
+
title: '',
|
|
1116
|
+
def: (_e = vm.data.seo_image) !== null && _e !== void 0 ? _e : '',
|
|
1117
|
+
callback: text => {
|
|
1118
|
+
vm.data.seo_image = text;
|
|
1119
|
+
},
|
|
1120
|
+
})}`,
|
|
1121
|
+
,
|
|
1122
|
+
].join(BgWidget.mbContainer(10)),
|
|
1123
|
+
].join(`<div class="mx-n2 border-top my-3"></div>`),
|
|
1124
|
+
BgWidget.mbContainer(240),
|
|
1125
|
+
].join(BgWidget.mbContainer(24)), {
|
|
1126
|
+
style: `width: 100%;overflow-x:hidden;`,
|
|
1127
|
+
});
|
|
1128
|
+
},
|
|
1129
|
+
divCreate: {
|
|
1130
|
+
style: ``,
|
|
1131
|
+
class: `w-100`,
|
|
1112
1132
|
},
|
|
1113
1133
|
};
|
|
1114
1134
|
});
|