提交 a0cdee9d 作者: Hao

add

父级 368a7b31
...@@ -7,5 +7,4 @@ const langMap = { ...@@ -7,5 +7,4 @@ const langMap = {
ja: window?.lang?.ja || _getJSONKey('ja', langJSON), ja: window?.lang?.ja || _getJSONKey('ja', langJSON),
} }
const lang = window.localStorage.getItem('lang') || 'zhcn' const lang = window.localStorage.getItem('lang') || 'zhcn'
console.log(langMap[lang])
window.$t.locale(langMap[lang], 'lang') window.$t.locale(langMap[lang], 'lang')
...@@ -162,7 +162,7 @@ export const upLoadHander = async (obj: any) => { ...@@ -162,7 +162,7 @@ export const upLoadHander = async (obj: any) => {
formData.append("biz", fileInfo.biz); formData.append("biz", fileInfo.biz);
formData.append("file", newFile); formData.append("file", newFile);
const uploadRes = await axios.post( const uploadRes = await axios.post(
`${VITE_USER_APP_API_URL}/upload/uploadFile`, `${VITE_USER_APP_API_URL}/common/uploadFile`,
formData, formData,
{ {
headers: { ...obj.headers }, headers: { ...obj.headers },
...@@ -171,11 +171,11 @@ export const upLoadHander = async (obj: any) => { ...@@ -171,11 +171,11 @@ export const upLoadHander = async (obj: any) => {
async: false, async: false,
} }
); );
let data = uploadRes.data; let res = uploadRes.data;
console.log(data, "uploadRes"); console.log(res, "uploadRes");
if (data.success && data.result) { if (res.code == "200" && res.data) {
//保存绝对路径,不然小程序会有问题 //保存绝对路径,不然小程序会有问题
let url = data.result; let url = res.data;
// console.log(url,'url') // console.log(url,'url')
// url = data.message.replaceAll("//", "/"); // url = data.message.replaceAll("//", "/");
// const pre = url.startsWith("/") ? "" : "/"; // const pre = url.startsWith("/") ? "" : "/";
...@@ -185,7 +185,7 @@ export const upLoadHander = async (obj: any) => { ...@@ -185,7 +185,7 @@ export const upLoadHander = async (obj: any) => {
} else { } else {
obj.onError({ obj.onError({
success: false, success: false,
message: data.result || "图片上传失败", message: res.description || "图片上传失败",
}); });
} }
} }
......
...@@ -2,6 +2,5 @@ import { createPinia } from "pinia"; ...@@ -2,6 +2,5 @@ import { createPinia } from "pinia";
// 创建 Pinia 实例 // 创建 Pinia 实例
import piniaPluginPersistedstate from "pinia-plugin-persistedstate"; import piniaPluginPersistedstate from "pinia-plugin-persistedstate";
const pinia = createPinia(); const pinia = createPinia();
console.log(piniaPluginPersistedstate,'打印')
pinia.use(piniaPluginPersistedstate); pinia.use(piniaPluginPersistedstate);
export default pinia; export default pinia;
...@@ -4,14 +4,15 @@ let HeartbeatTime: any = null; ...@@ -4,14 +4,15 @@ let HeartbeatTime: any = null;
let websocket: WebSocket | null = null; // 用于存储实例化后websocket let websocket: WebSocket | null = null; // 用于存储实例化后websocket
let rec: any; // 断线重连后,延迟5秒重新创建WebSocket连接 rec用来存储延迟请求的代码 let rec: any; // 断线重连后,延迟5秒重新创建WebSocket连接 rec用来存储延迟请求的代码
// 创建websocket // 创建websocket
let wsUrl: any = "";
let callBack: any = null; let callBack: any = null;
const connectMsg = (fun: Function) => { const connectMsg = (fun: Function) => {
callBack = fun; callBack = fun;
const useUser = useUserStore(); const useUser = useUserStore();
const wsUrl = `${import.meta.env.VITE_USER_APP_WS_API_URL}?type=yk&code=${ wsUrl = `${import.meta.env.VITE_USER_APP_WS_API_URL}?type=yk&code=${
useUser.chatInfo.clientId useUser.chatInfo.clientId
}&kf=${useUser.chatInfo.serviceId}`; }&kf=${useUser.chatInfo.serviceId}`;
console.log(wsUrl); console.log("建立连接地址:" + wsUrl);
initWebSocket(wsUrl); initWebSocket(wsUrl);
}; };
function creatWebSocket(wsUrl: string) { function creatWebSocket(wsUrl: string) {
...@@ -54,7 +55,6 @@ function initWebSocket(wsUrl: string) { ...@@ -54,7 +55,6 @@ function initWebSocket(wsUrl: string) {
function websocketHeartbeat() { function websocketHeartbeat() {
clearInterval(HeartbeatTime); clearInterval(HeartbeatTime);
HeartbeatTime = setInterval(() => { HeartbeatTime = setInterval(() => {
console.log("调取心跳");
websocketsend({ websocketsend({
cmd: 13, cmd: 13,
}); });
...@@ -78,13 +78,11 @@ function websocketOpen() { ...@@ -78,13 +78,11 @@ function websocketOpen() {
// 数据接收 // 数据接收
function websocketonmessage(e: MessageEvent<any>) { function websocketonmessage(e: MessageEvent<any>) {
const res = JSON.parse(e.data); // 解析JSON格式的数据 const res = JSON.parse(e.data); // 解析JSON格式的数据
console.log(res, "res"); console.log(res, "接收数据");
if (res.command == 11) { if (res.command == 11) {
console.log("收到");
//将数据放在store中 //将数据放在store中
// 下面的判断则是后台返回的接收到的数据 如何处理自己决定 // 下面的判断则是后台返回的接收到的数据 如何处理自己决定
setTimeout(() => { setTimeout(() => {
console.log(callBack, "callBack");
callBack(); callBack();
// useUserStore().setUserListMessages(res.data).then(); // useUserStore().setUserListMessages(res.data).then();
}, 10); }, 10);
...@@ -93,7 +91,7 @@ function websocketonmessage(e: MessageEvent<any>) { ...@@ -93,7 +91,7 @@ function websocketonmessage(e: MessageEvent<any>) {
// 关闭 // 关闭
function websocketclose(e: any) { function websocketclose(e: any) {
console.log("关闭"); console.log("连接关闭");
clearInterval(HeartbeatTime); clearInterval(HeartbeatTime);
useUserStore().disconnect(); // 修改连接状态 useUserStore().disconnect(); // 修改连接状态
} }
...@@ -125,6 +123,11 @@ function sendWebSocket(data: any) { ...@@ -125,6 +123,11 @@ function sendWebSocket(data: any) {
}); });
// websocketsend(data); // websocketsend(data);
} else { } else {
console.log("发送时的数据,方便调试", {
data,
url:wsUrl
});
websocketsend(data); websocketsend(data);
console.log("------------------"); console.log("------------------");
} }
......
...@@ -428,7 +428,7 @@ function getKfCodeInfo() { ...@@ -428,7 +428,7 @@ function getKfCodeInfo() {
if (code == 200) { if (code == 200) {
const chatInfo = { const chatInfo = {
clientId: routeParams.supplierId || new Date().getTime(), clientId: routeParams.supplierId || new Date().getTime(),
serviceId: data || routeParams.priceId, serviceId: data || routeParams.priceId || routeParams.supplierId,
} }
store.setChatInfo(chatInfo) store.setChatInfo(chatInfo)
connectMsg(getCheckMesssages) connectMsg(getCheckMesssages)
...@@ -475,7 +475,7 @@ const vShrink: Directive<HTMLElement, boolean | Props> = { ...@@ -475,7 +475,7 @@ const vShrink: Directive<HTMLElement, boolean | Props> = {
function getCheckMesssages() { function getCheckMesssages() {
let query = { let query = {
sessionId: `${store.chatInfo.clientId}-${store.chatInfo.serviceId}`, sessionId: `${store.chatInfo.serviceId}-${store.chatInfo.clientId}`,
} }
checkMesssages(query).then(({ code, data, description }) => { checkMesssages(query).then(({ code, data, description }) => {
data = data || [] data = data || []
...@@ -483,11 +483,12 @@ function getCheckMesssages() { ...@@ -483,11 +483,12 @@ function getCheckMesssages() {
if ([3, 4].includes(item.msgType)) { if ([3, 4].includes(item.msgType)) {
item.content = JSON.parse(item.content) item.content = JSON.parse(item.content)
} }
item.isSent = item.fromCode == store.chatInfo.serviceId item.isSent = item.fromCode == store.chatInfo.clientId
item.userImg = '/assets/img/user.png' item.userImg = '/assets/img/user.png'
item.time = moment(item.createTime).format('HH:MM') item.time = moment(item.createTime).format('HH:MM')
}) })
messages.value = data console.log(data, 'data')
messages.value = data.reverse()
}) })
} }
//设置style的属性值 //设置style的属性值
...@@ -506,11 +507,9 @@ function fileImgChange() { ...@@ -506,11 +507,9 @@ function fileImgChange() {
upLoadFilesHander(oFile).then((ress) => { upLoadFilesHander(oFile).then((ress) => {
const { success, result }: any = ress const { success, result }: any = ress
if (success) { if (success) {
console.log(oFile, 'oFile')
ruleForm.value.flieUrl = result ruleForm.value.flieUrl = result
ruleForm.value.flieName = oFile.name ruleForm.value.flieName = oFile.name
ruleForm.value.flieSize = oFile.size ruleForm.value.flieSize = oFile.size
console.log(ruleForm, 'ruleForm')
} }
}) })
const loading: any = ElLoading?.service({ const loading: any = ElLoading?.service({
...@@ -534,7 +533,6 @@ function formatCOlorOption(val: string | Props) { ...@@ -534,7 +533,6 @@ function formatCOlorOption(val: string | Props) {
} }
} }
const deleteFlieName = (val: any) => { const deleteFlieName = (val: any) => {
console.log(isUpload.value, '打印', 'val')
ruleForm.value.flieUrl = '' ruleForm.value.flieUrl = ''
} }
...@@ -679,7 +677,6 @@ const sendData = (msg, msgType) => { ...@@ -679,7 +677,6 @@ const sendData = (msg, msgType) => {
to: store.chatInfo.serviceId, to: store.chatInfo.serviceId,
form: store.chatInfo.clientId, form: store.chatInfo.clientId,
} }
console.log(data)
messages.value?.push(data) messages.value?.push(data)
sendWebSocket(data) sendWebSocket(data)
} }
...@@ -703,7 +700,6 @@ const openWindow = (event: any) => { ...@@ -703,7 +700,6 @@ const openWindow = (event: any) => {
} }
const handleMessageClick = (event: any) => { const handleMessageClick = (event: any) => {
const target = event.target const target = event.target
console.log(target, 'target')
if (target.tagName === 'A') { if (target.tagName === 'A') {
openWindow(target.href) openWindow(target.href)
} else if (target.tagName === 'IMG') { } else if (target.tagName === 'IMG') {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论