欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序?qū)崿F(xiàn)首頁彈出廣告

 更新時間:2020年12月03日 14:35:44   作者:貓清  
這篇文章主要為大家詳細介紹了微信小程序?qū)崿F(xiàn)首頁彈出廣告,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了微信小程序?qū)崿F(xiàn)首頁彈出廣告的具體代碼,供大家參考,具體內(nèi)容如下

這個微信小程序首頁廣告demo

僅供有需要的參考

.wxml

<!-- 廣告展示 -->
 
<view class="AdView" hidden="{{showAd}}" catchtouchmove="preventMove">
<view class="bg" ></view>
<view class="active active-sport" >
<view class="cancel" bind:tap = "cancelTap" ></view>
<view class="active-content" bind:tap ="activeContent" data-id='2340173092'>
 <text>this is ad</text>
 <image class="active-img" src ='cloud://international-3bp20.696e-international-3bp20-1300609829/my-image.jpeg' mode="aspectFit"></image>
</view>
</view>
</view>

//事件 catchtouchmove方法主要作用是固定廣告防止點擊穿透,就是使用彈出廣告的后面內(nèi)容不能上下拉動。其中對應(yīng)的.js方法可以不做任何處理。此處只能在真機上看到實際效果,在電腦上不能。并且此方法要放到廣告view最外層 

.wxss

.bg{
 width: 100%;
 height: 100%;
 position: fixed;
 top: 0;
 left: 0; 
 z-index: 990;
 background-color:rgb(180, 180, 180);
 opacity: 0.5;
}
.active{
 width: 80%;
 height:80%;
 background-color: #fff;
 position: absolute;
 top:10%;
 left:50%;
 transform: translate(-50%);
 
 z-index: 992;
}
.active-sport{
 animation: sport 1.5s linear 1;
}
@keyframes sport{
 from{ transform:rotate(0deg) skew(-10deg) scale(2.0) translate(-100%,0)}
 
 to{ transform:rotate(360deg) skew(0deg) scale(1.0) translate(-50%,0)}
}
.active-content{
 width: 80%;
 height:80%;
 background-color: blue ;
 position: absolute;
 top: 50%;
 left: 50%;
 transform: translate(-50%,-50%);
 text-align: center;
 
}
.active-img{
 width: 100%;
 
}
.cancel{
 background: url('data:image/svg+xml;base64,P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IDAtMjIuOTg4NTc0LTQuMzg2OTE0LTMxLjc2MzQyNC0xMy4xNjE3NjQtMTcuNTQ4Njc4LTE3LjUzNDM1Mi0xNy41NDg2NzgtNDUuOTkyNDk3IDAtNjMuNTI1ODI1bDY3Ny42NzEyMjctNjc3LjY4NTU1M2MxNy41NDg2NzgtMTcuNTQ4Njc4IDQ1Ljk3NzE0Ny0xNy41NDg2NzggNjMuNTI1ODI1IDAgMTcuNTQ4Njc4IDE3LjUzNDM1MiAxNy41NDg2NzggNDUuOTkyNDk3IDAgNjMuNTI1ODI1TDIwNC42Mjk1MTcgODgyLjM1NDk3OUMxOTUuODU1NjkgODkxLjEyODgwNyAxODQuMzYwODkxIDg5NS41MTY3NDQgMTcyLjg2NzExNiA4OTUuNTE2NzQ0eiIgcC1pZD0iMjEyMSIgZmlsbD0iI2NkY2RjZCI+PC9wYXRoPjwvc3ZnPg==') no-repeat 10rpx 10rpx/40rpx 40rpx;
width: 60rpx;
height: 60rpx;
position: absolute;
top:5rpx;
right: 5rpx;
z-index: 998;
 
}

此處cancel的背景圖片只能使用base64或本地。

image 只能是網(wǎng)絡(luò)或者fieldId上

可以作用CSS3特性,制作動畫,制作動畫時要注意加上transform之后,才可以增加rotate旋轉(zhuǎn),skew翻轉(zhuǎn),scale縮放,translate移動。

.js 

// miniprogram/pages/demo/demo.js
Page({
 
 /**
 * 頁面的初始數(shù)據(jù)
 */
 data: {
 playlist:[],
 showAd:false
 },
 //cancelTap隱藏方向
 cancelTap(){
 this.setData({showAd:!this.data.showAd});
 },
 //廣告鏈接
 activeContent(event){
 console.log(event.currentTarget.dataset.id);
 // this.setData({showAd:!this.data.showAd});
 let musicId=event.currentTarget.dataset.id;
 wx.navigateTo({
 url:`../musicList/musicList?playlistId=${musicId}`, 
 
 success(){
 console.log('navigate success')
 },
 fail(err){
 console.log(err)
 }
 });
 
 },
 //阻止?jié)L動穿透
 
 preventMove(e){
 console.log(e);
 },
 /**
 * 生命周期函數(shù)--監(jiān)聽頁面加載
 */
 async onLoad(options) {
 this._getPlaylist();
 },
 
 async _getPlaylist(){
 wx.showLoading({
  title: '加載中',
 })
 let listCount = await wx.cloud.callFunction({
 name: 'music',
 data: {
 $url: 'getPlaylist',
 start: this.data.playlist.length,
 count: 15
 }
 })
 .then(res => { 
 console.log(res); 
 res.result.map(value=>{
  this.setData({
  playlist:this.data.playlist.concat(value)
  })
  
 })
 wx.hideLoading();
 return res.result.length;
 })
 .catch(err=>{console.error;wx.hideLoading();wx.showToast({
 title: '加載失敗,稍后再試!',
 icon:'none',
 duration:1500
 })});
 
 return listCount;
 },
//tcbRouter 
 async tcbmusicTap(){
 let result = await wx.cloud.callFunction({
 name:'tcbRouter',
 data:{
  $url:'music'
 }
 })
 .then(res=>console.log(res))
 .catch(err=>console.error);
 },
 async tcbmovieTap(){
 let result = await wx.cloud.callFunction({
  name:'tcbRouter',
  data:{
  $url:'movie'
  }
 })
 .then(res=>console.log(res))
 .catch(err=>console.error);
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
 */
 onReady: function () {
 
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽頁面顯示
 */
 onShow: function () {
 // this.setData({showAd:false});
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽頁面隱藏
 */
 onHide: function () {
 
 },
 
 /**
 * 生命周期函數(shù)--監(jiān)聽頁面卸載
 */
 onUnload: function () {
 
 },
 
 /**
 * 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動作
 */
 async onPullDownRefresh() {
 this.setData({ playlist:[]});
 await this._getPlaylist();
 wx.stopPullDownRefresh();
 },
 
 /**
 * 頁面上拉觸底事件的處理函數(shù)
 */
 async onReachBottom() {
 
 let flag = await this._getPlaylist();
 
 if(!flag){
  wx.showToast({
  title: '我是一個有底的人!',
  duration:2000,
  image:'../../images/girl3.png'
  })
 }
 
 },
 
 /**
 * 用戶點擊右上角分享
 */
 onShareAppMessage: function () {
 
 }
})

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論