瀏覽代碼

feat: 完成参数定义

huangzhichao 1 年之前
父節點
當前提交
9b4938f451
共有 2 個文件被更改,包括 35 次插入60 次删除
  1. 28 55
      src/plugin/components/custom/index.tsx
  2. 7 5
      src/plugin/share/const.ts

+ 28 - 55
src/plugin/components/custom/index.tsx

@@ -15,21 +15,10 @@ let loadedMetaFiredInOnce = 0
 function PqCustom(props: PropsWithChildren<CustomPropsType>) {
   let {
     adpId,
-    autoplay,
-    loop,
-    muted,
-    showMusk,
     zIndex,
     openEmbeddedMiniProgram,
-    onPlay,
-    onPause,
-    onEnded,
-    onTimeUpdate,
-    onStop,
     onError,
     onLoad,
-    onView,
-    onClick,
     onClose
   } = wrapProps(props)
   const [show, setShow] = useState(true)
@@ -37,8 +26,6 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
 
   useReady(() => {
     getAdConfig()
-
-    adActionReport(reportBusinessType.buttonView, 'adView')
   })
 
   function getAdConfig() {
@@ -73,36 +60,39 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
   }
 
   function videoPlay() {
-    onPlay()
+    adActionReport(reportBusinessType.adPlay, 'adPlay')
   }
-
-  function videoPause() {
-    onPause()
+  
+  function videoClick() {
+    adActionReport(reportBusinessType.adPlay, 'adClick')
+    adActionReport(reportBusinessType.adPlay, 'adOpen')
+    openEmbeddedMiniProgram()
+    closeCustom()
   }
 
-  function videoPlayEnded() {
-    onEnded()
+  function videoLoad() {
+    adActionReport(reportBusinessType.adPlay, 'adLoad')
+    onLoad()
   }
 
-  function videoTimeUpdate() {
-    onTimeUpdate()
+  function videoError() {
+    adActionReport(reportBusinessType.adPlay, 'adError')
+    onError()
   }
 
-  function videoStop() {
-    onStop()
+  function videoView() {
+    adActionReport(reportBusinessType.adPlay, 'adView')
   }
 
-  function videoClick() {
-    closeCustom()
-  }
+  function videoTimeUpdate() {}
 
   function closeCustom() {
+    adActionReport(reportBusinessType.adPlay, 'adClose')
     onClose()
     setShow(false)
   }
 
   function clickMask() {
-    onClick()
     closeCustom()
   }
 
@@ -129,7 +119,8 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
       pageSource: 'plugin',
       planId,
       pqtId: generateUUID(),
-      videoId: '000'
+      videoId: '000',
+      adpId
     }])
   }
 
@@ -142,25 +133,15 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
           </View>
           <View className='close-icon'style={{zIndex: (zIndex || 1) + 1}} onClick={closeCustom}>
           </View>
-
-          {/* <Navigator url={WEB_VIEW_URL}> */}
             <Custom
-              autoplay={autoplay}
-              loop={loop}
-              muted={muted}
               adData={adData}
               onPlay={videoPlay}
-              onTimeUpdate={videoTimeUpdate}
-              onPause={videoPause}
-              onEnded={videoPlayEnded}
-              onStop={videoStop}
-
               onClick={videoClick}
-              onLoad={onLoad}
-              onView={onView}
-              onError={onError}
+              onLoad={videoLoad}
+              onView={videoView}
+              onError={videoError}
+              onTimeUpdate={videoTimeUpdate}
             />
-          {/* </Navigator> */}
         </View>
       </View>}
     </>
@@ -168,9 +149,8 @@ function PqCustom(props: PropsWithChildren<CustomPropsType>) {
 }
 
 function Custom({
-  autoplay, loop, muted, adData,
-  onPlay, onPause, onEnded, onTimeUpdate, onStop, // 播放事件
-  onClick, onLoad, onView, onError
+  adData, onPlay, // 播放事件
+  onClick, onLoad, onView, onError, onTimeUpdate
 }) {
   const [style, setStyle] = useState({ width: '0px', height: 'px' })
 
@@ -192,6 +172,7 @@ function Custom({
     if (loadedMetaFiredInOnce++ < 1) {
       // 上报load
       onLoad()
+      console.log('load')
     }
   }
 
@@ -202,21 +183,13 @@ function Custom({
         className='custom-video'
         objectFit='fill'
         controls={false}
-        // video属性
-        autoplay={autoplay}
-        loop={loop}
-        muted={muted}
+        autoplay={false}
+        loop
         src={adData.materialAddress}
         poster={adData.materialCoverPic}
-        // video事件
         onPlay={onPlay}
         onTimeUpdate={onTimeUpdate}
-        onPause={onPause}
-        onEnded={onEnded}
-        onStop={onStop}
         onError={onError}
-
-        // video交互
         onClick={onClick}
         onLoadedMetaData={onLoadedMetaData}
       />

+ 7 - 5
src/plugin/share/const.ts

@@ -1,7 +1,9 @@
 export const reportBusinessType = {
-  buttonClick: 'buttonClick',
-  buttonView: 'buttonView',
-  windowView: 'windowView',
-  autoJump: 'autoJump',
-  pageView: 'pageView'
+  adClick: 'adClick',
+  adView: 'adView',
+  adPlay: 'adPlay',
+  adLoad: 'adLoad',
+  adOpen: 'adOpen',
+  adError: 'adError',
+  adClose: 'adClose'
 }