commit
fe38ced8a2
@ -1,3 +1,4 @@
|
|||||||
VITE_BASE_URL=https://you-gateway.mashibing.com
|
VITE_BASE_URL=https://you-gateway.mashibing.com
|
||||||
VITE_SOCKET_URL=wss://you-gateway.mashibing.com/ws
|
VITE_SOCKET_URL=wss://you-gateway.mashibing.com/ws
|
||||||
VITE_REQUEST_TIMEOUT=20000
|
VITE_REQUEST_TIMEOUT=20000
|
||||||
|
VITE_BROWSER_URL = https://k8s-shop-pc.mashibing.cn
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
VITE_BASE_URL=https://k8s-horse-gateway.mashibing.cn/
|
VITE_BASE_URL=https://k8s-horse-gateway.mashibing.cn/
|
||||||
VITE_SOCKET_URL=wss://k8s-horse-gateway.mashibing.cn/ws
|
VITE_SOCKET_URL=wss://k8s-horse-gateway.mashibing.cn/ws
|
||||||
VITE_REQUEST_TIMEOUT=20000
|
VITE_REQUEST_TIMEOUT=20000
|
||||||
|
VITE_BROWSER_URL = https://k8s-shop-pc.mashibing.cn
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* @Author: ch
|
||||||
|
* @Date: 2022-06-07 15:52:37
|
||||||
|
* @LastEditors: ch
|
||||||
|
* @LastEditTime: 2022-06-13 17:32:19
|
||||||
|
* @Description: file content
|
||||||
|
*/
|
||||||
|
import * as api from '@/api/chat';
|
||||||
|
import config from '@/configs';
|
||||||
|
import $store from '@/store';
|
||||||
|
import MsbIm from '@/utils/msb-im';
|
||||||
|
import { FormatJsonSearch, ToAsyncAwait } from '@/utils/utils';
|
||||||
|
const Im = new MsbIm({
|
||||||
|
reconnect: true,
|
||||||
|
});
|
||||||
|
const ImInit = (waiterId) => {
|
||||||
|
return new Promise((reslove, reject) => {
|
||||||
|
api.getCustomeServiceTicket().then(async (res) => {
|
||||||
|
console.log(res);
|
||||||
|
const par = FormatJsonSearch({
|
||||||
|
client: res.client,
|
||||||
|
ticket: res.ticket,
|
||||||
|
user: waiterId,
|
||||||
|
connect: 2,
|
||||||
|
});
|
||||||
|
const { error, result } = await ToAsyncAwait(
|
||||||
|
Im.init({
|
||||||
|
url: `${config.socketURL}${par}`,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
reslove(result);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
Im.interceptors.dataChangeAfter = () => {
|
||||||
|
$store.commit('chat/SET_SESSION_DATA', JSON.parse(JSON.stringify(Im.sessionData)));
|
||||||
|
// let msgCount = 0;
|
||||||
|
// Im.sessionData.forEach((i) => {
|
||||||
|
// msgCount += i.unreadCount;
|
||||||
|
// });
|
||||||
|
// $store.commit('SET_IM_MSG_COUNT', msgCount);
|
||||||
|
};
|
||||||
|
|
||||||
|
Im.interceptors.onLogout = () => {
|
||||||
|
Im.setSessionData([]);
|
||||||
|
// Im.setCurSessionId(null);
|
||||||
|
$store.commit('chat/SET_SESSION_DATA', []);
|
||||||
|
// $store.commit('SET_IM_MSG_COUNT', 0);
|
||||||
|
};
|
||||||
|
export { Im, ImInit };
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* @Author: ch
|
||||||
|
* @Date: 2022-06-07 11:34:12
|
||||||
|
* @LastEditors: ch
|
||||||
|
* @LastEditTime: 2022-06-07 16:12:42
|
||||||
|
* @Description: file content
|
||||||
|
*/
|
||||||
|
|
||||||
|
//生成UUID
|
||||||
|
const CreateUUID = () => {
|
||||||
|
let d = _.now();
|
||||||
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||||
|
var r = (d + _.random(16)) % 16 | 0;
|
||||||
|
d = Math.floor(d / 16);
|
||||||
|
return (c === 'x' ? r : (r & 0x3) | 0x8).toString(16);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const ToAsyncAwait = (promise, fromatResult = true) => {
|
||||||
|
if (!fromatResult) {
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
return promise.then((res) => ({ error: null, result: res })).catch((err) => ({ error: err, result: null }));
|
||||||
|
};
|
||||||
|
|
||||||
|
const FormatJsonSearch = (myJson, connector = '?') => {
|
||||||
|
if (myJson.constructor !== Object) {
|
||||||
|
throw new Error('必须是JSON对象');
|
||||||
|
}
|
||||||
|
let arr = [];
|
||||||
|
for (let i in myJson) {
|
||||||
|
arr.push(`${i}=${encodeURIComponent(myJson[i])}`);
|
||||||
|
}
|
||||||
|
return `${connector}${arr.join('&')}`;
|
||||||
|
};
|
||||||
|
export { CreateUUID, ToAsyncAwait, FormatJsonSearch };
|
Loading…
Reference in new issue