فهرست منبع

feat: 配置adpid

huangzhichao 1 سال پیش
والد
کامیت
da4735e9cd
2فایلهای تغییر یافته به همراه16 افزوده شده و 16 حذف شده
  1. 1 1
      src/pages/index/index.tsx
  2. 15 15
      src/plugin/components/custom/index.tsx

+ 1 - 1
src/pages/index/index.tsx

@@ -19,7 +19,7 @@ const Index: React.FC = () => {
 
   return (
     <View className='index'>
-      <custom props={{ onEmitOpenMiniProgram, adpId: 'uh2321awe1', width:250 }}/>
+      <custom props={{ onEmitOpenMiniProgram, adpId: 'ADY_17097254415021673', width:250 }}/>
     </View>
   )
 }

+ 15 - 15
src/plugin/components/custom/index.tsx

@@ -39,13 +39,13 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
         typeof adpId !== 'string' ||
         typeof onEmitOpenMiniProgram !== 'function'
       ) {
-      catchError('参数错误', 1031)
+      catchError('参数错误', 1031, '用户必传参数没传')
       return
     }
   }
 
   function getAdConfig() {
-    http.post(`${adSelfPredict}?adpId=uh2321awe1`, {
+    http.post(`${adSelfPredict}?adpId=${adpId}`, {
       baseInfo: {},
       positionId: 1,
       phoneModel : '',
@@ -54,19 +54,19 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
     }, {
       header: { 'content-type': 'application/json;' }
     }).then((res: RequestType) => {
-      const { code, data } = res
-      if(code === 10001) {
-        catchError('广告资源加载失败', 1022)
+      const { code, data, msg } = res
+      if(code === 1001) {
+        catchError('广告资源加载失败', 1022, msg)
         return
       }
 
-      if(code === 10002) {
-        catchError('adpId 无效', 1021)
+      if(code === 1002) {
+        catchError('adpId 无效', 1021, msg)
         return
       }
 
-      if(code === 10003) {
-        catchError('初始化失败', 1011)
+      if(code === 1003) {
+        catchError('初始化失败', 1011, msg)
         return
       }
 
@@ -75,7 +75,7 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
       const { landingPageAddress } = platformCreativeInfo || {}
 
       if (!landingPageAddress) {
-        catchError('数据异常', 1013)
+        catchError('数据异常', 1013, '无landingPageAddress')
         return
       }
 
@@ -84,8 +84,7 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
         ...platformCreativeInfo
       })
     }).catch((e) => {
-      console.log(e)
-      catchError('初始化失败', 1011)
+      catchError('初始化失败', 1011,  e.message)
     })
   }
 
@@ -121,7 +120,7 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
   }
 
   function videoError() {
-    catchError('广告加载失败', 1012)
+    catchError('广告加载失败', 1012, '素材播放视频')
   }
 
   function videoView() {
@@ -189,12 +188,13 @@ function YLQCustom(props: PropsWithChildren<CustomPropsType>) {
     }
   }
 
-  function catchError(message, code) {
+  function catchError(message, code, errMessage) {
     onError(code)
     setShow(false)
     adActionReport(reportBusinessType.adError, 'adError', {
       errorCode: code,
-      message
+      message,
+      errMessage
     })
   }