## uni-ad 原生微信小程序开发接入方式 **app.json** ```json { "plugins": { "uni-ad": { "version": "1.1.11", "provider": "wxf72d316417b6767f" }, "coral-adv": { "version": "1.0.18", "provider": "wx0e203209e27b1e66" } } } ``` **page.json** ```json { "usingComponents": { "uni-ad": "plugin://uni-ad/ad" } } ``` **page.wxml** ```html ``` **page.js** ```js Page({ data: {}, showRewardedVideoAd: function (e) { this.selectComponent('.uni-rewarded-video-ad').show(); }, showInterstitialAd: function (e) { this.selectComponent('.uni-interstitial-ad').show(); }, onadclose: function(e) { const detail = e.detail // 用户点击了【关闭广告】按钮 if (detail && detail.isEnded) { // 正常播放结束 console.log("onClose-正常播放结束:" + detail.isEnded); } else { // 播放中途退出 console.log("onClose-播放中途退出:" + detail.isEnded); } }, onaderror: function(e) { // 广告加载失败 console.log('广告加载失败:', e.detail) } }) ```