溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

小程序怎么實(shí)現(xiàn)仿貓眼電影

發(fā)布時(shí)間:2022-03-07 10:16:55 來源:億速云 閱讀:237 作者:iii 欄目:開發(fā)技術(shù)

本文小編為大家詳細(xì)介紹“小程序怎么實(shí)現(xiàn)仿貓眼電影”,內(nèi)容詳細(xì),步驟清晰,細(xì)節(jié)處理妥當(dāng),希望這篇“小程序怎么實(shí)現(xiàn)仿貓眼電影”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學(xué)習(xí)新知識吧。

實(shí)現(xiàn)實(shí)例

movie.js

Page({

data: {

movies:null,

scrollTop : 0,

scrollHeight:0

},

onLoad: function (options) {

// 生命周期函數(shù)--監(jiān)聽頁面加載

// 這里要非常注意,微信的scroll-view必須要設(shè)置高度才能監(jiān)聽滾動(dòng)事件,所以,需要在頁面的onLoad事件中給scroll-view的高度賦值

var that = this;

wx.getSystemInfo({

success:function(res){

console.info(res.windowHeight);

that.setData({

scrollHeight:res.windowHeight

});

}

});

that.getAllMovies();

},

getAllMovies() {

let thispage=this;

//展示 加載框

wx.showToast({

title: '加載中',

icon: 'loading',

duration: 10000

})

//網(wǎng)絡(luò)請求數(shù)據(jù)

wx.request({

url: 'http://m.maoyan.com/movie/list.json?type=hot&offset=0&limit=1000',

method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT

header: {'content-type':'json'}, // 設(shè)置請求的 header

success: function(res){

// success

let obj=res.data.data.movies;

//將獲取到的數(shù)據(jù)設(shè)置到 page 中的movies上

thispage.setData({movies:obj});

//隱藏加載框

wx.hideToast();

//停止刷新

wx.stopPullDownRefresh();

},

fail: function() {

// fail

},

complete: function() {

// complete

}

})

},

//點(diǎn)擊事件

itemClick(event){

},

//刷新

onPullDownRefresh: function () {

this.getAllMovies();

},

})

movie.json

{

"enablePullDownRefresh": true

}

movie.wxml

<view class="top">
  <text class="top_text">深圳</text>
  <view class="top_input">
   <input placeholder="Q找影視劇、找影院" />
  </view>
 </view>
 <view class="item" wx:for="{{movies}}" wx:key="{{index}}" bindtap="itemClick" hover-class="item_press" hover="true" >
  <view class="pic">
   <image src="{{item.img}}"></image>
  </view>
  <view class="detail">
   <title>{{item.nm}}
    <text class="threeD" wx:if='{{item["3d"]}}'>3D</text><text class="iMax" wx:if='{{item["imax"]}}'>IMAX</text><text class="score" wx:if="{{item.preSale !=1}}">{{item.sc}}<text style='font-size:11px'>分</text></text><text class="wish" wx:else>{{item.wish}}<text style='font-size:11px'>人想看</text></text>
   </title>
   <view class="type">{{item.cat}}
   </view>
   <view class="star">{{item.star}}
   </view>
   <view class="showinfo">{{item.showInfo}}
   </view>
   <view class="buy" wx:if="{{item.preSale !=1}}" >購買</view>
   <view class="buy" wx:else style="background:#008aff">預(yù)售</view>
  </view>
 </view>

movie.wxss

page{

background-color: #f2f2f2;

}

.top {

background-color: #f2f2f2;

display: flex;

}

.top_text {

margin-left: 15px;

font-size: 15px;

padding: 20px 0;

}

.top_input {

border-radius: 10rpx;

text-align: center;

padding: 4px;

font-size: 15px;

flex: 1;

margin: 10px 20px 10px 10px;

background-color: #fff;

}

.item {

background-color: #FFFFFF;

position:relative;

padding: 10px;

display: flex;

border-width:1px;

border-bottom-style: solid;

border-color: #ccc;

}

.item_press {

background-color: #F0F0F0;

}

.pic image {

margin-right: 10px;

width: 70px;

height: 100px;

}

.detail{

flex: 1;

display: flex;

flex-direction: column;

}

.detail title{

margin-top: 5px;

color: #222222;

flex: 1;

font-size: 16px;

}

.threeD{

border-radius: 2px;

padding: 3px;

background-color: #8bb7ce;

font-size: 10px;

color: white;

}

.iMax{

border-style:solid;

border-width:1px;

margin-left: -2px;

border-top-right-radius: 2px;

border-bottom-right-radius: 2px;

font-size: 10px;

color: #8bb7ce;

padding: 2px;

}

.score,

.wish{

float:right;

color: orange;

margin-right: 15px;

}

.type,

.star{

color: #666666;

font-size: 13px;

overflow:hidden;

white-space: nowrap;

text-overflow:ellipsis;

width: 210px;

flex: 1;

}

.showinfo{

color: #999999;

font-size: 13px;

flex: 1;

}

.buy{

padding: 8px;

border-radius: 5px;

font-size: 13px;

color: #FFFFFF;

background-color: #ee4137;

float: right;

position: absolute;

right: 10px;

top:52px;

}

讀到這里,這篇“小程序怎么實(shí)現(xiàn)仿貓眼電影”文章已經(jīng)介紹完畢,想要掌握這篇文章的知識點(diǎn)還需要大家自己動(dòng)手實(shí)踐使用過才能領(lǐng)會(huì),如果想了解更多相關(guān)內(nèi)容的文章,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI