1 | import { ComponentType } from 'react'
|
2 | import { StandardProps, CommonEventFunction } from './common'
|
3 | interface AdProps extends StandardProps {
|
4 | /** 广告单元id,可在[小程序管理后台](https://mp.weixin.qq.com/)的流量主模块新建
|
5 | * @supported weapp, tt, qq
|
6 | */
|
7 | unitId: string
|
8 |
|
9 | /** 广告自动刷新的间隔时间,单位为秒,参数值必须大于等于30(该参数不传入时 Banner 广告不会自动刷新)
|
10 | * @supported weapp, tt
|
11 | */
|
12 | adIntervals?: number
|
13 |
|
14 | /** 广告类型,默认为展示`banner`,可通过设置该属性为`video`展示视频广告, `grid`为格子广告
|
15 | * @supported weapp
|
16 | */
|
17 | adType?: 'banner' | 'video' | 'grid'
|
18 |
|
19 | /** 广告主题样式设置
|
20 | * @supported weapp
|
21 | */
|
22 | adTheme?: 'white' | 'black'
|
23 |
|
24 | /** 小程序应用 ID
|
25 | * @supported swan
|
26 | */
|
27 | appid?: string
|
28 |
|
29 | /** 小程序广告位 ID
|
30 | * @supported swan
|
31 | */
|
32 | apid?: string
|
33 |
|
34 | /** 广告类型:banner、feed ,需和百青藤平台上的代码位类型相匹配
|
35 | * @supported swan, tt, qq
|
36 | * @default feed
|
37 | */
|
38 | type?: string
|
39 |
|
40 | /** 更改该属性,可以触发广告刷新
|
41 | * @supported swan
|
42 | */
|
43 | updatetime?: string
|
44 |
|
45 | /** 广告是否在屏幕中固定展示
|
46 | * @supported tt
|
47 | */
|
48 | fixed?: string
|
49 |
|
50 | /** 广告的缩放比例,100 为标准尺寸
|
51 | * @supported tt
|
52 | * @default 100
|
53 | */
|
54 | scale?: string
|
55 |
|
56 | /** type 为 feeds 时广告左边距(px),必须大于 0
|
57 | * @supported qq
|
58 | */
|
59 | adLeft?: string
|
60 |
|
61 | /** type 为 feeds 时广告上边距(px),必须大于 0
|
62 | * @supported qq
|
63 | */
|
64 | adTop?: string
|
65 |
|
66 | /** type 为 feeds 时广告宽度(px),默认 100%,最大值为屏幕宽度,最小值为 265
|
67 | * @supported qq
|
68 | */
|
69 | adWidth?: string
|
70 |
|
71 | /** type 为 feeds 时广告高度(px),最小 85,最大 160
|
72 | * @supported qq
|
73 | */
|
74 | adHeight?: string
|
75 |
|
76 | /** type 为 block 时请求积木广告数量(展示以实际拉取广告数量为准)
|
77 | * @supported qq
|
78 | * @default 1
|
79 | */
|
80 | blockSize?: string
|
81 |
|
82 | /** type 为 block 时请求积木广告排列方向
|
83 | * @supported qq
|
84 | * @default landscape
|
85 | */
|
86 | blockOrientation?: 'vertical' | 'landscape'
|
87 |
|
88 | /** 开发者工具下,type 为 banner 时,指定 banner 广告展示三图文还是单图
|
89 | * @supported qq
|
90 | * @default three
|
91 | */
|
92 | testBannerType?: 'one' | 'three'
|
93 |
|
94 | /** 广告加载成功的回调
|
95 | * @supported weapp, swan, tt, qq
|
96 | */
|
97 | onLoad?: CommonEventFunction
|
98 |
|
99 | /** 当广告发生错误时,触发的事件,可以通过该事件获取错误码及原因,事件对象 event.detail = {errCode: 1002}
|
100 | * @supported weapp, swan, tt, qq
|
101 | */
|
102 | onError?: CommonEventFunction<AdProps.onErrorEventDetail>
|
103 |
|
104 | /** 广告关闭的回调
|
105 | * @supported weapp, swan, tt
|
106 | */
|
107 | onClose?: CommonEventFunction
|
108 |
|
109 | /** 贴片类型广告播放期间触发
|
110 | * @supported swan
|
111 | */
|
112 | onStatus?: CommonEventFunction
|
113 |
|
114 | /** type 为 feeds 时广告实际宽高回调
|
115 | * @supported qq
|
116 | */
|
117 | onSize?: CommonEventFunction<AdProps.onSizeEventDetail>
|
118 | }
|
119 | declare namespace AdProps {
|
120 | interface onErrorEventDetail {
|
121 | errCode: keyof AdErrCode
|
122 | }
|
123 |
|
124 | /**
|
125 | * 广告错误码
|
126 | *
|
127 | * 错误码是通过onError获取到的错误信息。调试期间,可以通过异常返回来捕获信息。
|
128 | * 在小程序发布上线之后,如果遇到异常问题,可以在[“运维中心“](https://mp.weixin.qq.com/)里面搜寻错误日志,还可以针对异常返回加上适当的监控信息。
|
129 | */
|
130 | interface AdErrCode {
|
131 | /**
|
132 | * @illustrate 后端错误调用失败
|
133 | * @reason 该项错误不是开发者的异常情况
|
134 | * @solution 一般情况下忽略一段时间即可恢复。
|
135 | */
|
136 | 1000
|
137 |
|
138 | /**
|
139 | * @illustrate 参数错误
|
140 | * @reason 使用方法错误
|
141 | * @solution 可以前往 developers.weixin.qq.com 确认具体教程(小程序和小游戏分别有各自的教程,可以在顶部选项中,“设计”一栏的右侧进行切换。
|
142 | */
|
143 | 1001
|
144 |
|
145 | /**
|
146 | * @illustrate 广告单元无效
|
147 | * @reason 可能是拼写错误、或者误用了其他APP的广告ID
|
148 | * @solution 请重新前往 mp.weixin.qq.com 确认广告位ID。
|
149 | */
|
150 | 1002
|
151 |
|
152 | /**
|
153 | * @illustrate 内部错误
|
154 | * @reason 该项错误不是开发者的异常情况
|
155 | * @solution 一般情况下忽略一段时间即可恢复。
|
156 | */
|
157 | 1003
|
158 |
|
159 | /**
|
160 | * @illustrate 无合适的广告
|
161 | * @reason 广告不是每一次都会出现,这次没有出现可能是由于该用户不适合浏览广告
|
162 | * @solution 属于正常情况,且开发者需要针对这种情况做形态上的兼容。
|
163 | */
|
164 | 1004
|
165 |
|
166 | /**
|
167 | * @illustrate 广告组件审核中
|
168 | * @reason 你的广告正在被审核,无法展现广告
|
169 | * @solution 请前往 mp.weixin.qq.com 确认审核状态,且开发者需要针对这种情况做形态上的兼容。
|
170 | */
|
171 | 1005
|
172 |
|
173 | /**
|
174 | * @illustrate 广告组件被驳回
|
175 | * @reason 你的广告审核失败,无法展现广告
|
176 | * @solution 请前往 mp.weixin.qq.com 确认审核状态,且开发者需要针对这种情况做形态上的兼容。
|
177 | */
|
178 | 1006
|
179 |
|
180 | /**
|
181 | * @illustrate 广告组件被封禁
|
182 | * @reason 你的广告能力已经被封禁,封禁期间无法展现广告
|
183 | * @solution 请前往 mp.weixin.qq.com 确认小程序广告封禁状态。
|
184 | */
|
185 | 1007
|
186 |
|
187 | /**
|
188 | * @illustrate 广告单元已关闭
|
189 | * @reason 该广告位的广告能力已经被关闭
|
190 | * @solution 请前往 mp.weixin.qq.com 重新打开对应广告位的展现。
|
191 | */
|
192 | 1008
|
193 | }
|
194 | interface onSizeEventDetail {
|
195 | width: number
|
196 | height: number
|
197 | }
|
198 | }
|
199 |
|
200 | /** Banner 广告
|
201 | * @classification open
|
202 | * @supported weapp, swan, tt, qq
|
203 | * @example_react
|
204 | * ```tsx
|
205 | * class App extends Component {
|
206 | * render () {
|
207 | * return (
|
208 | * <Ad
|
209 | * unitId=''
|
210 | * adIntervals={60}
|
211 | * onLoad={() => console.log('ad onLoad')}
|
212 | * onError={() => console.log('ad onError')}
|
213 | * onClose={() => console.log('ad onClose')}
|
214 | * />
|
215 | * )
|
216 | * }
|
217 | * }
|
218 | * ```
|
219 | * @example_vue
|
220 | * ```html
|
221 | * <template>
|
222 | * <ad
|
223 | * unit-id=""
|
224 | * ad-intervals="60"
|
225 | * `@load="onLoad"
|
226 | * `@error="onError"
|
227 | * `@close="onClose"
|
228 | * />
|
229 | * </template>
|
230 | * ```
|
231 | * @see https://developers.weixin.qq.com/miniprogram/dev/component/ad.html
|
232 | */
|
233 | declare const Ad: ComponentType<AdProps>
|
234 | export { Ad, AdProps }
|