feat: 视频号
This commit is contained in:
parent
f8ff13639d
commit
47c255157a
@ -84,6 +84,7 @@ import { storeToRefs } from "pinia";
|
|||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import api from "@/utils/api.js";
|
import api from "@/utils/api.js";
|
||||||
import useAccountStore from "@/store/account.js";
|
import useAccountStore from "@/store/account.js";
|
||||||
|
import { toast } from "@/utils/widget.js";
|
||||||
|
|
||||||
import fullPage from "@/components/full-page.vue";
|
import fullPage from "@/components/full-page.vue";
|
||||||
import EmptyData from "@/components/empty-data.vue";
|
import EmptyData from "@/components/empty-data.vue";
|
||||||
@ -138,6 +139,7 @@ const mapRowToView = (row) => {
|
|||||||
person: row?.customer?.name || "",
|
person: row?.customer?.name || "",
|
||||||
team: row?.team?.name || "-",
|
team: row?.team?.name || "-",
|
||||||
time: sendTime,
|
time: sendTime,
|
||||||
|
articleInfo: row?.articleInfo,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -196,8 +198,50 @@ const loadArticleList = async (reset = false) => {
|
|||||||
|
|
||||||
function goToDetail(item) {
|
function goToDetail(item) {
|
||||||
if (!item?.articleId) return;
|
if (!item?.articleId) return;
|
||||||
|
if (isWechatChannels(item.articleInfo)) {
|
||||||
|
uni.openChannelsActivity({
|
||||||
|
finderUserName: item.articleInfo.wechatChannels.finderUserName,
|
||||||
|
feedId: item.articleInfo.wechatChannels.feedId,
|
||||||
|
success: () => {
|
||||||
|
markArticleRead(item._id);
|
||||||
|
},
|
||||||
|
fail: err => {
|
||||||
|
const errMsg = err.errMsg || '';
|
||||||
|
if (/cancel/i.test(errMsg)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
toast(`打开视频号失败:${errMsg}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
uni.navigateTo({ url: `/pages/article/article-detail?sendId=${item._id}&id=${item.articleId}&corpId=${corpId.value}` });
|
uni.navigateTo({ url: `/pages/article/article-detail?sendId=${item._id}&id=${item.articleId}&corpId=${corpId.value}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isWechatChannels(item) {
|
||||||
|
return item?.wechatChannels?.finderUserName && item?.wechatChannels?.feedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function markArticleRead(sendId) {
|
||||||
|
const unionid = account.value?.unionid;
|
||||||
|
if (!unionid || !articleId) return;
|
||||||
|
try {
|
||||||
|
const { success } = await api(
|
||||||
|
"addArticleReadRecord",
|
||||||
|
{ corpId: corpId.value, articleId, unionid, sendId },
|
||||||
|
false
|
||||||
|
);
|
||||||
|
if (success) {
|
||||||
|
const idx = articles.value.findIndex(i => i._id === sendId);
|
||||||
|
if (idx !== -1) {
|
||||||
|
articles.value[idx].status = "YES";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.warn("markArticleRead failed:", err?.message || err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
onLoad(opts => {
|
onLoad(opts => {
|
||||||
corpId.value = opts.corpId;
|
corpId.value = opts.corpId;
|
||||||
teamId.value = opts.teamId;
|
teamId.value = opts.teamId;
|
||||||
|
|||||||
@ -78,6 +78,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
import { getParsedCustomMessage } from "@/utils/chat-utils.js";
|
import { getParsedCustomMessage } from "@/utils/chat-utils.js";
|
||||||
|
import { toast } from '@/utils/widget'
|
||||||
// import MessageCard from "./message-card/message-card.vue";
|
// import MessageCard from "./message-card/message-card.vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -98,6 +99,15 @@ const isPlaying = computed(() => {
|
|||||||
return props.playingVoiceId === props.message.ID;
|
return props.playingVoiceId === props.message.ID;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const payloadData = computed(() => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(props.message.payload.data);
|
||||||
|
} catch (e) {
|
||||||
|
return {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
// 计算图片样式
|
// 计算图片样式
|
||||||
const getImageStyle = (imageInfo) => {
|
const getImageStyle = (imageInfo) => {
|
||||||
// 如果没有尺寸信息,使用默认样式
|
// 如果没有尺寸信息,使用默认样式
|
||||||
@ -195,6 +205,20 @@ const getArticleData = (message) => {
|
|||||||
|
|
||||||
// 处理文章点击
|
// 处理文章点击
|
||||||
const handleArticleClick = (message) => {
|
const handleArticleClick = (message) => {
|
||||||
|
if (isWechatChannels()) {
|
||||||
|
uni.openChannelsActivity({
|
||||||
|
finderUserName: payloadData.value.wechatChannels.finderUserName,
|
||||||
|
feedId: payloadData.value.wechatChannels.feedId,
|
||||||
|
fail: err => {
|
||||||
|
const errMsg = err.errMsg || '';
|
||||||
|
if (/cancel/i.test(errMsg)) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
toast(`打开视频号失败:${errMsg}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
const { articleId, sendId } = getArticleData(message);
|
const { articleId, sendId } = getArticleData(message);
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: `/pages/article/article-detail?id=${articleId}&sendId=${sendId || ''}&corpId=${props.corpId}`,
|
url: `/pages/article/article-detail?id=${articleId}&sendId=${sendId || ''}&corpId=${props.corpId}`,
|
||||||
@ -244,6 +268,11 @@ const handleSurveyClick = (message) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function isWechatChannels() {
|
||||||
|
const wechatChannels = payloadData.value.wechatChannels || {};
|
||||||
|
return typeof wechatChannels.finderUserName === 'string' && wechatChannels.finderUserName.trim() && typeof wechatChannels.feedId === 'string' && wechatChannels.feedId.trim();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user