chat-customer-47net 1.1.0 → 1.1.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/chat-customer-47net.es.js +200 -39
- package/chat-customer-47net.umd.js +1148 -1045
- package/package.json +1 -1
- package/style.css +1 -1
|
@@ -1004,6 +1004,10 @@ const __vue2_script$7 = {
|
|
|
1004
1004
|
initData: {
|
|
1005
1005
|
type: Object,
|
|
1006
1006
|
default: () => ({})
|
|
1007
|
+
},
|
|
1008
|
+
buttonLock: {
|
|
1009
|
+
type: Boolean,
|
|
1010
|
+
default: false
|
|
1007
1011
|
}
|
|
1008
1012
|
},
|
|
1009
1013
|
computed: {
|
|
@@ -1077,7 +1081,7 @@ const __vue2_script$7 = {
|
|
|
1077
1081
|
}
|
|
1078
1082
|
};
|
|
1079
1083
|
const __cssModules$7 = {};
|
|
1080
|
-
var __component__$7 = /* @__PURE__ */normalizeComponent(__vue2_script$7, render$8, staticRenderFns$7, false, __vue2_injectStyles$7, "
|
|
1084
|
+
var __component__$7 = /* @__PURE__ */normalizeComponent(__vue2_script$7, render$8, staticRenderFns$7, false, __vue2_injectStyles$7, "4b80e726", null, null);
|
|
1081
1085
|
function __vue2_injectStyles$7(context) {
|
|
1082
1086
|
for (let o in __cssModules$7) {
|
|
1083
1087
|
this[o] = __cssModules$7[o];
|
|
@@ -6100,7 +6104,12 @@ var render$5 = function () {
|
|
|
6100
6104
|
}
|
|
6101
6105
|
}, [_vm.userOrOther === "user" || _vm.itemUserId === _vm.userId ? _c("div", {
|
|
6102
6106
|
staticClass: "consult-47this-chat-item-user"
|
|
6103
|
-
}, [_c("p", [
|
|
6107
|
+
}, [_c("p", [_c("b", {
|
|
6108
|
+
staticClass: "markdown-body",
|
|
6109
|
+
domProps: {
|
|
6110
|
+
"innerHTML": _vm._s(_vm.markdownToHtml)
|
|
6111
|
+
}
|
|
6112
|
+
}), _c("span", {
|
|
6104
6113
|
staticClass: "time"
|
|
6105
6114
|
}, [_vm._v(_vm._s(_vm.time))])])]) : _c("div", {
|
|
6106
6115
|
staticClass: "consult-47this-chat-item-consult"
|
|
@@ -6325,6 +6334,10 @@ const __vue2_script$4 = {
|
|
|
6325
6334
|
activeItem: {
|
|
6326
6335
|
type: Object,
|
|
6327
6336
|
default: () => ({})
|
|
6337
|
+
},
|
|
6338
|
+
socket: {
|
|
6339
|
+
type: Object,
|
|
6340
|
+
default: () => ({})
|
|
6328
6341
|
}
|
|
6329
6342
|
},
|
|
6330
6343
|
data() {
|
|
@@ -6345,9 +6358,14 @@ const __vue2_script$4 = {
|
|
|
6345
6358
|
},
|
|
6346
6359
|
markdownToHtml() {
|
|
6347
6360
|
const text = this.message.replace(/ {2,}/g, match => " ".repeat(match.length));
|
|
6361
|
+
const renderer = new marked.Renderer();
|
|
6362
|
+
renderer.link = href => {
|
|
6363
|
+
return `<a href="${href.href}" target="_blank" rel="noopener noreferrer"${href.title ? ` title="${href.title}"` : ""}>${href.text}</a>`;
|
|
6364
|
+
};
|
|
6348
6365
|
marked.setOptions({
|
|
6349
6366
|
breaks: true,
|
|
6350
|
-
sanitize: false
|
|
6367
|
+
sanitize: false,
|
|
6368
|
+
renderer
|
|
6351
6369
|
});
|
|
6352
6370
|
return marked(text);
|
|
6353
6371
|
}
|
|
@@ -6363,9 +6381,6 @@ const __vue2_script$4 = {
|
|
|
6363
6381
|
roomId: this.roomId,
|
|
6364
6382
|
userId: this.userId
|
|
6365
6383
|
}, this.initData.socketUrl);
|
|
6366
|
-
if (this.initData.socket) {
|
|
6367
|
-
this.initData.socket.emit("setVisitedpage", this.userId, window.location.href, this.initData.siteName);
|
|
6368
|
-
}
|
|
6369
6384
|
} catch (error) {
|
|
6370
6385
|
console.error("changeByHumanAgent error:", error);
|
|
6371
6386
|
} finally {
|
|
@@ -6469,7 +6484,7 @@ const __vue2_script$4 = {
|
|
|
6469
6484
|
}
|
|
6470
6485
|
};
|
|
6471
6486
|
const __cssModules$4 = {};
|
|
6472
|
-
var __component__$4 = /* @__PURE__ */normalizeComponent(__vue2_script$4, render$5, staticRenderFns$4, false, __vue2_injectStyles$4, "
|
|
6487
|
+
var __component__$4 = /* @__PURE__ */normalizeComponent(__vue2_script$4, render$5, staticRenderFns$4, false, __vue2_injectStyles$4, "0db74679", null, null);
|
|
6473
6488
|
function __vue2_injectStyles$4(context) {
|
|
6474
6489
|
for (let o in __cssModules$4) {
|
|
6475
6490
|
this[o] = __cssModules$4[o];
|
|
@@ -6519,7 +6534,8 @@ var render$3 = function () {
|
|
|
6519
6534
|
"init-data": _vm.initData,
|
|
6520
6535
|
"type": item.type,
|
|
6521
6536
|
"update-time": item.updateTime,
|
|
6522
|
-
"active-item": _vm.activeItem
|
|
6537
|
+
"active-item": _vm.activeItem,
|
|
6538
|
+
"socket": _vm.socket
|
|
6523
6539
|
},
|
|
6524
6540
|
on: {
|
|
6525
6541
|
"submitEmail": _vm.submitEmail,
|
|
@@ -6602,6 +6618,10 @@ const __vue2_script$3 = {
|
|
|
6602
6618
|
activeItem: {
|
|
6603
6619
|
type: Object,
|
|
6604
6620
|
default: () => ({})
|
|
6621
|
+
},
|
|
6622
|
+
socket: {
|
|
6623
|
+
type: Object,
|
|
6624
|
+
default: () => ({})
|
|
6605
6625
|
}
|
|
6606
6626
|
},
|
|
6607
6627
|
data() {
|
|
@@ -6668,6 +6688,7 @@ const __vue2_script$3 = {
|
|
|
6668
6688
|
},
|
|
6669
6689
|
updateMessage(event) {
|
|
6670
6690
|
this.message = event.target.value;
|
|
6691
|
+
this.$emit("updateMessage");
|
|
6671
6692
|
},
|
|
6672
6693
|
loadMore() {
|
|
6673
6694
|
if (this.isInit || this.loading || this.noMore) {
|
|
@@ -6734,7 +6755,7 @@ const __vue2_script$3 = {
|
|
|
6734
6755
|
}
|
|
6735
6756
|
};
|
|
6736
6757
|
const __cssModules$3 = {};
|
|
6737
|
-
var __component__$3 = /* @__PURE__ */normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "
|
|
6758
|
+
var __component__$3 = /* @__PURE__ */normalizeComponent(__vue2_script$3, render$3, staticRenderFns$3, false, __vue2_injectStyles$3, "b72de9f2", null, null);
|
|
6738
6759
|
function __vue2_injectStyles$3(context) {
|
|
6739
6760
|
for (let o in __cssModules$3) {
|
|
6740
6761
|
this[o] = __cssModules$3[o];
|
|
@@ -6775,7 +6796,8 @@ var render$2 = function () {
|
|
|
6775
6796
|
"themeColors": _vm.initData.themeColors,
|
|
6776
6797
|
"conversations": _vm.conversations,
|
|
6777
6798
|
"messages": _vm.messages,
|
|
6778
|
-
"activeItem": _vm.activeItem
|
|
6799
|
+
"activeItem": _vm.activeItem,
|
|
6800
|
+
"socket": _vm.socket
|
|
6779
6801
|
},
|
|
6780
6802
|
on: {
|
|
6781
6803
|
"handleRoute": _vm.handleRoute,
|
|
@@ -6786,7 +6808,8 @@ var render$2 = function () {
|
|
|
6786
6808
|
"loadMore": _vm.loadMore,
|
|
6787
6809
|
"submitEmail": _vm.submitEmail,
|
|
6788
6810
|
"sendLeaveMessage": _vm.sendLeaveMessage,
|
|
6789
|
-
"restart": _vm.restart
|
|
6811
|
+
"restart": _vm.restart,
|
|
6812
|
+
"updateMessage": _vm.updateMessage
|
|
6790
6813
|
}
|
|
6791
6814
|
})], 1);
|
|
6792
6815
|
};
|
|
@@ -6809,6 +6832,10 @@ const __vue2_script$2 = {
|
|
|
6809
6832
|
conversations: {
|
|
6810
6833
|
type: Array,
|
|
6811
6834
|
default: () => []
|
|
6835
|
+
},
|
|
6836
|
+
socket: {
|
|
6837
|
+
type: Object,
|
|
6838
|
+
default: () => ({})
|
|
6812
6839
|
}
|
|
6813
6840
|
},
|
|
6814
6841
|
data() {
|
|
@@ -6824,7 +6851,8 @@ const __vue2_script$2 = {
|
|
|
6824
6851
|
chatList: [],
|
|
6825
6852
|
roomId: ""
|
|
6826
6853
|
},
|
|
6827
|
-
salesUserStatus: ""
|
|
6854
|
+
salesUserStatus: "",
|
|
6855
|
+
buttonLock: false
|
|
6828
6856
|
};
|
|
6829
6857
|
},
|
|
6830
6858
|
computed: {
|
|
@@ -6858,9 +6886,6 @@ const __vue2_script$2 = {
|
|
|
6858
6886
|
};
|
|
6859
6887
|
});
|
|
6860
6888
|
return list2;
|
|
6861
|
-
},
|
|
6862
|
-
socket() {
|
|
6863
|
-
return this.initData.socket;
|
|
6864
6889
|
}
|
|
6865
6890
|
},
|
|
6866
6891
|
watch: {
|
|
@@ -6870,6 +6895,9 @@ const __vue2_script$2 = {
|
|
|
6870
6895
|
this.onListenMessage();
|
|
6871
6896
|
this.onListenEnd();
|
|
6872
6897
|
}
|
|
6898
|
+
},
|
|
6899
|
+
route(newVal, oldVal) {
|
|
6900
|
+
this.$emit("onChangeRoute", newVal);
|
|
6873
6901
|
}
|
|
6874
6902
|
},
|
|
6875
6903
|
methods: {
|
|
@@ -6877,7 +6905,7 @@ const __vue2_script$2 = {
|
|
|
6877
6905
|
this.userId = getClientId();
|
|
6878
6906
|
},
|
|
6879
6907
|
loginSocket() {
|
|
6880
|
-
this.
|
|
6908
|
+
this.socket.emit("login", {
|
|
6881
6909
|
userId: this.userId,
|
|
6882
6910
|
userName: this.initData.userName,
|
|
6883
6911
|
token: getToken(),
|
|
@@ -6896,6 +6924,8 @@ const __vue2_script$2 = {
|
|
|
6896
6924
|
this.historyRoute.push(route);
|
|
6897
6925
|
},
|
|
6898
6926
|
handleNewConversation() {
|
|
6927
|
+
if (this.buttonLock) return;
|
|
6928
|
+
this.buttonLock = true;
|
|
6899
6929
|
if (getClientId()) {
|
|
6900
6930
|
this.createNewConversation("dialog");
|
|
6901
6931
|
} else {
|
|
@@ -6911,6 +6941,7 @@ const __vue2_script$2 = {
|
|
|
6911
6941
|
siteName: this.initData.siteName
|
|
6912
6942
|
}, () => {
|
|
6913
6943
|
this.handleRoute("dialog");
|
|
6944
|
+
this.buttonLock = false;
|
|
6914
6945
|
});
|
|
6915
6946
|
},
|
|
6916
6947
|
onListenMessage() {
|
|
@@ -6955,7 +6986,7 @@ const __vue2_script$2 = {
|
|
|
6955
6986
|
setClientId(res.userId);
|
|
6956
6987
|
this.userId = res.userId;
|
|
6957
6988
|
this.createNewConversation("dialog");
|
|
6958
|
-
this.
|
|
6989
|
+
this.socket.emit("login", {
|
|
6959
6990
|
userId: this.userId,
|
|
6960
6991
|
userName: res.userName,
|
|
6961
6992
|
token: getToken(),
|
|
@@ -6985,11 +7016,15 @@ const __vue2_script$2 = {
|
|
|
6985
7016
|
if (err.status === 401) {
|
|
6986
7017
|
localStorage.setItem("auth._token.login", "false");
|
|
6987
7018
|
removeClientId();
|
|
6988
|
-
this.handleRoute("
|
|
7019
|
+
this.handleRoute("cover");
|
|
6989
7020
|
}
|
|
7021
|
+
}).finally(() => {
|
|
7022
|
+
this.buttonLock = false;
|
|
6990
7023
|
});
|
|
6991
7024
|
},
|
|
6992
7025
|
handleToConversation(conversation) {
|
|
7026
|
+
if (this.buttonLock) return;
|
|
7027
|
+
this.buttonLock = true;
|
|
6993
7028
|
this.joinRoom(conversation.roomId);
|
|
6994
7029
|
this.repeatOnChat(conversation.roomId);
|
|
6995
7030
|
this.getChatList(conversation.roomId);
|
|
@@ -7022,6 +7057,7 @@ const __vue2_script$2 = {
|
|
|
7022
7057
|
},
|
|
7023
7058
|
async getChatList(roomId) {
|
|
7024
7059
|
const query = {
|
|
7060
|
+
userId: this.userId,
|
|
7025
7061
|
roomId,
|
|
7026
7062
|
page: this.chats.page,
|
|
7027
7063
|
size: 20
|
|
@@ -7086,6 +7122,7 @@ const __vue2_script$2 = {
|
|
|
7086
7122
|
},
|
|
7087
7123
|
async loadMore(callback) {
|
|
7088
7124
|
const query = {
|
|
7125
|
+
userId: this.userId,
|
|
7089
7126
|
roomId: this.onRoomId,
|
|
7090
7127
|
page: this.chats.page,
|
|
7091
7128
|
size: 20
|
|
@@ -7183,11 +7220,14 @@ const __vue2_script$2 = {
|
|
|
7183
7220
|
}).catch(() => {
|
|
7184
7221
|
this.salesUserStatus = "";
|
|
7185
7222
|
});
|
|
7223
|
+
},
|
|
7224
|
+
updateMessage() {
|
|
7225
|
+
this.$emit("updateMessage");
|
|
7186
7226
|
}
|
|
7187
7227
|
}
|
|
7188
7228
|
};
|
|
7189
7229
|
const __cssModules$2 = {};
|
|
7190
|
-
var __component__$2 = /* @__PURE__ */normalizeComponent(__vue2_script$2, render$2, staticRenderFns$2, false, __vue2_injectStyles$2, "
|
|
7230
|
+
var __component__$2 = /* @__PURE__ */normalizeComponent(__vue2_script$2, render$2, staticRenderFns$2, false, __vue2_injectStyles$2, "28aea5c6", null, null);
|
|
7191
7231
|
function __vue2_injectStyles$2(context) {
|
|
7192
7232
|
for (let o in __cssModules$2) {
|
|
7193
7233
|
this[o] = __cssModules$2[o];
|
|
@@ -7210,7 +7250,9 @@ var render$1 = function () {
|
|
|
7210
7250
|
"touchstart": _vm.handleTouchStart,
|
|
7211
7251
|
"touchend": _vm.handleTouchEnd
|
|
7212
7252
|
}
|
|
7213
|
-
}
|
|
7253
|
+
}, [_vm.remindNum ? _c("div", {
|
|
7254
|
+
staticClass: "consult-47this-remind-num"
|
|
7255
|
+
}, [_vm._v(_vm._s(_vm.remindNum))]) : _vm._e()]);
|
|
7214
7256
|
};
|
|
7215
7257
|
var staticRenderFns$1 = [];
|
|
7216
7258
|
const ConsultButton_vue_vue_type_style_index_0_scoped_true_lang = "";
|
|
@@ -7220,11 +7262,16 @@ const __vue2_script$1 = {
|
|
|
7220
7262
|
themeColors: {
|
|
7221
7263
|
type: String,
|
|
7222
7264
|
default: "transparent"
|
|
7265
|
+
},
|
|
7266
|
+
remindNum: {
|
|
7267
|
+
type: Number,
|
|
7268
|
+
default: 0
|
|
7223
7269
|
}
|
|
7224
7270
|
},
|
|
7225
7271
|
data() {
|
|
7226
7272
|
return {
|
|
7227
7273
|
touchStartTime: 0
|
|
7274
|
+
// remindNum: 2
|
|
7228
7275
|
};
|
|
7229
7276
|
},
|
|
7230
7277
|
methods: {
|
|
@@ -7246,7 +7293,7 @@ const __vue2_script$1 = {
|
|
|
7246
7293
|
}
|
|
7247
7294
|
};
|
|
7248
7295
|
const __cssModules$1 = {};
|
|
7249
|
-
var __component__$1 = /* @__PURE__ */normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, "
|
|
7296
|
+
var __component__$1 = /* @__PURE__ */normalizeComponent(__vue2_script$1, render$1, staticRenderFns$1, false, __vue2_injectStyles$1, "3d081358", null, null);
|
|
7250
7297
|
function __vue2_injectStyles$1(context) {
|
|
7251
7298
|
for (let o in __cssModules$1) {
|
|
7252
7299
|
this[o] = __cssModules$1[o];
|
|
@@ -7272,11 +7319,15 @@ var render = function () {
|
|
|
7272
7319
|
attrs: {
|
|
7273
7320
|
"init-data": _vm.initData,
|
|
7274
7321
|
"conversations": _vm.conversations,
|
|
7275
|
-
"getInitData": _vm.getInitData
|
|
7322
|
+
"getInitData": _vm.getInitData,
|
|
7323
|
+
"socket": _vm.socket,
|
|
7324
|
+
"isSetVisitedpage": _vm.isSetVisitedpage
|
|
7276
7325
|
},
|
|
7277
7326
|
on: {
|
|
7278
7327
|
"packUp": _vm.packUp,
|
|
7279
|
-
"updateInitData": _vm.getInitData
|
|
7328
|
+
"updateInitData": _vm.getInitData,
|
|
7329
|
+
"onChangeRoute": _vm.onChangeRoute,
|
|
7330
|
+
"updateMessage": _vm.updateMessage
|
|
7280
7331
|
}
|
|
7281
7332
|
}), _vm.showButton ? _c("ConsultButton", {
|
|
7282
7333
|
directives: [{
|
|
@@ -7286,7 +7337,8 @@ var render = function () {
|
|
|
7286
7337
|
expression: "!showView"
|
|
7287
7338
|
}],
|
|
7288
7339
|
attrs: {
|
|
7289
|
-
"theme-colors": _vm.initData.themeColors
|
|
7340
|
+
"theme-colors": _vm.initData.themeColors,
|
|
7341
|
+
"remindNum": _vm.unRead
|
|
7290
7342
|
},
|
|
7291
7343
|
on: {
|
|
7292
7344
|
"click": _vm.handleClick
|
|
@@ -7312,21 +7364,50 @@ const __vue2_script = {
|
|
|
7312
7364
|
conversations: [],
|
|
7313
7365
|
userId: getClientId(),
|
|
7314
7366
|
isHandlingStorage: false,
|
|
7315
|
-
onCurrentValue: false
|
|
7367
|
+
onCurrentValue: false,
|
|
7368
|
+
onRoute: "cover",
|
|
7369
|
+
socket: null,
|
|
7370
|
+
audio: null,
|
|
7371
|
+
isAudioInited: false,
|
|
7372
|
+
onWindowUrl: window.location.href,
|
|
7373
|
+
isSetVisitedpage: true
|
|
7316
7374
|
};
|
|
7317
7375
|
},
|
|
7376
|
+
computed: {
|
|
7377
|
+
unRead() {
|
|
7378
|
+
var _a2;
|
|
7379
|
+
if (!this.initData.user) return 0;
|
|
7380
|
+
if (!this.initData.user.room) return 0;
|
|
7381
|
+
const room = this.initData.user.room;
|
|
7382
|
+
const unRead = ((_a2 = room.find(item => item.topic === this.initData.siteName)) == null ? void 0 : _a2.unRead) || 0;
|
|
7383
|
+
if (unRead > 99) {
|
|
7384
|
+
return 99;
|
|
7385
|
+
}
|
|
7386
|
+
return unRead;
|
|
7387
|
+
},
|
|
7388
|
+
customerAudio() {
|
|
7389
|
+
if (!this.initData.socketUrl) {
|
|
7390
|
+
return "";
|
|
7391
|
+
}
|
|
7392
|
+
return `${this.initData.socketUrl}/static/audio/unread.mp3`;
|
|
7393
|
+
}
|
|
7394
|
+
},
|
|
7318
7395
|
mounted() {
|
|
7319
7396
|
this.watchLocalStorage();
|
|
7320
|
-
this.setCurrentUrl();
|
|
7321
7397
|
this.onCurrentValue = localStorage.getItem("auth._token.login");
|
|
7398
|
+
document.addEventListener("touchstart", this.initAudio);
|
|
7399
|
+
document.addEventListener("click", this.initAudio);
|
|
7322
7400
|
},
|
|
7323
7401
|
beforeDestroy() {
|
|
7324
7402
|
window.removeEventListener("storage", this.handleStorageChange);
|
|
7403
|
+
document.removeEventListener("touchstart", this.initAudio);
|
|
7404
|
+
document.removeEventListener("click", this.initAudio);
|
|
7325
7405
|
if (this.unwatchRoute) this.unwatchRoute();
|
|
7326
7406
|
},
|
|
7327
7407
|
watch: {
|
|
7328
7408
|
"$route"(to, from) {
|
|
7329
|
-
this.
|
|
7409
|
+
this.onWindowUrl = window.location.href;
|
|
7410
|
+
this.isSetVisitedpage = true;
|
|
7330
7411
|
}
|
|
7331
7412
|
},
|
|
7332
7413
|
methods: {
|
|
@@ -7352,13 +7433,19 @@ const __vue2_script = {
|
|
|
7352
7433
|
},
|
|
7353
7434
|
// 获取当前页面的URL
|
|
7354
7435
|
setCurrentUrl() {
|
|
7355
|
-
if (this.
|
|
7356
|
-
this.
|
|
7436
|
+
if (this.socket) {
|
|
7437
|
+
this.socket.emit("setVisitedpage", this.userId, window.location.href, this.initData.siteName);
|
|
7438
|
+
}
|
|
7439
|
+
},
|
|
7440
|
+
updateMessage() {
|
|
7441
|
+
if (this.isSetVisitedpage) {
|
|
7442
|
+
this.setCurrentUrl();
|
|
7443
|
+
this.isSetVisitedpage = false;
|
|
7357
7444
|
}
|
|
7358
7445
|
},
|
|
7359
7446
|
logOut() {
|
|
7360
|
-
if (this.
|
|
7361
|
-
this.
|
|
7447
|
+
if (this.socket) {
|
|
7448
|
+
this.socket.emit("logOut");
|
|
7362
7449
|
}
|
|
7363
7450
|
},
|
|
7364
7451
|
async handleStorageChange(e) {
|
|
@@ -7383,7 +7470,7 @@ const __vue2_script = {
|
|
|
7383
7470
|
this.changeRoute("cover");
|
|
7384
7471
|
const user = await getNxcUserOrCreate({}, this.initData.socketUrl);
|
|
7385
7472
|
this.userId = user.userId;
|
|
7386
|
-
this.initData
|
|
7473
|
+
this.$set(this.initData, "user", user);
|
|
7387
7474
|
setClientId(this.userId);
|
|
7388
7475
|
this.conversations = [];
|
|
7389
7476
|
this.getConversations();
|
|
@@ -7392,7 +7479,7 @@ const __vue2_script = {
|
|
|
7392
7479
|
console.log("err", err);
|
|
7393
7480
|
if (err.status === 401) {
|
|
7394
7481
|
this.userId = "";
|
|
7395
|
-
this.initData
|
|
7482
|
+
this.$set(this.initData, "user", {});
|
|
7396
7483
|
this.conversations = [];
|
|
7397
7484
|
this.changeRoute("cover");
|
|
7398
7485
|
localStorage.setItem("auth._token.login", false);
|
|
@@ -7406,7 +7493,7 @@ const __vue2_script = {
|
|
|
7406
7493
|
} else {
|
|
7407
7494
|
setClientId("");
|
|
7408
7495
|
this.userId = "";
|
|
7409
|
-
this.initData
|
|
7496
|
+
this.$set(this.initData, "user", {});
|
|
7410
7497
|
this.conversations = [];
|
|
7411
7498
|
this.logOut();
|
|
7412
7499
|
this.changeRoute("cover");
|
|
@@ -7419,9 +7506,30 @@ const __vue2_script = {
|
|
|
7419
7506
|
},
|
|
7420
7507
|
handleClick() {
|
|
7421
7508
|
this.showView = true;
|
|
7509
|
+
if (this.onRoute === "dialog") {
|
|
7510
|
+
this.updateOpenView(true);
|
|
7511
|
+
this.clearClinetUnRead();
|
|
7512
|
+
if (this.$refs.consultContainer) {
|
|
7513
|
+
this.$refs.consultContainer.scrollToBottom();
|
|
7514
|
+
}
|
|
7515
|
+
}
|
|
7422
7516
|
},
|
|
7423
7517
|
packUp() {
|
|
7424
7518
|
this.showView = false;
|
|
7519
|
+
this.updateOpenView(false);
|
|
7520
|
+
},
|
|
7521
|
+
updateOpenView(isOpenView) {
|
|
7522
|
+
this.socket.emit("updateOpenView", {
|
|
7523
|
+
isOpenView,
|
|
7524
|
+
userId: this.userId,
|
|
7525
|
+
siteName: this.initData.siteName
|
|
7526
|
+
});
|
|
7527
|
+
},
|
|
7528
|
+
clearClinetUnRead() {
|
|
7529
|
+
this.socket.emit("clearClinetUnRead", {
|
|
7530
|
+
siteName: this.initData.siteName
|
|
7531
|
+
});
|
|
7532
|
+
this.updateUserUnRead(0);
|
|
7425
7533
|
},
|
|
7426
7534
|
getConversations() {
|
|
7427
7535
|
if (!this.userId) return;
|
|
@@ -7443,8 +7551,10 @@ const __vue2_script = {
|
|
|
7443
7551
|
getUser({
|
|
7444
7552
|
userId: this.userId
|
|
7445
7553
|
}, this.initData.socketUrl).then(res => {
|
|
7446
|
-
|
|
7447
|
-
|
|
7554
|
+
if (res) {
|
|
7555
|
+
this.$set(this.initData, "user", res);
|
|
7556
|
+
removeVisitor(res.createTime);
|
|
7557
|
+
}
|
|
7448
7558
|
});
|
|
7449
7559
|
},
|
|
7450
7560
|
getInitData() {
|
|
@@ -7453,12 +7563,29 @@ const __vue2_script = {
|
|
|
7453
7563
|
this.getConversations();
|
|
7454
7564
|
},
|
|
7455
7565
|
onUpdateConversations() {
|
|
7456
|
-
this.
|
|
7566
|
+
this.socket.on("updateConversations", () => {
|
|
7457
7567
|
this.getInitData();
|
|
7458
7568
|
});
|
|
7459
7569
|
},
|
|
7570
|
+
onUpdateUserUnRead() {
|
|
7571
|
+
this.socket.on("updateUserUnRead", data => {
|
|
7572
|
+
this.updateUserUnRead(data);
|
|
7573
|
+
});
|
|
7574
|
+
},
|
|
7575
|
+
updateUserUnRead(unRead) {
|
|
7576
|
+
var _a2;
|
|
7577
|
+
const room = ((_a2 = this.initData.user) == null ? void 0 : _a2.room) || [];
|
|
7578
|
+
room.forEach(item => {
|
|
7579
|
+
if (item.topic === this.initData.siteName) {
|
|
7580
|
+
this.$set(item, "unRead", unRead);
|
|
7581
|
+
}
|
|
7582
|
+
});
|
|
7583
|
+
if (unRead && unRead > 0) {
|
|
7584
|
+
this.playAudio();
|
|
7585
|
+
}
|
|
7586
|
+
},
|
|
7460
7587
|
joinRoom(roomId) {
|
|
7461
|
-
this.
|
|
7588
|
+
this.socket.emit("join", {
|
|
7462
7589
|
userId: this.userId,
|
|
7463
7590
|
roomId: "",
|
|
7464
7591
|
token: getToken(),
|
|
@@ -7468,6 +7595,38 @@ const __vue2_script = {
|
|
|
7468
7595
|
changeRoute(route) {
|
|
7469
7596
|
this.$refs.consultContainer.handleRoute(route);
|
|
7470
7597
|
},
|
|
7598
|
+
onChangeRoute(route) {
|
|
7599
|
+
this.onRoute = route;
|
|
7600
|
+
if (route === "cover") {
|
|
7601
|
+
this.updateOpenView(false);
|
|
7602
|
+
}
|
|
7603
|
+
if (route === "dialog") {
|
|
7604
|
+
this.updateOpenView(true);
|
|
7605
|
+
this.clearClinetUnRead();
|
|
7606
|
+
}
|
|
7607
|
+
},
|
|
7608
|
+
initAudio() {
|
|
7609
|
+
if (this.isAudioInited || !this.audio) return;
|
|
7610
|
+
this.audio.muted = true;
|
|
7611
|
+
this.audio.play().then(() => {
|
|
7612
|
+
this.audio.pause();
|
|
7613
|
+
this.audio.currentTime = 0;
|
|
7614
|
+
this.audio.muted = false;
|
|
7615
|
+
this.isAudioInited = true;
|
|
7616
|
+
}).catch(error => {
|
|
7617
|
+
console.error("audio play error:", error);
|
|
7618
|
+
});
|
|
7619
|
+
},
|
|
7620
|
+
playAudio() {
|
|
7621
|
+
if (this.audio) {
|
|
7622
|
+
clearTimeout(this.audioTimer);
|
|
7623
|
+
this.audioTimer = setTimeout(() => {
|
|
7624
|
+
this.audio.pause();
|
|
7625
|
+
this.audio.currentTime = 0;
|
|
7626
|
+
this.audio.play();
|
|
7627
|
+
}, 200);
|
|
7628
|
+
}
|
|
7629
|
+
},
|
|
7471
7630
|
async init(data, callback, error) {
|
|
7472
7631
|
if (!data) {
|
|
7473
7632
|
error && error("data is required");
|
|
@@ -7488,8 +7647,10 @@ const __vue2_script = {
|
|
|
7488
7647
|
const {
|
|
7489
7648
|
io
|
|
7490
7649
|
} = await Promise.resolve().then(() => _interopRequireWildcard(require("./index-6fdde059.mjs")));
|
|
7491
|
-
this
|
|
7650
|
+
this.socket = io(data.socketUrl);
|
|
7492
7651
|
this.onUpdateConversations();
|
|
7652
|
+
this.onUpdateUserUnRead();
|
|
7653
|
+
this.audio = new Audio(`${data.socketUrl}/static/audio/unread.mp3`);
|
|
7493
7654
|
if (accessToken && accessToken !== "false") {
|
|
7494
7655
|
this.processTokenChange({
|
|
7495
7656
|
key: "auth._token.login",
|