diff --git a/pages/archive/edit-archive.vue b/pages/archive/edit-archive.vue index 8ef48e5..1f1ae23 100644 --- a/pages/archive/edit-archive.vue +++ b/pages/archive/edit-archive.vue @@ -237,7 +237,7 @@ async function getBaseForm() { } async function getCustomer() { - const res = await api('getRefrencePeople', { customerId: customerId.value }); + const res = await api('getCustomerByCustomerId', { customerId: customerId.value }); if (res && res.success && res.data) { customer.value = res.data; setDisabledTitles(res.data) diff --git a/pages/article/article-detail.vue b/pages/article/article-detail.vue index a6f58fe..8658e62 100644 --- a/pages/article/article-detail.vue +++ b/pages/article/article-detail.vue @@ -30,10 +30,13 @@ import { onLoad } from "@dcloudio/uni-app"; import FullPage from "@/components/full-page.vue"; import api from "@/utils/api.js"; +import { set } from "@/utils/cache"; +import { toast } from "@/utils/widget.js"; import { ref } from "vue"; import { storeToRefs } from "pinia"; import useAccountStore from "@/store/account.js"; const { account } = storeToRefs(useAccountStore()); +const { login } = useAccountStore() const loading = ref(true); const error = ref(""); const articleData = ref({ @@ -102,6 +105,7 @@ const loadArticle = async () => { if (res.success && res.data) { // 格式化日期 let date = ""; + if (res.data.createTime) { const d = new Date(res.data.createTime); const year = d.getFullYear(); @@ -115,6 +119,34 @@ const loadArticle = async () => { content: processRichTextContent(res.data.content || ""), date: date, }; + if (isWechatChannels(res.data)) { + uni.openChannelsActivity({ + finderUserName: res.data.wechatChannels.finderUserName, + feedId: res.data.wechatChannels.feedId, + fail: err => { + const errMsg = err.errMsg || ''; + if (/cancel/i.test(errMsg)) { + return + } + toast(`打开视频号失败:${errMsg}`) + } + }) + return + } + // if (res.data.link) { + // uni.openOfficialAccountArticle({ + // url: res.data.link, + // fail: err => { + // const errMsg = err.errMsg || ''; + // console.error(errMsg) + // console.log(errMsg) + // if (/cancel/i.test(errMsg)) { + // return + // } + // toast(`打开文章失败:${errMsg}`) + // } + // }) + // } } else { error.value = res.message || "加载文章失败"; } @@ -126,11 +158,41 @@ const loadArticle = async () => { } }; +function isWechatChannels(item) { + return item?.wechatChannels?.finderUserName && item?.wechatChannels?.feedId; +} + +async function handleSend(sendId) { + try { + await login(); + markArticleRead(sendId); + authToTeam(sendId) + } catch (e) { + console.log(e) + } +} + +// 通过发送记录 将微信用户关联到团队 +async function authToTeam(sendId) { + const res = await api("relateWechatAccountWithTeam", { + sendId, + openid: account.value?.openid, + unionid: account.value?.unionid, + appid: account.value?.appId, + }) + if (res.success) { + set('home-invite-team-info', { teamId: res.data }) + } +} + + onLoad((options) => { corpId.value = options.corpId; if (options.id) { articleId = options.id; - markArticleRead(options.sendId || ''); + if (options.sendId) { + handleSend(options.sendId) + } loadArticle(); } else { error.value = "文章信息不完整"; diff --git a/pages/article/article-list.vue b/pages/article/article-list.vue index bddd0bd..5d33bcb 100644 --- a/pages/article/article-list.vue +++ b/pages/article/article-list.vue @@ -198,23 +198,23 @@ const loadArticleList = async (reset = false) => { function goToDetail(item) { if (!item?.articleId) return; - if (isWechatChannels(item.articleInfo)) { - uni.openChannelsActivity({ - finderUserName: item.articleInfo.wechatChannels.finderUserName, - feedId: item.articleInfo.wechatChannels.feedId, - success: () => { - markArticleRead(item._id, item.articleId); - }, - fail: err => { - const errMsg = err.errMsg || ''; - if (/cancel/i.test(errMsg)) { - return - } - toast(`打开视频号失败:${errMsg}`) - } - }) - return - } + // if (isWechatChannels(item.articleInfo)) { + // uni.openChannelsActivity({ + // finderUserName: item.articleInfo.wechatChannels.finderUserName, + // feedId: item.articleInfo.wechatChannels.feedId, + // success: () => { + // markArticleRead(item._id, item.articleId); + // }, + // 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}` }); } diff --git a/utils/api.js b/utils/api.js index 62475ab..aeec03d 100644 --- a/utils/api.js +++ b/utils/api.js @@ -42,6 +42,7 @@ const urlsConfig = { searchRateList: 'searchRateList', submitRateRecord: 'submitRateRecord', getRateRecord: 'getRateRecord', + relateWechatAccountWithTeam: 'relateWechatAccountWithTeam' }, member: { addCustomer: 'add',