Parcourir la source

📦 发贴图埋点统计接口

快乐的梦鱼 il y a 1 mois
Parent
commit
08d660b570

+ 13 - 1
src/api/light/OfficialApi.ts

@@ -334,7 +334,9 @@ export class OfficialApi extends AppServerRequestModule<DataModel> {
    * 发布贴图
    */
   async publishMessage(params: PostMessage) {
-    return await this.post<KeyValue>('/village/collect/wechatContentSave', '发布微信贴图', params.toServerSide());
+    return transformDataModel<PostMessage>(PostMessage, 
+      (await this.post<KeyValue>('/village/collect/wechatContentSave', '发布微信贴图', params.toServerSide())).requireData()
+    );
   }
 
   /**
@@ -498,6 +500,16 @@ export class OfficialApi extends AppServerRequestModule<DataModel> {
       pay: data.pay,
     };
   }
+
+  /**
+   * 埋点统计
+   */
+  async traceLogApi(action: string, data: KeyValue) {
+    return await this.post('/village/ai/package', '埋点统计', {
+      action,
+      data,
+    });
+  }
 }
 
 

+ 3 - 1
src/common/components/OfficialAccountPublishWrap.vue

@@ -4,7 +4,8 @@
     :topic="topic"
     :background-color="backgroundColor"
     :limit="limit"
-    :path="path"
+    :recommend-path="path"
+    :recommend-title="recommendTitle || '亮乡源'"
     :show-related="showRelated"
     @publishsuccess="emit('publishsuccess', $event)"
     @publishfail="emit('publishfail', $event)"
@@ -22,6 +23,7 @@ const props = withDefaults( defineProps<{
   backgroundColor?: string,
   limit?: number,
   path?: string,
+  recommendTitle?: string,
   showRelated?: boolean,
 }>(), {
   topic: '亮乡源',

+ 1 - 1
src/components/basic/Button.vue

@@ -30,12 +30,12 @@
     </slot>
     <slot>
       <Text 
-        v-bind="textProps"
         :color="textColorFinal" 
         :fontSize="selectStyleType(size, 'medium', FonstSizes)" 
         :fontWeight="type === 'text' ? 'bold' : undefined"
         :innerStyle="textStyle"
         :text="currentText"
+        v-bind="textProps"
       />
     </slot>
     <slot name="rightIcon">

+ 17 - 17
src/pages/home/chat/dependent/post/publish.vue

@@ -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);

+ 30 - 3
src/pages/home/composeabe/OfficialAccount.ts

@@ -1,14 +1,35 @@
 import OfficialApi, { PostMessage } from "@/api/light/OfficialApi";
+import { useAuthStore } from "@/store/auth";
 
 export function useOfficialAccount(getInfoObj: () => any) {
 
-  function onPublishSuccess(postObj: { postUrl: string }) {
+  const authStore = useAuthStore();
+
+  async function prePublish() {
     const res = getInfoObj();
-    OfficialApi.publishMessage(new PostMessage().setSelfValues({
+    return await OfficialApi.publishMessage(new PostMessage().setSelfValues({
       path: `/pages/index`,
       villageId: res.villageId,
       userId: res.userId,
+      images: res.images,
+      title: res.title,
+      content: res.content,
+      nick_name: res.nick_name,
+      topicName: res.tag || '亮乡源',
+    }))
+  }
+
+  async function onPublishSuccess(postObj: { postUrl: string }, id?: number) {
+    const res = getInfoObj();
+    await OfficialApi.publishMessage(new PostMessage().setSelfValues({
+      id,
+      villageId: res.villageId,
+      userId: res.userId,
       jumpUrl: postObj.postUrl,
+      images: res.images,
+      title: res.title,
+      content: res.content,
+      nick_name: res.nick_name,
       topicName: res.tag || '亮乡源',
     })).then(() => {
       console.log('发布成功');
@@ -17,7 +38,13 @@ export function useOfficialAccount(getInfoObj: () => any) {
     });
   }
 
+  function makeOfficialPublishLinkPathAndParams(path: string = '/pages/index', gid?: number | string) {
+    return `${path}?scene=offical:${authStore.userId}:${gid}`
+  }
+
   return {
     onPublishSuccess,
+    prePublish,
+    makeOfficialPublishLinkPathAndParams,
   };
-}
+}

+ 3 - 0
src/pages/home/index.vue

@@ -107,6 +107,7 @@
           radius="radius.lg" 
           :padding="[10, 30]"
           text="切换城市"
+          :textProps="{ fontSize: 'fontSize.sm' }"
           @click="showCityPopup = true"
         />
         <Button 
@@ -114,6 +115,7 @@
           radius="radius.lg" :padding="[10, 30]" 
           @click="showMyFollowPopup = true"
           text="我的关注"
+          :textProps="{ fontSize: 'fontSize.sm' }"
         />
         <BubbleTip
           v-model:show="showLightTip"
@@ -127,6 +129,7 @@
           <Button 
             icon="https://xy.wenlvti.net/app_static/images/home/IconLight.png" 
             radius="radius.lg" :padding="[10, 30]" 
+            :textProps="{ fontSize: 'fontSize.sm' }"
             text="点亮村社"
             @click="handleLightVillage"
           />

+ 6 - 2
src/pages/home/village/introd/card.vue

@@ -304,6 +304,7 @@
   </FlexCol>
   <OfficialAccountPublishWrap
     :topic="recommendTagName" 
+    :path="recommendPath"
     @publishsuccess="onPublishSuccess"
     @empty="isOfficialEmpty=true"
   />
@@ -420,7 +421,7 @@ const emit = defineEmits<{
 const authStore = useAuthStore();
 const { getIsVolunteer } = useUserTools();
 const { requireLogin } = useRequireLogin();
-const { onPublishSuccess } = useOfficialAccount(() => {
+const { onPublishSuccess, makeOfficialPublishLinkPathAndParams } = useOfficialAccount(() => {
   return {
     villageId: villageStore.currentVillage?.id ?? 0,
     userId: authStore.userId,
@@ -513,7 +514,7 @@ const showManageTipTimeout = new MemoryTimeOut('VillageManageTip', 1000 * 3600 *
 const showManageTip = ref(false);
 
 function handleManageFollowTip() {
-  //if (showManageTipTimeout.isTimeout() && !isOfficialEmpty.value)
+  if (showManageTipTimeout.isTimeout() && !isOfficialEmpty.value)
     showManageTip.value = true;
 }
 function handleCloseManageTip(goComp: boolean) {
@@ -529,6 +530,9 @@ watch(rankActiveTag, () => {
 const recommendTagName = computed(() => {
   return '亮乡源·' + villageInfoLoader.content.value?.title + '·' + listActiveTag.value;
 });
+const recommendPath = computed(() => {
+  return makeOfficialPublishLinkPathAndParams('/pages/index');
+});
 
 function handleGoJoin() {
   if (isJoined.value)

+ 16 - 3
src/pages/index.vue

@@ -58,6 +58,8 @@ import { useVillageStore } from '@/store/village';
 import { useAuthStore } from '@/store/auth';
 import { isDevEnv } from '@/common/config/AppCofig';
 import { navTo } from '@/components/utils/PageAction';
+import { waitTimeOut } from '@imengyu/imengyu-utils';
+import { injectAppConfiguration } from '@/api/system/useAppConfiguration';
 import StatusBarSpace from '@/components/layout/space/StatusBarSpace.vue';
 import NavBar from '@/components/nav/NavBar.vue';
 import TabBar from '@/components/nav/TabBar.vue';
@@ -69,9 +71,8 @@ import DiscoverIndex from './home/discover/index.vue';
 import VillageIndex from './home/village/index.vue';
 import CommonRoot from '@/components/dialog/CommonRoot.vue';
 import LightVillageApi from '@/api/light/LightVillageApi';
-import { waitTimeOut } from '@imengyu/imengyu-utils';
-import { injectAppConfiguration } from '@/api/system/useAppConfiguration';
 import BackToTop from '@/components/feedback/BackToTop.vue';
+import OfficialApi from '@/api/light/OfficialApi';
 
 const tabIndex = ref(0);
 const themeContext = useTheme();
@@ -93,14 +94,26 @@ const { querys } = useLoadQuerys({
     navTo('/pages/user/login');
   }
   if (_querys.scene) {
-    //处理从二维码进入村社情况
     const sp = _querys.scene.split(':');
     switch (sp[0]) {
       case 'invg':
+        //处理从二维码进入村社情况
         if (sp.length > 1) {
           querys.value.villageId = Number(sp[1]);
         }
         break;
+      case 'offical':
+        //处理从推广文章返回跳转小程序点击量情况
+        if (sp.length >= 2) {
+          OfficialApi.traceLogApi('click', {
+            action: 'offical_card_clickback',
+            data: {
+              user_id: Number(sp[1]),
+              wechat_content_id: Number(sp[2]),
+            },
+          });
+        }
+        break;
     }
   }
   if (_querys.userId) {