li.shaoyi преди 5 месеца
родител
ревизия
c78c86760e
променени са 2 файла, в които са добавени 19 реда и са изтрити 3 реда
  1. 8 3
      src/hooks/meta-pixel/index.ts
  2. 11 0
      src/packages/tss/views/home/main/index.vue

+ 8 - 3
src/hooks/meta-pixel/index.ts

@@ -1,5 +1,6 @@
 import { onMounted } from 'vue'
 import { useGlobalStore } from '@/stores'
+import plus from '@/utils/h5plus'
 
 // https://developers.facebook.com/docs/meta-pixel/reference
 declare global {
@@ -54,9 +55,13 @@ export function useMetaPixel() {
 
     // 跟踪自定义事件
     const trackEvent = (eventName: 'Lead' | 'Purchase', parameters?: Record<string, any>) => {
-        if (pixelId) {
-            window.fbq('track', eventName, parameters)
-        }
+        // if (pixelId) {
+        //     window.fbq('track', eventName, parameters)
+        // }
+
+        plus.onPlusReady((plus) => {
+            plus.bridge.exec('FacebookExpand', 'expandFunction', [])
+        })
     }
 
     // 在组件挂载时初始化

+ 11 - 0
src/packages/tss/views/home/main/index.vue

@@ -12,6 +12,14 @@
       </app-statusbar>
     </template>
     <div ref="containerRef" class="home-main__container" :style="{ backgroundImage: `url(${getFileUrl(topBanners)})` }">
+
+
+
+      <button type="button" style="border: 1px solid #000; padding: 20px; background-color: #fff;"
+        @click="trackEvent('Lead')">Facebook Test</button>
+
+
+
       <app-block class="home-main__notice">
         <h4 @click="$router.push({ name: 'notice-list' })">
           <span>{{ $t('routes.notice') }}</span>
@@ -55,12 +63,15 @@
 import { shallowRef, onMounted, onActivated, onDeactivated } from 'vue'
 import { Cell, CellGroup, Search, Icon } from 'vant'
 import { getFileUrl } from '@/filters'
+import { useMetaPixel } from '@/hooks/meta-pixel'
 import { queryImageConfigs } from '@/services/api/common'
 import { queryNewTitles } from '@/services/api/news'
 import { useNoticeStore, useGoodsCollectionStore } from '@/stores'
 import plus from '@/utils/h5plus'
 import ProductList from '../../product/list/components/waterfall-list/index.vue'
 
+const { trackEvent } = useMetaPixel()
+
 const noticeStore = useNoticeStore()
 const goodsCollectionStore = useGoodsCollectionStore()