jyj-components 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +11 -0
- package/.eslintrc.js +101 -0
- package/LICENSE +21 -0
- package/MIGRATION.md +336 -0
- package/QUICKSTART.md +300 -0
- package/README.md +200 -0
- package/gulpfile.js +26 -0
- package/miniprogram_dist/ad-banner/index.js +369 -0
- package/miniprogram_dist/ad-banner/index.js.map +1 -0
- package/miniprogram_dist/ad-banner/index.json +4 -0
- package/miniprogram_dist/ad-banner/index.wxml +10 -0
- package/miniprogram_dist/ad-banner/index.wxss +12 -0
- package/miniprogram_dist/ad-interstitial/index.js +450 -0
- package/miniprogram_dist/ad-interstitial/index.js.map +1 -0
- package/miniprogram_dist/ad-interstitial/index.json +4 -0
- package/miniprogram_dist/ad-interstitial/index.wxml +10 -0
- package/miniprogram_dist/ad-interstitial/index.wxss +56 -0
- package/miniprogram_dist/ad-rewarded-video/index.js +439 -0
- package/miniprogram_dist/ad-rewarded-video/index.js.map +1 -0
- package/miniprogram_dist/ad-rewarded-video/index.json +4 -0
- package/miniprogram_dist/ad-rewarded-video/index.wxml +2 -0
- package/miniprogram_dist/ad-rewarded-video/index.wxss +5 -0
- package/miniprogram_dist/ad-splash/index.js +402 -0
- package/miniprogram_dist/ad-splash/index.js.map +1 -0
- package/miniprogram_dist/ad-splash/index.json +4 -0
- package/miniprogram_dist/ad-splash/index.wxml +8 -0
- package/miniprogram_dist/ad-splash/index.wxss +31 -0
- package/miniprogram_dist/assets/copy.wxss +3 -0
- package/miniprogram_dist/assets/icon.png +0 -0
- package/miniprogram_dist/utils.js +5 -0
- package/nul +2 -0
- package/package.json +69 -0
- package/src/ad-banner/index.js +45 -0
- package/src/ad-banner/index.json +4 -0
- package/src/ad-banner/index.wxml +10 -0
- package/src/ad-banner/index.wxss +12 -0
- package/src/ad-interstitial/index.js +125 -0
- package/src/ad-interstitial/index.json +4 -0
- package/src/ad-interstitial/index.wxml +10 -0
- package/src/ad-interstitial/index.wxss +56 -0
- package/src/ad-rewarded-video/index.js +113 -0
- package/src/ad-rewarded-video/index.json +4 -0
- package/src/ad-rewarded-video/index.wxml +2 -0
- package/src/ad-rewarded-video/index.wxss +5 -0
- package/src/ad-splash/index.js +74 -0
- package/src/ad-splash/index.json +4 -0
- package/src/ad-splash/index.wxml +8 -0
- package/src/ad-splash/index.wxss +31 -0
- package/src/assets/copy.wxss +3 -0
- package/src/assets/icon.png +0 -0
- package/src/common.wxss +5 -0
- package/src/index.js +24 -0
- package/src/index.json +9 -0
- package/src/index.wxml +2 -0
- package/src/index.wxss +6 -0
- package/src/lib.ts +5 -0
- package/src/mixins/ad-base.js +125 -0
- package/src/request.js +40 -0
- package/src/reset.wxss +3 -0
- package/src/utils.js +5 -0
- package/tsconfig.json +25 -0
package/QUICKSTART.md
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
# 快速开始
|
|
2
|
+
|
|
3
|
+
## 5 分钟上手指南
|
|
4
|
+
|
|
5
|
+
### 1. 构建组件
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
cd D:\myCode\miniProgram\jyj-components
|
|
9
|
+
npm install
|
|
10
|
+
npm run build
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
构建完成后,会在项目根目录生成 `miniprogram_dist` 目录。
|
|
14
|
+
|
|
15
|
+
### 2. 在小程序中引入
|
|
16
|
+
|
|
17
|
+
#### 方式 A:本地引入(推荐用于开发测试)
|
|
18
|
+
|
|
19
|
+
将 `miniprogram_dist` 目录复制到你的小程序项目中,例如:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
your-miniprogram/
|
|
23
|
+
├── components/
|
|
24
|
+
│ └── jyj-components/ # 复制 miniprogram_dist 到这里并重命名
|
|
25
|
+
├── pages/
|
|
26
|
+
└── app.json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
在 `app.json` 中全局注册:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"usingComponents": {
|
|
34
|
+
"ad-banner": "/components/jyj-components/ad-banner/index",
|
|
35
|
+
"ad-interstitial": "/components/jyj-components/ad-interstitial/index",
|
|
36
|
+
"ad-rewarded-video": "/components/jyj-components/ad-rewarded-video/index",
|
|
37
|
+
"ad-splash": "/components/jyj-components/ad-splash/index",
|
|
38
|
+
"ad-coupon": "/components/jyj-components/ad-coupon/index"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
或在页面 JSON 中单独注册:
|
|
44
|
+
|
|
45
|
+
```json
|
|
46
|
+
{
|
|
47
|
+
"usingComponents": {
|
|
48
|
+
"ad-banner": "/components/jyj-components/ad-banner/index"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### 3. 使用组件
|
|
54
|
+
|
|
55
|
+
#### 示例 1:横幅广告
|
|
56
|
+
|
|
57
|
+
**pages/index/index.wxml**
|
|
58
|
+
```xml
|
|
59
|
+
<view class="container">
|
|
60
|
+
<text>页面内容</text>
|
|
61
|
+
|
|
62
|
+
<!-- 横幅广告 -->
|
|
63
|
+
<ad-banner
|
|
64
|
+
slotId="banner-slot-001"
|
|
65
|
+
bind:adLoad="onBannerLoad"
|
|
66
|
+
bind:adError="onBannerError"
|
|
67
|
+
/>
|
|
68
|
+
</view>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**pages/index/index.js**
|
|
72
|
+
```javascript
|
|
73
|
+
Page({
|
|
74
|
+
onBannerLoad(e) {
|
|
75
|
+
console.log('横幅广告加载成功', e.detail);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
onBannerError(e) {
|
|
79
|
+
console.error('横幅广告加载失败', e.detail);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### 示例 2:插屏广告
|
|
85
|
+
|
|
86
|
+
**pages/game/game.wxml**
|
|
87
|
+
```xml
|
|
88
|
+
<view class="container">
|
|
89
|
+
<button bindtap="showAd">显示插屏广告</button>
|
|
90
|
+
|
|
91
|
+
<ad-interstitial
|
|
92
|
+
slotId="interstitial-slot-001"
|
|
93
|
+
isShow="{{showInterstitial}}"
|
|
94
|
+
isDestroy="{{destroyInterstitial}}"
|
|
95
|
+
bind:adClose="onAdClose"
|
|
96
|
+
/>
|
|
97
|
+
</view>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**pages/game/game.js**
|
|
101
|
+
```javascript
|
|
102
|
+
Page({
|
|
103
|
+
data: {
|
|
104
|
+
showInterstitial: false,
|
|
105
|
+
destroyInterstitial: false
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
showAd() {
|
|
109
|
+
this.setData({ showInterstitial: true });
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
onAdClose() {
|
|
113
|
+
this.setData({
|
|
114
|
+
showInterstitial: false,
|
|
115
|
+
destroyInterstitial: true
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
#### 示例 3:激励视频
|
|
122
|
+
|
|
123
|
+
**pages/reward/reward.wxml**
|
|
124
|
+
```xml
|
|
125
|
+
<view class="container">
|
|
126
|
+
<button bindtap="watchVideo">观看视频获得奖励</button>
|
|
127
|
+
|
|
128
|
+
<ad-rewarded-video
|
|
129
|
+
slotId="video-slot-001"
|
|
130
|
+
isShow="{{showVideo}}"
|
|
131
|
+
bind:adFinished="onVideoFinished"
|
|
132
|
+
bind:adClose="onVideoClose"
|
|
133
|
+
/>
|
|
134
|
+
</view>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**pages/reward/reward.js**
|
|
138
|
+
```javascript
|
|
139
|
+
Page({
|
|
140
|
+
data: {
|
|
141
|
+
showVideo: false,
|
|
142
|
+
coins: 100
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
watchVideo() {
|
|
146
|
+
this.setData({ showVideo: true });
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
onVideoFinished(e) {
|
|
150
|
+
if (e.detail.isEnded) {
|
|
151
|
+
// 用户看完视频,发放奖励
|
|
152
|
+
this.setData({
|
|
153
|
+
coins: this.data.coins + 50,
|
|
154
|
+
showVideo: false
|
|
155
|
+
});
|
|
156
|
+
wx.showToast({
|
|
157
|
+
title: '获得 50 金币',
|
|
158
|
+
icon: 'success'
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
|
|
163
|
+
onVideoClose() {
|
|
164
|
+
this.setData({ showVideo: false });
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### 示例 4:开屏广告
|
|
170
|
+
|
|
171
|
+
**app.js 或首页**
|
|
172
|
+
```xml
|
|
173
|
+
<ad-splash
|
|
174
|
+
slotId="splash-slot-001"
|
|
175
|
+
bind:adFinished="onSplashFinished"
|
|
176
|
+
/>
|
|
177
|
+
|
|
178
|
+
<view class="main-content" wx:if="{{!showSplash}}">
|
|
179
|
+
<!-- 主要内容 -->
|
|
180
|
+
</view>
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
```javascript
|
|
184
|
+
Page({
|
|
185
|
+
data: {
|
|
186
|
+
showSplash: true
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
onSplashFinished() {
|
|
190
|
+
this.setData({ showSplash: false });
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### 示例 5:优惠券组件
|
|
196
|
+
|
|
197
|
+
**pages/coupon/coupon.wxml**
|
|
198
|
+
```xml
|
|
199
|
+
<ad-coupon
|
|
200
|
+
secret="{{couponSecret}}"
|
|
201
|
+
phone="{{userPhone}}"
|
|
202
|
+
userId="{{userId}}"
|
|
203
|
+
/>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**pages/coupon/coupon.js**
|
|
207
|
+
```javascript
|
|
208
|
+
Page({
|
|
209
|
+
data: {
|
|
210
|
+
couponSecret: 'secret-key-from-server',
|
|
211
|
+
userPhone: '13800138000',
|
|
212
|
+
userId: 'user123'
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### 4. 测试
|
|
218
|
+
|
|
219
|
+
在微信开发者工具中打开你的小程序项目,即可看到广告组件的效果。
|
|
220
|
+
|
|
221
|
+
### 5. 常见配置
|
|
222
|
+
|
|
223
|
+
#### 获取 slotId
|
|
224
|
+
|
|
225
|
+
联系后端开发人员或管理员获取有效的广告位 ID(slotId)。
|
|
226
|
+
|
|
227
|
+
#### 广告数据格式
|
|
228
|
+
|
|
229
|
+
后端接口应返回以下格式的数据:
|
|
230
|
+
|
|
231
|
+
```json
|
|
232
|
+
{
|
|
233
|
+
"code": 1,
|
|
234
|
+
"data": [
|
|
235
|
+
{
|
|
236
|
+
"id": "ad001",
|
|
237
|
+
"source": "wx",
|
|
238
|
+
"showCount": 3,
|
|
239
|
+
"banner": {
|
|
240
|
+
"unitId": "adunit-xxxxxxxx"
|
|
241
|
+
}
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
"id": "ad002",
|
|
245
|
+
"source": "custom",
|
|
246
|
+
"showCount": 2,
|
|
247
|
+
"banner": {
|
|
248
|
+
"material": "https://example.com/ad.jpg",
|
|
249
|
+
"appid": "wxAppId",
|
|
250
|
+
"path": "pages/index/index"
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### 6. 下一步
|
|
258
|
+
|
|
259
|
+
- 查看 [README.md](./README.md) 了解完整的 API 文档
|
|
260
|
+
- 查看 `tools/demo` 目录中的完整示例
|
|
261
|
+
- 运行 `npm run dev` 启动开发模式,实时预览组件效果
|
|
262
|
+
|
|
263
|
+
## 故障排除
|
|
264
|
+
|
|
265
|
+
### 问题:组件不显示
|
|
266
|
+
|
|
267
|
+
**解决方案:**
|
|
268
|
+
1. 检查 `slotId` 是否正确
|
|
269
|
+
2. 打开调试器查看网络请求是否成功
|
|
270
|
+
3. 确认后端返回的数据格式正确
|
|
271
|
+
|
|
272
|
+
### 问题:构建失败
|
|
273
|
+
|
|
274
|
+
**解决方案:**
|
|
275
|
+
```bash
|
|
276
|
+
# 清理并重新安装依赖
|
|
277
|
+
npm run clean
|
|
278
|
+
rm -rf node_modules
|
|
279
|
+
npm install
|
|
280
|
+
npm run build
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### 问题:组件路径找不到
|
|
284
|
+
|
|
285
|
+
**解决方案:**
|
|
286
|
+
确保路径正确,使用绝对路径:
|
|
287
|
+
```json
|
|
288
|
+
{
|
|
289
|
+
"usingComponents": {
|
|
290
|
+
"ad-banner": "/components/jyj-components/ad-banner/index"
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## 技术支持
|
|
296
|
+
|
|
297
|
+
如有问题,请查看:
|
|
298
|
+
- [完整文档](./README.md)
|
|
299
|
+
- [GitHub Issues](https://github.com/your-repo/issues)
|
|
300
|
+
- 联系开发团队
|
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# 聚优甲广告组件库
|
|
2
|
+
|
|
3
|
+
微信小程序广告组件库。
|
|
4
|
+
|
|
5
|
+
## 安装
|
|
6
|
+
|
|
7
|
+
### 方式一:npm 安装(推荐)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install jyj-components
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
在小程序 `app.json` 中配置:
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"usingComponents": {
|
|
18
|
+
"ad-banner": "jyj-components/ad-banner/index",
|
|
19
|
+
"ad-interstitial": "jyj-components/ad-interstitial/index",
|
|
20
|
+
"ad-rewarded-video": "jyj-components/ad-rewarded-video/index",
|
|
21
|
+
"ad-splash": "jyj-components/ad-splash/index"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### 方式二:本地引入
|
|
27
|
+
|
|
28
|
+
将 `miniprogram_dist` 目录复制到项目中,然后在 `app.json` 中配置相对路径。
|
|
29
|
+
|
|
30
|
+
## 组件使用
|
|
31
|
+
|
|
32
|
+
### 1. 横幅广告 (ad-banner)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
```xml
|
|
37
|
+
<ad-banner
|
|
38
|
+
slotId="your-slot-id"
|
|
39
|
+
bind:adLoad="onAdLoad"
|
|
40
|
+
bind:adError="onAdError"
|
|
41
|
+
/>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**属性:**
|
|
45
|
+
- `slotId` (String, 必填):广告位 ID
|
|
46
|
+
|
|
47
|
+
**事件:**
|
|
48
|
+
- `adLoad`:广告加载成功
|
|
49
|
+
- `adError`:广告加载失败
|
|
50
|
+
- `adOpenMiniProgram`:跳转小程序(自定义广告)
|
|
51
|
+
|
|
52
|
+
### 2. 插屏广告 (ad-interstitial)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
```xml
|
|
56
|
+
<ad-interstitial
|
|
57
|
+
slotId="your-slot-id"
|
|
58
|
+
isShow="{{showAd}}"
|
|
59
|
+
isDestroy="{{destroyAd}}"
|
|
60
|
+
bind:adLoad="onAdLoad"
|
|
61
|
+
bind:adError="onAdError"
|
|
62
|
+
bind:adClose="onAdClose"
|
|
63
|
+
/>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**属性:**
|
|
67
|
+
- `slotId` (String, 必填):广告位 ID
|
|
68
|
+
- `isShow` (Boolean):控制广告显示
|
|
69
|
+
- `isDestroy` (Boolean):控制广告销毁 默认false 每个广告实例只能修改一次
|
|
70
|
+
|
|
71
|
+
**事件:**
|
|
72
|
+
- `adLoad`:广告加载成功
|
|
73
|
+
- `adError`:广告加载失败
|
|
74
|
+
- `adClose`:广告关闭
|
|
75
|
+
|
|
76
|
+
**使用示例:**
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
Page({
|
|
80
|
+
data: {
|
|
81
|
+
showAd: false,
|
|
82
|
+
destroyAd: false
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
showInterstitialAd() {
|
|
86
|
+
this.setData({ showAd: true });
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
onAdClose() {
|
|
90
|
+
this.setData({
|
|
91
|
+
showAd: false,
|
|
92
|
+
destroyAd: true
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### 3. 激励视频广告 (ad-rewarded-video)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
```xml
|
|
103
|
+
<ad-rewarded-video
|
|
104
|
+
slotId="your-slot-id"
|
|
105
|
+
isShow="{{showVideo}}"
|
|
106
|
+
isDestroy="{{destroyVideo}}"
|
|
107
|
+
bind:adLoad="onAdLoad"
|
|
108
|
+
bind:adError="onAdError"
|
|
109
|
+
bind:adClose="onAdClose"
|
|
110
|
+
bind:adFinished="onAdFinished"
|
|
111
|
+
/>
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**属性:**
|
|
115
|
+
- `slotId` (String, 必填):广告位 ID
|
|
116
|
+
- `isShow` (Boolean):控制视频播放
|
|
117
|
+
- `isDestroy` (Boolean):控制广告销毁 默认false 每个广告实例只能修改一次
|
|
118
|
+
|
|
119
|
+
**事件:**
|
|
120
|
+
- `adLoad`:广告加载成功
|
|
121
|
+
- `adError`:广告加载失败
|
|
122
|
+
- `adClose`:广告关闭
|
|
123
|
+
- `adFinished`:视频播放完成(用户获得奖励)
|
|
124
|
+
|
|
125
|
+
**使用示例:**
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
Page({
|
|
129
|
+
data: {
|
|
130
|
+
showVideo: false
|
|
131
|
+
},
|
|
132
|
+
|
|
133
|
+
watchVideoForReward() {
|
|
134
|
+
this.setData({ showVideo: true });
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
onAdFinished(e) {
|
|
138
|
+
if (e.detail.isEnded) {
|
|
139
|
+
// 用户看完视频,发放奖励
|
|
140
|
+
this.giveReward();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### 4. 开屏广告 (ad-splash)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
```xml
|
|
150
|
+
<ad-splash
|
|
151
|
+
slotId="your-slot-id"
|
|
152
|
+
bind:adLoad="onAdLoad"
|
|
153
|
+
bind:adError="onAdError"
|
|
154
|
+
bind:adFinished="onAdFinished"
|
|
155
|
+
/>
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**属性:**
|
|
159
|
+
- `slotId` (String, 必填):广告位 ID
|
|
160
|
+
|
|
161
|
+
**事件:**
|
|
162
|
+
- `adLoad`:广告加载成功
|
|
163
|
+
- `adError`:广告加载失败
|
|
164
|
+
- `adFinished`:广告结束(倒计时结束或用户跳过)
|
|
165
|
+
|
|
166
|
+
**使用示例:**
|
|
167
|
+
|
|
168
|
+
```javascript
|
|
169
|
+
// app.js 或首页
|
|
170
|
+
Page({
|
|
171
|
+
onLoad() {
|
|
172
|
+
// 开屏广告会自动展示
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
onAdFinished() {
|
|
176
|
+
// 广告结束,进入主页面
|
|
177
|
+
console.log('开屏广告结束');
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## 注意事项
|
|
183
|
+
|
|
184
|
+
1. 向运营人员获取授权链接 通过授权链接授权权限
|
|
185
|
+
2. **广告位 ID**:需要向运营人员申请有效的 `slotId`
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
## 常见问题
|
|
189
|
+
|
|
190
|
+
### Q: 广告不显示?
|
|
191
|
+
A: 检查 `slotId` 是否正确,网络请求是否成功,广告数据格式是否正确。
|
|
192
|
+
|
|
193
|
+
### Q: 如何控制广告展示时机?
|
|
194
|
+
A: 使用 `isShow` 属性控制插屏和激励视频的展示时机。
|
|
195
|
+
|
|
196
|
+
### Q: 如何销毁广告实例?
|
|
197
|
+
A: 设置 `isDestroy` 为 `true` 即可销毁广告实例,释放内存。
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
package/gulpfile.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const gulp = require('gulp')
|
|
2
|
+
const clean = require('gulp-clean')
|
|
3
|
+
|
|
4
|
+
const config = require('./tools/config')
|
|
5
|
+
const BuildTask = require('./tools/build')
|
|
6
|
+
const id = require('./package.json').name || 'miniprogram-custom-component'
|
|
7
|
+
|
|
8
|
+
// 构建任务实例
|
|
9
|
+
// eslint-disable-next-line no-new
|
|
10
|
+
new BuildTask(id, config.entry)
|
|
11
|
+
|
|
12
|
+
// 清空生成目录和文件
|
|
13
|
+
gulp.task('clean', gulp.series(() => gulp.src(config.distPath, {read: false, allowEmpty: true}).pipe(clean()), done => {
|
|
14
|
+
if (config.isDev) {
|
|
15
|
+
return gulp.src(config.demoDist, {read: false, allowEmpty: true})
|
|
16
|
+
.pipe(clean())
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return done()
|
|
20
|
+
}))
|
|
21
|
+
// 监听文件变化并进行开发模式构建
|
|
22
|
+
gulp.task('watch', gulp.series(`${id}-watch`))
|
|
23
|
+
// 开发模式构建
|
|
24
|
+
gulp.task('dev', gulp.series(`${id}-dev`))
|
|
25
|
+
// 生产模式构建
|
|
26
|
+
gulp.task('default', gulp.series(`${id}-default`))
|