ts-glitter 21.3.0 → 21.3.1
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-customer-message.js +660 -566
- package/lowcode/backend-manager/bg-customer-message.ts +1738 -1580
- package/lowcode/cms-plugin/customer-message-user.ts +2 -0
- package/lowcode/cms-plugin/shopping-setting-advance.js +1 -1
- package/lowcode/cms-plugin/shopping-setting-advance.ts +1 -1
- package/package.json +1 -1
|
@@ -1,52 +1,58 @@
|
|
|
1
|
-
import {GVC} from '../glitterBundle/GVController.js';
|
|
2
|
-
import {Chat} from '../glitter-base/route/chat.js';
|
|
3
|
-
import {EditorElem} from '../glitterBundle/plugins/editor-elem.js';
|
|
4
|
-
import {ApiUser} from '../glitter-base/route/user.js';
|
|
5
|
-
import {FormWidget} from '../official_view_component/official/form.js';
|
|
6
|
-
import {ShareDialog} from '../glitterBundle/dialog/ShareDialog.js';
|
|
7
|
-
import {BgWidget} from './bg-widget.js';
|
|
8
|
-
import {CustomerMessageUser} from '../cms-plugin/customer-message-user.js';
|
|
1
|
+
import { GVC } from '../glitterBundle/GVController.js';
|
|
2
|
+
import { Chat } from '../glitter-base/route/chat.js';
|
|
3
|
+
import { EditorElem } from '../glitterBundle/plugins/editor-elem.js';
|
|
4
|
+
import { ApiUser } from '../glitter-base/route/user.js';
|
|
5
|
+
import { FormWidget } from '../official_view_component/official/form.js';
|
|
6
|
+
import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
|
|
7
|
+
import { BgWidget } from './bg-widget.js';
|
|
8
|
+
import { CustomerMessageUser } from '../cms-plugin/customer-message-user.js';
|
|
9
9
|
|
|
10
10
|
export class BgCustomerMessage {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
public static config = {
|
|
12
|
+
color: 'rgb(254, 85, 65);',
|
|
13
|
+
title: '',
|
|
14
|
+
content: '',
|
|
15
|
+
name: '',
|
|
16
|
+
head: '',
|
|
17
|
+
hideBar: false,
|
|
18
|
+
};
|
|
19
|
+
public static visible = false;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
public static vm: {
|
|
22
|
+
type: 'list' | 'detail';
|
|
23
|
+
chat_user: any;
|
|
24
|
+
select_bt: 'list' | 'robot' | 'preview' | 'setting';
|
|
25
|
+
} = {
|
|
26
|
+
type: 'list',
|
|
27
|
+
chat_user: '',
|
|
28
|
+
select_bt: 'list',
|
|
29
|
+
};
|
|
30
|
+
public static id = `dsmdklweew3`;
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
public static leftNav(gvc: GVC) {
|
|
33
|
+
const html = String.raw;
|
|
34
|
+
return html` <div
|
|
35
|
+
id="BgCustomerMessageHover"
|
|
36
|
+
class="d-none position-fixed vw-100 vh-100"
|
|
37
|
+
style="background: rgba(0,0,0,0.5);z-index: 99999;"
|
|
38
|
+
onclick="${gvc.event(() => {
|
|
39
|
+
BgCustomerMessage.toggle(false, gvc);
|
|
40
|
+
})}"
|
|
41
|
+
></div>
|
|
42
|
+
<div
|
|
43
|
+
id="BgCustomerMessage"
|
|
44
|
+
class="position-fixed left-0 top-0 h-100 bg-white shadow-lg "
|
|
45
|
+
style="width:480px;max-width:100vw; z-index: 99999; right: -125%;background: rgba(0,0,0,0.5);"
|
|
46
|
+
>
|
|
47
|
+
${BgCustomerMessage.view(gvc)}
|
|
48
|
+
</div>`;
|
|
49
|
+
}
|
|
44
50
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
public static view(gvc: GVC) {
|
|
52
|
+
return gvc.bindView(() => {
|
|
53
|
+
const html = String.raw;
|
|
54
|
+
const vm = BgCustomerMessage.vm;
|
|
55
|
+
gvc.addStyle(`
|
|
50
56
|
|
|
51
57
|
.btn-white-primary {
|
|
52
58
|
border: 2px solid #ffb400;;
|
|
@@ -85,44 +91,40 @@ export class BgCustomerMessage {
|
|
|
85
91
|
-webkit-text-fill-color: transparent;
|
|
86
92
|
}
|
|
87
93
|
`);
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
</div>`;
|
|
123
|
-
} else {
|
|
124
|
-
let view = [
|
|
125
|
-
` <div class="navbar d-flex align-items-center justify-content-between w-100 p-3 "
|
|
94
|
+
return {
|
|
95
|
+
bind: BgCustomerMessage.id,
|
|
96
|
+
view: () => {
|
|
97
|
+
if (!BgCustomerMessage.visible) {
|
|
98
|
+
return html` <div class="d-flex align-items-center justify-content-center w-100 flex-column pt-3">
|
|
99
|
+
<div class="spinner-border" role="status">
|
|
100
|
+
<span class="sr-only"></span>
|
|
101
|
+
</div>
|
|
102
|
+
<span class="mt-2">載入中...</span>
|
|
103
|
+
</div>`;
|
|
104
|
+
}
|
|
105
|
+
if (vm.type === 'detail') {
|
|
106
|
+
return html` <div style="padding-bottom: 70px;">
|
|
107
|
+
${CustomerMessageUser.detail({
|
|
108
|
+
gvc: gvc,
|
|
109
|
+
chat: vm.chat_user,
|
|
110
|
+
user_id: 'manager',
|
|
111
|
+
containerHeight: ($('body').height() as any) + 60 + 'px',
|
|
112
|
+
document: document,
|
|
113
|
+
goBack: () => {
|
|
114
|
+
vm.type = 'list';
|
|
115
|
+
vm.select_bt = 'list';
|
|
116
|
+
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
117
|
+
},
|
|
118
|
+
close: () => {
|
|
119
|
+
vm.type = 'list';
|
|
120
|
+
vm.select_bt = 'list';
|
|
121
|
+
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
122
|
+
},
|
|
123
|
+
})}
|
|
124
|
+
</div>`;
|
|
125
|
+
} else {
|
|
126
|
+
let view = [
|
|
127
|
+
` <div class="navbar d-flex align-items-center justify-content-between w-100 p-3 "
|
|
126
128
|
style="background: linear-gradient(135deg, #ffb400 0%, #ff6c02 100%);">
|
|
127
129
|
<div class="d-flex align-items-center pe-3 w-100"
|
|
128
130
|
style="gap:10px;display: flex;align-items: center;">
|
|
@@ -132,978 +134,1098 @@ export class BgCustomerMessage {
|
|
|
132
134
|
alt="Albert Flores">
|
|
133
135
|
<div class="d-flex px-1 text-white align-items-center" style="gap:8px;">
|
|
134
136
|
<h6 class="mb-0 text-white " style="">一站式客服整合系統</h6>
|
|
135
|
-
${BgWidget.iconButton(
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
137
|
+
${BgWidget.iconButton({
|
|
138
|
+
icon: 'question',
|
|
139
|
+
event: gvc.event(() => {
|
|
140
|
+
BgWidget.dialog({
|
|
141
|
+
gvc,
|
|
142
|
+
title: '提示',
|
|
143
|
+
innerHTML: () => {
|
|
144
|
+
return `<div class="w-100" style="white-space:normal;word-break: break-all;">${BgWidget.grayNote(
|
|
145
|
+
[
|
|
146
|
+
`*單一後台即可管理各渠道訊息`,
|
|
147
|
+
`*前往第三方整合設定,設定Line與Facebook官方訊息串接`,
|
|
148
|
+
`*為確保訊息同步,請統一透過SHOPNEX後台發送訊息`,
|
|
149
|
+
]
|
|
150
|
+
.map(dd => {
|
|
151
|
+
return `<div style="letter-spacing: 1.2px;white-space:normal;word-break: break-all;">${dd}</div>`;
|
|
152
|
+
})
|
|
153
|
+
.join('<div class="my-1"></div>')
|
|
154
|
+
)}</div>`;
|
|
155
|
+
},
|
|
156
|
+
width: 250,
|
|
157
|
+
});
|
|
158
|
+
}),
|
|
159
|
+
})}
|
|
152
160
|
</div>
|
|
153
161
|
<div class="flex-fill" style="flex: 1;"></div>
|
|
154
162
|
<i class="fa-regular fa-circle-xmark text-white fs-3 " aria-hidden="true"
|
|
155
163
|
onclick="${gvc.event(() => {
|
|
156
|
-
|
|
157
|
-
|
|
164
|
+
BgCustomerMessage.toggle(false, gvc);
|
|
165
|
+
})}"></i>
|
|
158
166
|
</div>
|
|
159
167
|
</div>`,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
168
|
+
html` <div class="d-flex align-items-center p-2 shadow border-bottom" style="gap:10px;">
|
|
169
|
+
${(() => {
|
|
170
|
+
const list = [
|
|
171
|
+
{
|
|
172
|
+
key: 'list',
|
|
173
|
+
label: '訊息列表',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
key: 'setting',
|
|
177
|
+
label: '客服設定',
|
|
178
|
+
},
|
|
179
|
+
// {
|
|
180
|
+
// key: 'preview',
|
|
181
|
+
// label: '預覽樣式',
|
|
182
|
+
// },
|
|
183
|
+
];
|
|
184
|
+
return list
|
|
185
|
+
.map(dd => {
|
|
186
|
+
if (BgCustomerMessage.vm.select_bt === dd.key) {
|
|
187
|
+
return html` <div
|
|
188
|
+
class="d-flex align-items-center justify-content-center fw-bold px-3 py-2 fw-500 select-label-ai-message"
|
|
189
|
+
>
|
|
190
|
+
${dd.label}
|
|
191
|
+
</div>`;
|
|
192
|
+
} else {
|
|
193
|
+
return html` <div
|
|
194
|
+
class="d-flex align-items-center justify-content-center fw-bold px-3 py-2 fw-500 select-btn-ai-message"
|
|
195
|
+
onclick="${gvc.event(() => {
|
|
196
|
+
BgCustomerMessage.vm.select_bt = dd.key as any;
|
|
197
|
+
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
198
|
+
})}"
|
|
199
|
+
>
|
|
200
|
+
${dd.label}
|
|
201
|
+
</div>`;
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
.join('');
|
|
205
|
+
})()}
|
|
206
|
+
</div>`,
|
|
207
|
+
];
|
|
208
|
+
if (BgCustomerMessage.vm.select_bt === 'list') {
|
|
209
|
+
view.push(
|
|
210
|
+
BgCustomerMessage.list(gvc, user => {
|
|
211
|
+
vm.type = 'detail';
|
|
212
|
+
vm.chat_user = user;
|
|
213
|
+
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
214
|
+
})
|
|
215
|
+
);
|
|
216
|
+
} else if (BgCustomerMessage.vm.select_bt === 'robot') {
|
|
217
|
+
view.push(
|
|
218
|
+
gvc.bindView(() => {
|
|
219
|
+
const id = gvc.glitter.getUUID();
|
|
220
|
+
const html = String.raw;
|
|
221
|
+
return {
|
|
222
|
+
bind: id,
|
|
223
|
+
view: () => {
|
|
224
|
+
return new Promise(async (resolve, reject) => {
|
|
225
|
+
let keyData =
|
|
226
|
+
(await ApiUser.getPublicConfig(`robot_auto_reply`, 'manager')).response.value || {};
|
|
227
|
+
if (Array.isArray(keyData)) {
|
|
228
|
+
keyData = {};
|
|
229
|
+
}
|
|
230
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
231
|
+
resolve(html`
|
|
232
|
+
<div
|
|
233
|
+
class="position-relative bgf6 d-flex align-items-center justify-content-between m-n2 p-2 border-bottom shadow"
|
|
234
|
+
>
|
|
235
|
+
<span class="fs-6 fw-bold " style="color:black;">自動問答</span>
|
|
236
|
+
<button
|
|
237
|
+
class="btn btn-primary-c "
|
|
238
|
+
style="height: 28px;width:40px;font-size:14px;"
|
|
239
|
+
onclick="${gvc.event(() => {
|
|
240
|
+
dialog.dataLoading({ visible: true });
|
|
232
241
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
},
|
|
281
|
-
input: {
|
|
282
|
-
class: '',
|
|
283
|
-
style: '',
|
|
284
|
-
},
|
|
285
|
-
container: {
|
|
286
|
-
class: '',
|
|
287
|
-
style: '',
|
|
288
|
-
},
|
|
289
|
-
},
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
title: '回應',
|
|
293
|
-
key: 'response',
|
|
294
|
-
readonly: 'write',
|
|
295
|
-
type: 'textArea',
|
|
296
|
-
require: 'true',
|
|
297
|
-
style_data: {
|
|
298
|
-
label: {
|
|
299
|
-
class: 'form-label fs-base ',
|
|
300
|
-
style: '',
|
|
301
|
-
},
|
|
302
|
-
input: {
|
|
303
|
-
class: '',
|
|
304
|
-
style: '',
|
|
305
|
-
},
|
|
306
|
-
container: {
|
|
307
|
-
class: '',
|
|
308
|
-
style: '',
|
|
309
|
-
},
|
|
310
|
-
},
|
|
311
|
-
},
|
|
312
|
-
],
|
|
313
|
-
},
|
|
314
|
-
],
|
|
315
|
-
refresh: () => {
|
|
316
|
-
},
|
|
317
|
-
formData: keyData,
|
|
318
|
-
})}
|
|
319
|
-
</div>
|
|
320
|
-
`);
|
|
321
|
-
});
|
|
242
|
+
ApiUser.setPublicConfig({
|
|
243
|
+
key: `robot_auto_reply`,
|
|
244
|
+
value: keyData,
|
|
245
|
+
user_id: 'manager',
|
|
246
|
+
}).then((data: any) => {
|
|
247
|
+
dialog.dataLoading({ visible: false });
|
|
248
|
+
dialog.successMessage({ text: '設定成功' });
|
|
249
|
+
});
|
|
250
|
+
})}"
|
|
251
|
+
>
|
|
252
|
+
儲存
|
|
253
|
+
</button>
|
|
254
|
+
</div>
|
|
255
|
+
<div style="margin-top: -30px;">
|
|
256
|
+
${FormWidget.editorView({
|
|
257
|
+
gvc: gvc,
|
|
258
|
+
array: [
|
|
259
|
+
{
|
|
260
|
+
title: '',
|
|
261
|
+
key: 'question',
|
|
262
|
+
readonly: 'write',
|
|
263
|
+
type: 'array',
|
|
264
|
+
require: 'true',
|
|
265
|
+
style_data: {
|
|
266
|
+
label: {
|
|
267
|
+
class: 'form-label fs-base ',
|
|
268
|
+
style: '',
|
|
269
|
+
},
|
|
270
|
+
input: { class: '', style: '' },
|
|
271
|
+
container: {
|
|
272
|
+
class: '',
|
|
273
|
+
style: '',
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
referTitile: 'ask',
|
|
277
|
+
plusBtn: '添加問答項目',
|
|
278
|
+
formList: [
|
|
279
|
+
{
|
|
280
|
+
title: '問題',
|
|
281
|
+
key: 'ask',
|
|
282
|
+
readonly: 'write',
|
|
283
|
+
type: 'text',
|
|
284
|
+
require: 'true',
|
|
285
|
+
style_data: {
|
|
286
|
+
label: {
|
|
287
|
+
class: 'form-label fs-base ',
|
|
288
|
+
style: '',
|
|
322
289
|
},
|
|
323
|
-
|
|
324
|
-
|
|
290
|
+
input: {
|
|
291
|
+
class: '',
|
|
292
|
+
style: '',
|
|
325
293
|
},
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
294
|
+
container: {
|
|
295
|
+
class: '',
|
|
296
|
+
style: '',
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
title: '回應',
|
|
302
|
+
key: 'response',
|
|
303
|
+
readonly: 'write',
|
|
304
|
+
type: 'textArea',
|
|
305
|
+
require: 'true',
|
|
306
|
+
style_data: {
|
|
307
|
+
label: {
|
|
308
|
+
class: 'form-label fs-base ',
|
|
309
|
+
style: '',
|
|
310
|
+
},
|
|
311
|
+
input: {
|
|
312
|
+
class: '',
|
|
313
|
+
style: '',
|
|
314
|
+
},
|
|
315
|
+
container: {
|
|
316
|
+
class: '',
|
|
317
|
+
style: '',
|
|
318
|
+
},
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
],
|
|
322
|
+
},
|
|
323
|
+
],
|
|
324
|
+
refresh: () => {},
|
|
325
|
+
formData: keyData,
|
|
326
|
+
})}
|
|
327
|
+
</div>
|
|
328
|
+
`);
|
|
329
|
+
});
|
|
330
|
+
},
|
|
331
|
+
divCreate: {
|
|
332
|
+
class: `p-2`,
|
|
333
|
+
style: ``,
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
})
|
|
337
|
+
);
|
|
338
|
+
} else if (BgCustomerMessage.vm.select_bt === 'preview') {
|
|
339
|
+
return `<div class="w-100 vh-100">${CustomerMessageUser.showCustomerMessage({
|
|
340
|
+
gvc: gvc,
|
|
341
|
+
userID: 'preview',
|
|
342
|
+
open: true,
|
|
343
|
+
type: 'preview',
|
|
344
|
+
})}</div>`;
|
|
345
|
+
} else if (BgCustomerMessage.vm.select_bt === 'setting') {
|
|
346
|
+
view.push(
|
|
347
|
+
gvc.bindView(() => {
|
|
348
|
+
const html = String.raw;
|
|
349
|
+
const vO: {
|
|
350
|
+
id: string;
|
|
351
|
+
loading: boolean;
|
|
352
|
+
data: any;
|
|
353
|
+
} = {
|
|
354
|
+
id: gvc.glitter.getUUID(),
|
|
355
|
+
loading: false,
|
|
356
|
+
data: {},
|
|
357
|
+
};
|
|
358
|
+
const keyData = ApiUser.getPublicConfig(`message_setting`, 'manager').then(res => {
|
|
359
|
+
vO.data = res.response.value;
|
|
360
|
+
gvc.notifyDataChange(vO.id);
|
|
361
|
+
});
|
|
362
|
+
return {
|
|
363
|
+
bind: vO.id,
|
|
364
|
+
view: () => {
|
|
365
|
+
if (vO.loading) {
|
|
366
|
+
return BgWidget.spinner();
|
|
367
|
+
}
|
|
368
|
+
const keyData = vO.data;
|
|
369
|
+
keyData.color = keyData.color ?? '#FE5541';
|
|
370
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
371
|
+
const vm = {
|
|
372
|
+
message_setting: keyData,
|
|
373
|
+
robot_setting: undefined,
|
|
374
|
+
};
|
|
384
375
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
return [
|
|
401
|
-
gvc.bindView(() => {
|
|
402
|
-
keyData.ask_manual_keyword=keyData.ask_manual_keyword||'真人客服'
|
|
403
|
-
keyData.ask_ai_keyword=keyData.ask_ai_keyword||'AI客服'
|
|
404
|
-
const cid = gvc.glitter.getUUID()
|
|
405
|
-
return {
|
|
406
|
-
bind: cid,
|
|
407
|
-
view: () => {
|
|
408
|
-
return html`
|
|
409
|
-
<div class="d-flex flex-column"
|
|
410
|
-
style="gap:5px;">
|
|
411
|
-
<div class="tx_normal fw-normal"
|
|
412
|
-
style="">AI客服機器人
|
|
413
|
-
</div>
|
|
414
|
-
<div class="d-flex">
|
|
415
|
-
${BgWidget.switchButton(gvc, keyData.ai_toggle, (bool) => {
|
|
416
|
-
keyData.ai_toggle = bool;
|
|
417
|
-
gvc.notifyDataChange(cid)
|
|
418
|
-
})}
|
|
419
|
-
${keyData.ai_toggle ? `啟用` : `關閉`}
|
|
420
|
-
</div>
|
|
421
|
-
${keyData.ai_toggle ? html`
|
|
422
|
-
<div class="mt-2 d-flex align-items-center"
|
|
423
|
-
style="gap:10px;">
|
|
424
|
-
${BgWidget.grayButton('AI 問答設定', gvc.event(async () => {
|
|
425
|
-
let keyData = (await ApiUser.getPublicConfig(`robot_ai_reply`, 'manager')).response.value || {};
|
|
426
|
-
BgWidget.settingDialog({
|
|
427
|
-
gvc: gvc,
|
|
428
|
-
title: 'AI問答設定',
|
|
429
|
-
innerHTML: (gvc) => {
|
|
430
|
-
return gvc.bindView(() => {
|
|
431
|
-
const id = gvc.glitter.getUUID();
|
|
432
|
-
const html = String.raw;
|
|
433
|
-
return {
|
|
434
|
-
bind: id,
|
|
435
|
-
view: () => {
|
|
436
|
-
if (Array.isArray(keyData)) {
|
|
437
|
-
keyData = {};
|
|
438
|
-
}
|
|
439
|
-
keyData.question = keyData.question ?? []
|
|
440
|
-
const parId = gvc.glitter.getUUID()
|
|
441
|
-
const id = gvc.glitter.getUUID()
|
|
376
|
+
async function save() {
|
|
377
|
+
dialog.dataLoading({ visible: true });
|
|
378
|
+
await ApiUser.setPublicConfig({
|
|
379
|
+
key: `message_setting`,
|
|
380
|
+
value: vm.message_setting,
|
|
381
|
+
user_id: 'manager',
|
|
382
|
+
});
|
|
383
|
+
await ApiUser.setPublicConfig({
|
|
384
|
+
key: `robot_auto_reply`,
|
|
385
|
+
value: vm.robot_setting,
|
|
386
|
+
user_id: 'manager',
|
|
387
|
+
});
|
|
388
|
+
dialog.dataLoading({ visible: false });
|
|
389
|
+
dialog.successMessage({ text: '設定成功' });
|
|
390
|
+
}
|
|
442
391
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
392
|
+
const view = [
|
|
393
|
+
html` <div
|
|
394
|
+
class="position-relative bgf6 d-flex align-items-center justify-content-between m-n2 p-2 border-bottom shadow"
|
|
395
|
+
>
|
|
396
|
+
<span class="fs-6 fw-bold " style="color:black;">功能設定</span>
|
|
397
|
+
${BgWidget.darkButton(
|
|
398
|
+
'儲存',
|
|
399
|
+
gvc.event(() => {
|
|
400
|
+
save();
|
|
401
|
+
})
|
|
402
|
+
)}
|
|
403
|
+
</div>
|
|
404
|
+
<div style="margin-top: 10px;" class="p-2">
|
|
405
|
+
${[
|
|
406
|
+
...(() => {
|
|
407
|
+
if (keyData.toggle) {
|
|
408
|
+
return [
|
|
409
|
+
gvc.bindView(() => {
|
|
410
|
+
keyData.ask_manual_keyword = keyData.ask_manual_keyword || '真人客服';
|
|
411
|
+
keyData.ask_ai_keyword = keyData.ask_ai_keyword || 'AI客服';
|
|
412
|
+
const cid = gvc.glitter.getUUID();
|
|
413
|
+
return {
|
|
414
|
+
bind: cid,
|
|
415
|
+
view: () => {
|
|
416
|
+
return html`
|
|
417
|
+
<div class="d-flex flex-column" style="gap:5px;">
|
|
418
|
+
<div class="tx_normal fw-normal" style="">AI客服機器人</div>
|
|
419
|
+
<div class="d-flex">
|
|
420
|
+
${BgWidget.switchButton(gvc, keyData.ai_toggle, bool => {
|
|
421
|
+
keyData.ai_toggle = bool;
|
|
422
|
+
gvc.notifyDataChange(cid);
|
|
423
|
+
})}
|
|
424
|
+
${keyData.ai_toggle ? `啟用` : `關閉`}
|
|
425
|
+
</div>
|
|
426
|
+
${keyData.ai_toggle
|
|
427
|
+
? html` <div class="mt-2 d-flex align-items-center" style="gap:10px;">
|
|
428
|
+
${BgWidget.grayButton(
|
|
429
|
+
'AI 問答設定',
|
|
430
|
+
gvc.event(async () => {
|
|
431
|
+
let keyData =
|
|
432
|
+
(await ApiUser.getPublicConfig(`robot_ai_reply`, 'manager'))
|
|
433
|
+
.response.value || {};
|
|
434
|
+
BgWidget.settingDialog({
|
|
435
|
+
gvc: gvc,
|
|
436
|
+
title: 'AI問答設定',
|
|
437
|
+
innerHTML: gvc => {
|
|
438
|
+
return gvc.bindView(() => {
|
|
439
|
+
const id = gvc.glitter.getUUID();
|
|
440
|
+
const html = String.raw;
|
|
441
|
+
return {
|
|
442
|
+
bind: id,
|
|
443
|
+
view: () => {
|
|
444
|
+
if (Array.isArray(keyData)) {
|
|
445
|
+
keyData = {};
|
|
446
|
+
}
|
|
447
|
+
keyData.question = keyData.question ?? [];
|
|
448
|
+
const parId = gvc.glitter.getUUID();
|
|
449
|
+
const id = gvc.glitter.getUUID();
|
|
446
450
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
`<span class="fw-500 fs-6">*建議設定多個問答項目,來提升機器人客服的妥善率。</span>`,
|
|
451
|
-
], {
|
|
452
|
-
class: 'p-2',
|
|
453
|
-
style: ``
|
|
454
|
-
})}
|
|
455
|
-
<div style=""
|
|
456
|
-
class="p-2">
|
|
451
|
+
function refresh() {
|
|
452
|
+
gvc.notifyDataChange(id);
|
|
453
|
+
}
|
|
457
454
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
455
|
+
return html`
|
|
456
|
+
${BgWidget.alertInfo(
|
|
457
|
+
'',
|
|
458
|
+
[
|
|
459
|
+
`<span class="fw-500 fs-6">*當AI判斷,客戶提出的問題與你設定的問題有關聯的話,將會直接回答你設定的回覆內容。</span>`,
|
|
460
|
+
`<span class="fw-500 fs-6">*建議設定多個問答項目,來提升機器人客服的妥善率。</span>`,
|
|
461
|
+
],
|
|
462
|
+
{
|
|
463
|
+
class: 'p-2',
|
|
464
|
+
style: ``,
|
|
465
|
+
}
|
|
466
|
+
)}
|
|
467
|
+
<div style="" class="p-2">
|
|
468
|
+
${gvc.bindView(() => {
|
|
469
|
+
return {
|
|
470
|
+
bind: id,
|
|
471
|
+
view: () => {
|
|
472
|
+
return (keyData.question || [])
|
|
473
|
+
.map((d2: any, index: number) => {
|
|
474
|
+
return html` <li
|
|
475
|
+
onclick="${gvc.event(() => {
|
|
476
|
+
const copy = JSON.parse(
|
|
477
|
+
JSON.stringify(d2)
|
|
478
|
+
);
|
|
479
|
+
BgWidget.settingDialog({
|
|
480
|
+
gvc: gvc,
|
|
481
|
+
title: '設定問答',
|
|
482
|
+
innerHTML: gvc => {
|
|
483
|
+
return [
|
|
484
|
+
BgWidget.editeInput({
|
|
485
|
+
gvc: gvc,
|
|
486
|
+
title: '問題',
|
|
487
|
+
placeHolder: `請輸入問題`,
|
|
488
|
+
default: copy.ask,
|
|
489
|
+
callback: text => {
|
|
490
|
+
copy.ask = text;
|
|
491
|
+
},
|
|
492
|
+
}),
|
|
493
|
+
BgWidget.textArea({
|
|
494
|
+
gvc: gvc,
|
|
495
|
+
title: '回答',
|
|
496
|
+
placeHolder: `請輸入回答`,
|
|
497
|
+
default: copy.response,
|
|
498
|
+
callback: text => {
|
|
499
|
+
copy.response = text;
|
|
500
|
+
},
|
|
501
|
+
}),
|
|
502
|
+
]
|
|
503
|
+
.map(dd => {
|
|
504
|
+
return `<div>${dd}</div>`;
|
|
505
|
+
})
|
|
506
|
+
.join('');
|
|
507
|
+
},
|
|
508
|
+
footer_html: gvc => {
|
|
509
|
+
return [
|
|
510
|
+
BgWidget.cancel(
|
|
511
|
+
gvc.event(() => {
|
|
512
|
+
gvc.closeDialog();
|
|
513
|
+
})
|
|
514
|
+
),
|
|
515
|
+
BgWidget.save(
|
|
516
|
+
gvc.event(() => {
|
|
517
|
+
refresh();
|
|
518
|
+
gvc.closeDialog();
|
|
519
|
+
})
|
|
520
|
+
),
|
|
521
|
+
].join(``);
|
|
522
|
+
},
|
|
523
|
+
});
|
|
524
|
+
})}"
|
|
525
|
+
>
|
|
526
|
+
<div
|
|
527
|
+
class="w-100 fw-500 d-flex align-items-center fs-6 hoverBtn h_item rounded px-2 hoverF2 mb-1 subComponentGuide"
|
|
528
|
+
style="gap:5px;color:#393939;"
|
|
529
|
+
>
|
|
530
|
+
<div class=" p-1 dragItem ">
|
|
531
|
+
<i
|
|
532
|
+
class="fa-solid fa-grip-dots-vertical d-flex align-items-center justify-content-center "
|
|
533
|
+
style="width:15px;height:15px;"
|
|
534
|
+
aria-hidden="true"
|
|
535
|
+
></i>
|
|
536
|
+
</div>
|
|
537
|
+
<span
|
|
538
|
+
style="max-width:calc(100% - 60px);text-overflow: ellipsis;white-space: nowrap;overflow: hidden;"
|
|
539
|
+
>${d2.ask}</span
|
|
540
|
+
>
|
|
541
|
+
<div class="flex-fill"></div>
|
|
542
|
+
<div
|
|
543
|
+
class="hoverBtn p-1 child"
|
|
544
|
+
onclick="${gvc.event(
|
|
545
|
+
(e, event) => {
|
|
546
|
+
event.stopPropagation();
|
|
547
|
+
event.preventDefault();
|
|
548
|
+
dialog.checkYesOrNot({
|
|
549
|
+
text: '是否確認移除問答?',
|
|
550
|
+
callback: response => {
|
|
551
|
+
if (response) {
|
|
552
|
+
keyData.question.splice(
|
|
553
|
+
index,
|
|
554
|
+
1
|
|
555
|
+
);
|
|
556
|
+
gvc.notifyDataChange(
|
|
557
|
+
id
|
|
558
|
+
);
|
|
559
|
+
}
|
|
560
|
+
},
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
)}"
|
|
564
|
+
>
|
|
565
|
+
<i
|
|
566
|
+
class="fa-regular fa-trash d-flex align-items-center justify-content-center "
|
|
567
|
+
aria-hidden="true"
|
|
568
|
+
></i>
|
|
569
|
+
</div>
|
|
570
|
+
</div>
|
|
571
|
+
</li>`;
|
|
572
|
+
})
|
|
573
|
+
.join('');
|
|
574
|
+
},
|
|
575
|
+
divCreate: {
|
|
576
|
+
class: `mx-n2`,
|
|
577
|
+
elem: 'ul',
|
|
578
|
+
option: [
|
|
579
|
+
{
|
|
580
|
+
key: 'id',
|
|
581
|
+
value: parId,
|
|
582
|
+
},
|
|
583
|
+
],
|
|
584
|
+
},
|
|
585
|
+
onCreate: () => {
|
|
586
|
+
gvc.glitter.addMtScript(
|
|
587
|
+
[
|
|
588
|
+
{
|
|
589
|
+
src: `https://raw.githack.com/SortableJS/Sortable/master/Sortable.js`,
|
|
590
|
+
},
|
|
591
|
+
],
|
|
592
|
+
() => {
|
|
593
|
+
const interval = setInterval(() => {
|
|
594
|
+
if ((window as any).Sortable) {
|
|
595
|
+
try {
|
|
596
|
+
gvc.addStyle(`
|
|
553
597
|
ul {
|
|
554
598
|
list-style: none;
|
|
555
599
|
padding: 0;
|
|
556
600
|
}
|
|
557
601
|
`);
|
|
558
602
|
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
603
|
+
function swapArr(
|
|
604
|
+
arr: any,
|
|
605
|
+
index1: number,
|
|
606
|
+
index2: number
|
|
607
|
+
) {
|
|
608
|
+
const data = arr[index1];
|
|
609
|
+
arr.splice(index1, 1);
|
|
610
|
+
arr.splice(index2, 0, data);
|
|
611
|
+
}
|
|
564
612
|
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
613
|
+
let startIndex = 0;
|
|
614
|
+
//@ts-ignore
|
|
615
|
+
Sortable.create(
|
|
616
|
+
gvc.glitter.document.getElementById(
|
|
617
|
+
parId
|
|
618
|
+
),
|
|
619
|
+
{
|
|
620
|
+
handle: '.dragItem',
|
|
621
|
+
group: gvc.glitter.getUUID(),
|
|
570
622
|
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
title: '問題',
|
|
613
|
-
placeHolder: `請輸入問題`,
|
|
614
|
-
default: copy.ask,
|
|
615
|
-
callback: (text) => {
|
|
616
|
-
copy.ask = text;
|
|
617
|
-
},
|
|
618
|
-
}), BgWidget.textArea({
|
|
619
|
-
gvc: gvc,
|
|
620
|
-
title: '回答',
|
|
621
|
-
placeHolder: `請輸入回答`,
|
|
622
|
-
default: copy.response,
|
|
623
|
-
callback: (text) => {
|
|
624
|
-
copy.response = text;
|
|
625
|
-
},
|
|
626
|
-
})].map((dd) => {
|
|
627
|
-
return `<div>${dd}</div>`
|
|
628
|
-
}).join('')
|
|
629
|
-
},
|
|
630
|
-
footer_html: (gvc) => {
|
|
631
|
-
return [
|
|
632
|
-
BgWidget.cancel(gvc.event(() => {
|
|
633
|
-
gvc.closeDialog()
|
|
634
|
-
})),
|
|
635
|
-
BgWidget.save(gvc.event(() => {
|
|
636
|
-
if (!copy.ask || !copy.response) {
|
|
637
|
-
dialog.errorMessage({text: '內容不得為空'})
|
|
638
|
-
return
|
|
639
|
-
}
|
|
640
|
-
keyData.question.push(copy)
|
|
641
|
-
refresh()
|
|
642
|
-
gvc.closeDialog()
|
|
643
|
-
}))
|
|
644
|
-
].join(``)
|
|
645
|
-
}
|
|
646
|
-
})
|
|
647
|
-
})}">
|
|
648
|
-
<div style="font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word">
|
|
649
|
-
新增一則問答
|
|
650
|
-
</div>
|
|
651
|
-
<i class="fa-solid fa-plus"
|
|
652
|
-
aria-hidden="true"></i>
|
|
653
|
-
</div>
|
|
654
|
-
</div>
|
|
655
|
-
`
|
|
656
|
-
},
|
|
657
|
-
divCreate: {
|
|
658
|
-
class: `m-n2`,
|
|
659
|
-
},
|
|
660
|
-
};
|
|
661
|
-
})
|
|
662
|
-
},
|
|
663
|
-
footer_html: (gvc) => {
|
|
664
|
-
return [BgWidget.cancel(gvc.event(() => {
|
|
665
|
-
gvc.closeDialog()
|
|
666
|
-
}), '取消'), BgWidget.save(gvc.event(async () => {
|
|
667
|
-
dialog.dataLoading({visible: true});
|
|
668
|
-
await ApiUser.setPublicConfig({
|
|
669
|
-
key: `robot_ai_reply`,
|
|
670
|
-
value: keyData,
|
|
671
|
-
user_id: 'manager',
|
|
672
|
-
});
|
|
673
|
-
dialog.dataLoading({visible: false});
|
|
674
|
-
dialog.successMessage({text: '設定成功'});
|
|
675
|
-
gvc.closeDialog()
|
|
676
|
-
}), '儲存')].join('')
|
|
677
|
-
}
|
|
678
|
-
})
|
|
679
|
-
}))}
|
|
680
|
-
</div>` : ``}
|
|
681
|
-
</div>
|
|
682
|
-
`
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}),
|
|
686
|
-
BgWidget.editeInput({
|
|
687
|
-
gvc: gvc,
|
|
688
|
-
title: '客服名稱',
|
|
689
|
-
type: 'name',
|
|
690
|
-
placeHolder: `請輸入客服名稱`,
|
|
691
|
-
default: keyData.name,
|
|
692
|
-
callback: (text) => {
|
|
693
|
-
keyData.name = text;
|
|
694
|
-
},
|
|
695
|
-
}),
|
|
696
|
-
EditorElem.uploadImage({
|
|
697
|
-
title: '大頭照',
|
|
623
|
+
animation: 100,
|
|
624
|
+
onChange: function (
|
|
625
|
+
evt: any
|
|
626
|
+
) {
|
|
627
|
+
swapArr(
|
|
628
|
+
keyData.question,
|
|
629
|
+
startIndex,
|
|
630
|
+
evt.newIndex
|
|
631
|
+
);
|
|
632
|
+
const newIndex =
|
|
633
|
+
evt.newIndex;
|
|
634
|
+
startIndex = newIndex;
|
|
635
|
+
},
|
|
636
|
+
onEnd: (evt: any) => {},
|
|
637
|
+
onStart: function (evt: any) {
|
|
638
|
+
startIndex = evt.oldIndex;
|
|
639
|
+
},
|
|
640
|
+
}
|
|
641
|
+
);
|
|
642
|
+
} catch (e) {}
|
|
643
|
+
clearInterval(interval);
|
|
644
|
+
}
|
|
645
|
+
}, 100);
|
|
646
|
+
},
|
|
647
|
+
() => {}
|
|
648
|
+
);
|
|
649
|
+
},
|
|
650
|
+
};
|
|
651
|
+
})}
|
|
652
|
+
<div
|
|
653
|
+
class="w-100"
|
|
654
|
+
style="justify-content: center; align-items: center; gap: 4px; display: flex;color: #3366BB;cursor: pointer;"
|
|
655
|
+
data-bs-toggle="dropdown"
|
|
656
|
+
aria-haspopup="true"
|
|
657
|
+
aria-expanded="false"
|
|
658
|
+
onclick="${gvc.event(() => {
|
|
659
|
+
const copy = {
|
|
660
|
+
ask: '',
|
|
661
|
+
response: '',
|
|
662
|
+
};
|
|
663
|
+
BgWidget.settingDialog({
|
|
698
664
|
gvc: gvc,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
665
|
+
title: '設定問答',
|
|
666
|
+
innerHTML: gvc => {
|
|
667
|
+
return [
|
|
668
|
+
BgWidget.editeInput({
|
|
669
|
+
gvc: gvc,
|
|
670
|
+
title: '問題',
|
|
671
|
+
placeHolder: `請輸入問題`,
|
|
672
|
+
default: copy.ask,
|
|
673
|
+
callback: text => {
|
|
674
|
+
copy.ask = text;
|
|
675
|
+
},
|
|
676
|
+
}),
|
|
677
|
+
BgWidget.textArea({
|
|
678
|
+
gvc: gvc,
|
|
679
|
+
title: '回答',
|
|
680
|
+
placeHolder: `請輸入回答`,
|
|
681
|
+
default: copy.response,
|
|
682
|
+
callback: text => {
|
|
683
|
+
copy.response = text;
|
|
684
|
+
},
|
|
685
|
+
}),
|
|
686
|
+
]
|
|
687
|
+
.map(dd => {
|
|
688
|
+
return `<div>${dd}</div>`;
|
|
689
|
+
})
|
|
690
|
+
.join('');
|
|
702
691
|
},
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
692
|
+
footer_html: gvc => {
|
|
693
|
+
return [
|
|
694
|
+
BgWidget.cancel(
|
|
695
|
+
gvc.event(() => {
|
|
696
|
+
gvc.closeDialog();
|
|
697
|
+
})
|
|
698
|
+
),
|
|
699
|
+
BgWidget.save(
|
|
700
|
+
gvc.event(() => {
|
|
701
|
+
if (!copy.ask || !copy.response) {
|
|
702
|
+
dialog.errorMessage({
|
|
703
|
+
text: '內容不得為空',
|
|
704
|
+
});
|
|
705
|
+
return;
|
|
706
|
+
}
|
|
707
|
+
keyData.question.push(copy);
|
|
708
|
+
refresh();
|
|
709
|
+
gvc.closeDialog();
|
|
710
|
+
})
|
|
711
|
+
),
|
|
712
|
+
].join(``);
|
|
711
713
|
},
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
placeHolder: `請輸入置頂內文`,
|
|
726
|
-
default: keyData.content,
|
|
727
|
-
callback: (text) => {
|
|
728
|
-
keyData.content = text;
|
|
729
|
-
},
|
|
730
|
-
})
|
|
731
|
-
]
|
|
732
|
-
} else {
|
|
733
|
-
return []
|
|
734
|
-
}
|
|
735
|
-
})()
|
|
736
|
-
].join(`<div class="my-2"></div>`)}
|
|
737
|
-
</div>`,
|
|
738
|
-
gvc.bindView(() => {
|
|
739
|
-
const id = gvc.glitter.getUUID();
|
|
740
|
-
const html = String.raw;
|
|
741
|
-
return {
|
|
742
|
-
bind: id,
|
|
743
|
-
view: () => {
|
|
744
|
-
if (!keyData.toggle) {
|
|
745
|
-
return ``
|
|
746
|
-
}
|
|
747
|
-
return new Promise(async (resolve, reject) => {
|
|
748
|
-
let keyData = (await ApiUser.getPublicConfig(`robot_auto_reply`, 'manager')).response.value || {};
|
|
749
|
-
if (Array.isArray(keyData)) {
|
|
750
|
-
keyData = {};
|
|
751
|
-
}
|
|
752
|
-
vm.robot_setting = keyData;
|
|
753
|
-
keyData.question = keyData.question ?? []
|
|
754
|
-
const parId = gvc.glitter.getUUID()
|
|
755
|
-
const id = gvc.glitter.getUUID()
|
|
756
|
-
|
|
757
|
-
function refresh() {
|
|
758
|
-
gvc.notifyDataChange(id)
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
resolve(html`
|
|
762
|
-
<div class="position-relative bgf6 d-flex align-items-center justify-content-between mx-n2 p-2 py-3 border-top border-bottom mt-2 shadow">
|
|
763
|
-
<span class="fs-6 fw-bold d-flex flex-column"
|
|
764
|
-
style="color:black;">常見問題
|
|
765
|
-
${BgWidget.grayNote('將顯示於客服聊天首頁,讓用戶直接點選')}</span>
|
|
714
|
+
});
|
|
715
|
+
})}"
|
|
716
|
+
>
|
|
717
|
+
<div
|
|
718
|
+
style="font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
|
|
719
|
+
>
|
|
720
|
+
新增一則問答
|
|
721
|
+
</div>
|
|
722
|
+
<i
|
|
723
|
+
class="fa-solid fa-plus"
|
|
724
|
+
aria-hidden="true"
|
|
725
|
+
></i>
|
|
726
|
+
</div>
|
|
766
727
|
</div>
|
|
767
|
-
|
|
728
|
+
`;
|
|
729
|
+
},
|
|
730
|
+
divCreate: {
|
|
731
|
+
class: `m-n2`,
|
|
732
|
+
},
|
|
733
|
+
};
|
|
734
|
+
});
|
|
735
|
+
},
|
|
736
|
+
footer_html: gvc => {
|
|
737
|
+
return [
|
|
738
|
+
BgWidget.cancel(
|
|
739
|
+
gvc.event(() => {
|
|
740
|
+
gvc.closeDialog();
|
|
741
|
+
}),
|
|
742
|
+
'取消'
|
|
743
|
+
),
|
|
744
|
+
BgWidget.save(
|
|
745
|
+
gvc.event(async () => {
|
|
746
|
+
dialog.dataLoading({ visible: true });
|
|
747
|
+
await ApiUser.setPublicConfig({
|
|
748
|
+
key: `robot_ai_reply`,
|
|
749
|
+
value: keyData,
|
|
750
|
+
user_id: 'manager',
|
|
751
|
+
});
|
|
752
|
+
dialog.dataLoading({ visible: false });
|
|
753
|
+
dialog.successMessage({ text: '設定成功' });
|
|
754
|
+
gvc.closeDialog();
|
|
755
|
+
}),
|
|
756
|
+
'儲存'
|
|
757
|
+
),
|
|
758
|
+
].join('');
|
|
759
|
+
},
|
|
760
|
+
});
|
|
761
|
+
})
|
|
762
|
+
)}
|
|
763
|
+
</div>`
|
|
764
|
+
: ``}
|
|
765
|
+
</div>
|
|
766
|
+
`;
|
|
767
|
+
},
|
|
768
|
+
};
|
|
769
|
+
}),
|
|
770
|
+
BgWidget.editeInput({
|
|
771
|
+
gvc: gvc,
|
|
772
|
+
title: '客服名稱',
|
|
773
|
+
type: 'name',
|
|
774
|
+
placeHolder: `請輸入客服名稱`,
|
|
775
|
+
default: keyData.name,
|
|
776
|
+
callback: text => {
|
|
777
|
+
keyData.name = text;
|
|
778
|
+
},
|
|
779
|
+
}),
|
|
780
|
+
EditorElem.uploadImage({
|
|
781
|
+
title: '大頭照',
|
|
782
|
+
gvc: gvc,
|
|
783
|
+
def: keyData.head || '',
|
|
784
|
+
callback: (text: string) => {
|
|
785
|
+
keyData.head = text;
|
|
786
|
+
},
|
|
787
|
+
}),
|
|
788
|
+
EditorElem.colorSelect({
|
|
789
|
+
gvc: gvc,
|
|
790
|
+
title: '設定主色調',
|
|
791
|
+
def: keyData.color,
|
|
792
|
+
callback: text => {
|
|
793
|
+
keyData.color = text;
|
|
794
|
+
gvc.notifyDataChange(vO.id);
|
|
795
|
+
},
|
|
796
|
+
}),
|
|
797
|
+
BgWidget.editeInput({
|
|
798
|
+
gvc: gvc,
|
|
799
|
+
title: '置頂標題',
|
|
800
|
+
placeHolder: `請輸入置頂標題`,
|
|
801
|
+
default: keyData.title,
|
|
802
|
+
callback: text => {
|
|
803
|
+
keyData.title = text;
|
|
804
|
+
},
|
|
805
|
+
}),
|
|
806
|
+
BgWidget.textArea({
|
|
807
|
+
gvc: gvc,
|
|
808
|
+
title: '置頂內文',
|
|
809
|
+
placeHolder: `請輸入置頂內文`,
|
|
810
|
+
default: keyData.content,
|
|
811
|
+
callback: text => {
|
|
812
|
+
keyData.content = text;
|
|
813
|
+
},
|
|
814
|
+
}),
|
|
815
|
+
];
|
|
816
|
+
} else {
|
|
817
|
+
return [];
|
|
818
|
+
}
|
|
819
|
+
})(),
|
|
820
|
+
].join(`<div class="my-2"></div>`)}
|
|
821
|
+
</div>`,
|
|
822
|
+
gvc.bindView(() => {
|
|
823
|
+
const id = gvc.glitter.getUUID();
|
|
824
|
+
const html = String.raw;
|
|
825
|
+
return {
|
|
826
|
+
bind: id,
|
|
827
|
+
view: () => {
|
|
828
|
+
if (!keyData.toggle) {
|
|
829
|
+
return ``;
|
|
830
|
+
}
|
|
831
|
+
return new Promise(async (resolve, reject) => {
|
|
832
|
+
let keyData =
|
|
833
|
+
(await ApiUser.getPublicConfig(`robot_auto_reply`, 'manager')).response.value || {};
|
|
834
|
+
if (Array.isArray(keyData)) {
|
|
835
|
+
keyData = {};
|
|
836
|
+
}
|
|
837
|
+
vm.robot_setting = keyData;
|
|
838
|
+
keyData.question = keyData.question ?? [];
|
|
839
|
+
const parId = gvc.glitter.getUUID();
|
|
840
|
+
const id = gvc.glitter.getUUID();
|
|
768
841
|
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
842
|
+
function refresh() {
|
|
843
|
+
gvc.notifyDataChange(id);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
resolve(html`
|
|
847
|
+
<div
|
|
848
|
+
class="position-relative bgf6 d-flex align-items-center justify-content-between mx-n2 p-2 py-3 border-top border-bottom mt-2 shadow"
|
|
849
|
+
>
|
|
850
|
+
<span class="fs-6 fw-bold d-flex flex-column" style="color:black;"
|
|
851
|
+
>常見問題 ${BgWidget.grayNote('將顯示於客服聊天首頁,讓用戶直接點選')}</span
|
|
852
|
+
>
|
|
853
|
+
</div>
|
|
854
|
+
<div style="" class="p-2">
|
|
855
|
+
${gvc.bindView(() => {
|
|
856
|
+
return {
|
|
857
|
+
bind: id,
|
|
858
|
+
view: () => {
|
|
859
|
+
return (keyData.question || [])
|
|
860
|
+
.map((d2: any, index: number) => {
|
|
861
|
+
return html` <li
|
|
862
|
+
onclick="${gvc.event(() => {
|
|
863
|
+
const copy = JSON.parse(JSON.stringify(d2));
|
|
864
|
+
BgWidget.settingDialog({
|
|
865
|
+
gvc: gvc,
|
|
866
|
+
title: '設定問答',
|
|
867
|
+
innerHTML: gvc => {
|
|
868
|
+
return [
|
|
869
|
+
BgWidget.editeInput({
|
|
870
|
+
gvc: gvc,
|
|
871
|
+
title: '問題',
|
|
872
|
+
placeHolder: `請輸入問題`,
|
|
873
|
+
default: copy.ask,
|
|
874
|
+
callback: text => {
|
|
875
|
+
copy.ask = text;
|
|
876
|
+
},
|
|
877
|
+
}),
|
|
878
|
+
BgWidget.textArea({
|
|
879
|
+
gvc: gvc,
|
|
880
|
+
title: '回答',
|
|
881
|
+
placeHolder: `請輸入回答`,
|
|
882
|
+
default: copy.response,
|
|
883
|
+
callback: text => {
|
|
884
|
+
copy.response = text;
|
|
885
|
+
},
|
|
886
|
+
}),
|
|
887
|
+
]
|
|
888
|
+
.map(dd => {
|
|
889
|
+
return `<div>${dd}</div>`;
|
|
890
|
+
})
|
|
891
|
+
.join('');
|
|
892
|
+
},
|
|
893
|
+
footer_html: gvc => {
|
|
894
|
+
return [
|
|
895
|
+
BgWidget.cancel(
|
|
896
|
+
gvc.event(() => {
|
|
897
|
+
gvc.closeDialog();
|
|
898
|
+
})
|
|
899
|
+
),
|
|
900
|
+
BgWidget.save(
|
|
901
|
+
gvc.event(() => {
|
|
902
|
+
keyData.question[index] = copy;
|
|
903
|
+
refresh();
|
|
904
|
+
gvc.closeDialog();
|
|
905
|
+
})
|
|
906
|
+
),
|
|
907
|
+
].join(``);
|
|
908
|
+
},
|
|
909
|
+
});
|
|
910
|
+
})}"
|
|
911
|
+
>
|
|
912
|
+
<div
|
|
913
|
+
class="w-100 fw-500 d-flex align-items-center fs-6 hoverBtn h_item rounded px-2 hoverF2 mb-1 subComponentGuide"
|
|
914
|
+
style="gap:5px;color:#393939;"
|
|
915
|
+
>
|
|
916
|
+
<div class=" p-1 dragItem ">
|
|
917
|
+
<i
|
|
918
|
+
class="fa-solid fa-grip-dots-vertical d-flex align-items-center justify-content-center "
|
|
919
|
+
style="width:15px;height:15px;"
|
|
920
|
+
aria-hidden="true"
|
|
921
|
+
></i>
|
|
922
|
+
</div>
|
|
923
|
+
<span>${d2.ask}</span>
|
|
924
|
+
<div class="flex-fill"></div>
|
|
925
|
+
<div
|
|
926
|
+
class="hoverBtn p-1 child"
|
|
927
|
+
onclick="${gvc.event((e, event) => {
|
|
928
|
+
event.stopPropagation();
|
|
929
|
+
event.preventDefault();
|
|
930
|
+
dialog.checkYesOrNot({
|
|
931
|
+
text: '是否確認移除問答?',
|
|
932
|
+
callback: response => {
|
|
933
|
+
if (response) {
|
|
934
|
+
keyData.question.splice(index, 1);
|
|
935
|
+
gvc.notifyDataChange(id);
|
|
936
|
+
}
|
|
937
|
+
},
|
|
938
|
+
});
|
|
939
|
+
})}"
|
|
940
|
+
>
|
|
941
|
+
<i
|
|
942
|
+
class="fa-regular fa-trash d-flex align-items-center justify-content-center "
|
|
943
|
+
aria-hidden="true"
|
|
944
|
+
></i>
|
|
945
|
+
</div>
|
|
946
|
+
</div>
|
|
947
|
+
</li>`;
|
|
948
|
+
})
|
|
949
|
+
.join('');
|
|
950
|
+
},
|
|
951
|
+
divCreate: {
|
|
952
|
+
class: `mx-n2`,
|
|
953
|
+
elem: 'ul',
|
|
954
|
+
option: [{ key: 'id', value: parId }],
|
|
955
|
+
},
|
|
956
|
+
onCreate: () => {
|
|
957
|
+
gvc.glitter.addMtScript(
|
|
958
|
+
[
|
|
959
|
+
{
|
|
960
|
+
src: `https://raw.githack.com/SortableJS/Sortable/master/Sortable.js`,
|
|
961
|
+
},
|
|
962
|
+
],
|
|
963
|
+
() => {
|
|
964
|
+
const interval = setInterval(() => {
|
|
965
|
+
if ((window as any).Sortable) {
|
|
966
|
+
try {
|
|
967
|
+
gvc.addStyle(`
|
|
862
968
|
ul {
|
|
863
969
|
list-style: none;
|
|
864
970
|
padding: 0;
|
|
865
971
|
}
|
|
866
972
|
`);
|
|
867
973
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
let startIndex = 0;
|
|
875
|
-
//@ts-ignore
|
|
876
|
-
Sortable.create(gvc.glitter.document.getElementById(parId), {
|
|
877
|
-
handle: '.dragItem',
|
|
878
|
-
group: gvc.glitter.getUUID(),
|
|
974
|
+
function swapArr(arr: any, index1: number, index2: number) {
|
|
975
|
+
const data = arr[index1];
|
|
976
|
+
arr.splice(index1, 1);
|
|
977
|
+
arr.splice(index2, 0, data);
|
|
978
|
+
}
|
|
879
979
|
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
},
|
|
886
|
-
onEnd: (evt: any) => {
|
|
980
|
+
let startIndex = 0;
|
|
981
|
+
//@ts-ignore
|
|
982
|
+
Sortable.create(gvc.glitter.document.getElementById(parId), {
|
|
983
|
+
handle: '.dragItem',
|
|
984
|
+
group: gvc.glitter.getUUID(),
|
|
887
985
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
style="justify-content: center; align-items: center; gap: 4px; display: flex;color: #3366BB;cursor: pointer;"
|
|
907
|
-
data-bs-toggle="dropdown"
|
|
908
|
-
aria-haspopup="true" aria-expanded="false"
|
|
909
|
-
onclick="${gvc.event(() => {
|
|
910
|
-
const copy = {ask: '', response: ''}
|
|
911
|
-
BgWidget.settingDialog({
|
|
912
|
-
gvc: gvc,
|
|
913
|
-
title: '設定問答',
|
|
914
|
-
innerHTML: (gvc) => {
|
|
915
|
-
return [BgWidget.editeInput({
|
|
916
|
-
gvc: gvc,
|
|
917
|
-
title: '問題',
|
|
918
|
-
placeHolder: `請輸入問題`,
|
|
919
|
-
default: copy.ask,
|
|
920
|
-
callback: (text) => {
|
|
921
|
-
copy.ask = text;
|
|
922
|
-
},
|
|
923
|
-
}), BgWidget.textArea({
|
|
924
|
-
gvc: gvc,
|
|
925
|
-
title: '回答',
|
|
926
|
-
placeHolder: `請輸入回答`,
|
|
927
|
-
default: copy.response,
|
|
928
|
-
callback: (text) => {
|
|
929
|
-
copy.response = text;
|
|
930
|
-
},
|
|
931
|
-
})].map((dd) => {
|
|
932
|
-
return `<div>${dd}</div>`
|
|
933
|
-
}).join('')
|
|
934
|
-
},
|
|
935
|
-
footer_html: (gvc) => {
|
|
936
|
-
return [
|
|
937
|
-
BgWidget.cancel(gvc.event(() => {
|
|
938
|
-
gvc.closeDialog()
|
|
939
|
-
})),
|
|
940
|
-
BgWidget.save(gvc.event(() => {
|
|
941
|
-
if (!copy.ask || !copy.response) {
|
|
942
|
-
dialog.errorMessage({text: '內容不得為空'})
|
|
943
|
-
return
|
|
944
|
-
}
|
|
945
|
-
keyData.question.push(copy)
|
|
946
|
-
refresh()
|
|
947
|
-
gvc.closeDialog()
|
|
948
|
-
}))
|
|
949
|
-
].join(``)
|
|
950
|
-
}
|
|
951
|
-
})
|
|
952
|
-
})}">
|
|
953
|
-
<div style="font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word">
|
|
954
|
-
新增一則回覆
|
|
955
|
-
</div>
|
|
956
|
-
<i class="fa-solid fa-plus"
|
|
957
|
-
aria-hidden="true"></i>
|
|
958
|
-
</div>
|
|
959
|
-
</div>
|
|
960
|
-
`);
|
|
961
|
-
});
|
|
962
|
-
},
|
|
963
|
-
divCreate: {
|
|
964
|
-
class: ``,
|
|
965
|
-
},
|
|
966
|
-
};
|
|
967
|
-
}),
|
|
968
|
-
];
|
|
969
|
-
return view.join('')
|
|
970
|
-
},
|
|
971
|
-
divCreate: {
|
|
972
|
-
class: `p-2`,
|
|
973
|
-
style: `height: calc(100vh - 132px);overflow-y:auto;${(parseInt(gvc.glitter.share.top_inset, 10)) ? `padding-bottom:${parseInt(gvc.glitter.share.top_inset, 10) + parseInt(gvc.glitter.share.bottom_inset, 10)}px !important;` : ``}`
|
|
986
|
+
animation: 100,
|
|
987
|
+
onChange: function (evt: any) {
|
|
988
|
+
swapArr(keyData.question, startIndex, evt.newIndex);
|
|
989
|
+
const newIndex = evt.newIndex;
|
|
990
|
+
startIndex = newIndex;
|
|
991
|
+
},
|
|
992
|
+
onEnd: (evt: any) => {},
|
|
993
|
+
onStart: function (evt: any) {
|
|
994
|
+
startIndex = evt.oldIndex;
|
|
995
|
+
},
|
|
996
|
+
});
|
|
997
|
+
} catch (e) {}
|
|
998
|
+
clearInterval(interval);
|
|
999
|
+
}
|
|
1000
|
+
}, 100);
|
|
1001
|
+
},
|
|
1002
|
+
() => {}
|
|
1003
|
+
);
|
|
974
1004
|
},
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1005
|
+
};
|
|
1006
|
+
})}
|
|
1007
|
+
<div
|
|
1008
|
+
class="w-100"
|
|
1009
|
+
style="justify-content: center; align-items: center; gap: 4px; display: flex;color: #3366BB;cursor: pointer;"
|
|
1010
|
+
data-bs-toggle="dropdown"
|
|
1011
|
+
aria-haspopup="true"
|
|
1012
|
+
aria-expanded="false"
|
|
1013
|
+
onclick="${gvc.event(() => {
|
|
1014
|
+
const copy = { ask: '', response: '' };
|
|
1015
|
+
BgWidget.settingDialog({
|
|
1016
|
+
gvc: gvc,
|
|
1017
|
+
title: '設定問答',
|
|
1018
|
+
innerHTML: gvc => {
|
|
1019
|
+
return [
|
|
1020
|
+
BgWidget.editeInput({
|
|
1021
|
+
gvc: gvc,
|
|
1022
|
+
title: '問題',
|
|
1023
|
+
placeHolder: `請輸入問題`,
|
|
1024
|
+
default: copy.ask,
|
|
1025
|
+
callback: text => {
|
|
1026
|
+
copy.ask = text;
|
|
1027
|
+
},
|
|
1028
|
+
}),
|
|
1029
|
+
BgWidget.textArea({
|
|
1030
|
+
gvc: gvc,
|
|
1031
|
+
title: '回答',
|
|
1032
|
+
placeHolder: `請輸入回答`,
|
|
1033
|
+
default: copy.response,
|
|
1034
|
+
callback: text => {
|
|
1035
|
+
copy.response = text;
|
|
1036
|
+
},
|
|
1037
|
+
}),
|
|
1038
|
+
]
|
|
1039
|
+
.map(dd => {
|
|
1040
|
+
return `<div>${dd}</div>`;
|
|
1041
|
+
})
|
|
1042
|
+
.join('');
|
|
1043
|
+
},
|
|
1044
|
+
footer_html: gvc => {
|
|
1045
|
+
return [
|
|
1046
|
+
BgWidget.cancel(
|
|
1047
|
+
gvc.event(() => {
|
|
1048
|
+
gvc.closeDialog();
|
|
1049
|
+
})
|
|
1050
|
+
),
|
|
1051
|
+
BgWidget.save(
|
|
1052
|
+
gvc.event(() => {
|
|
1053
|
+
if (!copy.ask || !copy.response) {
|
|
1054
|
+
dialog.errorMessage({ text: '內容不得為空' });
|
|
1055
|
+
return;
|
|
1056
|
+
}
|
|
1057
|
+
keyData.question.push(copy);
|
|
1058
|
+
refresh();
|
|
1059
|
+
gvc.closeDialog();
|
|
1060
|
+
})
|
|
1061
|
+
),
|
|
1062
|
+
].join(``);
|
|
1063
|
+
},
|
|
1064
|
+
});
|
|
1065
|
+
})}"
|
|
1066
|
+
>
|
|
1067
|
+
<div
|
|
1068
|
+
style="font-size: 16px; font-family: Noto Sans; font-weight: 400; word-wrap: break-word"
|
|
1069
|
+
>
|
|
1070
|
+
新增一則回覆
|
|
1071
|
+
</div>
|
|
1072
|
+
<i class="fa-solid fa-plus" aria-hidden="true"></i>
|
|
1073
|
+
</div>
|
|
1074
|
+
</div>
|
|
1075
|
+
`);
|
|
1076
|
+
});
|
|
1077
|
+
},
|
|
1078
|
+
divCreate: {
|
|
1079
|
+
class: ``,
|
|
1080
|
+
},
|
|
1081
|
+
};
|
|
1082
|
+
}),
|
|
1083
|
+
];
|
|
1084
|
+
return view.join('');
|
|
1085
|
+
},
|
|
1086
|
+
divCreate: {
|
|
1087
|
+
class: `p-2`,
|
|
1088
|
+
style: `height: calc(100vh - 132px);overflow-y:auto;${parseInt(gvc.glitter.share.top_inset, 10) ? `padding-bottom:${parseInt(gvc.glitter.share.top_inset, 10) + parseInt(gvc.glitter.share.bottom_inset, 10)}px !important;` : ``}`,
|
|
1089
|
+
},
|
|
1090
|
+
};
|
|
1091
|
+
})
|
|
1092
|
+
);
|
|
1015
1093
|
}
|
|
1094
|
+
return view.join('');
|
|
1095
|
+
}
|
|
1096
|
+
},
|
|
1097
|
+
divCreate: {
|
|
1098
|
+
style: `position:relative;`,
|
|
1099
|
+
class: `h-100`,
|
|
1100
|
+
},
|
|
1101
|
+
onCreate: () => {
|
|
1102
|
+
$('.tooltip').remove();
|
|
1103
|
+
($('[data-bs-toggle="tooltip"]') as any).tooltip();
|
|
1104
|
+
},
|
|
1105
|
+
};
|
|
1106
|
+
});
|
|
1107
|
+
}
|
|
1016
1108
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1109
|
+
public static list(gvc: GVC, callback: (chat_id: any) => void): string {
|
|
1110
|
+
return gvc.bindView(() => {
|
|
1111
|
+
const html = String.raw;
|
|
1112
|
+
const listId = gvc.glitter.getUUID();
|
|
1113
|
+
let chatData: any = undefined;
|
|
1114
|
+
let unRead: any = undefined;
|
|
1022
1115
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
socket && socket.close()
|
|
1039
|
-
loadData()
|
|
1040
|
-
}
|
|
1041
|
-
});
|
|
1042
|
-
socket.addEventListener('close', function (event: any) {
|
|
1043
|
-
console.log('Disconnected from server');
|
|
1044
|
-
if (!vm.close) {
|
|
1045
|
-
console.log('Reconnected from server');
|
|
1046
|
-
connect()
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1049
|
-
}
|
|
1116
|
+
function loadData() {
|
|
1117
|
+
Chat.getChatRoom({
|
|
1118
|
+
page: 0,
|
|
1119
|
+
limit: 1000,
|
|
1120
|
+
user_id: 'manager',
|
|
1121
|
+
}).then(async data => {
|
|
1122
|
+
chatData = data.response.data;
|
|
1123
|
+
//過濾掉空白的聊天室
|
|
1124
|
+
chatData = chatData.filter((data: any) => data.topMessage !== undefined);
|
|
1125
|
+
Chat.getUnRead({ user_id: 'manager' }).then(data => {
|
|
1126
|
+
unRead = data.response;
|
|
1127
|
+
gvc.notifyDataChange(listId);
|
|
1128
|
+
});
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1050
1131
|
|
|
1051
|
-
|
|
1132
|
+
let socket: any = undefined;
|
|
1133
|
+
const url = new URL((window as any).glitterBackend);
|
|
1134
|
+
let vm = {
|
|
1135
|
+
close: false,
|
|
1136
|
+
};
|
|
1052
1137
|
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1138
|
+
function connect() {
|
|
1139
|
+
const socket_id = gvc.glitter.getUUID();
|
|
1140
|
+
socket = location.href.includes('https://')
|
|
1141
|
+
? new WebSocket(`wss://${url.hostname}/websocket`)
|
|
1142
|
+
: new WebSocket(`ws://${url.hostname}:9003`);
|
|
1143
|
+
socket.addEventListener('open', function (event: any) {
|
|
1144
|
+
console.log(`Connected to update list server-${socket_id}`);
|
|
1145
|
+
socket.send(
|
|
1146
|
+
JSON.stringify({
|
|
1147
|
+
type: 'message-count-change',
|
|
1148
|
+
user_id: 'manager',
|
|
1149
|
+
app_name: (window as any).appName,
|
|
1150
|
+
})
|
|
1151
|
+
);
|
|
1152
|
+
});
|
|
1153
|
+
socket.addEventListener('message', async function (event: any) {
|
|
1154
|
+
console.log(`update_message_count-${socket_id}`);
|
|
1155
|
+
const data = JSON.parse(event.data);
|
|
1156
|
+
if (data.type === 'update_message_count') {
|
|
1157
|
+
vm.close = true;
|
|
1158
|
+
socket && socket.close();
|
|
1159
|
+
loadData();
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
socket.addEventListener('close', function (event: any) {
|
|
1163
|
+
console.log(`Disconnected from server-${socket_id}`);
|
|
1164
|
+
if (!vm.close) {
|
|
1165
|
+
console.log('Reconnected from server');
|
|
1166
|
+
connect();
|
|
1167
|
+
}
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1071
1170
|
|
|
1072
|
-
|
|
1073
|
-
dd.topMessage.text = dd.topMessage?.text ?? "圖片內容";
|
|
1074
|
-
dd.user_data = dd.user_data ?? {}
|
|
1075
|
-
if (dd.topMessage && dd.chat_id !== 'manager-preview') {
|
|
1076
|
-
console.log(`unRead==>`, unRead)
|
|
1077
|
-
const unReadCount = unRead.filter((d2: any) => {
|
|
1078
|
-
return dd.chat_id === d2.chat_id;
|
|
1079
|
-
}).length;
|
|
1080
|
-
if (dd.chat_id) {
|
|
1081
|
-
if (dd.chat_id.startsWith('line')) {
|
|
1082
|
-
dd.user_data.head = dd.info.line.head;
|
|
1083
|
-
dd.user_data.name = dd.info.line.name;
|
|
1084
|
-
}
|
|
1085
|
-
if (dd.chat_id.startsWith('fb')) {
|
|
1086
|
-
dd.info.fb = dd.info.fb ?? {
|
|
1087
|
-
head: `https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`,
|
|
1088
|
-
name: '訪客'
|
|
1089
|
-
}
|
|
1090
|
-
dd.user_data.head = dd.info.fb.head;
|
|
1091
|
-
dd.user_data.name = dd.info.fb.name;
|
|
1092
|
-
}
|
|
1093
|
-
let head = (dd.user_data && dd.user_data.head) || `https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`;
|
|
1094
|
-
let name = (dd.user_data && dd.user_data.name) || `訪客`
|
|
1095
|
-
let socket: any = undefined;
|
|
1096
|
-
const vm = {
|
|
1097
|
-
close: false
|
|
1098
|
-
}
|
|
1099
|
-
const id = gvc.glitter.getUUID()
|
|
1171
|
+
loadData();
|
|
1100
1172
|
|
|
1173
|
+
return {
|
|
1174
|
+
bind: listId,
|
|
1175
|
+
view: () => {
|
|
1176
|
+
if (chatData) {
|
|
1177
|
+
const view = [];
|
|
1178
|
+
try {
|
|
1179
|
+
view.push(html`
|
|
1180
|
+
<div class="p-2">
|
|
1181
|
+
<div class="position-relative">
|
|
1182
|
+
<input type="text" class="form-control pe-5" placeholder="搜尋用戶" />
|
|
1183
|
+
<i class="bx bx-search fs-xl text-nav position-absolute top-50 end-0 translate-middle-y me-3"></i>
|
|
1184
|
+
</div>
|
|
1185
|
+
</div>
|
|
1186
|
+
<div style="max-height: calc(100vh - 180px);overflow-y: auto;">
|
|
1187
|
+
${chatData
|
|
1188
|
+
.filter((dd: any) => {
|
|
1189
|
+
return !['manager-operation_guide', 'manager-order_analysis', 'manager-writer'].includes(
|
|
1190
|
+
dd.chat_id
|
|
1191
|
+
);
|
|
1192
|
+
})
|
|
1193
|
+
.map((dd: any) => {
|
|
1194
|
+
dd.topMessage = dd.topMessage ?? {};
|
|
1195
|
+
dd.topMessage.text = dd.topMessage?.text ?? '圖片內容';
|
|
1196
|
+
dd.user_data = dd.user_data ?? {};
|
|
1197
|
+
if (dd.topMessage && dd.chat_id !== 'manager-preview') {
|
|
1198
|
+
const unReadCount = unRead.filter((d2: any) => {
|
|
1199
|
+
return dd.chat_id === d2.chat_id;
|
|
1200
|
+
}).length;
|
|
1201
|
+
if (dd.chat_id) {
|
|
1202
|
+
if (dd.chat_id.startsWith('line')) {
|
|
1203
|
+
dd.user_data.head = dd.info.line.head;
|
|
1204
|
+
dd.user_data.name = dd.info.line.name;
|
|
1205
|
+
}
|
|
1206
|
+
if (dd.chat_id.startsWith('fb')) {
|
|
1207
|
+
dd.info.fb = dd.info.fb ?? {
|
|
1208
|
+
head: `https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`,
|
|
1209
|
+
name: '訪客',
|
|
1210
|
+
};
|
|
1211
|
+
dd.user_data.head = dd.info.fb.head;
|
|
1212
|
+
dd.user_data.name = dd.info.fb.name;
|
|
1213
|
+
}
|
|
1214
|
+
let head =
|
|
1215
|
+
(dd.user_data && dd.user_data.head) ||
|
|
1216
|
+
`https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`;
|
|
1217
|
+
let name = (dd.user_data && dd.user_data.name) || `訪客`;
|
|
1218
|
+
let socket: any = undefined;
|
|
1219
|
+
const vm = {
|
|
1220
|
+
close: false,
|
|
1221
|
+
};
|
|
1222
|
+
const id = gvc.glitter.getUUID();
|
|
1101
1223
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1224
|
+
return gvc.bindView(() => {
|
|
1225
|
+
return {
|
|
1226
|
+
bind: id,
|
|
1227
|
+
view: () => {
|
|
1228
|
+
return `<div class="rounded-circle position-relative "
|
|
1107
1229
|
style="width: 40px;height: 40px;">
|
|
1108
1230
|
<div
|
|
1109
1231
|
class="rounded-circle text-white bg-danger ${unReadCount ? `` : `d-none`} fw-500 d-flex align-items-center justify-content-center me-2"
|
|
@@ -1113,28 +1235,27 @@ export class BgCustomerMessage {
|
|
|
1113
1235
|
</div>
|
|
1114
1236
|
<img
|
|
1115
1237
|
src="${head}"
|
|
1116
|
-
class="rounded-circle ${
|
|
1238
|
+
class="rounded-circle ${dd.chat_id.startsWith('line') || dd.chat_id.startsWith('fb') ? `` : `border`}"
|
|
1117
1239
|
style="border-radius: 50%;${(() => {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1240
|
+
if (dd.chat_id.startsWith('line')) {
|
|
1241
|
+
return `border:2px solid green;`;
|
|
1242
|
+
} else if (dd.chat_id.startsWith('fb')) {
|
|
1243
|
+
return `border:2px solid #0078ff;`;
|
|
1244
|
+
}
|
|
1123
1245
|
})()}"
|
|
1124
1246
|
width="40"
|
|
1125
1247
|
alt="Devon Lane"
|
|
1126
1248
|
/>
|
|
1127
1249
|
${(() => {
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
})()}
|
|
1250
|
+
let id: string = dd.chat_id;
|
|
1251
|
+
if (id.startsWith('line')) {
|
|
1252
|
+
return `<i class="fa-brands fa-line bg-white rounded" style="position:absolute;right:0;bottom:0;color:green;"></i>`;
|
|
1253
|
+
}
|
|
1254
|
+
if (id.startsWith('fb')) {
|
|
1255
|
+
return `<i class="fa-brands fa-facebook-messenger bg-white rounded" style="position:absolute;right:0;bottom:0;color:#0078ff;"></i>`;
|
|
1256
|
+
}
|
|
1257
|
+
return ``;
|
|
1258
|
+
})()}
|
|
1138
1259
|
</div>
|
|
1139
1260
|
|
|
1140
1261
|
<div class="w-100 ps-2 ms-1">
|
|
@@ -1145,166 +1266,172 @@ export class BgCustomerMessage {
|
|
|
1145
1266
|
</div>
|
|
1146
1267
|
<p class="fs-sm mb-0 "
|
|
1147
1268
|
style="white-space: normal;${unReadCount ? `color:black;` : `color:#585c7b !important;`}">
|
|
1148
|
-
${
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
class: `d-flex align-items-center border-bottom text-decoration-none bg-faded-primary-hover py-3 px-4`,
|
|
1158
|
-
style: `cursor: pointer;`,
|
|
1159
|
-
option: [
|
|
1160
|
-
{
|
|
1161
|
-
key: 'onclick',
|
|
1162
|
-
value: gvc.event(() => {
|
|
1163
|
-
callback(dd);
|
|
1164
|
-
})
|
|
1165
|
-
}
|
|
1166
|
-
]
|
|
1269
|
+
${
|
|
1270
|
+
(dd.topMessage ? dd.topMessage.text : ``).length > 50
|
|
1271
|
+
? (dd.topMessage
|
|
1272
|
+
? dd.topMessage.text
|
|
1273
|
+
: ``
|
|
1274
|
+
).substring(0, 50) + '.....'
|
|
1275
|
+
: dd.topMessage
|
|
1276
|
+
? dd.topMessage.text
|
|
1277
|
+
: ``
|
|
1167
1278
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
background="transparent"
|
|
1186
|
-
></lottie-player>
|
|
1187
|
-
<h3 class="text-dark fs-6 mt-n3 px-2"
|
|
1188
|
-
style="line-height: 200%;text-align: center;">尚未收到任何訊息</h3>
|
|
1189
|
-
</div>`}
|
|
1190
|
-
</div>
|
|
1191
|
-
`);
|
|
1192
|
-
return view.join('');
|
|
1193
|
-
} catch (e) {
|
|
1194
|
-
console.log(e)
|
|
1195
|
-
return `${e}`
|
|
1279
|
+
</p>
|
|
1280
|
+
</div>`;
|
|
1281
|
+
},
|
|
1282
|
+
divCreate: {
|
|
1283
|
+
class: `d-flex align-items-center border-bottom text-decoration-none bg-faded-primary-hover py-3 px-4`,
|
|
1284
|
+
style: `cursor: pointer;`,
|
|
1285
|
+
option: [
|
|
1286
|
+
{
|
|
1287
|
+
key: 'onclick',
|
|
1288
|
+
value: gvc.event(() => {
|
|
1289
|
+
callback(dd);
|
|
1290
|
+
}),
|
|
1291
|
+
},
|
|
1292
|
+
],
|
|
1293
|
+
},
|
|
1294
|
+
};
|
|
1295
|
+
});
|
|
1196
1296
|
}
|
|
1297
|
+
} else {
|
|
1298
|
+
return ``;
|
|
1299
|
+
}
|
|
1300
|
+
})
|
|
1301
|
+
.join('') ||
|
|
1302
|
+
html` <div
|
|
1303
|
+
class="d-flex align-items-center justify-content-center flex-column w-100"
|
|
1304
|
+
style="width:700px;"
|
|
1305
|
+
>
|
|
1306
|
+
<lottie-player
|
|
1307
|
+
style="max-width: 100%;width: 300px;"
|
|
1308
|
+
src="https://assets10.lottiefiles.com/packages/lf20_rc6CDU.json"
|
|
1309
|
+
speed="1"
|
|
1310
|
+
loop="true"
|
|
1311
|
+
background="transparent"
|
|
1312
|
+
></lottie-player>
|
|
1313
|
+
<h3 class="text-dark fs-6 mt-n3 px-2" style="line-height: 200%;text-align: center;">
|
|
1314
|
+
尚未收到任何訊息
|
|
1315
|
+
</h3>
|
|
1316
|
+
</div>`}
|
|
1317
|
+
</div>
|
|
1318
|
+
`);
|
|
1319
|
+
return view.join('');
|
|
1320
|
+
} catch (e) {
|
|
1321
|
+
console.log(e);
|
|
1322
|
+
return `${e}`;
|
|
1323
|
+
}
|
|
1324
|
+
} else {
|
|
1325
|
+
return html` <div class="d-flex align-items-center justify-content-center w-100 flex-column pt-3">
|
|
1326
|
+
<div class="spinner-border" role="status">
|
|
1327
|
+
<span class="sr-only"></span>
|
|
1328
|
+
</div>
|
|
1329
|
+
<span class="mt-2">載入中...</span>
|
|
1330
|
+
</div>`;
|
|
1331
|
+
}
|
|
1332
|
+
},
|
|
1333
|
+
divCreate: {},
|
|
1334
|
+
onCreate: () => {
|
|
1335
|
+
setTimeout(() => {
|
|
1336
|
+
vm.close = true;
|
|
1337
|
+
socket && socket.close();
|
|
1338
|
+
vm.close = false;
|
|
1339
|
+
connect();
|
|
1340
|
+
}, 50);
|
|
1341
|
+
},
|
|
1342
|
+
onDestroy: () => {
|
|
1343
|
+
vm.close = true;
|
|
1344
|
+
socket && socket.close();
|
|
1345
|
+
},
|
|
1346
|
+
};
|
|
1347
|
+
});
|
|
1348
|
+
}
|
|
1197
1349
|
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
onCreate: () => {
|
|
1210
|
-
setTimeout(() => {
|
|
1211
|
-
vm.close = false
|
|
1212
|
-
connect()
|
|
1213
|
-
}, 50)
|
|
1214
|
-
|
|
1215
|
-
},
|
|
1216
|
-
onDestroy: () => {
|
|
1217
|
-
vm.close = true
|
|
1218
|
-
socket && socket.close()
|
|
1219
|
-
}
|
|
1220
|
-
};
|
|
1221
|
-
});
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
public static toggle(visible: boolean, gvc: GVC) {
|
|
1225
|
-
BgCustomerMessage.visible = visible;
|
|
1226
|
-
BgCustomerMessage.vm.type = 'list';
|
|
1227
|
-
if (visible) {
|
|
1228
|
-
$('#BgCustomerMessageHover').removeClass('d-none');
|
|
1229
|
-
$('#BgCustomerMessage').removeClass('scroll-out');
|
|
1230
|
-
$('#BgCustomerMessage').addClass('scroll-in');
|
|
1231
|
-
} else {
|
|
1232
|
-
$('#BgCustomerMessageHover').addClass('d-none');
|
|
1233
|
-
$('#BgCustomerMessage').addClass('scroll-out');
|
|
1234
|
-
$('#BgCustomerMessage').removeClass('scroll-in');
|
|
1235
|
-
}
|
|
1236
|
-
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
1350
|
+
public static toggle(visible: boolean, gvc: GVC) {
|
|
1351
|
+
BgCustomerMessage.visible = visible;
|
|
1352
|
+
BgCustomerMessage.vm.type = 'list';
|
|
1353
|
+
if (visible) {
|
|
1354
|
+
$('#BgCustomerMessageHover').removeClass('d-none');
|
|
1355
|
+
$('#BgCustomerMessage').removeClass('scroll-out');
|
|
1356
|
+
$('#BgCustomerMessage').addClass('scroll-in');
|
|
1357
|
+
} else {
|
|
1358
|
+
$('#BgCustomerMessageHover').addClass('d-none');
|
|
1359
|
+
$('#BgCustomerMessage').addClass('scroll-out');
|
|
1360
|
+
$('#BgCustomerMessage').removeClass('scroll-in');
|
|
1237
1361
|
}
|
|
1362
|
+
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
1363
|
+
}
|
|
1238
1364
|
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1365
|
+
public static userMessage(cf: {
|
|
1366
|
+
gvc: GVC;
|
|
1367
|
+
userID: string;
|
|
1368
|
+
toUser: string;
|
|
1369
|
+
width: number;
|
|
1370
|
+
height: number;
|
|
1371
|
+
color: string;
|
|
1372
|
+
hideBar: boolean;
|
|
1373
|
+
}) {
|
|
1374
|
+
const gvc = cf.gvc;
|
|
1375
|
+
const html = String.raw;
|
|
1376
|
+
cf.userID = `${cf.userID}`;
|
|
1377
|
+
const chatID = [cf.userID, cf.toUser].sort().join('-');
|
|
1378
|
+
return gvc.bindView(() => {
|
|
1379
|
+
const id = gvc.glitter.getUUID();
|
|
1380
|
+
return {
|
|
1381
|
+
bind: id,
|
|
1382
|
+
view: () => {
|
|
1383
|
+
return ``;
|
|
1384
|
+
},
|
|
1385
|
+
divCreate: {
|
|
1386
|
+
elem: 'web-component',
|
|
1387
|
+
option: [
|
|
1388
|
+
{
|
|
1389
|
+
key: 'id',
|
|
1390
|
+
value: id,
|
|
1391
|
+
},
|
|
1392
|
+
],
|
|
1393
|
+
class: `w-100 h-100`,
|
|
1394
|
+
style: `z-index:9999;bottom:0px;left:0px;`,
|
|
1395
|
+
},
|
|
1396
|
+
onCreate: async () => {
|
|
1397
|
+
BgCustomerMessage.config.hideBar = cf.hideBar;
|
|
1398
|
+
BgCustomerMessage.config.color = cf.color;
|
|
1399
|
+
await Chat.post({
|
|
1400
|
+
type: 'user',
|
|
1401
|
+
participant: [cf.userID, cf.toUser],
|
|
1402
|
+
});
|
|
1403
|
+
const viewId = gvc.glitter.getUUID();
|
|
1404
|
+
const chatView = html` <div class="w-100 h-100" style="position: relative;">
|
|
1405
|
+
${BgCustomerMessage.detail({
|
|
1406
|
+
gvc: gvc,
|
|
1407
|
+
chat: {
|
|
1408
|
+
chat_id: chatID,
|
|
1409
|
+
type: 'user',
|
|
1410
|
+
},
|
|
1411
|
+
user_id: cf.userID,
|
|
1412
|
+
containerHeight: `${cf.height}px`,
|
|
1413
|
+
document: (document.querySelector('#' + id)! as any).shadowRoot,
|
|
1414
|
+
goBack: () => {
|
|
1415
|
+
gvc.notifyDataChange(viewId);
|
|
1416
|
+
},
|
|
1417
|
+
close: gvc.glitter.ut.frSize(
|
|
1418
|
+
{
|
|
1419
|
+
sm: undefined,
|
|
1258
1420
|
},
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
},
|
|
1266
|
-
],
|
|
1267
|
-
class: `w-100 h-100`,
|
|
1268
|
-
style: `z-index:9999;bottom:0px;left:0px;`,
|
|
1269
|
-
},
|
|
1270
|
-
onCreate: async () => {
|
|
1271
|
-
BgCustomerMessage.config.hideBar = cf.hideBar;
|
|
1272
|
-
BgCustomerMessage.config.color = cf.color;
|
|
1273
|
-
await Chat.post({
|
|
1274
|
-
type: 'user',
|
|
1275
|
-
participant: [cf.userID, cf.toUser],
|
|
1276
|
-
});
|
|
1277
|
-
const viewId = gvc.glitter.getUUID();
|
|
1278
|
-
const chatView = html`
|
|
1279
|
-
<div class="w-100 h-100" style="position: relative;">
|
|
1280
|
-
${BgCustomerMessage.detail({
|
|
1281
|
-
gvc: gvc,
|
|
1282
|
-
chat: {
|
|
1283
|
-
chat_id: chatID,
|
|
1284
|
-
type: 'user',
|
|
1285
|
-
},
|
|
1286
|
-
user_id: cf.userID,
|
|
1287
|
-
containerHeight: `${cf.height}px`,
|
|
1288
|
-
document: (document.querySelector('#' + id)! as any).shadowRoot,
|
|
1289
|
-
goBack: () => {
|
|
1290
|
-
gvc.notifyDataChange(viewId);
|
|
1291
|
-
},
|
|
1292
|
-
close: gvc.glitter.ut.frSize(
|
|
1293
|
-
{
|
|
1294
|
-
sm: undefined,
|
|
1295
|
-
},
|
|
1296
|
-
() => {
|
|
1297
|
-
gvc.notifyDataChange(id);
|
|
1298
|
-
}
|
|
1299
|
-
),
|
|
1300
|
-
})}
|
|
1301
|
-
</div>`;
|
|
1421
|
+
() => {
|
|
1422
|
+
gvc.notifyDataChange(id);
|
|
1423
|
+
}
|
|
1424
|
+
),
|
|
1425
|
+
})}
|
|
1426
|
+
</div>`;
|
|
1302
1427
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1428
|
+
const baseUrl = new URL('../', import.meta.url);
|
|
1429
|
+
(document.querySelector('#' + id)! as any).addStyleLink(baseUrl.href + `assets/css/theme.css`);
|
|
1430
|
+
(document.querySelector('#' + id)! as any).addStyleLink(
|
|
1431
|
+
baseUrl.href + `assets/vendor/boxicons/css/boxicons.min.css`
|
|
1432
|
+
);
|
|
1433
|
+
(document.querySelector('#' + id)! as any).addStyleLink(`https://kit.fontawesome.com/cccedec0f8.css`);
|
|
1434
|
+
(document.querySelector('#' + id)! as any).addStyle(`
|
|
1308
1435
|
.btn-white-primary {
|
|
1309
1436
|
border: 2px solid ${BgCustomerMessage.config.color};
|
|
1310
1437
|
justify-content: space-between;
|
|
@@ -1319,428 +1446,459 @@ export class BgCustomerMessage {
|
|
|
1319
1446
|
color: white !important;
|
|
1320
1447
|
}
|
|
1321
1448
|
`);
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1449
|
+
(document.querySelector('#' + id)! as any).setView({
|
|
1450
|
+
gvc: gvc,
|
|
1451
|
+
view: chatView,
|
|
1452
|
+
id: id,
|
|
1453
|
+
});
|
|
1454
|
+
},
|
|
1455
|
+
};
|
|
1456
|
+
});
|
|
1457
|
+
}
|
|
1331
1458
|
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1459
|
+
public static detail(cf: {
|
|
1460
|
+
gvc: GVC;
|
|
1461
|
+
chat: any;
|
|
1462
|
+
user_id: string;
|
|
1463
|
+
containerHeight: string;
|
|
1464
|
+
document: any;
|
|
1465
|
+
goBack: () => void;
|
|
1466
|
+
close?: () => void;
|
|
1467
|
+
}) {
|
|
1468
|
+
const gvc = cf.gvc;
|
|
1469
|
+
const document = cf.document;
|
|
1470
|
+
const html = String.raw;
|
|
1471
|
+
return gvc.bindView(() => {
|
|
1472
|
+
const id = gvc.glitter.getUUID();
|
|
1346
1473
|
|
|
1347
|
-
|
|
1474
|
+
return {
|
|
1475
|
+
bind: id,
|
|
1476
|
+
view: () => {
|
|
1477
|
+
return [
|
|
1478
|
+
gvc.bindView(() => {
|
|
1479
|
+
const id = gvc.glitter.getUUID();
|
|
1480
|
+
return {
|
|
1348
1481
|
bind: id,
|
|
1349
1482
|
view: () => {
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
chat_id: cf.chat.chat_id,
|
|
1363
|
-
})
|
|
1364
|
-
).response.data[0];
|
|
1365
|
-
if (chatRoom.who === 'manager') {
|
|
1366
|
-
chatRoom.user_data = BgCustomerMessage.config;
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
if (chatRoom.chat_id.startsWith('line')) {
|
|
1370
|
-
chatRoom.user_data.head = chatRoom.info.line?.head;
|
|
1371
|
-
chatRoom.user_data.name = chatRoom.info.line?.name;
|
|
1372
|
-
}
|
|
1373
|
-
if (chatRoom.chat_id.startsWith('fb')) {
|
|
1374
|
-
chatRoom.user_data.head = chatRoom.fb.line?.head;
|
|
1375
|
-
chatRoom.user_data.name = chatRoom.fb.line?.name;
|
|
1376
|
-
}
|
|
1377
|
-
resolve(html`
|
|
1378
|
-
<div
|
|
1379
|
-
class="navbar d-flex align-items-center justify-content-between w-100 p-3 ${BgCustomerMessage.config.hideBar ? `d-none` : ``}"
|
|
1380
|
-
style="background: ${BgCustomerMessage.config.color};"
|
|
1381
|
-
>
|
|
1382
|
-
<div class="d-flex align-items-center pe-3 w-100"
|
|
1383
|
-
style="gap:10px;display: flex;align-items: center;">
|
|
1384
|
-
<i
|
|
1385
|
-
class="fa-solid fa-chevron-left fs-6"
|
|
1386
|
-
style="color:white;cursor: pointer;"
|
|
1387
|
-
onclick="${gvc.event(() => {
|
|
1388
|
-
if (cf.user_id === 'manager') {
|
|
1389
|
-
BgCustomerMessage.vm.type = 'list';
|
|
1390
|
-
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
1391
|
-
} else {
|
|
1392
|
-
cf.goBack();
|
|
1393
|
-
}
|
|
1394
|
-
})}"
|
|
1395
|
-
></i>
|
|
1396
|
-
<img
|
|
1397
|
-
src="${chatRoom.type === 'user'
|
|
1398
|
-
? (chatRoom.user_data && chatRoom.user_data.head) ||
|
|
1399
|
-
chatRoom.user_data.head_img ||
|
|
1400
|
-
'https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png'
|
|
1401
|
-
: `https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`}"
|
|
1402
|
-
class="rounded-circle border"
|
|
1403
|
-
style="background: white;"
|
|
1404
|
-
width="40"
|
|
1405
|
-
alt="Albert Flores"
|
|
1406
|
-
/>
|
|
1407
|
-
<h6 class="mb-0 px-1 text-white">
|
|
1408
|
-
${chatRoom.type === 'user' ? (chatRoom.user_data && chatRoom.user_data.name) || '訪客' : `群組`}</h6>
|
|
1409
|
-
<div class="flex-fill" style="flex: 1;"></div>
|
|
1410
|
-
<i
|
|
1411
|
-
class="fa-regular fa-circle-xmark text-white fs-3 ${cf.close ? `` : `d-none`}"
|
|
1412
|
-
onclick="${gvc.event(() => {
|
|
1413
|
-
cf.close && cf.close();
|
|
1414
|
-
})}"
|
|
1415
|
-
></i>
|
|
1416
|
-
</div>
|
|
1417
|
-
</div>`);
|
|
1418
|
-
});
|
|
1419
|
-
},
|
|
1420
|
-
};
|
|
1421
|
-
}),
|
|
1422
|
-
gvc.bindView(() => {
|
|
1423
|
-
const viewId = gvc.glitter.getUUID();
|
|
1424
|
-
const messageID = gvc.glitter.getUUID();
|
|
1425
|
-
const vm: {
|
|
1426
|
-
data: any;
|
|
1427
|
-
loading: boolean;
|
|
1428
|
-
scrollToBtn: boolean;
|
|
1429
|
-
lastScroll: number;
|
|
1430
|
-
message: string;
|
|
1431
|
-
prefixScroll: number;
|
|
1432
|
-
last_read: any;
|
|
1433
|
-
close: boolean;
|
|
1434
|
-
} = {
|
|
1435
|
-
data: [],
|
|
1436
|
-
loading: true,
|
|
1437
|
-
scrollToBtn: false,
|
|
1438
|
-
lastScroll: -1,
|
|
1439
|
-
message: '',
|
|
1440
|
-
prefixScroll: 0,
|
|
1441
|
-
last_read: {},
|
|
1442
|
-
close: false,
|
|
1443
|
-
};
|
|
1444
|
-
//chat_id
|
|
1445
|
-
Chat.getMessage({
|
|
1446
|
-
page: 0,
|
|
1447
|
-
limit: 50,
|
|
1448
|
-
chat_id: cf.chat.chat_id,
|
|
1449
|
-
user_id: cf.user_id,
|
|
1450
|
-
}).then((res) => {
|
|
1483
|
+
return new Promise(async (resolve, reject) => {
|
|
1484
|
+
const chatRoom = (
|
|
1485
|
+
await Chat.getChatRoom({
|
|
1486
|
+
page: 0,
|
|
1487
|
+
limit: 1000,
|
|
1488
|
+
user_id: cf.user_id,
|
|
1489
|
+
chat_id: cf.chat.chat_id,
|
|
1490
|
+
})
|
|
1491
|
+
).response.data[0];
|
|
1492
|
+
if (chatRoom.who === 'manager') {
|
|
1493
|
+
chatRoom.user_data = BgCustomerMessage.config;
|
|
1494
|
+
}
|
|
1451
1495
|
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1496
|
+
if (chatRoom.chat_id.startsWith('line')) {
|
|
1497
|
+
chatRoom.user_data.head = chatRoom.info.line?.head;
|
|
1498
|
+
chatRoom.user_data.name = chatRoom.info.line?.name;
|
|
1499
|
+
}
|
|
1500
|
+
if (chatRoom.chat_id.startsWith('fb')) {
|
|
1501
|
+
chatRoom.user_data.head = chatRoom.fb.line?.head;
|
|
1502
|
+
chatRoom.user_data.name = chatRoom.fb.line?.name;
|
|
1503
|
+
}
|
|
1504
|
+
resolve(
|
|
1505
|
+
html` <div
|
|
1506
|
+
class="navbar d-flex align-items-center justify-content-between w-100 p-3 ${BgCustomerMessage
|
|
1507
|
+
.config.hideBar
|
|
1508
|
+
? `d-none`
|
|
1509
|
+
: ``}"
|
|
1510
|
+
style="background: ${BgCustomerMessage.config.color};"
|
|
1511
|
+
>
|
|
1512
|
+
<div
|
|
1513
|
+
class="d-flex align-items-center pe-3 w-100"
|
|
1514
|
+
style="gap:10px;display: flex;align-items: center;"
|
|
1515
|
+
>
|
|
1516
|
+
<i
|
|
1517
|
+
class="fa-solid fa-chevron-left fs-6"
|
|
1518
|
+
style="color:white;cursor: pointer;"
|
|
1519
|
+
onclick="${gvc.event(() => {
|
|
1520
|
+
if (cf.user_id === 'manager') {
|
|
1521
|
+
BgCustomerMessage.vm.type = 'list';
|
|
1522
|
+
gvc.notifyDataChange(BgCustomerMessage.id);
|
|
1523
|
+
} else {
|
|
1524
|
+
cf.goBack();
|
|
1525
|
+
}
|
|
1526
|
+
})}"
|
|
1527
|
+
></i>
|
|
1528
|
+
<img
|
|
1529
|
+
src="${chatRoom.type === 'user'
|
|
1530
|
+
? (chatRoom.user_data && chatRoom.user_data.head) ||
|
|
1531
|
+
chatRoom.user_data.head_img ||
|
|
1532
|
+
'https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png'
|
|
1533
|
+
: `https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`}"
|
|
1534
|
+
class="rounded-circle border"
|
|
1535
|
+
style="background: white;"
|
|
1536
|
+
width="40"
|
|
1537
|
+
alt="Albert Flores"
|
|
1538
|
+
/>
|
|
1539
|
+
<h6 class="mb-0 px-1 text-white">
|
|
1540
|
+
${chatRoom.type === 'user'
|
|
1541
|
+
? (chatRoom.user_data && chatRoom.user_data.name) || '訪客'
|
|
1542
|
+
: `群組`}
|
|
1543
|
+
</h6>
|
|
1544
|
+
<div class="flex-fill" style="flex: 1;"></div>
|
|
1545
|
+
<i
|
|
1546
|
+
class="fa-regular fa-circle-xmark text-white fs-3 ${cf.close ? `` : `d-none`}"
|
|
1547
|
+
onclick="${gvc.event(() => {
|
|
1548
|
+
cf.close && cf.close();
|
|
1549
|
+
})}"
|
|
1550
|
+
></i>
|
|
1551
|
+
</div>
|
|
1552
|
+
</div>`
|
|
1553
|
+
);
|
|
1554
|
+
});
|
|
1555
|
+
},
|
|
1556
|
+
};
|
|
1557
|
+
}),
|
|
1558
|
+
gvc.bindView(() => {
|
|
1559
|
+
const viewId = gvc.glitter.getUUID();
|
|
1560
|
+
const messageID = gvc.glitter.getUUID();
|
|
1561
|
+
const vm: {
|
|
1562
|
+
data: any;
|
|
1563
|
+
loading: boolean;
|
|
1564
|
+
scrollToBtn: boolean;
|
|
1565
|
+
lastScroll: number;
|
|
1566
|
+
message: string;
|
|
1567
|
+
prefixScroll: number;
|
|
1568
|
+
last_read: any;
|
|
1569
|
+
close: boolean;
|
|
1570
|
+
} = {
|
|
1571
|
+
data: [],
|
|
1572
|
+
loading: true,
|
|
1573
|
+
scrollToBtn: false,
|
|
1574
|
+
lastScroll: -1,
|
|
1575
|
+
message: '',
|
|
1576
|
+
prefixScroll: 0,
|
|
1577
|
+
last_read: {},
|
|
1578
|
+
close: false,
|
|
1579
|
+
};
|
|
1580
|
+
//chat_id
|
|
1581
|
+
Chat.getMessage({
|
|
1582
|
+
page: 0,
|
|
1583
|
+
limit: 50,
|
|
1584
|
+
chat_id: cf.chat.chat_id,
|
|
1585
|
+
user_id: cf.user_id,
|
|
1586
|
+
}).then(res => {
|
|
1587
|
+
vm.data = res.response.data.reverse();
|
|
1588
|
+
vm.last_read = res.response.lastRead;
|
|
1589
|
+
vm.loading = false;
|
|
1590
|
+
gvc.notifyDataChange(viewId);
|
|
1591
|
+
});
|
|
1457
1592
|
|
|
1458
|
-
|
|
1593
|
+
const url = new URL((window as any).glitterBackend);
|
|
1459
1594
|
|
|
1460
|
-
|
|
1595
|
+
let socket: any = undefined;
|
|
1461
1596
|
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1597
|
+
function connect() {
|
|
1598
|
+
if (gvc.glitter.share.close_socket) {
|
|
1599
|
+
gvc.glitter.share.close_socket();
|
|
1600
|
+
}
|
|
1601
|
+
vm.close = false;
|
|
1602
|
+
socket = location.href.includes('https://')
|
|
1603
|
+
? new WebSocket(`wss://${url.hostname}/websocket`)
|
|
1604
|
+
: new WebSocket(`ws://${url.hostname}:9003`);
|
|
1605
|
+
gvc.glitter.share.close_socket = () => {
|
|
1606
|
+
vm.close = true;
|
|
1607
|
+
socket.close();
|
|
1608
|
+
gvc.glitter.share.close_socket = undefined;
|
|
1609
|
+
};
|
|
1610
|
+
gvc.glitter.share.socket = socket;
|
|
1611
|
+
socket.addEventListener('open', function (event: any) {
|
|
1612
|
+
console.log('Connected to server');
|
|
1613
|
+
socket.send(
|
|
1614
|
+
JSON.stringify({
|
|
1615
|
+
type: 'message',
|
|
1616
|
+
chatID: cf.chat.chat_id,
|
|
1617
|
+
user_id: cf.user_id,
|
|
1618
|
+
app_name: (window as any).appName,
|
|
1619
|
+
})
|
|
1620
|
+
);
|
|
1621
|
+
});
|
|
1622
|
+
let interVal: any = 0;
|
|
1623
|
+
socket.addEventListener('message', function (event: any) {
|
|
1624
|
+
const data = JSON.parse(event.data);
|
|
1625
|
+
if (data.type === 'update_read_count') {
|
|
1626
|
+
vm.last_read = data.data;
|
|
1627
|
+
} else {
|
|
1628
|
+
vm.data.push(data);
|
|
1629
|
+
const element: any = document.querySelector('.chatContainer')!;
|
|
1630
|
+
const st = element.scrollTop;
|
|
1631
|
+
const ofs = element.offsetHeight;
|
|
1632
|
+
const sh = element.scrollHeight;
|
|
1633
|
+
for (const dd of document.querySelectorAll('.time-mute')) {
|
|
1634
|
+
dd.remove();
|
|
1635
|
+
}
|
|
1636
|
+
document.querySelector(`#message-lines`).innerHTML += BgCustomerMessage.message_line(
|
|
1637
|
+
data,
|
|
1638
|
+
cf,
|
|
1639
|
+
vm.data.length - 1,
|
|
1640
|
+
vm,
|
|
1641
|
+
gvc
|
|
1642
|
+
);
|
|
1643
|
+
if (st + ofs >= sh - 50) {
|
|
1644
|
+
element.scrollTop = element.scrollHeight;
|
|
1645
|
+
setTimeout(() => {
|
|
1646
|
+
element.scrollTop = element.scrollHeight;
|
|
1647
|
+
}, 1000);
|
|
1648
|
+
}
|
|
1649
|
+
}
|
|
1650
|
+
});
|
|
1651
|
+
socket.addEventListener('close', function (event: any) {
|
|
1652
|
+
console.log('Disconnected from server');
|
|
1653
|
+
if (!vm.close) {
|
|
1654
|
+
console.log('Reconnected from server');
|
|
1655
|
+
connect();
|
|
1656
|
+
}
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1516
1659
|
|
|
1517
|
-
|
|
1660
|
+
connect();
|
|
1518
1661
|
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1662
|
+
const textAreaId = gvc.glitter.getUUID();
|
|
1663
|
+
const html = String.raw;
|
|
1664
|
+
return {
|
|
1665
|
+
bind: viewId,
|
|
1666
|
+
view: () => {
|
|
1667
|
+
if (vm.loading) {
|
|
1668
|
+
return String.raw`<div class="d-flex align-items-center justify-content-center w-100 flex-column pt-3">
|
|
1526
1669
|
<div class="spinner-border" role="status">
|
|
1527
1670
|
<span class="sr-only"></span>
|
|
1528
1671
|
</div>
|
|
1529
1672
|
<span class="mt-2">載入中...</span>
|
|
1530
1673
|
</div>`;
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
</div>
|
|
1545
|
-
|
|
1546
|
-
${vm.data.length === 0
|
|
1547
|
-
? html`
|
|
1548
|
-
<div class="w-100 text-center">
|
|
1549
|
-
<div class="badge bg-secondary">
|
|
1550
|
-
尚未展開對話,於下方輸入訊息並傳送。
|
|
1551
|
-
</div>
|
|
1552
|
-
</div> `
|
|
1553
|
-
: ``}`;
|
|
1554
|
-
},
|
|
1555
|
-
divCreate: {
|
|
1556
|
-
class: `chatContainer p-3 d-flex flex-column`,
|
|
1557
|
-
style: `overflow-y: auto;height: calc(${cf.containerHeight} - 220px);background: white;padding-bottom:80px !important;`,
|
|
1558
|
-
},
|
|
1559
|
-
onCreate: () => {
|
|
1560
|
-
vm.close = false;
|
|
1561
|
-
// 取得要監聽的元素
|
|
1562
|
-
let targetElement = document.querySelector('.chatContainer')!;
|
|
1563
|
-
if (vm.lastScroll === -1) {
|
|
1564
|
-
setTimeout(() => {
|
|
1565
|
-
document.querySelector('.chatContainer')!.scrollTop = document.querySelector('.chatContainer')!.scrollHeight;
|
|
1566
|
-
}, 100)
|
|
1567
|
-
} else {
|
|
1568
|
-
if (vm.prefixScroll) {
|
|
1569
|
-
vm.lastScroll = targetElement.scrollHeight - vm.prefixScroll + vm.lastScroll;
|
|
1570
|
-
vm.prefixScroll = 0;
|
|
1571
|
-
}
|
|
1572
|
-
document.querySelector('.chatContainer')!.scrollTop = vm.lastScroll;
|
|
1573
|
-
}
|
|
1574
|
-
// 添加滾動事件監聽器
|
|
1575
|
-
targetElement.addEventListener('scroll', () => {
|
|
1576
|
-
vm.lastScroll = targetElement.scrollTop;
|
|
1577
|
-
if (targetElement.scrollTop === 0) {
|
|
1578
|
-
console.log(`scrollTop===0`);
|
|
1579
|
-
if (vm.loading) {
|
|
1580
|
-
return;
|
|
1581
|
-
}
|
|
1582
|
-
vm.loading = true;
|
|
1583
|
-
Chat.getMessage({
|
|
1584
|
-
page: 0,
|
|
1585
|
-
limit: 50,
|
|
1586
|
-
chat_id: cf.chat.chat_id,
|
|
1587
|
-
olderID: vm.data[0].id,
|
|
1588
|
-
user_id: cf.user_id,
|
|
1589
|
-
}).then((res) => {
|
|
1590
|
-
vm.loading = false;
|
|
1591
|
-
vm.prefixScroll = targetElement.scrollHeight;
|
|
1592
|
-
vm.data = res.response.data.reverse().concat(vm.data);
|
|
1593
|
-
gvc.notifyDataChange(viewId);
|
|
1594
|
-
});
|
|
1595
|
-
}
|
|
1596
|
-
});
|
|
1597
|
-
},
|
|
1598
|
-
};
|
|
1599
|
-
})}
|
|
1600
|
-
<div
|
|
1601
|
-
class="card-footer border-top d-flex align-items-center w-100 border-0 pt-3 pb-3 px-4 position-fixed bottom-0 position-lg-absolute"
|
|
1602
|
-
style="background: white;"
|
|
1603
|
-
>
|
|
1674
|
+
}
|
|
1675
|
+
return html` ${gvc.bindView(() => {
|
|
1676
|
+
return {
|
|
1677
|
+
bind: messageID,
|
|
1678
|
+
view: () => {
|
|
1679
|
+
return html` <div class="my-auto flex-fill" id=""></div>
|
|
1680
|
+
<div class="w-100" id="message-lines">
|
|
1681
|
+
${vm.data
|
|
1682
|
+
.map((dd: any, index: number) => {
|
|
1683
|
+
return BgCustomerMessage.message_line(dd, cf, index, vm, gvc);
|
|
1684
|
+
})
|
|
1685
|
+
.join('')}
|
|
1686
|
+
</div>
|
|
1604
1687
|
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1688
|
+
${vm.data.length === 0
|
|
1689
|
+
? html`
|
|
1690
|
+
<div class="w-100 text-center">
|
|
1691
|
+
<div class="badge bg-secondary">尚未展開對話,於下方輸入訊息並傳送。</div>
|
|
1692
|
+
</div>
|
|
1693
|
+
`
|
|
1694
|
+
: ``}`;
|
|
1695
|
+
},
|
|
1696
|
+
divCreate: {
|
|
1697
|
+
class: `chatContainer p-3 d-flex flex-column`,
|
|
1698
|
+
style: `overflow-y: auto;height: calc(${cf.containerHeight} - 220px);background: white;padding-bottom:80px !important;`,
|
|
1699
|
+
},
|
|
1700
|
+
onCreate: () => {
|
|
1701
|
+
vm.close = false;
|
|
1702
|
+
// 取得要監聽的元素
|
|
1703
|
+
let targetElement = document.querySelector('.chatContainer')!;
|
|
1704
|
+
if (vm.lastScroll === -1) {
|
|
1705
|
+
setTimeout(() => {
|
|
1706
|
+
document.querySelector('.chatContainer')!.scrollTop =
|
|
1707
|
+
document.querySelector('.chatContainer')!.scrollHeight;
|
|
1708
|
+
}, 100);
|
|
1709
|
+
} else {
|
|
1710
|
+
if (vm.prefixScroll) {
|
|
1711
|
+
vm.lastScroll = targetElement.scrollHeight - vm.prefixScroll + vm.lastScroll;
|
|
1712
|
+
vm.prefixScroll = 0;
|
|
1713
|
+
}
|
|
1714
|
+
document.querySelector('.chatContainer')!.scrollTop = vm.lastScroll;
|
|
1715
|
+
}
|
|
1716
|
+
// 添加滾動事件監聽器
|
|
1717
|
+
targetElement.addEventListener('scroll', () => {
|
|
1718
|
+
vm.lastScroll = targetElement.scrollTop;
|
|
1719
|
+
if (targetElement.scrollTop === 0) {
|
|
1720
|
+
console.log(`scrollTop===0`);
|
|
1721
|
+
if (vm.loading) {
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1724
|
+
vm.loading = true;
|
|
1725
|
+
Chat.getMessage({
|
|
1726
|
+
page: 0,
|
|
1727
|
+
limit: 50,
|
|
1728
|
+
chat_id: cf.chat.chat_id,
|
|
1729
|
+
olderID: vm.data[0].id,
|
|
1730
|
+
user_id: cf.user_id,
|
|
1731
|
+
}).then(res => {
|
|
1732
|
+
vm.loading = false;
|
|
1733
|
+
vm.prefixScroll = targetElement.scrollHeight;
|
|
1734
|
+
vm.data = res.response.data.reverse().concat(vm.data);
|
|
1735
|
+
gvc.notifyDataChange(viewId);
|
|
1736
|
+
});
|
|
1737
|
+
}
|
|
1738
|
+
});
|
|
1739
|
+
},
|
|
1740
|
+
};
|
|
1741
|
+
})}
|
|
1742
|
+
<div
|
|
1743
|
+
class="card-footer border-top d-flex align-items-center w-100 border-0 pt-3 pb-3 px-4 position-fixed bottom-0 position-lg-absolute"
|
|
1744
|
+
style="background: white;"
|
|
1745
|
+
>
|
|
1746
|
+
<div class="position-relative w-100 me-2 ">
|
|
1747
|
+
${gvc.bindView(() => {
|
|
1748
|
+
return {
|
|
1749
|
+
bind: textAreaId,
|
|
1750
|
+
view: () => {
|
|
1751
|
+
return vm.message ?? '';
|
|
1752
|
+
},
|
|
1753
|
+
divCreate: {
|
|
1754
|
+
elem: `textArea`,
|
|
1755
|
+
style: `max-height:100px;white-space: pre-wrap; word-wrap: break-word;height:40px;`,
|
|
1756
|
+
class: `form-control`,
|
|
1757
|
+
option: [
|
|
1758
|
+
{ key: 'placeholder', value: '輸入訊息內容' },
|
|
1759
|
+
{
|
|
1760
|
+
key: 'onchange',
|
|
1761
|
+
value: gvc.event(e => {
|
|
1762
|
+
vm.message = e.value;
|
|
1763
|
+
}),
|
|
1669
1764
|
},
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1765
|
+
],
|
|
1766
|
+
},
|
|
1767
|
+
onCreate: () => {
|
|
1768
|
+
const input = gvc.getBindViewElem(id).get(0);
|
|
1769
|
+
input.addEventListener('input', function () {
|
|
1770
|
+
console.log(`input.scrollHeight->`, input.scrollHeight);
|
|
1771
|
+
input.style.height = 'auto'; // 重置高度
|
|
1772
|
+
input.style.height = input.scrollHeight + 'px'; // 设置为内容高度
|
|
1773
|
+
});
|
|
1774
|
+
},
|
|
1775
|
+
};
|
|
1776
|
+
})}
|
|
1777
|
+
</div>
|
|
1778
|
+
<button
|
|
1779
|
+
type="button"
|
|
1780
|
+
class="btn btn-icon btn-lg d-sm-inline-flex ms-1"
|
|
1781
|
+
style="height: 36px;background: ${BgCustomerMessage.config.color};"
|
|
1782
|
+
onclick="${gvc.event(() => {
|
|
1783
|
+
if (vm.message) {
|
|
1784
|
+
Chat.postMessage({
|
|
1785
|
+
chat_id: cf.chat.chat_id,
|
|
1786
|
+
user_id: cf.user_id,
|
|
1787
|
+
message: {
|
|
1788
|
+
text: vm.message,
|
|
1789
|
+
attachment: '',
|
|
1790
|
+
},
|
|
1791
|
+
}).then(() => {
|
|
1792
|
+
vm.message = '';
|
|
1793
|
+
});
|
|
1794
|
+
const textArea = gvc.getBindViewElem(textAreaId).get(0);
|
|
1795
|
+
textArea.value = '';
|
|
1796
|
+
textArea.focus();
|
|
1797
|
+
}
|
|
1798
|
+
})}"
|
|
1799
|
+
>
|
|
1800
|
+
<i class="fa-regular fa-paper-plane-top"></i>
|
|
1801
|
+
</button>
|
|
1802
|
+
</div>`;
|
|
1673
1803
|
},
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
} else {
|
|
1688
|
-
return dd.message.text.replace(/\n/g, '<br>')
|
|
1689
|
-
}
|
|
1690
|
-
}
|
|
1804
|
+
divCreate: {},
|
|
1805
|
+
onCreate: () => {},
|
|
1806
|
+
onDestroy: () => {
|
|
1807
|
+
vm.close = true;
|
|
1808
|
+
socket.close();
|
|
1809
|
+
},
|
|
1810
|
+
};
|
|
1811
|
+
}),
|
|
1812
|
+
].join('');
|
|
1813
|
+
},
|
|
1814
|
+
};
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1691
1817
|
|
|
1692
|
-
|
|
1818
|
+
public static message_line(dd: any, cf: any, index: number, vm: any, gvc: GVC) {
|
|
1819
|
+
const html = String.raw;
|
|
1820
|
+
if (dd.user_id == 'manager') {
|
|
1821
|
+
dd.user_data = BgCustomerMessage.config;
|
|
1822
|
+
}
|
|
1693
1823
|
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
/>
|
|
1702
|
-
<div class="ps-2 ms-1" style="max-width: 348px;">
|
|
1703
|
-
<div class="p-3 mb-1 ${dd.message.image ? '' : 'py-2'}"
|
|
1704
|
-
style="background:#eeeef1;border-top-right-radius: .5rem; border-bottom-right-radius: .5rem; border-bottom-left-radius: .5rem;white-space: normal;">
|
|
1824
|
+
function drawChatContent() {
|
|
1825
|
+
if (dd.message.image) {
|
|
1826
|
+
return html`<img src="${dd.message.image}" />`;
|
|
1827
|
+
} else {
|
|
1828
|
+
return dd.message.text.replace(/\n/g, '<br>');
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1705
1831
|
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1832
|
+
if (cf.user_id !== dd.user_id) {
|
|
1833
|
+
return html` <div
|
|
1834
|
+
class="mt-auto d-flex align-items-start ${vm.data[index + 1] && vm.data[index + 1].user_id === dd.user_id
|
|
1835
|
+
? `mb-1`
|
|
1836
|
+
: `mb-3`}"
|
|
1837
|
+
>
|
|
1838
|
+
<img
|
|
1839
|
+
src="${(dd.user_data && dd.user_data.head) ||
|
|
1840
|
+
`https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`}"
|
|
1841
|
+
class="rounded-circle border"
|
|
1842
|
+
width="40"
|
|
1843
|
+
alt="Albert Flores"
|
|
1844
|
+
/>
|
|
1845
|
+
<div class="ps-2 ms-1" style="max-width: 348px;">
|
|
1846
|
+
<div
|
|
1847
|
+
class="p-3 mb-1 ${dd.message.image ? '' : 'py-2'}"
|
|
1848
|
+
style="background:#eeeef1;border-top-right-radius: .5rem; border-bottom-right-radius: .5rem; border-bottom-left-radius: .5rem;white-space: normal;"
|
|
1849
|
+
>
|
|
1850
|
+
${drawChatContent()}
|
|
1851
|
+
</div>
|
|
1852
|
+
<div
|
|
1853
|
+
class="fs-sm text-muted ${vm.data[index + 1] && vm.data[index + 1].user_id === dd.user_id ? `d-none` : ``}"
|
|
1854
|
+
>
|
|
1855
|
+
${gvc.glitter.ut.dateFormat(new Date(dd.created_time), 'MM-dd hh:mm')}
|
|
1856
|
+
</div>
|
|
1857
|
+
</div>
|
|
1858
|
+
</div>`;
|
|
1859
|
+
} else {
|
|
1860
|
+
return html` <div
|
|
1861
|
+
class="d-flex align-items-start justify-content-end ${vm.data[index + 1] &&
|
|
1862
|
+
vm.data[index + 1].user_id === dd.user_id
|
|
1863
|
+
? `mb-1`
|
|
1864
|
+
: `mb-3`}"
|
|
1865
|
+
>
|
|
1866
|
+
<div class="pe-2 me-1" style="max-width: 348px;">
|
|
1867
|
+
<div
|
|
1868
|
+
class=" text-light p-3 mb-1 ${dd?.message?.image ? '' : 'py-2'}"
|
|
1869
|
+
style="background:${BgCustomerMessage.config
|
|
1870
|
+
.color};border-top-left-radius: .5rem; border-bottom-right-radius: .5rem; border-bottom-left-radius: .5rem;white-space: normal;"
|
|
1871
|
+
>
|
|
1872
|
+
${drawChatContent()}
|
|
1873
|
+
</div>
|
|
1874
|
+
<div
|
|
1875
|
+
class="time-mute fw-500 d-flex justify-content-end align-items-center fs-sm text-muted ${vm.data[
|
|
1876
|
+
index + 1
|
|
1877
|
+
] && vm.data[index + 1].user_id === dd.user_id
|
|
1878
|
+
? `d-none`
|
|
1879
|
+
: ``}"
|
|
1880
|
+
style="gap:5px;"
|
|
1881
|
+
>
|
|
1882
|
+
<span> ${gvc.glitter.ut.dateFormat(new Date(dd.created_time), 'MM/dd hh:mm')}</span>
|
|
1883
|
+
${vm.last_read.find((d2: any) => {
|
|
1884
|
+
return (
|
|
1885
|
+
d2.user_id !== cf.user_id && new Date(d2.last_read).getTime() >= new Date(dd.created_time).getTime()
|
|
1886
|
+
);
|
|
1887
|
+
})
|
|
1888
|
+
? `已讀`
|
|
1889
|
+
: ``}
|
|
1890
|
+
</div>
|
|
1891
|
+
</div>
|
|
1892
|
+
<img
|
|
1893
|
+
src="${(dd.user_data && dd.user_data.head) ||
|
|
1894
|
+
`https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`}"
|
|
1895
|
+
class="rounded-circle border"
|
|
1896
|
+
width="40"
|
|
1897
|
+
alt="Albert Flores"
|
|
1898
|
+
/>
|
|
1899
|
+
</div>`;
|
|
1743
1900
|
}
|
|
1901
|
+
}
|
|
1744
1902
|
}
|
|
1745
1903
|
|
|
1746
1904
|
(window as any).glitter.setModule(import.meta.url, BgCustomerMessage);
|