Pārlūkot izejas kodu

feat: 完成开发

huangzhichao 1 gadu atpakaļ
vecāks
revīzija
4b2e99f816

+ 2 - 2
src/http/api/index.ts

@@ -3,8 +3,8 @@ import { BASE_DOMAIN, INVITE_API_DOMAIN, BASE_COMMON_DOMAIN } from './base'
 
 function env(BASE_DOMAIN) {
   // const envApi = Taro.getStorageSync('env')
-  return BASE_DOMAIN['production']
-  // return BASE_DOMAIN['development']
+  // return BASE_DOMAIN['production']
+  return BASE_DOMAIN['development']
 }
 
 export const adSelfPredict =  `${env(INVITE_API_DOMAIN)}/ad/alliance/self/predict`

+ 12 - 3
src/pages/index/index.tsx

@@ -1,13 +1,22 @@
+import Taro from '@tarojs/taro'
 import React from 'react'
 import { View } from '@tarojs/components'
 import './index.less'
-
-const adpId = 'ADY_17103126327291030'
+// dev ADY_17097254415021673
+// pro ADY_17103126327291030
+const adpId = 'ADY_17119548862451948'
 const Index: React.FC = () => {
+
+  function onEmitOpenMiniProgram(appId, path, extraData) {
+    Taro.openEmbeddedMiniProgram({
+      appId, path, extraData
+    })
+  }
+
   return (
     <View className='index'>
       {/* <calendar /> */}
-      <custom props={{ adpId, width: 200 }}/>
+      <custom props={{ adpId, width: 200, onEmitOpenMiniProgram }} />
     </View>
   )
 }

+ 17 - 4
src/plugin/components/custom/index.tsx

@@ -93,12 +93,16 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
   
   function videoClick() {
     adActionReport(reportBusinessType.adClick, 'adClick')
-    videoOpenMiniProgram()
+    const { landingPageAddress, landingPageType, landingPageAppid } = adData
+    if (landingPageType === 1) { // 半屏小程序
+      openOriginMiniProgram(landingPageAddress, landingPageAppid)
+    } else if (landingPageType === 2) { // h5
+      openSelfMiniProgram(landingPageAddress)
+    }
     closeCustom()
   }
 
-  function videoOpenMiniProgram() {
-    const { landingPageAddress } = adData
+  function openSelfMiniProgram(landingPageAddress) {
     const query = queryURLParams(createAdActionReportData())
 
     adActionReport(reportBusinessType.adPlay, 'adOpen')
@@ -107,7 +111,16 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
 
     onEmitOpenMiniProgram(
       'wx5ef216d1caf4a0ea',
-      `/pages/ad-launch-page/index?q=${path}`
+      `/pages/ad-launch-page/index?q=${path}`,
+      {}
+    )
+  }
+
+  function openOriginMiniProgram(landingPageAddress, landingPageAppid) {
+    onEmitOpenMiniProgram(
+      landingPageAppid,
+      landingPageAddress,
+      { pqtId }
     )
   }
 

+ 1 - 1
types/global.d.ts

@@ -36,7 +36,7 @@ declare namespace Taro {
 type CustomPropsType = {
   adpId: number
   width?: number
-  onEmitOpenMiniProgram(appId: string, path: string): void
+  onEmitOpenMiniProgram(appId: string, path: string, extraData: { pqtId?: string }): void
   onError?(code: number): void
   onLoad?(): void
   onClose?(): void