huangzhichao il y a 1 an
Parent
commit
026f9196a9
3 fichiers modifiés avec 59 ajouts et 18 suppressions
  1. 35 2
      src/http/index.ts
  2. 24 14
      src/plugin/components/custom/index.tsx
  3. 0 2
      src/plugin/index.ts

+ 35 - 2
src/http/index.ts

@@ -52,8 +52,41 @@ class Http {
             reject(data)
             return
           }
-
-          resolve(data)
+          const mockData = {
+            "code": 0,
+            "msg": "success",
+            "data": {
+              "ownPlatformAlliance": {
+                "adType": "ownPlatformAlliance",
+                "platformCreativeInfo": {
+                  "id": 3403,
+                  "creativeCode": "CREATIVE_17096086444271430",
+                  "adId": 1136,
+                  "adCode": "AD_17095512471071489",
+                  "campaignId": 172,
+                  "campaignCode": "CAMPAIGN_17024525411821220",
+                  "advertiserId": 332,
+                  "advertiserCode": "ADA_17024523941341815",
+                  "creativePattern": 3,
+                  "creativeTitle": "联盟广告测试",
+                  "copywriting": "111",
+                  "materialType": "VIDEO",
+                  "materialAddress": "http://rescdn.yishihui.com/ad/transcode/prod/video/material_CREATIVE_17096086444271430_1709608644427.mp4",
+                  "creativeLogoAddress": "http://rescdn.yishihui.com/ad/prod/image/logo_1709608644242.png",
+                  "clickButtonText": "按钮啊啊",
+                  "clickButtonColor": "#00C25D",
+                  "clickButtonEffects": 0,
+                  "landingPageType": 2,
+                  "landingPageAddress": "https://nbtga.whjiaoy.com/putin/linkTovnn7Pb?ewpCode=10008&channel=786&subChannel=415&lxqAdid=pqAdOpDrKrMMm8",
+                  "positionId": 13,
+                  "adpId":"xxxxxx",
+                  "trafficCode":"ATP182138123"
+                }
+              }
+            },
+            "success": true
+          }
+          resolve(mockData || data)
         },
         fail(res) {
           reject(res)

+ 24 - 14
src/plugin/components/custom/index.tsx

@@ -7,14 +7,9 @@ import './index.less'
 import http from '@/http/index'
 import { adSelfPredict } from '@/http/api/index'
 
-// const WEB_VIEW_URL = 'plugin-private://wxf7261ed54f2e450e/pages/customPage/index'
-const VIDEO_SRC = 'https://xycdn.yishihui.com/ad/prod/video/material_AD_1708595757_1708595757542.mp4'
-const VIDEO_COVER = 'http://rescdn.yishihui.com/ad/prod/video/material_AD_1702267670_1702267670233.mp4?x-oss-process=video/snapshot,t_5000,f_jpg,w_0,h_0,m_fast'
-
 // 在一些场景下 loadedMetaFiredInOnce 被触发了很多次
 let loadedMetaFiredInOnce = 0
 
-
 function PqCustom(props: PropsWithChildren<CustomPropsType>) {
   let {
     adpId,
@@ -36,6 +31,7 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
     onClose
   } = wrapProps(props)
   const [show, setShow] = useState(true)
+  const [adData, setAdData] = useState<any>({})
 
   useReady(() => {
     getAdConfig()
@@ -51,7 +47,22 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
     }, {
       header: { 'content-type': 'application/json;' }
     }).then((res: RequestType) => {
-      console.log(res)
+      const { code, message, data } = res
+      // TODO: onError、logUpload
+      if(code !== 0) {
+        onError()
+        // logUpload()
+        return
+      }
+
+      const { ownPlatformAlliance } = data || {}
+      const { adType, platformCreativeInfo } = ownPlatformAlliance || {}
+      setAdData({
+        adType,
+        ...platformCreativeInfo
+      })
+
+      console.log(data)
     })
   }
 
@@ -104,8 +115,7 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
               autoplay={autoplay}
               loop={loop}
               muted={muted}
-              src={VIDEO_SRC}
-              poster={VIDEO_COVER}
+              adData={adData}
               onPlay={videoPlay}
               onTimeUpdate={videoTimeUpdate}
               onPause={videoPause}
@@ -125,7 +135,7 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
 }
 
 function Custom({
-  autoplay, loop, muted, src, poster,
+  autoplay, loop, muted, adData,
   onPlay, onPause, onEnded, onTimeUpdate, onStop, // 播放事件
   onClick, onLoad, onView, onError
 }) {
@@ -163,8 +173,8 @@ function Custom({
         autoplay={autoplay}
         loop={loop}
         muted={muted}
-        src={src}
-        poster={poster}
+        src={adData.materialAddress}
+        poster={adData.materialCoverPic}
         // video事件
         onPlay={onPlay}
         onTimeUpdate={onTimeUpdate}
@@ -178,9 +188,9 @@ function Custom({
         onLoadedMetaData={onLoadedMetaData}
       />
       <View className='custom-bottom'>
-        <Image src='http://rescdn.yishihui.com/ad/prod/image/logo_AD_1702267670_1702267670233.png' className='logo' />
-        <View className='title'>5天站桩入门课</View>
-        <View className='button'>免费领取</View>
+        <Image src={adData.creativeLogoAddress} className='logo' />
+        <View className='title'>{adData.creativeTitle}</View>
+        <View className='button'>{adData.clickButtonText}</View>
       </View>
     </View>
   )

+ 0 - 2
src/plugin/index.ts

@@ -3,8 +3,6 @@ import Taro from '@tarojs/taro'
 async function loadPlugin() {
   Taro.$global = await createTaroGlobal()
   listenNetwork()
-  console.log(Taro.$global)
-
 }
 
 async function createTaroGlobal() {