Compare commits
2 Commits
1e6102b49a
...
6201973ca4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6201973ca4 | ||
|
|
512678dde3 |
@ -30,7 +30,7 @@ const forbidLogin = computed(() => {
|
||||
|
||||
if (terminalType === "App") {
|
||||
window.upNativeComm.addEventListener("UPUser", (opt) => {
|
||||
if (opt.action == "userChange" && store.state.userInfo.account) {
|
||||
if (opt.action == "userChange" && store.state.userInfo.userId) {
|
||||
console.log("userChange-->", opt);
|
||||
// app里监听用户资金账号切换
|
||||
userLogin();
|
||||
|
||||
@ -14,7 +14,7 @@ export default function useVideoPlay(
|
||||
let playCtx = ref();
|
||||
let showPlayBtn = ref(false);
|
||||
let sessionId = localStorage.getItem(
|
||||
`sessionId-${store.state.userInfo.account}-${detail.id}`
|
||||
`sessionId-${store.state.userInfo.userId}-${detail.id}`
|
||||
);
|
||||
console.log("sessionId", sessionId);
|
||||
const playVideo = async (videoEl) => {
|
||||
@ -78,7 +78,7 @@ export default function useVideoPlay(
|
||||
setPlayCtx({ playCtx: playCtx.value });
|
||||
playCtx.value.on("loadedmetadata", () => {
|
||||
const currentTime = localStorage.getItem(
|
||||
`${store.state.userInfo.account}-${detail.id}-videoPlayTime`,
|
||||
`${store.state.userInfo.userId}-${detail.id}-videoPlayTime`,
|
||||
playCtx.value.currentTime()
|
||||
);
|
||||
if (playCtx.value && currentTime) {
|
||||
@ -94,7 +94,7 @@ export default function useVideoPlay(
|
||||
// 做一些处理
|
||||
console.log("play", {
|
||||
reportVideoTopic: `/app/chat/report/video/${detail.id}`,
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
reportType: 2,
|
||||
GroupId: detail.id,
|
||||
});
|
||||
@ -104,7 +104,7 @@ export default function useVideoPlay(
|
||||
stompClient.value.publish({
|
||||
destination: `/app/chat/report/video/${detail.id}`,
|
||||
headers: {
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
reportType: 2,
|
||||
GroupId: detail.id,
|
||||
sessionId,
|
||||
@ -117,7 +117,7 @@ export default function useVideoPlay(
|
||||
// 做一些处理
|
||||
console.log("pause", {
|
||||
reportVideoTopic: `/app/chat/report/video/${detail.id}`,
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
reportType: 1,
|
||||
GroupId: detail.id,
|
||||
});
|
||||
@ -127,7 +127,7 @@ export default function useVideoPlay(
|
||||
stompClient.value.publish({
|
||||
destination: `/app/chat/report/video/${detail.id}`,
|
||||
headers: {
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
reportType: 1,
|
||||
GroupId: detail.id,
|
||||
sessionId,
|
||||
@ -182,7 +182,7 @@ export default function useVideoPlay(
|
||||
});
|
||||
playCtx.value.on("timeupdate", () => {
|
||||
localStorage.setItem(
|
||||
`${store.state.userInfo.account}-${detail.id}-videoPlayTime`,
|
||||
`${store.state.userInfo.userId}-${detail.id}-videoPlayTime`,
|
||||
playCtx.value.currentTime()
|
||||
);
|
||||
});
|
||||
@ -229,7 +229,7 @@ export default function useVideoPlay(
|
||||
stompClient.value.publish({
|
||||
destination: `/app/chat/report/video/${detail.id}`,
|
||||
headers: {
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
reportType: 2,
|
||||
GroupId: detail.id,
|
||||
sessionId,
|
||||
@ -247,7 +247,7 @@ export default function useVideoPlay(
|
||||
stompClient.value.publish({
|
||||
destination: `/app/chat/report/video/${detail.id}`,
|
||||
headers: {
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
reportType: 1,
|
||||
GroupId: detail.id,
|
||||
sessionId,
|
||||
|
||||
@ -29,15 +29,15 @@ export default function ({ id, subMessage, chatMessage, saleUserId }) {
|
||||
console.log("connect建立连接");
|
||||
const frontToken = store.state.token;
|
||||
if (
|
||||
localStorage.getItem(`sessionId-${store.state.userInfo.account}-${id}`)
|
||||
localStorage.getItem(`sessionId-${store.state.userInfo.userId}-${id}`)
|
||||
) {
|
||||
sessionId = localStorage.getItem(
|
||||
`sessionId-${store.state.userInfo.account}-${id}`
|
||||
`sessionId-${store.state.userInfo.userId}-${id}`
|
||||
);
|
||||
} else {
|
||||
sessionId = Math.random().toString(36).substring(2, 8);
|
||||
localStorage.setItem(
|
||||
`sessionId-${store.state.userInfo.account}-${id}`,
|
||||
`sessionId-${store.state.userInfo.userId}-${id}`,
|
||||
sessionId
|
||||
);
|
||||
}
|
||||
|
||||
@ -45,8 +45,11 @@ export default function ({ detail, videoClass }) {
|
||||
|
||||
onMounted(async () => {
|
||||
if (
|
||||
[$liveStatusObj.InLive, $liveStatusObj.PausePlay].includes(liveStatus.value) ||
|
||||
((liveStatus.value === $liveStatusObj.FinishPlay || detail.playType === 2)&&
|
||||
[$liveStatusObj.InLive, $liveStatusObj.PausePlay].includes(
|
||||
liveStatus.value
|
||||
) ||
|
||||
((liveStatus.value === $liveStatusObj.FinishPlay ||
|
||||
detail.playType === 2) &&
|
||||
detail.libraryList &&
|
||||
detail.libraryList.length)
|
||||
) {
|
||||
@ -74,7 +77,7 @@ export default function ({ detail, videoClass }) {
|
||||
function processingData(data) {
|
||||
if (data && data.type === 3) {
|
||||
online.value = data.online;
|
||||
if (store.state.userInfo.account !== data.userId) {
|
||||
if (store.state.userInfo.userId !== data.userId) {
|
||||
// 判断是否是本人进入直播间
|
||||
// informMsgList.value.push(data);
|
||||
store.commit("setInteractMsg", {
|
||||
@ -235,10 +238,10 @@ export default function ({ detail, videoClass }) {
|
||||
msgObj.isOpen = msgBody.data.isOpen;
|
||||
msgObj.show =
|
||||
(!msgObj.replyBasic && msgObj.isOpen !== 2) ||
|
||||
store.state.userInfo.account === msgObj.phone ||
|
||||
store.state.userInfo.userId === msgObj.phone ||
|
||||
(msgObj.replyBasic &&
|
||||
(msgObj.replyBasic.isOpen === 1 ||
|
||||
store.state.userInfo.account === msgObj.replyBasic.userId));
|
||||
store.state.userInfo.userId === msgObj.replyBasic.userId));
|
||||
}
|
||||
|
||||
var replyMsgObj =
|
||||
@ -249,11 +252,10 @@ export default function ({ detail, videoClass }) {
|
||||
replyMsgObj.replyBasic.isOpen = msgBody.data.isOpen;
|
||||
replyMsgObj.show =
|
||||
(!replyMsgObj.replyBasic && replyMsgObj.isOpen !== 2) ||
|
||||
store.state.userInfo.account === replyMsgObj.phone ||
|
||||
store.state.userInfo.userId === replyMsgObj.phone ||
|
||||
(replyMsgObj.replyBasic &&
|
||||
(replyMsgObj.replyBasic.isOpen === 1 ||
|
||||
store.state.userInfo.account ===
|
||||
replyMsgObj.replyBasic.userId));
|
||||
store.state.userInfo.userId === replyMsgObj.replyBasic.userId));
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
@ -262,7 +264,7 @@ export default function ({ detail, videoClass }) {
|
||||
!questionnaireTipRef.value.showPopup &&
|
||||
!questionnaireTipRef.value.questionnairePopupRef.showPopup &&
|
||||
!msgBody.data.questionVO.userIdList.includes(
|
||||
store.state.userInfo.account
|
||||
store.state.userInfo.userId
|
||||
)
|
||||
) {
|
||||
questionId.value = msgBody.data.questionVO?.id;
|
||||
@ -286,7 +288,9 @@ export default function ({ detail, videoClass }) {
|
||||
break;
|
||||
case 16:
|
||||
// 隐藏用户昵称
|
||||
emitter.emit("updateVideoDetail", { showNickname: msgBody.data.openQW });
|
||||
emitter.emit("updateVideoDetail", {
|
||||
showNickname: msgBody.data.openQW,
|
||||
});
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -301,7 +305,7 @@ export default function ({ detail, videoClass }) {
|
||||
case 1:
|
||||
// 文本详细
|
||||
ret = await liveMsgSend({
|
||||
from: store.state.userInfo.account,
|
||||
from: store.state.userInfo.userId,
|
||||
groupId: detail.id,
|
||||
text,
|
||||
type,
|
||||
|
||||
@ -86,16 +86,16 @@ export default createStore({
|
||||
let chatTime = dayjs(item.createTime).format("MM-DD HH:mm");
|
||||
item.show =
|
||||
(!item.replyBasic && item.isOpen !== 2) ||
|
||||
state.userInfo.account === item.phone ||
|
||||
state.userInfo.userId === item.phone ||
|
||||
(item.replyBasic &&
|
||||
(item.replyBasic.isOpen === 1 ||
|
||||
state.userInfo.account === item.replyBasic.userId));
|
||||
state.userInfo.userId === item.replyBasic.userId));
|
||||
if (payload.type === 1) {
|
||||
// 新消息
|
||||
// 公开的或者是本人发的文本消息
|
||||
if (
|
||||
((item.userId && item.isOpen === 1) ||
|
||||
item.phone === state.userInfo.account) &&
|
||||
item.phone === state.userInfo.userId) &&
|
||||
item.type === 1
|
||||
) {
|
||||
state.interactMsgObj.newTreeMsg.push(item);
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
v-for="item in msgList"
|
||||
:class="[
|
||||
`li${item.id}`,
|
||||
item.userId === store.state.userInfo.account ? 'row-reverse' : '',
|
||||
item.userId === store.state.userInfo.userId ? 'row-reverse' : '',
|
||||
]"
|
||||
:key="item.id"
|
||||
>
|
||||
@ -27,7 +27,7 @@
|
||||
v-if="
|
||||
item.status === 2 ||
|
||||
(item.userType === 2 &&
|
||||
item.userId === store.state.userInfo.account)
|
||||
item.userId === store.state.userInfo.userId)
|
||||
"
|
||||
>
|
||||
<div class="chat-time" v-if="item.chatTime">
|
||||
@ -36,7 +36,7 @@
|
||||
<div
|
||||
:class="[
|
||||
'flex',
|
||||
item.userId === store.state.userInfo.account
|
||||
item.userId === store.state.userInfo.userId
|
||||
? 'row-reverse'
|
||||
: '',
|
||||
]"
|
||||
@ -62,7 +62,7 @@
|
||||
<h3>
|
||||
{{
|
||||
item.userType === 2
|
||||
? item.userId === store.state.userInfo.account
|
||||
? item.userId === store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickName === 2
|
||||
? maskUserName(item.userName)
|
||||
@ -81,7 +81,7 @@
|
||||
><label
|
||||
>{{
|
||||
item.replyMessage?.userId ===
|
||||
store.state.userInfo.account
|
||||
store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickName === 2
|
||||
? maskUserName(item.replyMessage?.userName)
|
||||
@ -102,7 +102,7 @@
|
||||
<div class="reply" style="color: rgba(154, 164, 182, 1)">
|
||||
{{
|
||||
item.replyMessage?.userId ===
|
||||
store.state.userInfo.account
|
||||
store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickName === 2
|
||||
? maskUserName(item.replyMessage?.userName)
|
||||
@ -181,6 +181,10 @@ const props = defineProps({
|
||||
type: Object,
|
||||
default: () => {},
|
||||
},
|
||||
stompClient: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const defaultAvatar = {
|
||||
@ -237,6 +241,7 @@ const {
|
||||
className: `.interact-scroll${props.type}`,
|
||||
id: route.query.id,
|
||||
type: props.type,
|
||||
stompClient: props.stompClient,
|
||||
});
|
||||
|
||||
const maskUserName = (value) => {
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
import { readMessage } from "@/api/circle";
|
||||
|
||||
// type 1 公共互动 2私聊
|
||||
function getStorageTeacherMsg({
|
||||
productId,
|
||||
productType = 41,
|
||||
type = 1,
|
||||
userId,
|
||||
}) {
|
||||
const getMsgIds = localStorage.getItem(
|
||||
`read-msg-${productType}-${productId}-${userId}-${type}`
|
||||
);
|
||||
if (getMsgIds) {
|
||||
return JSON.parse(getMsgIds);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// 老师发的言,并且已经上报的缓存起来
|
||||
export function setStorageTeacherMsg({
|
||||
productId,
|
||||
productType = 41,
|
||||
userId,
|
||||
type = 1, // type 1 公共互动 2私聊
|
||||
msg, // 单条消息
|
||||
msgArr, // 多条消息
|
||||
}) {
|
||||
const storageMsgIds = getStorageTeacherMsg({
|
||||
productId,
|
||||
productType,
|
||||
type,
|
||||
userId,
|
||||
});
|
||||
|
||||
let messageIds = [];
|
||||
// userType用户类型:1投顾;2用户;3助教;4运营人员
|
||||
if (msg) {
|
||||
if (!storageMsgIds.includes(msg.id) && msg.userType !== 2) {
|
||||
messageIds = [msg.id];
|
||||
}
|
||||
} else if (msgArr && msgArr.length) {
|
||||
msgArr.forEach((msg) => {
|
||||
if (msg.userType !== 2 && !storageMsgIds.includes(msg.id)) {
|
||||
messageIds.push(msg.id);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (messageIds.length) {
|
||||
setTimeout(async () => {
|
||||
let ret = await readMessage({ messageIds }).catch(() => {});
|
||||
if (ret && ret.code === 0) {
|
||||
localStorage.setItem(
|
||||
`read-msg-${productType}-${productId}-${userId}-${type}`,
|
||||
JSON.stringify(messageIds.concat(storageMsgIds))
|
||||
);
|
||||
}
|
||||
}, Math.random() * 3);
|
||||
}
|
||||
}
|
||||
@ -4,13 +4,13 @@ import BScroll from "@better-scroll/core";
|
||||
import PullDown from "@better-scroll/pull-down";
|
||||
import MouseWheel from "@better-scroll/mouse-wheel";
|
||||
import useDisableScroll from "@/hooks/useDisableScroll";
|
||||
import { setStorageTeacherMsg } from "./storage";
|
||||
import useReadMessage from "./useReadMessage";
|
||||
import store from "@/store/index";
|
||||
|
||||
BScroll.use(PullDown);
|
||||
BScroll.use(MouseWheel);
|
||||
|
||||
export default function useChatData({ id, className, type }) {
|
||||
export default function useChatData({ id, className, type, stompClient }) {
|
||||
const { addScrollEvent } = useDisableScroll();
|
||||
const hasNext = ref(true);
|
||||
let bs = ref();
|
||||
@ -20,6 +20,8 @@ export default function useChatData({ id, className, type }) {
|
||||
const msgIdsObj = ref({});
|
||||
const loading = ref(false);
|
||||
|
||||
const { setStorageTeacherMsg } = useReadMessage();
|
||||
|
||||
const getLiveHisMsg = async () => {
|
||||
loading.value = true;
|
||||
if (isPullingDown.value) return;
|
||||
@ -44,9 +46,10 @@ export default function useChatData({ id, className, type }) {
|
||||
}
|
||||
setStorageTeacherMsg({
|
||||
productId: id,
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
msgArr: list,
|
||||
type: type === 5 ? 2 : 1,
|
||||
stompClient,
|
||||
});
|
||||
}
|
||||
isPullingDown.value = false;
|
||||
@ -77,7 +80,7 @@ export default function useChatData({ id, className, type }) {
|
||||
});
|
||||
setStorageTeacherMsg({
|
||||
productId: id,
|
||||
userId: store.state.userInfo.account,
|
||||
userId: store.state.userInfo.userId,
|
||||
msg,
|
||||
type: type === 5 ? 2 : 1,
|
||||
});
|
||||
|
||||
104
src/views/Circle/hooks/useReadMessage.js
Normal file
104
src/views/Circle/hooks/useReadMessage.js
Normal file
@ -0,0 +1,104 @@
|
||||
// import { readMessage } from "@/api/circle";
|
||||
|
||||
export default function useReadMessage() {
|
||||
// type 1 公共互动 2私聊
|
||||
const getStorageTeacherMsg = ({
|
||||
productId,
|
||||
productType = 41,
|
||||
type = 1,
|
||||
userId,
|
||||
}) => {
|
||||
const getMsgIds = localStorage.getItem(
|
||||
`read-msg-${productType}-${productId}-${userId}-${type}`
|
||||
);
|
||||
if (getMsgIds) {
|
||||
return JSON.parse(getMsgIds);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
|
||||
// 老师发的言,并且已经上报的缓存起来
|
||||
let uploadReadMsgIds = []; // 存储需要上传的ids
|
||||
let timeout = null;
|
||||
|
||||
const uploadReadMsg = ({
|
||||
productId,
|
||||
productType,
|
||||
userId,
|
||||
type, // type 1 公共互动 2私聊
|
||||
stompClient,
|
||||
messageIds,
|
||||
storageMsgIds,
|
||||
}) => {
|
||||
console.log("stompClient", stompClient);
|
||||
uploadReadMsgIds = Array.from(new Set(uploadReadMsgIds.concat(messageIds)));
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(async () => {
|
||||
stompClient &&
|
||||
stompClient.publish({
|
||||
destination: `/chat/group/readMessage`,
|
||||
headers: {
|
||||
userId: userId,
|
||||
messageIds: uploadReadMsgIds,
|
||||
},
|
||||
});
|
||||
localStorage.setItem(
|
||||
`read-msg-${productType}-${productId}-${userId}-${type}`,
|
||||
JSON.stringify(uploadReadMsgIds.concat(storageMsgIds).sort())
|
||||
);
|
||||
uploadReadMsgIds = [];
|
||||
}, 5000);
|
||||
};
|
||||
|
||||
const setStorageTeacherMsg = ({
|
||||
productId,
|
||||
productType = 41,
|
||||
userId,
|
||||
type = 1, // type 1 公共互动 2私聊
|
||||
msg, // 单条消息
|
||||
msgArr, // 多条消息
|
||||
stompClient,
|
||||
}) => {
|
||||
const storageMsgIds = getStorageTeacherMsg({
|
||||
productId,
|
||||
productType,
|
||||
type,
|
||||
userId,
|
||||
});
|
||||
|
||||
let messageIds = [];
|
||||
// userType用户类型:1投顾;2用户;3助教;4运营人员
|
||||
if (msg) {
|
||||
if (!storageMsgIds.includes(msg.id) && msg.userType !== 2) {
|
||||
messageIds = [msg.id];
|
||||
}
|
||||
} else if (msgArr && msgArr.length) {
|
||||
msgArr.forEach((msg) => {
|
||||
if (msg.userType !== 2 && !storageMsgIds.includes(msg.id)) {
|
||||
messageIds.push(msg.id);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (messageIds.length) {
|
||||
uploadReadMsg({
|
||||
productId,
|
||||
productType,
|
||||
userId,
|
||||
type, // type 1 公共互动 2私聊
|
||||
msg, // 单条消息
|
||||
msgArr, // 多条消息
|
||||
stompClient,
|
||||
messageIds,
|
||||
storageMsgIds,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
setStorageTeacherMsg,
|
||||
};
|
||||
}
|
||||
@ -23,15 +23,15 @@ export default function ({ id, privateMessage, chatMessage }) {
|
||||
console.log("connect建立连接");
|
||||
const frontToken = store.state.token;
|
||||
if (
|
||||
localStorage.getItem(`sessionId-${store.state.userInfo.account}-${id}`)
|
||||
localStorage.getItem(`sessionId-${store.state.userInfo.userId}-${id}`)
|
||||
) {
|
||||
sessionId = localStorage.getItem(
|
||||
`sessionId-${store.state.userInfo.account}-${id}`
|
||||
`sessionId-${store.state.userInfo.userId}-${id}`
|
||||
);
|
||||
} else {
|
||||
sessionId = Math.random().toString(36).substring(2, 8);
|
||||
localStorage.setItem(
|
||||
`sessionId-${store.state.userInfo.account}-${id}`,
|
||||
`sessionId-${store.state.userInfo.userId}-${id}`,
|
||||
sessionId
|
||||
);
|
||||
}
|
||||
@ -77,7 +77,7 @@ export default function ({ id, privateMessage, chatMessage }) {
|
||||
// APP端私聊消息
|
||||
privateMessage &&
|
||||
(await stompClient.value.subscribe(
|
||||
`/app/private/topic/${id}/${store.state.userInfo.account}`,
|
||||
`/app/private/topic/${id}/${store.state.userInfo.userId}`,
|
||||
privateMessage
|
||||
));
|
||||
};
|
||||
@ -138,4 +138,7 @@ export default function ({ id, privateMessage, chatMessage }) {
|
||||
}
|
||||
}
|
||||
});
|
||||
return {
|
||||
stompClient,
|
||||
};
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@
|
||||
:bsRefresh="active === 0"
|
||||
:detail="detail"
|
||||
:newMsg="newMsg"
|
||||
:stompClient="stompClient"
|
||||
/>
|
||||
</van-tab>
|
||||
<van-tab title="老师" :name="1">
|
||||
@ -27,6 +28,7 @@
|
||||
:bsRefresh="active === 1"
|
||||
:detail="detail"
|
||||
:newMsg="newMsg"
|
||||
:stompClient="stompClient"
|
||||
/>
|
||||
</van-tab>
|
||||
<van-tab title="私聊" :name="2">
|
||||
@ -35,6 +37,7 @@
|
||||
:bsRefresh="active === 2"
|
||||
:detail="detail"
|
||||
:newMsg="privateNewMsg"
|
||||
:stompClient="stompClient"
|
||||
/>
|
||||
</van-tab>
|
||||
<van-tab title="精选" :name="3">
|
||||
@ -43,6 +46,7 @@
|
||||
:bsRefresh="active === 3"
|
||||
:detail="detail"
|
||||
:newMsg="newMsg"
|
||||
:stompClient="stompClient"
|
||||
/>
|
||||
</van-tab>
|
||||
</van-tabs>
|
||||
@ -95,7 +99,7 @@ const queryCircleDetail = async () => {
|
||||
const ret = await getCircleDetail({ id: route.query.id });
|
||||
if (ret && ret.code === 0) {
|
||||
detail.value = ret.data;
|
||||
const key = `circleNotice-${detail.value.id}-${store.state.userInfo.account}`;
|
||||
const key = `circleNotice-${detail.value.id}-${store.state.userInfo.userId}`;
|
||||
const storageCircleNotice = localStorage.getItem(key);
|
||||
if (!storageCircleNotice || storageCircleNotice !== detail.value.notice) {
|
||||
showNotice.value = true;
|
||||
@ -138,7 +142,11 @@ const chatMessage = (msg) => {
|
||||
detail.value.showMemberCount = data;
|
||||
}
|
||||
};
|
||||
useWebSocket({ id: route.query.id, privateMessage, chatMessage });
|
||||
const { stompClient } = useWebSocket({
|
||||
id: route.query.id,
|
||||
privateMessage,
|
||||
chatMessage,
|
||||
});
|
||||
|
||||
const sendMsg = async () => {
|
||||
let ret = await sendMessage({
|
||||
|
||||
@ -5,7 +5,11 @@
|
||||
<div class="form">
|
||||
<div class="input-group">
|
||||
<label>账户</label>
|
||||
<input placeholder="请输入账号" v-model="fromData.userId" />
|
||||
<input placeholder="请输入账号" v-model.trim="fromData.userName" />
|
||||
</div>
|
||||
<div class="input-group">
|
||||
<label>密码</label>
|
||||
<input placeholder="请输入密码" v-model.trim="fromData.password" />
|
||||
</div>
|
||||
<!-- <div class="input-group">
|
||||
<label>验证码</label>
|
||||
@ -13,7 +17,7 @@
|
||||
<span v-if="!showTime" @click="getCode">点击获取</span>
|
||||
<i v-else>{{ time }}S后重试</i>
|
||||
</div> -->
|
||||
<button @click="login">登录</button>
|
||||
<button @click="login" :disabled="disabled">登录</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -24,7 +28,7 @@ import { useRoute, useRouter } from "vue-router";
|
||||
import Nav from "@/components/NavBar.vue";
|
||||
// import { queryLogin } from "@/api/index";
|
||||
import { useStore } from "vuex";
|
||||
// import { showToast } from "vant";
|
||||
import { showToast } from "vant";
|
||||
import { getUserInfo } from "@/api/index";
|
||||
|
||||
const store = useStore();
|
||||
@ -34,11 +38,12 @@ const router = useRouter();
|
||||
const disabled = ref(true);
|
||||
// const showTime = ref(false);
|
||||
const fromData = reactive({
|
||||
userId: "",
|
||||
userName: "",
|
||||
password: "",
|
||||
clientType: 1,
|
||||
});
|
||||
watch(fromData, (val) => {
|
||||
if (val.account && val.code) {
|
||||
if (val.userName && val.password) {
|
||||
disabled.value = false;
|
||||
} else {
|
||||
disabled.value = true;
|
||||
@ -47,9 +52,11 @@ watch(fromData, (val) => {
|
||||
|
||||
// const reg = /^1[34578]\d{9}$/;
|
||||
const login = async () => {
|
||||
// if (!reg.test(fromData.account)) {
|
||||
// return showToast("请输入正确手机号!");
|
||||
// }
|
||||
if (!fromData.userName) {
|
||||
return showToast("请输入账号!");
|
||||
} else if (!fromData.password) {
|
||||
return showToast("请输入密码!");
|
||||
}
|
||||
let ret = await getUserInfo({ ...fromData });
|
||||
if (ret.code === 0) {
|
||||
store.commit("setToken", ret.data.upToken);
|
||||
|
||||
@ -99,7 +99,7 @@ const getSerialDetailFn = async () => {
|
||||
|
||||
window.shareApi.initWxH5({
|
||||
env: window.config.shareEnv,
|
||||
shareusername: store.state.userInfo.account,
|
||||
shareusername: store.state.userInfo.userId,
|
||||
title: serial.value.name,
|
||||
summary: serial.value.remark,
|
||||
linkurl: location.href,
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
<h3>
|
||||
{{
|
||||
!item.replyUserId
|
||||
? item.userName === store.state.userInfo.account
|
||||
? item.userName === store.state.userInfo.userId
|
||||
? "我"
|
||||
: item.userName
|
||||
: item.replyUserName
|
||||
|
||||
@ -159,7 +159,7 @@ const { playVideo } = useShortVideoPlay();
|
||||
|
||||
// 之前是否已经进行邀请码校验且通过校验
|
||||
const codeVerify = localStorage.getItem(
|
||||
`${store.state.userInfo.account}-shotVideoPlay-${route.query.id}-code`
|
||||
`${store.state.userInfo.userId}-shotVideoPlay-${route.query.id}-code`
|
||||
);
|
||||
|
||||
const showCodeDialog = computed(() => {
|
||||
@ -253,7 +253,7 @@ const getLiveLimit = async () => {
|
||||
if (ret.data.result) {
|
||||
// 检验通过
|
||||
localStorage.setItem(
|
||||
`${store.state.userInfo.account}-shotVideoPlay-${route.query.id}-code`,
|
||||
`${store.state.userInfo.userId}-shotVideoPlay-${route.query.id}-code`,
|
||||
true
|
||||
);
|
||||
isPlay.value = true;
|
||||
|
||||
@ -15,10 +15,10 @@
|
||||
v-for="(item, index) in msgList.filter(
|
||||
(item) =>
|
||||
(!item.replyBasic && item.isOpen !== 2) ||
|
||||
store.state.userInfo.account === item.phone ||
|
||||
store.state.userInfo.userId === item.phone ||
|
||||
(item.replyBasic &&
|
||||
(item.replyBasic.isOpen === 1 ||
|
||||
store.state.userInfo.account === item.replyBasic.userId))
|
||||
store.state.userInfo.userId === item.replyBasic.userId))
|
||||
)"
|
||||
:class="[`li${index}`]"
|
||||
:key="index"
|
||||
@ -41,7 +41,7 @@
|
||||
<label
|
||||
>{{
|
||||
item.userId
|
||||
? item.phone === store.state.userInfo.account
|
||||
? item.phone === store.state.userInfo.userId
|
||||
? "我"
|
||||
: item.userName
|
||||
: "直播老师"
|
||||
@ -71,7 +71,7 @@
|
||||
<p>
|
||||
<label
|
||||
>{{
|
||||
item.phone === store.state.userInfo.account
|
||||
item.phone === store.state.userInfo.userId
|
||||
? "我"
|
||||
: item.userName
|
||||
}}:</label
|
||||
@ -81,7 +81,7 @@
|
||||
class="attention"
|
||||
@click="subAdvisor"
|
||||
v-if="
|
||||
item.phone !== store.state.userInfo.account &&
|
||||
item.phone !== store.state.userInfo.userId &&
|
||||
detail.isSubAdvisor !== 1
|
||||
"
|
||||
>
|
||||
@ -92,7 +92,7 @@
|
||||
<p>
|
||||
<label
|
||||
>{{
|
||||
item.phone === store.state.userInfo.account
|
||||
item.phone === store.state.userInfo.userId
|
||||
? "我"
|
||||
: item.userName
|
||||
}}:</label
|
||||
@ -101,7 +101,7 @@
|
||||
<button
|
||||
class="share"
|
||||
@click="sendMsg(5)"
|
||||
v-if="item.phone !== store.state.userInfo.account"
|
||||
v-if="item.phone !== store.state.userInfo.userId"
|
||||
>
|
||||
我也要分享
|
||||
</button>
|
||||
|
||||
@ -34,15 +34,20 @@
|
||||
2、直播界面显示讲师发布的内容,听众发言可以在讨论区或以弹幕的形式查看。
|
||||
</p>
|
||||
</div>
|
||||
<div class="license">{{ detail.advisorBasic.name }}<i v-if="detail.advisorBasic.license">({{detail.advisorBasic.license}})</i></div>
|
||||
<div class="license">
|
||||
{{ detail.advisorBasic.name
|
||||
}}<i v-if="detail.advisorBasic.license"
|
||||
>({{ detail.advisorBasic.license }})</i
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li
|
||||
v-for="(item) in informMsgList"
|
||||
v-for="item in informMsgList"
|
||||
:class="[
|
||||
`li${item.id}`,
|
||||
item.phone === store.state.userInfo.account ? 'row-reverse' : '',
|
||||
item.phone === store.state.userInfo.userId ? 'row-reverse' : '',
|
||||
]"
|
||||
:key="item.id"
|
||||
>
|
||||
@ -50,17 +55,24 @@
|
||||
<!-- <div v-if="item.type === 3" class="warn">
|
||||
{{ item.userName }}:进入直播间
|
||||
</div> -->
|
||||
<div class="chat-time" v-if="(isTg && item.tgChatTime) || (!isTg && item.chatTime)">{{ isTg ? item.tgChatTime : item.chatTime }}</div>
|
||||
<div
|
||||
class="chat-time"
|
||||
v-if="(isTg && item.tgChatTime) || (!isTg && item.chatTime)"
|
||||
>
|
||||
{{ isTg ? item.tgChatTime : item.chatTime }}
|
||||
</div>
|
||||
<div v-if="item.type === 5" class="warn">
|
||||
{{
|
||||
item.phone === store.state.userInfo.account
|
||||
item.phone === store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickname === 2 ? maskUserName(item.userName) : item.userName
|
||||
: detail.showNickname === 2
|
||||
? maskUserName(item.userName)
|
||||
: item.userName
|
||||
}}:分享了直播间
|
||||
<button
|
||||
class="share"
|
||||
@click="sendMsg(5)"
|
||||
v-if="item.phone !== store.state.userInfo.account"
|
||||
v-if="item.phone !== store.state.userInfo.userId"
|
||||
>
|
||||
我也要分享
|
||||
</button>
|
||||
@ -69,7 +81,7 @@
|
||||
v-else
|
||||
:class="[
|
||||
'flex',
|
||||
item.phone === store.state.userInfo.account ? 'row-reverse' : '',
|
||||
item.phone === store.state.userInfo.userId ? 'row-reverse' : '',
|
||||
]"
|
||||
>
|
||||
<div class="photo">
|
||||
@ -91,10 +103,14 @@
|
||||
<h3>
|
||||
{{
|
||||
item.userId
|
||||
? item.phone === store.state.userInfo.account
|
||||
? item.phone === store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickname === 2 ? maskUserName(item.userName) : item.userName
|
||||
: item.createUserVO ? item.createUserVO.name : item.advisorBasic?.showName
|
||||
: detail.showNickname === 2
|
||||
? maskUserName(item.userName)
|
||||
: item.userName
|
||||
: item.createUserVO
|
||||
? item.createUserVO.name
|
||||
: item.advisorBasic?.showName
|
||||
}}
|
||||
<span v-if="item.advisorId">讲师</span>
|
||||
<span v-else-if="item.createUserVO">助教</span>
|
||||
@ -105,20 +121,35 @@
|
||||
<div class="reply-content">
|
||||
<div class="reply">
|
||||
<span style="color: rgba(154, 164, 182, 1)">回复</span
|
||||
><label>{{ item.replyBasic.userId === store.state.userInfo.account
|
||||
? "我" : detail.showNickname === 2 ? maskUserName(item.replyBasic.userName) : item.replyBasic.userName }}:</label>
|
||||
><label
|
||||
>{{
|
||||
item.replyBasic.userId ===
|
||||
store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickname === 2
|
||||
? maskUserName(item.replyBasic.userName)
|
||||
: item.replyBasic.userName
|
||||
}}:</label
|
||||
>
|
||||
{{ item.content }}
|
||||
</div>
|
||||
<div class="reply" style="color: rgba(154, 164, 182, 1)">
|
||||
{{ item.replyBasic.userId === store.state.userInfo.account
|
||||
? "我" : detail.showNickname === 2 ? maskUserName(item.replyBasic.userName) : item.replyBasic.userName }}:{{
|
||||
item.replyBasic.content
|
||||
}}
|
||||
{{
|
||||
item.replyBasic.userId === store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickname === 2
|
||||
? maskUserName(item.replyBasic.userName)
|
||||
: item.replyBasic.userName
|
||||
}}:{{ item.replyBasic.content }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="license">{{ item.advisorBasic?.name }}<i v-if="detail.advisorBasic.license">({{item.advisorBasic?.license}})</i></div>
|
||||
<div class="license">
|
||||
{{ item.advisorBasic?.name
|
||||
}}<i v-if="detail.advisorBasic.license"
|
||||
>({{ item.advisorBasic?.license }})</i
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div v-else-if="item.type === 1 && !item.replyBasic">
|
||||
<div>
|
||||
@ -131,7 +162,12 @@
|
||||
@click="imagePreview(item.content.split('upImg-')[1])"
|
||||
:src="item.content.split('upImg-')[1]"
|
||||
/>
|
||||
<div v-if="item.advisorId" class="license">{{ detail.advisorBasic.name }}<i v-if="detail.advisorBasic.license">({{detail.advisorBasic.license}})</i></div>
|
||||
<div v-if="item.advisorId" class="license">
|
||||
{{ detail.advisorBasic.name
|
||||
}}<i v-if="detail.advisorBasic.license"
|
||||
>({{ detail.advisorBasic.license }})</i
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="item.type === 2" class="product-item">
|
||||
@ -147,9 +183,11 @@
|
||||
<p>
|
||||
<label
|
||||
>{{
|
||||
item.phone === store.state.userInfo.account
|
||||
item.phone === store.state.userInfo.userId
|
||||
? "我"
|
||||
: detail.showNickname === 2 ? maskUserName(item.userName) : item.userName
|
||||
: detail.showNickname === 2
|
||||
? maskUserName(item.userName)
|
||||
: item.userName
|
||||
}}:</label
|
||||
>关注了老师
|
||||
</p>
|
||||
@ -157,7 +195,7 @@
|
||||
class="attention"
|
||||
@click="subAdvisor"
|
||||
v-if="
|
||||
item.phone !== store.state.userInfo.account &&
|
||||
item.phone !== store.state.userInfo.userId &&
|
||||
detail.isSubAdvisor !== 1
|
||||
"
|
||||
>
|
||||
@ -172,7 +210,13 @@
|
||||
</div>
|
||||
<div v-else-if="item.type === 8" style="color: #f46946">
|
||||
<p>
|
||||
<label>{{ detail.showNickname === 2 ? maskUserName(item.userName) : item.userName }}:</label>{{ item.content }}
|
||||
<label
|
||||
>{{
|
||||
detail.showNickname === 2
|
||||
? maskUserName(item.userName)
|
||||
: item.userName
|
||||
}}:</label
|
||||
>{{ item.content }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-else-if="item.type === 11" class="question-item">
|
||||
@ -190,7 +234,9 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="new-msg-tip" @click="lookNewMsg" v-if="newMsgNum">您有{{newMsgNum}}条新的消息</div>
|
||||
<div class="new-msg-tip" @click="lookNewMsg" v-if="newMsgNum">
|
||||
您有{{ newMsgNum }}条新的消息
|
||||
</div>
|
||||
<!-- <div class="product-float" v-if="productFloatShow">
|
||||
<ProductItem
|
||||
:item="informMsgList[informMsgList.length - 1].productBasic"
|
||||
@ -208,7 +254,17 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineProps, onBeforeUnmount, defineExpose, watch, nextTick, onMounted, computed, defineEmits } from "vue";
|
||||
import {
|
||||
ref,
|
||||
defineProps,
|
||||
onBeforeUnmount,
|
||||
defineExpose,
|
||||
watch,
|
||||
nextTick,
|
||||
onMounted,
|
||||
computed,
|
||||
defineEmits,
|
||||
} from "vue";
|
||||
import { useStore } from "vuex";
|
||||
import { showToast, showImagePreview } from "vant";
|
||||
import {
|
||||
@ -260,23 +316,32 @@ const { msgListRef, bs } = useChatData(
|
||||
);
|
||||
|
||||
const hasNext = computed(() => {
|
||||
return props.isTg ? store.state.interactMsgObj.tgHasHisMsg : store.state.interactMsgObj.hasHisMsg
|
||||
})
|
||||
return props.isTg
|
||||
? store.state.interactMsgObj.tgHasHisMsg
|
||||
: store.state.interactMsgObj.hasHisMsg;
|
||||
});
|
||||
|
||||
watch(hasNext, (value) => {
|
||||
if (value) bs.value && bs.value.openPullDown();
|
||||
})
|
||||
});
|
||||
|
||||
watch(()=>props.informMsgList, ()=>{
|
||||
watch(
|
||||
() => props.informMsgList,
|
||||
() => {
|
||||
nextTick(() => {
|
||||
bs.value && bs.value.refresh();
|
||||
if((props.isTg && store.state.interactMsgObj.isTgScrollToBottom) || (!props.isTg && store.state.interactMsgObj.isScrollToBottom ) ) {
|
||||
if (
|
||||
(props.isTg && store.state.interactMsgObj.isTgScrollToBottom) ||
|
||||
(!props.isTg && store.state.interactMsgObj.isScrollToBottom)
|
||||
) {
|
||||
nextTick(() => {
|
||||
bs.value && bs.value.scrollTo(0, bs.value.maxScrollY, 0);
|
||||
})
|
||||
});
|
||||
}
|
||||
})
|
||||
},{deep: true})
|
||||
});
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
|
||||
let intervalTime = null;
|
||||
|
||||
@ -350,7 +415,7 @@ const goAnswer = async (item) => {
|
||||
const emit = defineEmits(["optShare"]);
|
||||
const sendMsg = (type, params) => {
|
||||
if (type === 5) {
|
||||
emit('optShare')
|
||||
emit("optShare");
|
||||
}
|
||||
emitter.emit("emSendMsg", {
|
||||
type,
|
||||
@ -370,41 +435,40 @@ const imagePreview = (url) => {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const newMsgNum = computed(() => {
|
||||
return props.isTg ? store.state.interactMsgObj.temTgInteractShowNum : store.state.interactMsgObj.temUserInteractShowNum
|
||||
})
|
||||
|
||||
return props.isTg
|
||||
? store.state.interactMsgObj.temTgInteractShowNum
|
||||
: store.state.interactMsgObj.temUserInteractShowNum;
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
bs.value.on("scrollEnd", () => {
|
||||
let isBottom = bs.value.maxScrollY+20 >= bs.value.y
|
||||
store.commit('setIsScrollToBottom', {
|
||||
let isBottom = bs.value.maxScrollY + 20 >= bs.value.y;
|
||||
store.commit("setIsScrollToBottom", {
|
||||
isTg: props.isTg,
|
||||
data: isBottom
|
||||
})
|
||||
if(isBottom)resetData()
|
||||
data: isBottom,
|
||||
});
|
||||
if (isBottom) resetData();
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
const lookNewMsg = () => {
|
||||
resetData()
|
||||
}
|
||||
|
||||
resetData();
|
||||
};
|
||||
|
||||
const resetData = () => {
|
||||
store.commit('interactMsgMerge',{isTg: props.isTg})
|
||||
store.commit("interactMsgMerge", { isTg: props.isTg });
|
||||
nextTick(() => {
|
||||
bs.value && bs.value.refresh()
|
||||
bs.value && bs.value.refresh();
|
||||
nextTick(() => {
|
||||
bs.value && bs.value.scrollTo(0, bs.value.maxScrollY, 0);
|
||||
})
|
||||
})
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const maskUserName = (value) => {
|
||||
return value.charAt(0) + '**';
|
||||
}
|
||||
return value.charAt(0) + "**";
|
||||
};
|
||||
|
||||
defineExpose({
|
||||
bs,
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
<NoLookTip v-if="[5, 6].includes(videoDetail.status)" text="该视频已下架" />
|
||||
<NoLookTip
|
||||
v-else-if="noAuth"
|
||||
:text="`${store.state.userInfo.account}账号暂无服务权限,请联系小助理开通`"
|
||||
:text="`${store.state.userInfo.userId}账号暂无服务权限,请联系小助理开通`"
|
||||
/>
|
||||
<van-dialog
|
||||
v-model:show="showCodeDialog"
|
||||
@ -50,7 +50,7 @@ const store = useStore();
|
||||
const router = useRouter();
|
||||
// 之前是否已经进行邀请码校验且通过校验
|
||||
const codeVerify = localStorage.getItem(
|
||||
`${store.state.userInfo.account}-${route.query.id}-code`
|
||||
`${store.state.userInfo.userId}-${route.query.id}-code`
|
||||
);
|
||||
|
||||
const showCodeDialog = computed(() => {
|
||||
@ -137,7 +137,7 @@ const getVideoDetail = async () => {
|
||||
videoDetail.value = ret.data;
|
||||
window.shareApi.initWxH5({
|
||||
env: window.config.shareEnv,
|
||||
shareusername: store.state.userInfo.account,
|
||||
shareusername: store.state.userInfo.userId,
|
||||
title: videoDetail.value.title,
|
||||
summary: videoDetail.value.viewPoint,
|
||||
linkurl: location.href,
|
||||
@ -171,9 +171,9 @@ const getVideoDetail = async () => {
|
||||
// deptId: "",
|
||||
// riskLevel: videoDetail.value.riskLevel,
|
||||
// saleUserId: route.query.saleUserId ? route.query.saleUserId : "",
|
||||
// userId: store.state.userInfo.account,
|
||||
// userId: store.state.userInfo.userId,
|
||||
// userName: store.state.userInfo.userName,
|
||||
// zjzh: store.state.userInfo.account,
|
||||
// zjzh: store.state.userInfo.userId,
|
||||
// imgUrl: store.state.userInfo.imgUrl,
|
||||
// videoId: videoDetail.value.id,
|
||||
// });
|
||||
@ -192,7 +192,7 @@ const getLiveLimit = async () => {
|
||||
// 检验通过
|
||||
if (ret.data.limitType === 3) {
|
||||
localStorage.setItem(
|
||||
`${store.state.userInfo.account}-${route.query.id}-code`,
|
||||
`${store.state.userInfo.userId}-${route.query.id}-code`,
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
<template>
|
||||
<div @click="clear">
|
||||
定时器暂停
|
||||
</div>
|
||||
<div @click="clear">定时器暂停</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@ -12,11 +10,14 @@ const store = useStore();
|
||||
|
||||
let msgIndex = 0;
|
||||
let time;
|
||||
if(store.state.userInfo.account === window.config.testReactionUserId && window.config.testReactionId) {
|
||||
console.log(time)
|
||||
if (
|
||||
store.state.userInfo.userId === window.config.testReactionUserId &&
|
||||
window.config.testReactionId
|
||||
) {
|
||||
console.log(time);
|
||||
time = setInterval(() => {
|
||||
msgIndex++;
|
||||
if(msgIndex === 10000) clearInterval(time)
|
||||
if (msgIndex === 10000) clearInterval(time);
|
||||
liveMsgSend({
|
||||
from: window.config.testReactionUserId,
|
||||
groupId: window.config.testReactionId,
|
||||
@ -29,9 +30,7 @@ if(store.state.userInfo.account === window.config.testReactionUserId && window.c
|
||||
}
|
||||
|
||||
const clear = () => {
|
||||
clearInterval(time)
|
||||
}
|
||||
|
||||
clearInterval(time);
|
||||
};
|
||||
</script>
|
||||
<style scoped lang='scss'>
|
||||
</style>
|
||||
<style scoped lang="scss"></style>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user