|
|
@@ -99,6 +99,7 @@ import Button from '@/components/basic/Button.vue';
|
|
|
import OfficialApi, { PostMessage } from '@/api/light/OfficialApi';
|
|
|
import LightVillageApi from '@/api/light/LightVillageApi';
|
|
|
import CommonContent from '@/api/CommonContent';
|
|
|
+import { useOfficialAccount } from '@/pages/home/composeabe/OfficialAccount';
|
|
|
|
|
|
const { querys } = useLoadQuerys({
|
|
|
tag: '',
|
|
|
@@ -127,6 +128,17 @@ const { querys } = useLoadQuerys({
|
|
|
});
|
|
|
const authStore = useAuthStore();
|
|
|
|
|
|
+const { onPublishSuccess, makeOfficialPublishLinkPathAndParams, prePublish } = useOfficialAccount(() => ({
|
|
|
+ villageId: querys.value.villageId,
|
|
|
+ userId: authStore.userId,
|
|
|
+ tag: querys.value.tag,
|
|
|
+ title: title.value,
|
|
|
+ content: content.value,
|
|
|
+ nick_name: authStore.userInfo?.nick_name || '',
|
|
|
+ images: images.value.map((image) => image.localUrl),
|
|
|
+}));
|
|
|
+
|
|
|
+
|
|
|
const title = ref('');
|
|
|
const content = ref('');
|
|
|
const images = ref<{
|
|
|
@@ -219,7 +231,7 @@ function uploadImage(item: UploaderAction) {
|
|
|
task?.abort();
|
|
|
};
|
|
|
}
|
|
|
-function publish() {
|
|
|
+async function publish() {
|
|
|
if (images.value.length === 0) {
|
|
|
toast('请上传图片');
|
|
|
return;
|
|
|
@@ -228,6 +240,8 @@ function publish() {
|
|
|
title: title.value,
|
|
|
content: content.value,
|
|
|
images: images.value.map((image) => image.localUrl),
|
|
|
+ recommendPath: makeOfficialPublishLinkPathAndParams('/pages/index', (await prePublish()).id),
|
|
|
+ recommendTitle: '亮乡源',
|
|
|
tags: [
|
|
|
'亮乡源',
|
|
|
`${querys.value.tag || '亮乡源'}`
|
|
|
@@ -237,23 +251,9 @@ function publish() {
|
|
|
(uni as any).shareToOfficialAccount({
|
|
|
...data,
|
|
|
success: (postObj: { postUrl: string }) => {
|
|
|
- OfficialApi.publishMessage(new PostMessage().setSelfValues({
|
|
|
- title: title.value,
|
|
|
- content: content.value,
|
|
|
- images: images.value.map((image) => image.url),
|
|
|
- image: images.value[0].url,
|
|
|
- path: `/pages/index`,
|
|
|
- villageId: querys.value.villageId,
|
|
|
- userId: authStore.userId,
|
|
|
- jumpUrl: postObj.postUrl,
|
|
|
- topicName: querys.value.tag || '亮乡源',
|
|
|
- })).then(() => {
|
|
|
- console.log('发布成功');
|
|
|
- }).catch((e) => {
|
|
|
- console.error(e);
|
|
|
- });
|
|
|
+ onPublishSuccess(postObj);
|
|
|
uni.removeStorageSync('postDraft');
|
|
|
- toast('发布成功, 文章可能需要审核稍后才能展示');
|
|
|
+ toast('发布成功, 文章可能需要等待微信审核,稍后才能展示');
|
|
|
setTimeout(() => {
|
|
|
backAndCallOnPageBack('refreshOfficialAccount', { })
|
|
|
}, 2000);
|