ts-glitter 14.6.46 → 14.7.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/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/cms-plugin/ai-generator/member-ai.js +183 -0
- package/lowcode/cms-plugin/ai-generator/member-ai.ts +187 -0
- package/lowcode/cms-plugin/ai-generator/product-ai.js +97 -106
- package/lowcode/cms-plugin/ai-generator/product-ai.ts +103 -112
- package/lowcode/cms-plugin/ai-message.js +686 -617
- package/lowcode/cms-plugin/ai-message.ts +755 -686
- package/lowcode/cms-plugin/product-config.js +66 -0
- package/lowcode/cms-plugin/product-config.ts +67 -0
- package/lowcode/cms-plugin/shopping-finance-setting.js +220 -257
- package/lowcode/cms-plugin/shopping-finance-setting.ts +1132 -1183
- package/lowcode/cms-plugin/shopping-order-manager.js +1 -1
- package/lowcode/cms-plugin/shopping-order-manager.ts +1 -1
- package/lowcode/cms-plugin/shopping-product-setting.js +7 -53
- package/lowcode/cms-plugin/shopping-product-setting.ts +9 -53
- package/lowcode/cms-plugin/user-list.js +33 -20
- package/lowcode/cms-plugin/user-list.ts +33 -19
- package/lowcode/glitter-base/global/language.js +77 -7
- package/lowcode/glitter-base/global/language.ts +88 -23
- package/lowcode/glitter-base/route/ai-chat.ts +2 -2
- package/lowcode/glitter-base/route/shopping.ts +3 -3
- package/lowcode/glitter-base/route/user.js +10 -0
- package/lowcode/glitter-base/route/user.ts +10 -0
- package/lowcode/jspage/function-page/setting_editor.ts +0 -2
- package/lowcode/public-components/checkout/index.js +2 -2
- package/lowcode/public-components/checkout/index.ts +4 -4
- package/lowcode/public-components/user-manager/um-order.js +849 -75
- package/lowcode/public-components/user-manager/um-order.ts +941 -105
- package/package.json +1 -1
- package/src/api-public/controllers/ai-chat.js +0 -1
- package/src/api-public/controllers/ai-chat.js.map +1 -1
- package/src/api-public/controllers/ai-chat.ts +0 -1
- package/src/api-public/controllers/ai-points.js.map +1 -1
- package/src/api-public/controllers/fcm.js.map +1 -1
- package/src/api-public/controllers/index.js +1 -0
- package/src/api-public/controllers/index.js.map +1 -1
- package/src/api-public/controllers/index.ts +1 -0
- package/src/api-public/controllers/rebate.js.map +1 -1
- package/src/api-public/controllers/sms-points.js.map +1 -1
- package/src/api-public/controllers/user.js +10 -0
- package/src/api-public/controllers/user.js.map +1 -1
- package/src/api-public/controllers/user.ts +10 -0
- package/src/api-public/controllers/wallet.js.map +1 -1
- package/src/api-public/services/EcInvoice.js.map +1 -1
- package/src/api-public/services/ai-pointes.js.map +1 -1
- package/src/api-public/services/auto-send-email.js.map +1 -1
- package/src/api-public/services/chat.js.map +1 -1
- package/src/api-public/services/custom-code.js.map +1 -1
- package/src/api-public/services/delivery.d.ts +21 -9
- package/src/api-public/services/delivery.js +15 -9
- package/src/api-public/services/delivery.js.map +1 -1
- package/src/api-public/services/delivery.ts +37 -13
- 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/invoice.js.map +1 -1
- package/src/api-public/services/monitor.d.ts +1 -0
- package/src/api-public/services/monitor.js.map +1 -1
- package/src/api-public/services/rebate.js.map +1 -1
- package/src/api-public/services/recommend.js +21 -11
- package/src/api-public/services/recommend.js.map +1 -1
- package/src/api-public/services/recommend.ts +25 -15
- package/src/api-public/services/share-permission.js.map +1 -1
- package/src/api-public/services/shopping.d.ts +1 -0
- package/src/api-public/services/shopping.js +96 -32
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +109 -41
- package/src/api-public/services/sms-pointes.js.map +1 -1
- package/src/api-public/services/user.d.ts +1 -0
- package/src/api-public/services/user.js +11 -0
- package/src/api-public/services/user.js.map +1 -1
- package/src/api-public/services/user.ts +16 -0
- package/src/api-public/services/wallet.js.map +1 -1
- package/src/index.js +84 -160
- package/src/index.js.map +1 -1
- package/src/index.ts +220 -289
- package/src/services/app.js.map +1 -1
- package/src/services/template.js +9 -3
- package/src/services/template.js.map +1 -1
- package/src/services/template.ts +40 -32
package/lowcode/Entry.js
CHANGED
|
@@ -80,7 +80,7 @@ export class Entry {
|
|
|
80
80
|
}
|
|
81
81
|
window.renderClock = (_a = window.renderClock) !== null && _a !== void 0 ? _a : clockF();
|
|
82
82
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
83
|
-
glitter.share.editerVersion = 'V_14.
|
|
83
|
+
glitter.share.editerVersion = 'V_14.7.3';
|
|
84
84
|
glitter.share.start = new Date();
|
|
85
85
|
const vm = {
|
|
86
86
|
appConfig: [],
|
package/lowcode/Entry.ts
CHANGED
|
@@ -82,7 +82,7 @@ export class Entry {
|
|
|
82
82
|
|
|
83
83
|
(window as any).renderClock = (window as any).renderClock ?? clockF();
|
|
84
84
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
85
|
-
glitter.share.editerVersion = 'V_14.
|
|
85
|
+
glitter.share.editerVersion = 'V_14.7.3';
|
|
86
86
|
glitter.share.start = new Date();
|
|
87
87
|
const vm: {
|
|
88
88
|
appConfig: any;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { BgWidget } from "../../backend-manager/bg-widget.js";
|
|
2
|
+
import { ShareDialog } from "../../glitterBundle/dialog/ShareDialog.js";
|
|
3
|
+
import { AiChat } from "../../glitter-base/route/ai-chat.js";
|
|
4
|
+
export class MemberAi {
|
|
5
|
+
static addMember(gvc, member_data, refresh) {
|
|
6
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
7
|
+
const html = String.raw;
|
|
8
|
+
const language = window.parent.store_info.language_setting.def;
|
|
9
|
+
let place_holder = '顧客姓名是王小明,電子信箱是sam12345@gmail.com,電話號碼是0912345678,生日是民國83年11月5日,地址是台北市大安區望安路10號,備註來自Facebook的消費用戶。';
|
|
10
|
+
let message = place_holder;
|
|
11
|
+
return html `
|
|
12
|
+
<div class="">
|
|
13
|
+
${[
|
|
14
|
+
html `
|
|
15
|
+
<lottie-player src="${gvc.glitter.root_path}lottie/ai.json" class="mx-auto my-n4"
|
|
16
|
+
speed="1"
|
|
17
|
+
style="max-width: 100%;width: 250px;height:250px;" loop
|
|
18
|
+
autoplay></lottie-player>`,
|
|
19
|
+
`<div class="w-100 d-flex align-items-center justify-content-center my-3">${BgWidget.grayNote('透過 AI 可以幫你快速新增會員資料', `font-weight: 500;`)}</div>`,
|
|
20
|
+
html `
|
|
21
|
+
<div class="w-100" ">
|
|
22
|
+
${BgWidget.textArea({
|
|
23
|
+
gvc: gvc,
|
|
24
|
+
title: '',
|
|
25
|
+
default: message,
|
|
26
|
+
placeHolder: place_holder,
|
|
27
|
+
callback: (text) => {
|
|
28
|
+
message = text;
|
|
29
|
+
},
|
|
30
|
+
style: `min-height:100px;`
|
|
31
|
+
})}
|
|
32
|
+
</div>`,
|
|
33
|
+
`<div class="w-100 d-flex align-items-center justify-content-end">
|
|
34
|
+
${BgWidget.save(gvc.event(() => {
|
|
35
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
36
|
+
dialog.dataLoading({ visible: true });
|
|
37
|
+
AiChat.editorHtml({
|
|
38
|
+
text: message,
|
|
39
|
+
format: MemberAi.schema,
|
|
40
|
+
assistant: `你是後台小幫手,幫我新增對應的會員資料`,
|
|
41
|
+
token: window.parent.saasConfig.config.token
|
|
42
|
+
}).then((res) => {
|
|
43
|
+
dialog.dataLoading({ visible: false });
|
|
44
|
+
const obj = res.response.data && res.response.data.obj;
|
|
45
|
+
if (obj) {
|
|
46
|
+
const usage = res.response.data.usage;
|
|
47
|
+
if (usage) {
|
|
48
|
+
(obj.name) && (member_data.name = obj.name);
|
|
49
|
+
(obj.email) && (member_data.email = obj.email);
|
|
50
|
+
(obj.phone) && (member_data.phone = obj.phone);
|
|
51
|
+
(obj.birth) && (member_data.birth = obj.birth);
|
|
52
|
+
(obj.address) && (member_data.address = obj.address);
|
|
53
|
+
(obj.managerNote) && (member_data.managerNote = obj.managerNote);
|
|
54
|
+
dialog.successMessage({ text: `生成成功,消耗了『${usage}』點 AI-Points` });
|
|
55
|
+
refresh();
|
|
56
|
+
gvc.closeDialog();
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
dialog.errorMessage({ text: 'AI Points 點數不足' });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
dialog.errorMessage({ text: '發生錯誤' });
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}), "確認生成", "w-100 mt-3 py-4 fs-6")}
|
|
67
|
+
</div>`
|
|
68
|
+
].join('<div class="my-2"></div>')}
|
|
69
|
+
</div>`;
|
|
70
|
+
}
|
|
71
|
+
static generateRichText(gvc, callback) {
|
|
72
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
73
|
+
BgWidget.settingDialog({
|
|
74
|
+
gvc: gvc,
|
|
75
|
+
title: 'AI 內容生成',
|
|
76
|
+
innerHTML: (gvc) => {
|
|
77
|
+
const html = String.raw;
|
|
78
|
+
let message = '';
|
|
79
|
+
return html `
|
|
80
|
+
<div class="">
|
|
81
|
+
${[
|
|
82
|
+
html `
|
|
83
|
+
<lottie-player src="${gvc.glitter.root_path}lottie/ai.json" class="mx-auto my-n4"
|
|
84
|
+
speed="1"
|
|
85
|
+
style="max-width: 100%;width: 250px;height:250px;" loop
|
|
86
|
+
autoplay></lottie-player>`,
|
|
87
|
+
`<div class="w-100 d-flex align-items-center justify-content-center my-3">${BgWidget.grayNote('透過 AI 可以快速幫您生成內文', `font-weight: 500;`)}</div>`,
|
|
88
|
+
html `
|
|
89
|
+
<div class="w-100" ">
|
|
90
|
+
${BgWidget.textArea({
|
|
91
|
+
gvc: gvc,
|
|
92
|
+
title: '',
|
|
93
|
+
default: message,
|
|
94
|
+
placeHolder: `幫我生成一個4*3的說明表格,內容是針對健康保健。`,
|
|
95
|
+
callback: (text) => {
|
|
96
|
+
message = text;
|
|
97
|
+
},
|
|
98
|
+
style: `min-height:100px;`
|
|
99
|
+
})}
|
|
100
|
+
</div>`,
|
|
101
|
+
html `
|
|
102
|
+
<div class="w-100 d-flex align-items-center justify-content-end">
|
|
103
|
+
${BgWidget.save(gvc.event(() => {
|
|
104
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
105
|
+
dialog.dataLoading({ visible: true });
|
|
106
|
+
AiChat.generateHtml({
|
|
107
|
+
token: window.parent.saasConfig.config.token,
|
|
108
|
+
app_name: window.parent.appName,
|
|
109
|
+
text: message
|
|
110
|
+
}).then((res) => {
|
|
111
|
+
if (res.result && res.response.data.usage === 0) {
|
|
112
|
+
dialog.dataLoading({ visible: false });
|
|
113
|
+
dialog.errorMessage({ text: `很抱歉你的AI代幣不足,請先前往加值` });
|
|
114
|
+
}
|
|
115
|
+
else if (res.result && (!res.response.data.obj.result)) {
|
|
116
|
+
dialog.dataLoading({ visible: false });
|
|
117
|
+
dialog.errorMessage({ text: `AI無法理解你的需求,請給出具體一點的描述` });
|
|
118
|
+
}
|
|
119
|
+
else if (!res.result) {
|
|
120
|
+
dialog.dataLoading({ visible: false });
|
|
121
|
+
dialog.errorMessage({ text: `發生錯誤` });
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
callback(res.response.data.obj.html);
|
|
125
|
+
dialog.dataLoading({ visible: false });
|
|
126
|
+
dialog.successMessage({ text: `AI生成完畢,使用了『${res.response.data.usage}』點 AI Points.` });
|
|
127
|
+
gvc.closeDialog();
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}), "確認生成", "w-100 mt-3 py-2")}
|
|
131
|
+
</div>`
|
|
132
|
+
].join('<div class="my-2"></div>')}
|
|
133
|
+
</div>`;
|
|
134
|
+
},
|
|
135
|
+
footer_html: (gvc) => {
|
|
136
|
+
return ``;
|
|
137
|
+
},
|
|
138
|
+
width: 500
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
MemberAi.schema = {
|
|
143
|
+
"name": "customer_data",
|
|
144
|
+
"strict": true,
|
|
145
|
+
"schema": {
|
|
146
|
+
"type": "object",
|
|
147
|
+
"properties": {
|
|
148
|
+
"name": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"description": "顧客的姓名"
|
|
151
|
+
},
|
|
152
|
+
"email": {
|
|
153
|
+
"type": "string",
|
|
154
|
+
"description": "顧客的電子信箱"
|
|
155
|
+
},
|
|
156
|
+
"phone": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"description": "顧客的電話"
|
|
159
|
+
},
|
|
160
|
+
"birth": {
|
|
161
|
+
"type": "string",
|
|
162
|
+
"description": "顧客的西元出生日期,範例19981223"
|
|
163
|
+
},
|
|
164
|
+
"address": {
|
|
165
|
+
"type": "string",
|
|
166
|
+
"description": "顧客的地址"
|
|
167
|
+
},
|
|
168
|
+
"managerNote": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"description": "顧客的備註"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
"required": [
|
|
174
|
+
"name",
|
|
175
|
+
"email",
|
|
176
|
+
"phone",
|
|
177
|
+
"birth",
|
|
178
|
+
"address",
|
|
179
|
+
"managerNote"
|
|
180
|
+
],
|
|
181
|
+
"additionalProperties": false
|
|
182
|
+
}
|
|
183
|
+
};
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
import {GVC} from "../../glitterBundle/GVController.js";
|
|
2
|
+
import {BgWidget} from "../../backend-manager/bg-widget.js";
|
|
3
|
+
import {ApiUser} from "../../glitter-base/route/user.js";
|
|
4
|
+
import {AiPointsApi} from "../../glitter-base/route/ai-points-api.js";
|
|
5
|
+
import {ShareDialog} from "../../glitterBundle/dialog/ShareDialog.js";
|
|
6
|
+
import {AiChat} from "../../glitter-base/route/ai-chat.js";
|
|
7
|
+
import {AddComponent} from "../../editor/add-component.js";
|
|
8
|
+
|
|
9
|
+
export class MemberAi {
|
|
10
|
+
public static schema = {
|
|
11
|
+
"name": "customer_data",
|
|
12
|
+
"strict": true,
|
|
13
|
+
"schema": {
|
|
14
|
+
"type": "object",
|
|
15
|
+
"properties": {
|
|
16
|
+
"name": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "顧客的姓名"
|
|
19
|
+
},
|
|
20
|
+
"email": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "顧客的電子信箱"
|
|
23
|
+
},
|
|
24
|
+
"phone": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"description": "顧客的電話"
|
|
27
|
+
},
|
|
28
|
+
"birth": {
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "顧客的西元出生日期,範例19981223"
|
|
31
|
+
},
|
|
32
|
+
"address": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "顧客的地址"
|
|
35
|
+
},
|
|
36
|
+
"managerNote": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"description": "顧客的備註"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": [
|
|
42
|
+
"name",
|
|
43
|
+
"email",
|
|
44
|
+
"phone",
|
|
45
|
+
"birth",
|
|
46
|
+
"address",
|
|
47
|
+
"managerNote"
|
|
48
|
+
],
|
|
49
|
+
"additionalProperties": false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public static addMember(gvc: GVC, member_data: any, refresh: () => void) {
|
|
54
|
+
const dialog = new ShareDialog(gvc.glitter)
|
|
55
|
+
const html = String.raw
|
|
56
|
+
//當前預設語言
|
|
57
|
+
const language = (window.parent as any).store_info.language_setting.def;
|
|
58
|
+
let place_holder = '顧客姓名是王小明,電子信箱是sam12345@gmail.com,電話號碼是0912345678,生日是民國83年11月5日,地址是台北市大安區望安路10號,備註來自Facebook的消費用戶。'
|
|
59
|
+
let message = place_holder
|
|
60
|
+
return html`
|
|
61
|
+
<div class="">
|
|
62
|
+
${[
|
|
63
|
+
html`
|
|
64
|
+
<lottie-player src="${gvc.glitter.root_path}lottie/ai.json" class="mx-auto my-n4"
|
|
65
|
+
speed="1"
|
|
66
|
+
style="max-width: 100%;width: 250px;height:250px;" loop
|
|
67
|
+
autoplay></lottie-player>`,
|
|
68
|
+
`<div class="w-100 d-flex align-items-center justify-content-center my-3">${BgWidget.grayNote('透過 AI 可以幫你快速新增會員資料', `font-weight: 500;`)}</div>`,
|
|
69
|
+
html`
|
|
70
|
+
<div class="w-100" ">
|
|
71
|
+
${BgWidget.textArea({
|
|
72
|
+
gvc: gvc,
|
|
73
|
+
title: '',
|
|
74
|
+
default: message,
|
|
75
|
+
placeHolder: place_holder,
|
|
76
|
+
callback: (text) => {
|
|
77
|
+
message = text;
|
|
78
|
+
},
|
|
79
|
+
style: `min-height:100px;`
|
|
80
|
+
})}
|
|
81
|
+
</div>`,
|
|
82
|
+
`<div class="w-100 d-flex align-items-center justify-content-end">
|
|
83
|
+
${BgWidget.save(gvc.event(() => {
|
|
84
|
+
const dialog = new ShareDialog(gvc.glitter)
|
|
85
|
+
dialog.dataLoading({visible: true})
|
|
86
|
+
AiChat.editorHtml({
|
|
87
|
+
text: message,
|
|
88
|
+
format: MemberAi.schema,
|
|
89
|
+
assistant: `你是後台小幫手,幫我新增對應的會員資料`,
|
|
90
|
+
token: (window.parent as any).saasConfig.config.token
|
|
91
|
+
}).then((res) => {
|
|
92
|
+
dialog.dataLoading({visible: false})
|
|
93
|
+
const obj = res.response.data && res.response.data.obj
|
|
94
|
+
if (obj) {
|
|
95
|
+
const usage = res.response.data.usage
|
|
96
|
+
if (usage) {
|
|
97
|
+
(obj.name) && (member_data.name = obj.name);
|
|
98
|
+
(obj.email) && (member_data.email = obj.email);
|
|
99
|
+
(obj.phone) && (member_data.phone = obj.phone);
|
|
100
|
+
(obj.birth) && (member_data.birth = obj.birth);
|
|
101
|
+
(obj.address) && (member_data.address = obj.address);
|
|
102
|
+
(obj.managerNote) && (member_data.managerNote = obj.managerNote);
|
|
103
|
+
dialog.successMessage({text: `生成成功,消耗了『${usage}』點 AI-Points`})
|
|
104
|
+
refresh()
|
|
105
|
+
gvc.closeDialog()
|
|
106
|
+
} else {
|
|
107
|
+
dialog.errorMessage({text: 'AI Points 點數不足'})
|
|
108
|
+
}
|
|
109
|
+
} else {
|
|
110
|
+
dialog.errorMessage({text: '發生錯誤'})
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
}), "確認生成", "w-100 mt-3 py-4 fs-6")}
|
|
114
|
+
</div>`
|
|
115
|
+
].join('<div class="my-2"></div>')}
|
|
116
|
+
</div>`
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public static generateRichText(gvc: GVC, callback: (text: string) => void) {
|
|
120
|
+
const dialog = new ShareDialog(gvc.glitter)
|
|
121
|
+
BgWidget.settingDialog({
|
|
122
|
+
gvc: gvc,
|
|
123
|
+
title: 'AI 內容生成',
|
|
124
|
+
innerHTML: (gvc: GVC) => {
|
|
125
|
+
const html = String.raw
|
|
126
|
+
let message = ''
|
|
127
|
+
return html`
|
|
128
|
+
<div class="">
|
|
129
|
+
${[
|
|
130
|
+
html`
|
|
131
|
+
<lottie-player src="${gvc.glitter.root_path}lottie/ai.json" class="mx-auto my-n4"
|
|
132
|
+
speed="1"
|
|
133
|
+
style="max-width: 100%;width: 250px;height:250px;" loop
|
|
134
|
+
autoplay></lottie-player>`,
|
|
135
|
+
`<div class="w-100 d-flex align-items-center justify-content-center my-3">${BgWidget.grayNote('透過 AI 可以快速幫您生成內文', `font-weight: 500;`)}</div>`,
|
|
136
|
+
html`
|
|
137
|
+
<div class="w-100" ">
|
|
138
|
+
${BgWidget.textArea({
|
|
139
|
+
gvc: gvc,
|
|
140
|
+
title: '',
|
|
141
|
+
default: message,
|
|
142
|
+
placeHolder: `幫我生成一個4*3的說明表格,內容是針對健康保健。`,
|
|
143
|
+
callback: (text) => {
|
|
144
|
+
message = text;
|
|
145
|
+
},
|
|
146
|
+
style: `min-height:100px;`
|
|
147
|
+
})}
|
|
148
|
+
</div>`,
|
|
149
|
+
html`
|
|
150
|
+
<div class="w-100 d-flex align-items-center justify-content-end">
|
|
151
|
+
${BgWidget.save(gvc.event(() => {
|
|
152
|
+
const dialog = new ShareDialog(gvc.glitter)
|
|
153
|
+
dialog.dataLoading({visible: true})
|
|
154
|
+
AiChat.generateHtml({
|
|
155
|
+
token: (window.parent as any).saasConfig.config.token,
|
|
156
|
+
app_name: (window.parent as any).appName,
|
|
157
|
+
text: message
|
|
158
|
+
}).then((res) => {
|
|
159
|
+
if (res.result && res.response.data.usage === 0) {
|
|
160
|
+
dialog.dataLoading({visible: false})
|
|
161
|
+
dialog.errorMessage({text: `很抱歉你的AI代幣不足,請先前往加值`})
|
|
162
|
+
} else if (res.result && (!res.response.data.obj.result)) {
|
|
163
|
+
dialog.dataLoading({visible: false})
|
|
164
|
+
dialog.errorMessage({text: `AI無法理解你的需求,請給出具體一點的描述`})
|
|
165
|
+
} else if (!res.result) {
|
|
166
|
+
dialog.dataLoading({visible: false})
|
|
167
|
+
dialog.errorMessage({text: `發生錯誤`})
|
|
168
|
+
} else {
|
|
169
|
+
callback(res.response.data.obj.html)
|
|
170
|
+
dialog.dataLoading({visible: false})
|
|
171
|
+
dialog.successMessage({text: `AI生成完畢,使用了『${res.response.data.usage}』點 AI Points.`})
|
|
172
|
+
gvc.closeDialog()
|
|
173
|
+
|
|
174
|
+
}
|
|
175
|
+
})
|
|
176
|
+
}), "確認生成", "w-100 mt-3 py-2")}
|
|
177
|
+
</div>`
|
|
178
|
+
].join('<div class="my-2"></div>')}
|
|
179
|
+
</div>`
|
|
180
|
+
},
|
|
181
|
+
footer_html: (gvc: GVC) => {
|
|
182
|
+
return ``
|
|
183
|
+
},
|
|
184
|
+
width: 500
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
@@ -4,118 +4,109 @@ import { AiChat } from "../../glitter-base/route/ai-chat.js";
|
|
|
4
4
|
export class ProductAi {
|
|
5
5
|
static setProduct(gvc, product_data, refresh) {
|
|
6
6
|
const dialog = new ShareDialog(gvc.glitter);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
})}
|
|
34
|
-
</div>`,
|
|
35
|
-
`<div class="w-100 d-flex align-items-center justify-content-end">
|
|
7
|
+
const html = String.raw;
|
|
8
|
+
const language = window.parent.store_info.language_setting.def;
|
|
9
|
+
let message = '商品標題為Adidas衣服,規格有顏色和尺寸,其中有紅藍黃三種顏色,尺寸有S,M,L三種尺寸,紅色S號的販售價格為2000,紅色M號的價格為1500,其餘販售價格為1000元。';
|
|
10
|
+
return html `
|
|
11
|
+
<div class="">
|
|
12
|
+
${[
|
|
13
|
+
html `
|
|
14
|
+
<lottie-player src="${gvc.glitter.root_path}lottie/ai.json" class="mx-auto my-n4"
|
|
15
|
+
speed="1"
|
|
16
|
+
style="max-width: 100%;width: 250px;height:250px;" loop
|
|
17
|
+
autoplay></lottie-player>`,
|
|
18
|
+
`<div class="w-100 d-flex align-items-center justify-content-center my-3">${BgWidget.grayNote('透過 AI 可以幫你快速新增商品', `font-weight: 500;`)}</div>`,
|
|
19
|
+
html `
|
|
20
|
+
<div class="w-100" ">
|
|
21
|
+
${BgWidget.textArea({
|
|
22
|
+
gvc: gvc,
|
|
23
|
+
title: '',
|
|
24
|
+
default: message,
|
|
25
|
+
placeHolder: html `商品標題為Adidas衣服,規格有顏色和尺寸,其中有紅藍黃三種顏色,尺寸有S,M,L三種尺寸,紅色S號的販售價格為2000,紅色M號的價格為1500,其餘販售價格為1000元。`,
|
|
26
|
+
callback: (text) => {
|
|
27
|
+
message = text;
|
|
28
|
+
},
|
|
29
|
+
style: `min-height:100px;`
|
|
30
|
+
})}
|
|
31
|
+
</div>`,
|
|
32
|
+
`<div class="w-100 d-flex align-items-center justify-content-end">
|
|
36
33
|
${BgWidget.save(gvc.event(() => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
35
|
+
dialog.dataLoading({ visible: true });
|
|
36
|
+
AiChat.editorHtml({
|
|
37
|
+
text: message,
|
|
38
|
+
format: ProductAi.schema,
|
|
39
|
+
assistant: `你是後台商品上架小幫手,幫我過濾出要調整的項目和內容,另外一點請你非常注意,variants中的規格標題不要包含規格單位,像是『顏色:灰色,尺寸:XS』這樣是錯誤的,請顯示成這樣這樣就好["灰色","XS"]`,
|
|
40
|
+
token: window.parent.saasConfig.config.token
|
|
41
|
+
}).then((res) => {
|
|
42
|
+
dialog.dataLoading({ visible: false });
|
|
43
|
+
const obj = res.response.data && res.response.data.obj;
|
|
44
|
+
if (obj) {
|
|
45
|
+
const usage = res.response.data.usage;
|
|
46
|
+
if (usage) {
|
|
47
|
+
const language_data = (product_data.language_data[language]);
|
|
48
|
+
(obj.name) && (language_data.title = obj.name);
|
|
49
|
+
(obj.content) && (language_data.content = obj.content);
|
|
50
|
+
if (obj.spec_define && obj.spec_define.length > 1) {
|
|
51
|
+
product_data.specs = obj.spec_define.map((dd) => {
|
|
52
|
+
return {
|
|
53
|
+
"title": dd.value,
|
|
54
|
+
"option": dd.spec_define.map((dd) => {
|
|
54
55
|
return {
|
|
55
|
-
"title": dd.value
|
|
56
|
-
"option": dd.spec_define.map((dd) => {
|
|
57
|
-
return {
|
|
58
|
-
"title": dd.value
|
|
59
|
-
};
|
|
60
|
-
})
|
|
56
|
+
"title": dd.value
|
|
61
57
|
};
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
product_data.variants = obj.spec.map((dd) => {
|
|
66
|
-
return {
|
|
67
|
-
"sku": "",
|
|
68
|
-
"cost": 0,
|
|
69
|
-
"spec": (obj.spec.length === 1) ? [] : dd.value.map((dd) => {
|
|
70
|
-
if (dd.value.includes(':')) {
|
|
71
|
-
return dd.value.split(':')[1];
|
|
72
|
-
}
|
|
73
|
-
return dd.value;
|
|
74
|
-
}),
|
|
75
|
-
"type": "variants",
|
|
76
|
-
"stock": 0,
|
|
77
|
-
"profit": 0,
|
|
78
|
-
"weight": "1",
|
|
79
|
-
"barcode": "",
|
|
80
|
-
"v_width": 0,
|
|
81
|
-
"editable": false,
|
|
82
|
-
"v_height": 0,
|
|
83
|
-
"v_length": 0,
|
|
84
|
-
"sale_price": dd.sale_price,
|
|
85
|
-
"compare_price": (dd.original_price === dd.sale_price) ? 0 : dd.original_price,
|
|
86
|
-
"preview_image": "",
|
|
87
|
-
"shipment_type": "weight",
|
|
88
|
-
"shipment_weight": 0,
|
|
89
|
-
"show_understocking": "false"
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
(obj.seo_title) && (product_data.seo.title = obj.seo_title);
|
|
94
|
-
(obj.seo_content) && (product_data.seo.content = obj.seo_content);
|
|
95
|
-
obj.ai_description && (product_data.ai_description = obj.ai_description);
|
|
96
|
-
console.log(`obj.ai_description==>`, obj.ai_description);
|
|
97
|
-
dialog.successMessage({ text: `生成成功,消耗了『${usage}』點 AI-Points` });
|
|
98
|
-
refresh();
|
|
99
|
-
gvc.closeDialog();
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
dialog.errorMessage({ text: 'AI Points 點數不足' });
|
|
103
|
-
}
|
|
58
|
+
})
|
|
59
|
+
};
|
|
60
|
+
});
|
|
104
61
|
}
|
|
105
|
-
|
|
106
|
-
|
|
62
|
+
if (obj.spec && obj.spec.length) {
|
|
63
|
+
product_data.variants = obj.spec.map((dd) => {
|
|
64
|
+
return {
|
|
65
|
+
"sku": "",
|
|
66
|
+
"cost": 0,
|
|
67
|
+
"spec": (obj.spec.length === 1) ? [] : dd.value.map((dd) => {
|
|
68
|
+
if (dd.value.includes(':')) {
|
|
69
|
+
return dd.value.split(':')[1];
|
|
70
|
+
}
|
|
71
|
+
return dd.value;
|
|
72
|
+
}),
|
|
73
|
+
"type": "variants",
|
|
74
|
+
"stock": 0,
|
|
75
|
+
"profit": 0,
|
|
76
|
+
"weight": "1",
|
|
77
|
+
"barcode": "",
|
|
78
|
+
"v_width": 0,
|
|
79
|
+
"editable": false,
|
|
80
|
+
"v_height": 0,
|
|
81
|
+
"v_length": 0,
|
|
82
|
+
"sale_price": dd.sale_price,
|
|
83
|
+
"compare_price": (dd.original_price === dd.sale_price) ? 0 : dd.original_price,
|
|
84
|
+
"preview_image": "",
|
|
85
|
+
"shipment_type": "weight",
|
|
86
|
+
"shipment_weight": 0,
|
|
87
|
+
"show_understocking": "false"
|
|
88
|
+
};
|
|
89
|
+
});
|
|
107
90
|
}
|
|
108
|
-
|
|
109
|
-
|
|
91
|
+
(obj.seo_title) && (language_data.seo.title = obj.seo_title);
|
|
92
|
+
(obj.seo_content) && (language_data.seo.content = obj.seo_content);
|
|
93
|
+
obj.ai_description && (product_data.ai_description = obj.ai_description);
|
|
94
|
+
dialog.successMessage({ text: `生成成功,消耗了『${usage}』點 AI-Points` });
|
|
95
|
+
refresh();
|
|
96
|
+
gvc.closeDialog();
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
dialog.errorMessage({ text: 'AI Points 點數不足' });
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
dialog.errorMessage({ text: '發生錯誤' });
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}), "確認生成", "w-100 mt-3 py-4 fs-6")}
|
|
110
107
|
</div>`
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
footer_html: (gvc) => {
|
|
115
|
-
return ``;
|
|
116
|
-
},
|
|
117
|
-
width: 500
|
|
118
|
-
});
|
|
108
|
+
].join('<div class="my-2"></div>')}
|
|
109
|
+
</div>`;
|
|
119
110
|
}
|
|
120
111
|
static generateRichText(gvc, callback) {
|
|
121
112
|
const dialog = new ShareDialog(gvc.glitter);
|