国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 課堂 > 小程序 > 正文

微信小程序仿貓眼電影的實現(xiàn)教程

2020-03-21 16:30:40
字體:
供稿:網(wǎng)友

微信小程序仿貓眼電影的實現(xiàn)教程

微信小程序,貓眼電影

movie.js

  1. Page({ 
  2.     data: { 
  3.         movies:null
  4.         scrollTop : 0, 
  5.         scrollHeight:0 
  6.     }, 
  7.     onLoad: function (options) { 
  8.         // 生命周期函數(shù)--監(jiān)聽頁面加載 
  9.          // 這里要非常注意,微信的scroll-view必須要設(shè)置高度才能監(jiān)聽滾動事件,所以,需要在頁面的onLoad事件中給scroll-view的高度賦值 
  10.         var that = this
  11.         wx.getSystemInfo({ 
  12.           success:function(res){ 
  13.               console.info(res.windowHeight); 
  14.               that.setData({ 
  15.                   scrollHeight:res.windowHeight 
  16.               }); 
  17.           } 
  18.       }); 
  19.       that.getAllMovies(); 
  20.     }, 
  21.     getAllMovies() { 
  22.         let thispage=this
  23.         //展示 加載框 
  24.         wx.showToast({ 
  25.             title: '加載中'
  26.             icon: 'loading'
  27.             duration: 10000 
  28.         }) 
  29.         //網(wǎng)絡(luò)請求數(shù)據(jù) 
  30.         wx.request({ 
  31.           url: 'https://m.maoyan.com/movie/list.json?type=hot&offset=0&limit=1000'
  32.           method: 'GET'// OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT 
  33.           header: {'content-type':'json'}, // 設(shè)置請求的 header 
  34.           success: function(res){ 
  35.             // success 
  36.             let obj=res.data.data.movies; 
  37.             //將獲取到的數(shù)據(jù)設(shè)置到  page 中的movies上 
  38.             thispage.setData({movies:obj}); 
  39.             //隱藏加載框 
  40.             wx.hideToast(); 
  41.             //停止刷新 
  42.             wx.stopPullDownRefresh(); 
  43.           }, 
  44.           fail: function() { 
  45.             // fail 
  46.           }, 
  47.           complete: function() { 
  48.             // complete 
  49.           } 
  50.         }) 
  51.     }, 
  52.     //點擊事件 
  53.     itemClick(event){ 
  54.     }, 
  55.     //刷新 
  56.     onPullDownRefresh: function () { 
  57.     this.getAllMovies(); 
  58.   }, 
  59. }) 



movie.json

  1.     "enablePullDownRefresh"true 



movie.wxml
 

  1. <view class="top"
  2.     <text class="top_text">深圳</text> 
  3.     <view class="top_input"
  4.       <input placeholder="Q找影視劇、找影院" /> 
  5.     </view> 
  6.   </view> 
  7.   <view class="item" wx:for="{{movies}}" wx:key="{{index}}" bindtap="itemClick" hover-class="item_press" hover="true" > 
  8.     <view class="pic"
  9.       <image src="{{item.img}}"></image> 
  10.     </view> 
  11.     <view class="detail"
  12.       <title>{{item.nm}} 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 岳西县| 威海市| 内江市| 沅江市| 尉犁县| 博白县| 庐江县| 长治市| 柳江县| 金华市| 静乐县| 赫章县| 长岛县| 都兰县| 红桥区| 余庆县| 凤庆县| 英山县| 辛集市| 阳江市| 枣阳市| 河间市| 尚志市| 民乐县| 平远县| 甘南县| 霍山县| 绥江县| 喜德县| 南木林县| 怀仁县| 临城县| 大竹县| 彰化市| 晋江市| 保康县| 德惠市| 阿荣旗| 界首市| 西乌| 台北县|