微信小程序--搜索电影app(续)

热门推荐页面各个文件代码如下:

recommendMovies.wxml:

<view class="wrapper">
  <view wx:for="{
   {topMovies}}" wx:for-item="item">
    <view class="content">
      <view class="picView">
        <image class="pic" src="{
   {item.images.medium}}" id="{
   {item.id}}" bindtap="toDetail" />
      </view>
      <view class="info">
        <view class="name">
          名称:{
   {item.title}}
        </view>
        <view class="score">{
   {item.rating.average}}分</view>
        <view class="type">
          类型:
          <block wx:for="{
   {item.genres}}" wx:for-item="type">
            {
   {type}},
            <!--注意不要使用<view>,不然调不出效果。。-->
          </block>
        </view>
        <view class="director">
          导演:
          <block wx:for="{
   {item.directors}}" wx:for-item="director">
            {
   {director.name}},
          </block>
        </view>
        <view class="actor">
          演员:
          <block wx:for="{
   {item.casts}}" wx:for-item="actor">
            {
   {actor.name}},
          </block>
        </view>
        <view class="time">年份: {
   {item.year}}</view>
      </view>
    </view>
  </view>
</view>


recommendMovies.wxss:

.wrapper{
  padding:0;
  margin:0;
  width:100%;
  height:100%;
}
.slide-image{
  width:750rpx;
  height:100%;
}

.content{
  width:100%;
  height:300rpx;
  padding:10rx;
  display: flex;
  flex-direction: row;
  border-bottom: 2rpx solid #CCCCCC;
}
.picView{
  float:left;
  padding:20rpx 15rpx;
}
.pic{
  width:210rpx;
  height:260rpx;
}
.info{
  float:left;
  display: flex;
  flex-direction: column;
  color:#888888;
  padding-top:20rpx;
  font-size: 30rpx;
}
.name{
  color:#000;
  width:100%;
  font-size: 32rpx;
  margin-bottom: -19rpx;
}
.score{
  position: relative;
  width:80rpx;
  float:right;
  top:-18rpx;
  color:#8C5A0D;
  right:-433rpx;
}
.type{
  display: flex;
  flex-direction: row;
  margin-bottom: 10rpx;
}
.director{
  display: flex;
  flex-direction: row;
  margin-bottom: 10rpx;  
}
.actor{
  margin-bottom: 10rpx;
}


recommendMovies.js:

//recommendMovies.js
var util = require('../../utils/util.js')
Page({
  data: { 
  },
  onLoad: function () {
    /*
    var city = wx.getStorageSync('city');
    console.log('只在初次进入此页面时执行一次');
    var topMovies = wx.getStorageSync('topMovies'+city);
    if (!topMovies){
      console.log('request');
      this.requestTopMovies();
    }else{
      console.log('storage');
      this.setData({
         topMovies:topMovies
      });
    }
     */
  },
  onShow: function () {
    /* var city = wx.getStorageSync('city'); */
    console.log('每次进入此页面都会执行此函数,适合放需要实时调用页面逻辑的代码');
    /*经测试,此处不需要加city特判,因为请求排行榜靠前的电影时不需要加city参数.
    var topMovies = wx.getStorageSync('topMovies' + city);*/
    var topMovies = wx.getStorageSync('topMovies'
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值