ts-glitter 18.2.6 → 18.2.8
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 +30 -1
- package/lowcode/Entry.ts +36 -1
- package/lowcode/cms-plugin/customer-message-user.js +503 -8
- package/lowcode/cms-plugin/customer-message-user.ts +549 -12
- package/lowcode/cms-plugin/shopping-finance-setting.js +4 -4
- package/lowcode/cms-plugin/shopping-finance-setting.ts +4 -4
- package/lowcode/cms-plugin/shopping-information.js +16 -0
- package/lowcode/cms-plugin/shopping-information.ts +16 -0
- package/lowcode/cms-plugin/shopping-order-manager.js +138 -77
- package/lowcode/cms-plugin/shopping-order-manager.ts +177 -102
- package/lowcode/glitter-base/global/language.js +6 -0
- package/lowcode/glitter-base/global/language.ts +6 -0
- package/lowcode/glitterBundle/GVController.js +2 -2
- package/lowcode/glitterBundle/GVController.ts +2 -2
- package/lowcode/glitterBundle/dialog/dialog_inner.js +5 -2
- package/lowcode/glitterBundle/dialog/dialog_inner.ts +5 -2
- package/lowcode/glitterBundle/module/Animation.js +59 -0
- package/lowcode/glitterBundle/module/Animation.ts +62 -0
- package/lowcode/glitterBundle/module/PageManager.js +3 -3
- package/lowcode/glitterBundle/module/PageManager.ts +1 -1
- package/lowcode/index.html +1 -0
- package/lowcode/public-components/checkout/index.js +77 -117
- package/lowcode/public-components/checkout/index.ts +174 -221
- package/lowcode/public-components/footer/footer-01.js +3 -0
- package/lowcode/public-components/footer/footer-01.ts +3 -0
- package/lowcode/public-components/footer/footer-02.js +3 -0
- package/lowcode/public-components/footer/footer-02.ts +3 -0
- package/lowcode/public-components/footer/footer-03.js +3 -0
- package/lowcode/public-components/footer/footer-03.ts +3 -0
- package/lowcode/public-components/product/pd-class.js +868 -355
- package/lowcode/public-components/product/pd-class.ts +1005 -438
- package/lowcode/public-components/product/product-detail.js +1 -1
- package/lowcode/public-components/product/product-detail.ts +3 -1
- package/package.json +1 -1
- package/src/api-public/controllers/article.js.map +1 -1
- package/src/api-public/controllers/delivery.js.map +1 -1
- package/src/api-public/controllers/delivery.ts +2 -0
- package/src/api-public/controllers/shop.js +3 -2
- package/src/api-public/controllers/shop.js.map +1 -1
- package/src/api-public/controllers/shop.ts +4 -3
- package/src/api-public/controllers/user.js.map +1 -1
- package/src/api-public/services/ai-robot.js.map +1 -1
- package/src/api-public/services/fb-api.js.map +1 -1
- package/src/api-public/services/financial-service.d.ts +4 -0
- package/src/api-public/services/financial-service.js +48 -23
- package/src/api-public/services/financial-service.js.map +1 -1
- package/src/api-public/services/financial-service.ts +57 -26
- package/src/api-public/services/public-table-check.js.map +1 -1
- package/src/api-public/services/shopping.js +7 -0
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +9 -0
- package/src/api-public/services/user.d.ts +2 -2
- package/src/api-public/services/user.js +8 -2
- package/src/api-public/services/user.js.map +1 -1
- package/src/api-public/services/user.ts +8 -2
- package/src/index.js +3 -3
- package/src/index.js.map +1 -1
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {GVC} from "../glitterBundle/GVController.js";
|
|
2
2
|
import {ApiUser} from "../glitter-base/route/user.js";
|
|
3
3
|
import {Chat} from "../glitter-base/route/chat.js";
|
|
4
|
-
import {TriggerEvent} from "../glitterBundle/plugins/trigger-event.js";
|
|
5
4
|
import {imageLibrary} from "../modules/image-library.js";
|
|
6
|
-
import {ApiPageConfig} from "../api/pageConfig.js";
|
|
7
|
-
import {BaseApi} from "../glitterBundle/api/base.js";
|
|
8
5
|
import {ShareDialog} from "../glitterBundle/dialog/ShareDialog.js";
|
|
6
|
+
import {Animation} from "../glitterBundle/module/Animation.js";
|
|
9
7
|
|
|
10
8
|
export class CustomerMessageUser {
|
|
11
9
|
public static config: any = {}
|
|
@@ -39,7 +37,9 @@ export class CustomerMessageUser {
|
|
|
39
37
|
} = {
|
|
40
38
|
viewType: (cf.viewType as any) || 'robot',
|
|
41
39
|
};
|
|
42
|
-
|
|
40
|
+
if(gvc.glitter.getUrlParameter('page').startsWith('products/') && document.body.clientWidth<800){
|
|
41
|
+
return ``
|
|
42
|
+
}
|
|
43
43
|
return gvc.bindView(() => {
|
|
44
44
|
const id = gvc.glitter.getUUID();
|
|
45
45
|
return {
|
|
@@ -420,7 +420,6 @@ export class CustomerMessageUser {
|
|
|
420
420
|
};
|
|
421
421
|
}),
|
|
422
422
|
gvc.bindView(() => {
|
|
423
|
-
|
|
424
423
|
const messageID = gvc.glitter.getUUID();
|
|
425
424
|
const vm: {
|
|
426
425
|
data: any;
|
|
@@ -846,6 +845,542 @@ export class CustomerMessageUser {
|
|
|
846
845
|
});
|
|
847
846
|
}
|
|
848
847
|
|
|
848
|
+
|
|
849
|
+
public static mobileChat(cf: {
|
|
850
|
+
gvc: GVC;
|
|
851
|
+
chat: any;
|
|
852
|
+
user_id: string;
|
|
853
|
+
hideBar?: boolean
|
|
854
|
+
}) {
|
|
855
|
+
const gvc = cf.gvc;
|
|
856
|
+
const css = String.raw;
|
|
857
|
+
const viewId = gvc.glitter.getUUID();
|
|
858
|
+
let chatRoomInf: any = {}
|
|
859
|
+
document.body.style.setProperty('overflow-y', 'hidden', 'important');
|
|
860
|
+
|
|
861
|
+
gvc.glitter.innerDialog((gvc: GVC) => {
|
|
862
|
+
return gvc.bindView(() => {
|
|
863
|
+
const id = gvc.glitter.getUUID();
|
|
864
|
+
return {
|
|
865
|
+
bind: id,
|
|
866
|
+
view: () => {
|
|
867
|
+
return new Promise(async (resolve, reject) => {
|
|
868
|
+
const config = (await ApiUser.getPublicConfig(`message_setting`, 'manager')).response.value || {
|
|
869
|
+
color: '#FE5541',
|
|
870
|
+
head: 'https://liondesign-prd.s3.amazonaws.com/file/252530754/1695093945424-Frame 62 (1).png',
|
|
871
|
+
name: '萊恩設計',
|
|
872
|
+
};
|
|
873
|
+
CustomerMessageUser.config = config
|
|
874
|
+
gvc.addStyle(css`
|
|
875
|
+
.btn-white-primary {
|
|
876
|
+
border: 2px solid ${CustomerMessageUser.config.color};
|
|
877
|
+
justify-content: space-between;
|
|
878
|
+
align-items: center;
|
|
879
|
+
cursor: pointer;
|
|
880
|
+
color: ${CustomerMessageUser.config.color};
|
|
881
|
+
gap: 10px;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
.btn-white-primary:hover {
|
|
885
|
+
background: ${CustomerMessageUser.config.color};
|
|
886
|
+
color: white !important;
|
|
887
|
+
}
|
|
888
|
+
`)
|
|
889
|
+
resolve([
|
|
890
|
+
gvc.bindView(() => {
|
|
891
|
+
const id = gvc.glitter.getUUID();
|
|
892
|
+
return {
|
|
893
|
+
bind: id,
|
|
894
|
+
view: () => {
|
|
895
|
+
if (cf.hideBar) {
|
|
896
|
+
return ``
|
|
897
|
+
}
|
|
898
|
+
return new Promise(async (resolve, reject) => {
|
|
899
|
+
const chatRoom = (
|
|
900
|
+
await Chat.getChatRoom({
|
|
901
|
+
page: 0,
|
|
902
|
+
limit: 1000,
|
|
903
|
+
user_id: cf.user_id,
|
|
904
|
+
chat_id: cf.chat.chat_id,
|
|
905
|
+
})
|
|
906
|
+
).response.data[0];
|
|
907
|
+
if (chatRoom.who === 'manager') {
|
|
908
|
+
chatRoom.user_data = CustomerMessageUser.config;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
if (chatRoom.who.startsWith('line')) {
|
|
912
|
+
chatRoom.user_data.head = chatRoom.info.line.head;
|
|
913
|
+
chatRoom.user_data.name = chatRoom.info.line.name;
|
|
914
|
+
chatRoomInf = chatRoom;
|
|
915
|
+
gvc.notifyDataChange(viewId)
|
|
916
|
+
}
|
|
917
|
+
if (chatRoom.who.startsWith('fb')) {
|
|
918
|
+
chatRoom.user_data.head = chatRoom.info.fb.head;
|
|
919
|
+
chatRoom.user_data.name = chatRoom.info.fb.name;
|
|
920
|
+
chatRoomInf = chatRoom;
|
|
921
|
+
gvc.notifyDataChange(viewId)
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
resolve(`<div class="navbar d-flex align-items-center justify-content-between w-100 p-3 ${
|
|
926
|
+
CustomerMessageUser.config.hideBar ? `d-none` : ``
|
|
927
|
+
}" style="background: ${CustomerMessageUser.config.color};">
|
|
928
|
+
<div class="d-flex align-items-center pe-3 w-100" style="gap:10px;display: flex;align-items: center;">
|
|
929
|
+
<i class="fa-solid fa-chevron-left fs-6" style="color:white;cursor: pointer;" onclick="${gvc.event(() => {
|
|
930
|
+
document.body.style.removeProperty('overflow-y')
|
|
931
|
+
gvc.closeDialog()
|
|
932
|
+
})}"></i>
|
|
933
|
+
<img src="${
|
|
934
|
+
chatRoom.type === 'user'
|
|
935
|
+
? (chatRoom.user_data && chatRoom.user_data.head) || chatRoom.user_data.head_img || 'https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png'
|
|
936
|
+
: `https://d3jnmi1tfjgtti.cloudfront.net/file/252530754/1704269678588-43.png`
|
|
937
|
+
}" class="rounded-circle border" style="background: white;border-radius: 50%;width: 40px;height: 40px;" width="40" alt="Albert Flores">
|
|
938
|
+
<h6 class="mb-0 px-1 text-white">${chatRoom.type === 'user' ? (chatRoom.user_data && chatRoom.user_data.name) || '訪客' : `群組`}</h6>
|
|
939
|
+
<div class="flex-fill" style="flex: 1;"></div>
|
|
940
|
+
<i class="fa-regular fa-circle-xmark text-white fs-3 " onclick="${gvc.event(() => {
|
|
941
|
+
document.body.style.removeProperty('overflow-y')
|
|
942
|
+
gvc.closeDialog()
|
|
943
|
+
})}"></i>
|
|
944
|
+
</div>
|
|
945
|
+
</div>`);
|
|
946
|
+
});
|
|
947
|
+
},
|
|
948
|
+
};
|
|
949
|
+
}),
|
|
950
|
+
gvc.bindView(() => {
|
|
951
|
+
const messageID = gvc.glitter.getUUID();
|
|
952
|
+
const vm: {
|
|
953
|
+
data: any;
|
|
954
|
+
loading: boolean;
|
|
955
|
+
scrollToBtn: boolean;
|
|
956
|
+
lastScroll: number;
|
|
957
|
+
message: string;
|
|
958
|
+
prefixScroll: number;
|
|
959
|
+
last_read: any;
|
|
960
|
+
close: boolean;
|
|
961
|
+
} = {
|
|
962
|
+
data: [],
|
|
963
|
+
loading: true,
|
|
964
|
+
scrollToBtn: false,
|
|
965
|
+
lastScroll: -1,
|
|
966
|
+
message: '',
|
|
967
|
+
prefixScroll: 0,
|
|
968
|
+
last_read: {},
|
|
969
|
+
close: false,
|
|
970
|
+
};
|
|
971
|
+
//chat_id
|
|
972
|
+
Chat.getMessage({
|
|
973
|
+
page: 0,
|
|
974
|
+
limit: 50,
|
|
975
|
+
chat_id: cf.chat.chat_id,
|
|
976
|
+
user_id: cf.user_id,
|
|
977
|
+
}).then((res) => {
|
|
978
|
+
vm.data = res.response.data.reverse();
|
|
979
|
+
vm.last_read = res.response.lastRead;
|
|
980
|
+
vm.loading = false;
|
|
981
|
+
gvc.notifyDataChange(viewId);
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
const url = new URL((window as any).glitterBackend);
|
|
985
|
+
|
|
986
|
+
let socket: any = undefined;
|
|
987
|
+
|
|
988
|
+
function connect() {
|
|
989
|
+
if (gvc.glitter.share.close_socket) {
|
|
990
|
+
gvc.glitter.share.close_socket();
|
|
991
|
+
}
|
|
992
|
+
vm.close = false;
|
|
993
|
+
socket = location.href.includes('https://') ? new WebSocket(`wss://${url.hostname}/websocket`) : new WebSocket(`ws://${url.hostname}:9003`);
|
|
994
|
+
gvc.glitter.share.close_socket = () => {
|
|
995
|
+
vm.close = true;
|
|
996
|
+
socket.close();
|
|
997
|
+
gvc.glitter.share.close_socket = undefined;
|
|
998
|
+
};
|
|
999
|
+
gvc.glitter.share.socket = socket;
|
|
1000
|
+
socket.addEventListener('open', function (event: any) {
|
|
1001
|
+
console.log('Connected to server');
|
|
1002
|
+
socket.send(
|
|
1003
|
+
JSON.stringify({
|
|
1004
|
+
type: 'message',
|
|
1005
|
+
chatID: cf.chat.chat_id,
|
|
1006
|
+
user_id: cf.user_id,
|
|
1007
|
+
app_name: (window as any).appName
|
|
1008
|
+
})
|
|
1009
|
+
);
|
|
1010
|
+
});
|
|
1011
|
+
let interVal: any = 0;
|
|
1012
|
+
socket.addEventListener('message', function (event: any) {
|
|
1013
|
+
const data = JSON.parse(event.data);
|
|
1014
|
+
console.log(`message_in`, data.data);
|
|
1015
|
+
if (data.type === 'update_read_count') {
|
|
1016
|
+
vm.last_read = data.data;
|
|
1017
|
+
} else {
|
|
1018
|
+
vm.data.push(data);
|
|
1019
|
+
const element: any = document.querySelector('.chatContainer')!;
|
|
1020
|
+
const st = element.scrollTop;
|
|
1021
|
+
const ofs = element.offsetHeight;
|
|
1022
|
+
const sh = element.scrollHeight;
|
|
1023
|
+
for (const dd of document.querySelectorAll('.time-mute')) {
|
|
1024
|
+
dd.remove();
|
|
1025
|
+
}
|
|
1026
|
+
(document.querySelector(`#message-lines`) as any).innerHTML += CustomerMessageUser.message_line(data, vm.data.length-1, gvc, vm, cf, chatRoomInf);
|
|
1027
|
+
if (st + ofs >= sh - 50) {
|
|
1028
|
+
element.scrollTop = element.scrollHeight;
|
|
1029
|
+
let clock=gvc.glitter.ut.clock()
|
|
1030
|
+
const interval=setInterval(()=>{
|
|
1031
|
+
if(clock.stop()>1000){
|
|
1032
|
+
clearInterval(interval)
|
|
1033
|
+
}
|
|
1034
|
+
element.scrollTop = element.scrollHeight;
|
|
1035
|
+
},50)
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
console.log('Message from server:', event.data);
|
|
1039
|
+
});
|
|
1040
|
+
socket.addEventListener('close', function (event: any) {
|
|
1041
|
+
console.log('Disconnected from server');
|
|
1042
|
+
if (!vm.close) {
|
|
1043
|
+
console.log('Reconnected from server');
|
|
1044
|
+
connect();
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
connect();
|
|
1050
|
+
const textAreaId = gvc.glitter.getUUID();
|
|
1051
|
+
const html = String.raw;
|
|
1052
|
+
return {
|
|
1053
|
+
bind: viewId,
|
|
1054
|
+
view: () => {
|
|
1055
|
+
let imageArray: any[] = []
|
|
1056
|
+
if (vm.loading) {
|
|
1057
|
+
return String.raw`<div class="d-flex align-items-center justify-content-center w-100 flex-column pt-3">
|
|
1058
|
+
<div class="spinner-border" role="status">
|
|
1059
|
+
<span class="sr-only"></span>
|
|
1060
|
+
</div>
|
|
1061
|
+
<span class="mt-2">載入中...</span>
|
|
1062
|
+
</div>`;
|
|
1063
|
+
}
|
|
1064
|
+
return html` ${gvc.bindView(() => {
|
|
1065
|
+
return {
|
|
1066
|
+
bind: messageID,
|
|
1067
|
+
view: () => {
|
|
1068
|
+
try {
|
|
1069
|
+
return `
|
|
1070
|
+
<div class="my-auto flex-fill"></div>
|
|
1071
|
+
<div class="w-100" id="message-lines">
|
|
1072
|
+
${vm.data
|
|
1073
|
+
.map((dd: any, index: number) => {
|
|
1074
|
+
return CustomerMessageUser.message_line(dd, index, gvc, vm, cf, chatRoomInf)
|
|
1075
|
+
|
|
1076
|
+
})
|
|
1077
|
+
.join('')}
|
|
1078
|
+
</div>
|
|
1079
|
+
${
|
|
1080
|
+
vm.data.length === 0
|
|
1081
|
+
? `
|
|
1082
|
+
<div class="w-100 text-center no_message"><div class="badge bg-secondary">尚未展開對話,於下方輸入訊息並傳送。</div></div>
|
|
1083
|
+
`
|
|
1084
|
+
: ``
|
|
1085
|
+
}`;
|
|
1086
|
+
} catch (e) {
|
|
1087
|
+
console.log(e)
|
|
1088
|
+
return `${e}`
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
},
|
|
1092
|
+
divCreate: {
|
|
1093
|
+
class: `chatContainer p-3 d-flex flex-column `,
|
|
1094
|
+
style: `overflow-y: auto;height: calc(100% - 150px);background: white;padding-bottom:${cf.hideBar ? `80` : `0`}px !important;`,
|
|
1095
|
+
},
|
|
1096
|
+
onCreate: () => {
|
|
1097
|
+
vm.close = false;
|
|
1098
|
+
// 取得要監聽的元素
|
|
1099
|
+
let targetElement = document.querySelector('.chatContainer')!;
|
|
1100
|
+
if (vm.lastScroll === -1) {
|
|
1101
|
+
const clock= gvc.glitter.ut.clock()
|
|
1102
|
+
const interval=setInterval(()=>{
|
|
1103
|
+
if(clock.stop()>1000){
|
|
1104
|
+
clearInterval(interval)
|
|
1105
|
+
}
|
|
1106
|
+
document.querySelector('.chatContainer')!.scrollTop = document.querySelector('.chatContainer')!.scrollHeight;
|
|
1107
|
+
},50)
|
|
1108
|
+
} else {
|
|
1109
|
+
if (vm.prefixScroll) {
|
|
1110
|
+
vm.lastScroll = targetElement.scrollHeight - vm.prefixScroll + vm.lastScroll;
|
|
1111
|
+
vm.prefixScroll = 0;
|
|
1112
|
+
}
|
|
1113
|
+
document.querySelector('.chatContainer')!.scrollTop = vm.lastScroll;
|
|
1114
|
+
}
|
|
1115
|
+
// 添加滾動事件監聽器
|
|
1116
|
+
targetElement.addEventListener('scroll', () => {
|
|
1117
|
+
vm.lastScroll = targetElement.scrollTop;
|
|
1118
|
+
if (targetElement.scrollTop === 0) {
|
|
1119
|
+
if (vm.loading) {
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
vm.loading = true;
|
|
1123
|
+
Chat.getMessage({
|
|
1124
|
+
page: 0,
|
|
1125
|
+
limit: 50,
|
|
1126
|
+
chat_id: cf.chat.chat_id,
|
|
1127
|
+
olderID: vm.data[0].id,
|
|
1128
|
+
user_id: cf.user_id,
|
|
1129
|
+
}).then((res) => {
|
|
1130
|
+
vm.loading = false;
|
|
1131
|
+
vm.prefixScroll = targetElement.scrollHeight;
|
|
1132
|
+
vm.data = res.response.data.reverse().concat(vm.data);
|
|
1133
|
+
gvc.notifyDataChange(viewId);
|
|
1134
|
+
});
|
|
1135
|
+
}
|
|
1136
|
+
});
|
|
1137
|
+
},
|
|
1138
|
+
};
|
|
1139
|
+
})}
|
|
1140
|
+
${gvc.bindView({
|
|
1141
|
+
bind: "inputRow",
|
|
1142
|
+
view: () => {
|
|
1143
|
+
return html`
|
|
1144
|
+
${gvc.bindView({
|
|
1145
|
+
bind: 'imageBox',
|
|
1146
|
+
view: () => {
|
|
1147
|
+
if (imageArray.length == 0) {
|
|
1148
|
+
return ``
|
|
1149
|
+
} else {
|
|
1150
|
+
return html`
|
|
1151
|
+
<div class="d-flex align-items-center w-100"
|
|
1152
|
+
style="overflow-x: scroll;gap: 5px;padding:10px 0;margin-bottom:10px;">
|
|
1153
|
+
${(() => {
|
|
1154
|
+
return imageArray.map((url: string,index:number) => {
|
|
1155
|
+
return html`
|
|
1156
|
+
<div class=""
|
|
1157
|
+
style="position: relative;flex-shrink: 0;width: 25%;aspect-ratio: 1 / 1;background:50%/cover url('${url}')">
|
|
1158
|
+
<i class="fa-sharp fa-regular fa-circle-xmark bg-white"
|
|
1159
|
+
style="position: absolute;right: -6px;top: -6px;cursor:pointer;font-size: 20px" onclick="${gvc.event(()=>{
|
|
1160
|
+
imageArray.splice(index,1)
|
|
1161
|
+
gvc.notifyDataChange('imageBox')
|
|
1162
|
+
})}"></i>
|
|
1163
|
+
</div>
|
|
1164
|
+
`
|
|
1165
|
+
})
|
|
1166
|
+
})()}
|
|
1167
|
+
|
|
1168
|
+
</div>
|
|
1169
|
+
`
|
|
1170
|
+
}
|
|
1171
|
+
}, divCreate: {
|
|
1172
|
+
class: `d-flex w-100`,
|
|
1173
|
+
style: ``
|
|
1174
|
+
}
|
|
1175
|
+
})}
|
|
1176
|
+
<div class="d-flex w-100">
|
|
1177
|
+
<div class="d-flex align-items-center">
|
|
1178
|
+
<button
|
|
1179
|
+
type="button"
|
|
1180
|
+
class="btn btn-icon d-sm-inline-flex text-white"
|
|
1181
|
+
style="height: 36px;"
|
|
1182
|
+
onclick="${gvc.event(() => {
|
|
1183
|
+
const queryParams = new URLSearchParams(window.location.search);
|
|
1184
|
+
|
|
1185
|
+
if (queryParams.get('function') != "backend-manger") {
|
|
1186
|
+
gvc.glitter.ut.chooseMediaCallback({
|
|
1187
|
+
single: true,
|
|
1188
|
+
accept: 'json,image/*',
|
|
1189
|
+
callback(data: any) {
|
|
1190
|
+
const saasConfig: {
|
|
1191
|
+
config: any;
|
|
1192
|
+
api: any
|
|
1193
|
+
} = (window as any).saasConfig;
|
|
1194
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
1195
|
+
dialog.dataLoading({visible: true});
|
|
1196
|
+
const file = data[0].file;
|
|
1197
|
+
saasConfig.api.uploadFile(file.name).then((data: any) => {
|
|
1198
|
+
dialog.dataLoading({visible: false});
|
|
1199
|
+
const data1 = data.response;
|
|
1200
|
+
dialog.dataLoading({visible: true});
|
|
1201
|
+
const objP: any = {
|
|
1202
|
+
url: data1.url,
|
|
1203
|
+
type: 'put',
|
|
1204
|
+
data: file,
|
|
1205
|
+
headers: {
|
|
1206
|
+
"Content-Type": data1.type
|
|
1207
|
+
},
|
|
1208
|
+
processData: false,
|
|
1209
|
+
crossDomain: true,
|
|
1210
|
+
success: () => {
|
|
1211
|
+
dialog.dataLoading({visible: false});
|
|
1212
|
+
|
|
1213
|
+
imageArray.push(data1.fullUrl);
|
|
1214
|
+
gvc.notifyDataChange(`inputRow`);
|
|
1215
|
+
},
|
|
1216
|
+
error: () => {
|
|
1217
|
+
dialog.dataLoading({visible: false});
|
|
1218
|
+
dialog.errorMessage({text: '上傳失敗'});
|
|
1219
|
+
},
|
|
1220
|
+
}
|
|
1221
|
+
if (file.type.indexOf('svg') !== -1) {
|
|
1222
|
+
objP["headers"] = {
|
|
1223
|
+
"Content-Type": file.type
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
$.ajax(objP);
|
|
1227
|
+
});
|
|
1228
|
+
},
|
|
1229
|
+
});
|
|
1230
|
+
} else {
|
|
1231
|
+
imageLibrary.selectImageLibrary(gvc, (urlArray) => {
|
|
1232
|
+
imageArray.push(...urlArray.map((data) => {
|
|
1233
|
+
return data.data
|
|
1234
|
+
}))
|
|
1235
|
+
// postMD.content_array = id
|
|
1236
|
+
// obj.gvc.notifyDataChange(bi)
|
|
1237
|
+
gvc.notifyDataChange(`inputRow`)
|
|
1238
|
+
}, `<div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">圖片庫</div>`
|
|
1239
|
+
, {mul: true})
|
|
1240
|
+
}
|
|
1241
|
+
|
|
1242
|
+
})}"
|
|
1243
|
+
>
|
|
1244
|
+
<i class="fa-sharp fa-solid fa-image"
|
|
1245
|
+
style="font-size: 23px;color: #393939;"></i>
|
|
1246
|
+
</button>
|
|
1247
|
+
</div>
|
|
1248
|
+
|
|
1249
|
+
<div class="position-relative w-100 me-2 ms-1 d-flex flex-column"
|
|
1250
|
+
style="">
|
|
1251
|
+
${gvc.bindView(() => {
|
|
1252
|
+
return {
|
|
1253
|
+
bind: textAreaId,
|
|
1254
|
+
view: () => {
|
|
1255
|
+
return vm.message ?? '';
|
|
1256
|
+
},
|
|
1257
|
+
divCreate: {
|
|
1258
|
+
elem: `textArea`,
|
|
1259
|
+
style: `max-height:100px;white-space: pre-wrap; word-wrap: break-word;height:40px;min-height:auto;height:45px;`,
|
|
1260
|
+
class: `form-control`,
|
|
1261
|
+
option: [
|
|
1262
|
+
{key: 'placeholder', value: '輸入訊息內容'},
|
|
1263
|
+
{
|
|
1264
|
+
key: 'onchange',
|
|
1265
|
+
value: gvc.event((e) => {
|
|
1266
|
+
vm.message = e.value;
|
|
1267
|
+
}),
|
|
1268
|
+
},
|
|
1269
|
+
],
|
|
1270
|
+
},
|
|
1271
|
+
onCreate: () => {
|
|
1272
|
+
const input = gvc.getBindViewElem(id).get(0);
|
|
1273
|
+
input.addEventListener('input', function () {
|
|
1274
|
+
console.log(`input.scrollHeight->`, input.scrollHeight);
|
|
1275
|
+
input.style.height = 'auto'; // 重置高度
|
|
1276
|
+
input.style.height = input.scrollHeight + 'px'; // 设置为内容高度
|
|
1277
|
+
});
|
|
1278
|
+
|
|
1279
|
+
// autosize(gvc.getBindViewElem(id))
|
|
1280
|
+
},
|
|
1281
|
+
};
|
|
1282
|
+
})}
|
|
1283
|
+
</div>
|
|
1284
|
+
<div class="d-flex align-items-end h-100">
|
|
1285
|
+
<button
|
|
1286
|
+
type="button"
|
|
1287
|
+
class="btn btn-icon btn-lg d-sm-inline-flex ms-1 text-white"
|
|
1288
|
+
style="background: ${CustomerMessageUser.config.color};height:45px;"
|
|
1289
|
+
onclick="${gvc.event(() => {
|
|
1290
|
+
const dialog = new ShareDialog(gvc.glitter);
|
|
1291
|
+
if (!imageArray.length && !vm.message) {
|
|
1292
|
+
dialog.errorMessage({text: '請輸入訊息'})
|
|
1293
|
+
return
|
|
1294
|
+
}
|
|
1295
|
+
dialog.dataLoading({
|
|
1296
|
+
visible: true
|
|
1297
|
+
})
|
|
1298
|
+
if (imageArray.length) {
|
|
1299
|
+
dialog.dataLoading({
|
|
1300
|
+
visible: true
|
|
1301
|
+
})
|
|
1302
|
+
for (const image of imageArray) {
|
|
1303
|
+
|
|
1304
|
+
Chat.postMessage({
|
|
1305
|
+
chat_id: cf.chat.chat_id,
|
|
1306
|
+
user_id: cf.user_id,
|
|
1307
|
+
message: {
|
|
1308
|
+
image: image,
|
|
1309
|
+
attachment: '',
|
|
1310
|
+
},
|
|
1311
|
+
}).then((res) => {
|
|
1312
|
+
imageArray = [];
|
|
1313
|
+
gvc.notifyDataChange('imageBox')
|
|
1314
|
+
dialog.dataLoading({
|
|
1315
|
+
visible: false
|
|
1316
|
+
})
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
if (vm.message) {
|
|
1321
|
+
dialog.dataLoading({
|
|
1322
|
+
visible: true
|
|
1323
|
+
})
|
|
1324
|
+
Chat.postMessage({
|
|
1325
|
+
chat_id: cf.chat.chat_id,
|
|
1326
|
+
user_id: cf.user_id,
|
|
1327
|
+
message: {
|
|
1328
|
+
text: vm.message,
|
|
1329
|
+
attachment: '',
|
|
1330
|
+
},
|
|
1331
|
+
}).then((res) => {
|
|
1332
|
+
vm.message = '';
|
|
1333
|
+
console.log(res)
|
|
1334
|
+
dialog.dataLoading({
|
|
1335
|
+
visible: false
|
|
1336
|
+
})
|
|
1337
|
+
});
|
|
1338
|
+
const textArea = gvc.getBindViewElem(textAreaId).get(0);
|
|
1339
|
+
textArea.value = '';
|
|
1340
|
+
vm.message = '';
|
|
1341
|
+
|
|
1342
|
+
// textArea.focus();
|
|
1343
|
+
}
|
|
1344
|
+
(document.querySelector('.no_message') as any).remove()
|
|
1345
|
+
})}"
|
|
1346
|
+
>
|
|
1347
|
+
<i class="fa-regular fa-paper-plane-top"></i>
|
|
1348
|
+
</button>
|
|
1349
|
+
</div>
|
|
1350
|
+
</div>
|
|
1351
|
+
|
|
1352
|
+
|
|
1353
|
+
`
|
|
1354
|
+
}, divCreate: {
|
|
1355
|
+
class: `card-footer border-top d-flex flex-column align-items-center w-100 border-0 pt-3 pb-3 pe-4 ps-3 position-fixed bottom-0 position-sm-absolute`,
|
|
1356
|
+
style: `background: white;min-height:45px;`
|
|
1357
|
+
}
|
|
1358
|
+
})}`;
|
|
1359
|
+
},
|
|
1360
|
+
divCreate: {
|
|
1361
|
+
class:`h-100`
|
|
1362
|
+
},
|
|
1363
|
+
onCreate: () => {
|
|
1364
|
+
},
|
|
1365
|
+
onDestroy: () => {
|
|
1366
|
+
vm.close = true;
|
|
1367
|
+
socket.close();
|
|
1368
|
+
},
|
|
1369
|
+
};
|
|
1370
|
+
}),
|
|
1371
|
+
].join(''))
|
|
1372
|
+
})
|
|
1373
|
+
},
|
|
1374
|
+
divCreate:{
|
|
1375
|
+
class:`h-100 bg-white w-100`
|
|
1376
|
+
}
|
|
1377
|
+
};
|
|
1378
|
+
});
|
|
1379
|
+
}, 'CustomerMessageUser',{
|
|
1380
|
+
animation:Animation.fade
|
|
1381
|
+
})
|
|
1382
|
+
}
|
|
1383
|
+
|
|
849
1384
|
public static robotMessage(gvc: GVC, goToChat: (text: string) => void) {
|
|
850
1385
|
const html = String.raw;
|
|
851
1386
|
return gvc.bindView(() => {
|
|
@@ -929,17 +1464,19 @@ export class CustomerMessageUser {
|
|
|
929
1464
|
const html = String.raw
|
|
930
1465
|
|
|
931
1466
|
function drawChatContent() {
|
|
932
|
-
|
|
1467
|
+
return `<span style="white-space: normal;word-break: break-all;">${(()=>{
|
|
1468
|
+
if (dd.message.image) {
|
|
933
1469
|
|
|
934
|
-
|
|
1470
|
+
return html`<img style="cursor: pointer;"
|
|
935
1471
|
src="${dd.message.image}"
|
|
936
1472
|
alt="image"
|
|
937
1473
|
onclick="${gvc.event(() => {
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
1474
|
+
gvc.glitter.openDiaLog(new URL('./dialog/image-preview.js', gvc.glitter.root_path).href, 'preview', dd.message.image)
|
|
1475
|
+
})}">`
|
|
1476
|
+
} else {
|
|
1477
|
+
return dd.message.text.replace(/\n/g, '<br>')
|
|
1478
|
+
}
|
|
1479
|
+
})()}</span>`
|
|
943
1480
|
}
|
|
944
1481
|
|
|
945
1482
|
dd.message.text = dd.message.text || "";
|
|
@@ -537,18 +537,18 @@ export class ShoppingFinanceSetting {
|
|
|
537
537
|
BgWidget.editeInput({
|
|
538
538
|
gvc: gvc,
|
|
539
539
|
title: '串接帳號',
|
|
540
|
-
default: key_d.
|
|
540
|
+
default: key_d.account,
|
|
541
541
|
callback: (text) => {
|
|
542
|
-
key_d.
|
|
542
|
+
key_d.account = text;
|
|
543
543
|
},
|
|
544
544
|
placeHolder: '請輸入串接帳號',
|
|
545
545
|
}),
|
|
546
546
|
BgWidget.editeInput({
|
|
547
547
|
gvc: gvc,
|
|
548
548
|
title: '串接密碼',
|
|
549
|
-
default: key_d.
|
|
549
|
+
default: key_d.pwd,
|
|
550
550
|
callback: (text) => {
|
|
551
|
-
key_d.
|
|
551
|
+
key_d.pwd = text;
|
|
552
552
|
},
|
|
553
553
|
placeHolder: '請輸入串接密碼',
|
|
554
554
|
})
|