li.shaoyi 5 ヶ月 前
コミット
91739fe779

+ 2 - 1
oem/tss/config/appconfig.json

@@ -12,5 +12,6 @@
   "quotationProperties": [
     "holdvolume"
   ],
-  "riskType": 1
+  "riskType": 1,
+  "metaPixelId": "1216740937129492"
 }

+ 7 - 4
src/hooks/meta-pixel/index.ts

@@ -1,4 +1,5 @@
 import { onMounted } from 'vue'
+import { useGlobalStore } from '@/stores'
 
 // https://developers.facebook.com/docs/meta-pixel/reference
 declare global {
@@ -8,12 +9,14 @@ declare global {
     }
 }
 
-export function useMetaPixel(pixelId = '1427950378223149') {
+export function useMetaPixel() {
+    const { getSystemInfo } = useGlobalStore()
+
     // 初始化 MetaPixel
     const initPixel = () => {
         if (window.fbq) return
 
-        const fbq = <T>(...args: T[]) => {
+        const fbq: any = <T>(...args: T[]) => {
             fbq.callMethod
                 ? fbq.callMethod(...args)
                 : fbq.queue.push(args)
@@ -26,7 +29,7 @@ export function useMetaPixel(pixelId = '1427950378223149') {
         fbq.push = fbq
         fbq.loaded = true
         fbq.version = '2.0'
-        fbq.queue = [] as any[]
+        fbq.queue = []
 
         const el = document.createElement('script')
         el.async = true
@@ -36,7 +39,7 @@ export function useMetaPixel(pixelId = '1427950378223149') {
         tag.parentNode?.insertBefore(el, tag)
 
         window.fbq = fbq
-        window.fbq('init', pixelId)
+        window.fbq('init', getSystemInfo('metaPixelId'))
     }
 
     // 跟踪页面视图

+ 3 - 1
src/stores/modules/global.ts

@@ -20,6 +20,7 @@ export interface SystemInfo {
     i18nEnabled: boolean; // 是否启用多语言设置
     allCloseEnabled: boolean; // 是否启用全部平仓
     allDeliveryEnabled: boolean; // 是否启用全部交收
+    metaPixelId: string;
 }
 
 export const useGlobalStore = defineStore(() => {
@@ -48,7 +49,8 @@ export const useGlobalStore = defineStore(() => {
             riskType: 0,
             i18nEnabled: true,
             allCloseEnabled: false,
-            allDeliveryEnabled: false
+            allDeliveryEnabled: false,
+            metaPixelId: ''
         }
     })