-
Notifications
You must be signed in to change notification settings - Fork 19
/
wxad.ts
40 lines (36 loc) · 916 Bytes
/
wxad.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
declare const wx;
import {wxFunc} from "./wxfuncs"
export interface WxBannerAd
{
onError:(cb:(err:any) => void) => void;
onLoad:(cb:() => void) => void;
onResize:(cb:(res) => void) => void;
offError:(cb?:(err:any) => void) => void;
offLoad:(cb?:() => void) => void;
offResize:(cb?:(res) => void) => void;
show:() => Promise<any>;
hide:() => void;
destroy:() => void;
adUnitId:string;
style;
}
class WxAd
{
createBannerAd(adUnitId:string, left:number, top:number, width?:number, height?:number):WxBannerAd
{
if(wxFunc.compareSDKVersion("2.0.4") < 0)
{
return null;
}
return wx.createBannerAd({
adUnitId,
style: {
left,
top,
width: width || 1,
height: height || 1,
}
});
}
}
export const wxAd = new WxAd();