diff --git a/docs/_sidebar.md b/docs/_sidebar.md index ab1e68ecd7001dff155963405d6af92a30979026..cb8c77d7473ad1ca7a30ff8446f118718c07a839 100644 --- a/docs/_sidebar.md +++ b/docs/_sidebar.md @@ -27,6 +27,7 @@ * [混合开发](hybrid.md) * [uni小程序sdk](https://nativesupport.dcloud.net.cn/README) * 运营服务 + * [App升级中心](uniCloud/upgrade-center.md) * [uni一键登录](univerify.md) * [统一推送uniPush](unipush.md) * [uni统计](uni-stat.md) @@ -80,7 +81,7 @@
官方QQ交流群
-
群24:672494800  点此加入
+
群27:811363410  点此加入
群35:713420817(2000人已满)
群34:530305531(2000人已满)
群33:498071674(2000人已满)
@@ -89,10 +90,10 @@
群30:371046920(2000人已满)
群29:202965481(2000人已满)
群28:166188776(2000人已满)
-
群27:811363410(2000人已满)
+
群26:147867597(2000人已满)
群25:165297000(2000人已满)
- +
群24:672494800(2000人已满)
群23:599958679(2000人已满)
群22:687186952(2000人已满)
群21:717019120(2000人已满)
diff --git a/docs/api/_sidebar.md b/docs/api/_sidebar.md index a3afca9ee044138e6b620bb5c42aa4a2a0ed1560..4b4a96aa9a197d9ac3428e6b6c6f75b4ef6086d6 100644 --- a/docs/api/_sidebar.md +++ b/docs/api/_sidebar.md @@ -5,6 +5,7 @@ * [uni.arrayBufferToBase64](api/arrayBufferToBase64?id=arraybuffertobase64) * [生命周期](api/lifecycle.md) * [应用级事件](api/application.md) + * [拦截器](api/interceptor.md) * 网络 * [发起请求](api/request/request.md) * [上传、下载](api/request/network-file.md) @@ -123,6 +124,7 @@ * [支付](api/plugins/payment.md) * [推送](api/plugins/push.md) * [语音](api/plugins/voice.md) + * [一键生成iOS通用链接](api/plugins/universal-links.md) * [uniCloud](api/uniCloud.md) * 平台扩展 * [App原生插件](api/extend/native-plugin.md) @@ -179,7 +181,7 @@
官方QQ交流群
-
群24:672494800  点此加入
+
群27:811363410  点此加入
群35:713420817(2000人已满)
群34:530305531(2000人已满)
群33:498071674(2000人已满)
@@ -188,10 +190,10 @@
群30:371046920(2000人已满)
群29:202965481(2000人已满)
群28:166188776(2000人已满)
-
群27:811363410(2000人已满)
+
群26:147867597(2000人已满)
群25:165297000(2000人已满)
- +
群24:672494800(2000人已满)
群23:599958679(2000人已满)
群22:687186952(2000人已满)
群21:717019120(2000人已满)
diff --git a/docs/api/a-d/content-page.md b/docs/api/a-d/content-page.md index 45b834d3ac63fa2290ed3524e82c1b5b9ca4f1e2..c1aa62f63b05cf291e10fab55f7c9b42a2b9714c 100644 --- a/docs/api/a-d/content-page.md +++ b/docs/api/a-d/content-page.md @@ -23,7 +23,7 @@ * App平台:[https://uniad.dcloud.net.cn/](https://uniad.dcloud.net.cn/) 2. 申请广告位id 在各位后台申请广告位id -3. App端打包后生效,打包时必须选择要集成的广告SDK(目前仅支持快手联盟)。 +3. App端打包后生效,打包时必须选择要集成的广告SDK(目前仅支持快手内容联盟)。 ### 语法 diff --git a/docs/api/a-d/full-screen-video.md b/docs/api/a-d/full-screen-video.md index a3c3c93e793ace076de4e42d78c10f00f607c750..4ca556c148a07ebba51e937e247abeb9aa40cf75 100644 --- a/docs/api/a-d/full-screen-video.md +++ b/docs/api/a-d/full-screen-video.md @@ -50,92 +50,75 @@ uni.createFullScreenVideoAd(Object) 示例代码 -``` +```html - - ``` diff --git a/docs/api/a-d/interstitial.md b/docs/api/a-d/interstitial.md index 87ed5df02959190eaf4adee9c9468cb472383058..18bd0a3534ffab47ec9be433e1d2d817a9c60eb4 100644 --- a/docs/api/a-d/interstitial.md +++ b/docs/api/a-d/interstitial.md @@ -1,31 +1,153 @@ ### 插屏广告 -插屏广告组件。插屏广告组件是一个原生组件,层级比普通组件高。插屏广告组件每次创建都会返回一个全新的实例,默认是隐藏的,需要调用 InterstitialAd.show() 将其显示。 +插屏广告组件是由客户端原生的图片、文本、视频控件组成的;插屏广告与信息流或横幅广告相比展现尺寸更大,同样能够满足您对大量曝光和用户转化的需求。 + +![](https://vkceyugu.cdn.bspapp.com/VKCEYUGU-a90b5f95-90ba-4d30-a6a7-cd4d057327db/5dc1ce6b-b786-4175-aec5-dd2ab4a5e34c.png) **平台差异说明** |App|H5|微信小程序|支付宝小程序|百度小程序|字节跳动小程序|QQ小程序| |:-:|:-:|:-:|:-:|:-:|:-:|:-:| -|x|x|√|x|x|x|x| - -uni.createInterstitialAd(Object object) +|App 3.1.10+|x|√|x|x|x|√| -|属性|类型|必填|说明| -|:-:|:-:|:-:|:-:| -|adUnitId|string|是|广告单元 id,微信小程序2.6.0+| +- app端的广告源由腾讯优量汇、头条穿山甲、快手等广告联盟提供,DCloud负责聚合 +- 小程序端的广告由小程序平台提供 +**开通配置广告** -#### 方法 +开通广告步骤: +1. 开通广告 +需在广告平台后台操作: + * App平台:[https://uniad.dcloud.net.cn/](https://uniad.dcloud.net.cn/) + * 小程序平台:在各自的小程序管理后台操作。 +2. 申请广告位id +在各位后台申请广告位id +3. App端打包后生效,打包时必须选择要集成的广告SDK(优量汇、穿山甲)。 + +### 语法 + +`uni.createInterstitialAd(options)` + +### 参数说明 + +`options` 为 object 类型,属性如下: + +|属性名 |类型 |必填 |描述 |最低支持版本 | +|:-:|:-:|:-:|:-:|:-:| +|adpid |string | 是|广告位 id |App 3.1.10+| +|adUnitId |string | 是|广告位 id |微信小程序2.6.0+, QQ0.1.26+| + + +HBuilder 基座的测试广告位 `adpid` 为 `1111111113` + + +### 广告创建 + +插屏广告组件默认是隐藏的,因此可以提前创建,以提前初始化组件。开发者可以在页面的 onReady 事件回调中创建广告实例,并在该页面的生命周期内重复调用该广告实例。 + + +### 显示/隐藏 + +插屏广告组件默认是隐藏的,开发者需要调用 InterstitialAd.show() 进行显示。如果广告拉取失败或触发频率限制,InterstitialAd.show() 方法会返回一个rejected Promise,开发者可自行监听错误信息 + +```js +interstitialAd.show().catch((err) => { + console.error(err) +}) +``` + +用户可以主动关闭插屏广告。开发者不可控制插屏广告组件的隐藏。 + + +### 监听用户关闭广告 + +如果广告被关闭,通过 InterstitialAd.onClose() 注册的回调函数会执行,回调函数没有参数传递。 + +```js +interstitialAd.onClose(res => { + console.log('插屏 广告关闭') +}) +``` + + +示例代码 + +```html + + + +``` -`Promise InterstitialAd.show()` - -显示插屏广告。 +#### 方法 `Promise InterstitialAd.load()` 加载插屏广告。 +`Promise InterstitialAd.show()` + +显示插屏广告。 + `InterstitialAd.destroy()` 销毁插屏广告实例。 @@ -53,3 +175,8 @@ uni.createInterstitialAd(Object object) `InterstitialAd.offClose(function callback)` 取消监听插屏广告关闭事件 + + +### 注意事项 + +在插屏广告展示过程中如果快速切换页面,可能会出现插屏广告展示在非调用页面的情况,如有需要请在页面切换完成后进行插屏广告展示。 diff --git a/docs/api/a-d/rewarded-video.md b/docs/api/a-d/rewarded-video.md index e705763d8762905aee8f23770be22656c9b25128..2fed9eb2cab16dec58c7d58dc00023096915cd01 100644 --- a/docs/api/a-d/rewarded-video.md +++ b/docs/api/a-d/rewarded-video.md @@ -124,28 +124,61 @@ options 为 object 类型,属性如下: 推荐使用此方案 ```html + + + ``` ```js // ad.js +const ADType = { + RewardedVideo: "RewardedVideo", + FullScreenVideo: "FullScreenVideo" +} + class AdHelper { constructor() { this._ads = {} } - load(adpid, onload, onerror) { + load(options, onload, onerror) { + let ops = this._fixOldOptions(options) + let { + adpid + } = ops + if (!adpid || this.isBusy(adpid)) { return } - this.get(adpid).load(onload, onerror) + this.get(ops).load(onload, onerror) } - show(adpid, onsuccess, onfail) { + show(options, onsuccess, onfail) { + let ops = this._fixOldOptions(options) + let { + adpid + } = ops + if (!adpid) { return } @@ -189,7 +238,7 @@ class AdHelper { mask: true }) - var ad = this.get(adpid) + var ad = this.get(ops) ad.load(() => { uni.hideLoading() @@ -206,23 +255,37 @@ class AdHelper { return (this._ads[adpid] && this._ads[adpid].isLoading) } - get(adpid) { + get(options) { + const { + adpid + } = options if (!this._ads[adpid]) { - this._ads[adpid] = new RewardedVideo({ - adpid: adpid - }) + this._ads[adpid] = this._createAdInstance(options) } return this._ads[adpid] } -} -const eventNames = [ - 'load', - 'close', - 'verify', - 'error' -] + _createAdInstance(options) { + const adType = options.adType || ADType.RewardedVideo + delete options.adType + + let ad = null; + if (adType === ADType.RewardedVideo) { + ad = new RewardedVideo(options) + } else if (adType === ADType.FullScreenVideo) { + ad = new FullScreenVideo(options) + } + + return ad + } + + _fixOldOptions(options) { + return (typeof options === "string") ? { + adpid: options + } : options + } +} const EXPIRED_TIME = 1000 * 60 * 30 const ProviderType = { @@ -232,8 +295,8 @@ const ProviderType = { const RETRY_COUNT = 1 -class RewardedVideo { - constructor(options = {}) { +class AdBase { + constructor(adInstance, options = {}) { this._isLoad = false this._isLoading = false this._lastLoadTime = 0 @@ -244,22 +307,22 @@ class RewardedVideo { this._closeCallback = null this._errorCallback = null - const rewardAd = this._rewardAd = plus.ad.createRewardedVideoAd(options) - rewardAd.onLoad((e) => { + const ad = this._ad = adInstance + ad.onLoad((e) => { this._isLoading = false this._isLoad = true this._lastLoadTime = Date.now() this.onLoad() }) - rewardAd.onClose((e) => { + ad.onClose((e) => { this._isLoad = false this.onClose(e) }) - rewardAd.onVerify((e) => { + ad.onVerify((e) => { // e.isValid }) - rewardAd.onError(({ + ad.onError(({ code, message }) => { @@ -294,7 +357,7 @@ class RewardedVideo { } getProvider() { - return this._rewardAd.getProvider() + return this._ad.getProvider() } load(onload, onerror) { @@ -333,7 +396,7 @@ class RewardedVideo { return } - this._rewardAd.show() + this._ad.show() } onLoad(e) { @@ -357,14 +420,26 @@ class RewardedVideo { } destroy() { - this._rewardAd.destroy() + this._ad.destroy() } _loadAd() { this._isLoad = false this._isLoading = true this._lastError = null - this._rewardAd.load() + this._ad.load() + } +} + +class RewardedVideo extends AdBase { + constructor(options = {}) { + super(plus.ad.createRewardedVideoAd(options), options) + } +} + +class FullScreenVideo extends AdBase { + constructor(options = {}) { + super(plus.ad.createFullScreenVideoAd(options), options) } } diff --git a/docs/api/interceptor.md b/docs/api/interceptor.md new file mode 100644 index 0000000000000000000000000000000000000000..df9d906332ba63de6d640ffa0c9ddd888ae56cae --- /dev/null +++ b/docs/api/interceptor.md @@ -0,0 +1,62 @@ +### uni.addInterceptor(STRING, OBJECT) +添加拦截器 + +**STRING 参数说明** + +需要拦截的`api`名称,如:`uni.addInterceptor('request', OBJECT)` ,将拦截 `uni.request()` + +**OBJECT 参数说明** + +|参数名 |类型 |必填 |默认值 |说明 |平台差异说明 | +|:- |:- |:- |:- |:- |:- | +|invoke |Function |否 | |拦截前触发 | | +|success |Function |否 | |成功回调拦截 | | +|fail |Function |否 | |失败回调拦截 | | +|complete |Function |否 | |完成回调拦截 | | + + +**示例** + +```javascript +uni.request({ + url: 'request/login', //仅为示例,并非真实接口地址。 + success: (res) => { + console.log(res.data); + // 打印: {code:1,...} + } +}); + + +uni.addInterceptor('request', { + invoke(args) { + // request 触发前拼接 url + args.url = 'https://www.example.com/'+args.url + }, + success(args) { + // 请求成功后,修改code值为1 + args.data.code = 1 + }, + fail(err) { + console.log('interceptor-fail',err) + }, + complete(res) { + console.log('interceptor-complete',res) + } +}) + +``` + +### uni.removeInterceptor(STRING) +删除拦截器 + +**STRING 参数说明** + +需要删除拦截器的`api`名称 + +**示例** + +```javascript + +uni.removeInterceptor('request') + +``` \ No newline at end of file diff --git a/docs/api/media/background-audio-manager.md b/docs/api/media/background-audio-manager.md index 994bedecc9f84d56ec2b7ff2298ce4e610e4a395..f48502701dbc668ca8f96eb1eb29e413c4169b66 100644 --- a/docs/api/media/background-audio-manager.md +++ b/docs/api/media/background-audio-manager.md @@ -62,7 +62,7 @@ const bgAudioMannager = uni.getBackgroundAudioManager(); bgAudioMannager.title = '致爱丽丝'; bgAudioMannager.singer = '暂无'; bgAudioMannager.coverImgUrl = 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-uni-app-doc/7fbf26a0-4f4a-11eb-b680-7980c8a877b8.png'; -bgAudioMannager.src = '1. https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3'; +bgAudioMannager.src = 'https://bjetxgzv.cdn.bspapp.com/VKCEYUGU-hello-uniapp/2cc220e0-c27a-11ea-9dfb-6da8e309e0d8.mp3'; ``` diff --git a/docs/api/media/file.md b/docs/api/media/file.md index ed7fc5d95bc8b9c9b5f76c0767774b58c80b614f..5f3c3d0c61f126e47f1385cc66fa3dcf3e4dc31d 100644 --- a/docs/api/media/file.md +++ b/docs/api/media/file.md @@ -20,7 +20,7 @@ |参数名|类型|默认值|必填|说明|平台差异说明| |:-|:-|:-|:-|:-|:-| -|count|Number|100|否|最多可以选择的图片张数|见下方说明| +|count|Number|100|否|最多可以选择的文件数量|见下方说明| |type|String|'all'|否|所选的文件的类型|见下方说明| |extension|Array<String>||否|根据文件拓展名过滤,每一项都不能是空字符串。默认不过滤。|见下方说明| |sourceType|Array<String>|['album','camera']|否|(仅在type为`image`或`video`时可用)`album` 从相册选图,`camera` 使用相机,默认二者都有。如需直接开相机或直接选相册,请只使用一个选项|| @@ -54,8 +54,8 @@ |参数|类型|说明| |:-|:-|:-| -|tempFilePaths|Array<String>|图片的本地文件路径列表| -|tempFiles|Array<Object>、Array<File>|图片的本地文件列表,每一项是一个 File 对象| +|tempFilePaths|Array<String>|文件的本地文件路径列表| +|tempFiles|Array<Object>、Array<File>|文件的本地文件列表,每一项是一个 File 对象| **File 对象结构如下** diff --git a/docs/api/plugins/share.md b/docs/api/plugins/share.md index cd18b07e72bdab7e030f589bc6fd8754581d8863..78f810f904b4ca619b7e2cb9588a598bccc80539 100644 --- a/docs/api/plugins/share.md +++ b/docs/api/plugins/share.md @@ -5,7 +5,8 @@ 1. 使用 ``uni.share`` API方式调用社交sdk分享 2. 使用[plus.share.sendWithSystem](http://www.html5plus.org/doc/zh_cn/share.html#plus.share.sendWithSystem)呼起手机os的系统分享菜单 - 小程序:不支持API调用,只能用户主动点击触发分享。可使用自定义按钮方式 <button open-type="share"> 或监听系统右上角的分享按钮 onShareAppMessage 进行自定义分享内容 -- H5:如果是普通浏览器,浏览器自带分享按钮;如果是在微信内嵌浏览器中,可调用js-sdk进行分享,[参考](https://ask.dcloud.net.cn/article/35380)| +- H5:如果是普通浏览器,浏览器自带分享按钮;如果是在微信内嵌浏览器中,可调用js-sdk进行分享,[参考](https://ask.dcloud.net.cn/article/35380) +- APP:可以直接使用已经封装好的uni-share插件[详情](https://ext.dcloud.net.cn/plugin?id=4860) ### uni.share(OBJECT) uni-app的App引擎已经封装了微信、QQ、微博的分享SDK,开发者可以直接调用相关功能。 @@ -350,7 +351,7 @@ App端可调用手机的系统分享,实现所有注册分享的应用的呼 小程序中用户点击分享后,在 js 中定义 onShareAppMessage 处理函数(和 onLoad 等生命周期函数同级),设置该页面的分享信息。 -* 用户点击分享按钮的时候会调用。这个分享按钮可能是小程序右上角原生菜单自带的分享按钮,也可能是开发者在页面中放置的分享按钮(\