加载更多页面
整个直接调用movieGridTemplate模版,即可。
CDOE
pages/movies/more-movies/more-movies.wxml
1 | <import src="../movie-grid/movie-grid-template.wxml" /> |
pages/movies/more-movies/more-movies.js
1 | var util = require("../../../utils/util.js"); |
pages/movies/more-movies/more-movies.josn
1 | { |
pages/movies/more-movies/more-movies.wxss
1 | @import "../movie-grid/movie-grid-template.wxss"; |
电影详情页面
CODE
pages/movies/movie-detail/movie-detail.wxml
<import src="../stars/stars-template.wxml" />
<view class="md-container">
<image class="head-img" src="{{movie.movieImg}}" mode="aspectFill" />
<view class="head-img-hover" data-src="{{movie.movieImg}}" catchtap="viewMoviePostImg">
<text class="main-title">{{movie.title}}</text>
<text class="sub-title">{{movie.country + " . " + movie.year}}</text>
<view class="like">
<text class="highlight-font">{{movie.wishCount}}</text>
<text class="plain-font">人喜欢</text>
<text class="highlight-font">{{movie.commentCount}}</text>
<text class="plain-font">条评论</text>
</view>
</view>
<image class="movie-img" src="{{movie.movieImg}}" data-src="{{movie.movieImg}}" catchtap="viewMoviePostImg"></image>
<view class="summary">
<view class="original-title">
<text>{{movie.originalTitle}}</text>
</view>
<view class="flex-row">
<text class="mark">评分</text>
<template is="starsTemplate" data="{{stars:movie.stars, score:movie.score}}" />
</view>
<view class="flex-row">
<text class="mark">导演</text>
<text>{{movie.director.name}}</text>
</view>
<view class="flex-row">
<text class="mark">影人</text>
<text>{{movie.casts}}</text>
</view>
<view class="flex-row">
<text class="mark">类型</text>
<text>{{movie.generes}}</text>
</view>
</view>
<view class="hr"></view>
<view class="synopsis">
<text class="synopsis-font">剧情简介</text>
<text class="summary-content">{{movie.summary}}</text>
</view>
<view class="hr"></view>
<view class="cast">
<text class="cast-font"> 影人</text>
<scroll-view class="cast-imgs" scroll-x="true" style="width:100%">
<block wx:for="{{movie.castsInfo}}" wx:for-item="item">
<view class="cast-container">
<image class="cast-img" src="{{item.img}}"></image>
<text class="cast-name">{{item.name}}</text>
</view>
</block>
</scroll-view>
</view>
</view>
pages/movies/movie-detail/movie-detail.js
var util = require("../../../utils/util.js");
var app = getApp();
Page({
//初始化上个页面提取的数据
data: {
movie:{}
},
onLoad: function (options) {
var movieId = options.id;
var url = app.globalData.doubanBase + "/v2/movie/subject/" + movieId;
util.http(url,this.processDoubanData);
},
// 从豆瓣API,提取有用数据。
processDoubanData:function(data){
if (!data) {
return;
}
//某些情况下可能会出现某些数据为空,可能导致乱码用if判断下。一下为举例。
var director = {
avatar: "",
name: "",
id: ""
}
if (data.directors[0] != null) {
if (data.directors[0].avatars != null) {
director.avatar = data.directors[0].avatars.large
}
director.name = data.directors[0].name;
director.id = data.directors[0].id;
}
var movie = {
movieImg: data.images ? data.images.large : "",
country: data.countries[0],
title: data.title,
originalTitle: data.original_title,
wishCount: data.wish_count,
commentCount: data.comments_count,
year: data.year,
generes: data.genres.join("、"),
stars: util.convertToStarsArray(data.rating.stars),//调用全局js中人名“/”隔开
score: data.rating.average,
director: director,
casts: util.convertToCastString(data.casts),
castsInfo: util.convertToCastInfos(data.casts),
summary: data.summary
}
this.setData({
movie:movie
})
},
// 影片海报预览
viewMoviePostImg:function(event){
wx.previewImage({
current: this.data.movie.movieImg , // 当前显示图片的http链接
urls: [this.data.movie.movieImg] // 需要预览的图片http链接列表
})
},
})
pages/movies/movie-detail/movie-detail.josn
{}
pages/movies/movie-detail/movie-detail.wxss
@import "../stars/stars-template.wxss";
.movie-container {
display: flex;
flex-direction: column;
padding: 0 22rpx;
}
.movie-img {
width: 200rpx;
height: 270rpx;
padding-bottom: 20rpx;
}
.movie-title {
margin-bottom: 16rpx;
font-size: 24rpx;
}