文章页面用的是离线数据。电影页面利用豆瓣电影API,更贴近实际开发。主要用到正在热映,即将上映,TOP250,电影详情,查找电影。
电影页面
因图中有多个重复组建,单独拿出来引用。如图中红色框为一个模版,绿色框为一个模版,引用模版时样式也要同步引用。
CODE
pages/movies/movies.wxml
1 | <!--引用绿色框模版--> |
pages/movies/movies.js
1 | //公共js脚本 |
pages/movies/movies.json
1 | { |
pages/movies/movies.wxss
1 | @import "movie-list/movie-list-template.wxss"; |
公共、模版—code—
utils/util.js
公共JS脚本。多出用到提取出来。
1 | // 公共函数 |
pages/movies/stars/stars-template.wxml.wxss
星级评分组建
1 | <template name="starsTemplate"> |
.stars-container{
display: flex;
flex-direction: row;
}
.stars{
display: flex;
flex-direction: row;
height: 17rpx;
margin-right: 24rpx;
margin-top:6rpx;
}
.stars image{
padding: 3rpx;
height: 17rpx;
width: 17rpx;
}
.stars-score{
color: #1f3463;
}
pages/movies/movies-list/movies-list-template.wxml.wxss
电影分栏组件
<import src="../movie/movie-template.wxml" />
<template name="movieListTemplate">
<view class="movie-list-container">
<view class="innet-container">
<view class="movie-head">
<text class="slogan">{{titles}}</text>
<view catchtap="onMoreTap" class="more"data-category="{{titles}}">
<text class="more-text">更多</text>
<image class="more-img" src="/image/icon/arrow-right.png"></image>
</view>
</view>
<view class="movies-container">
<block wx:for="{{movies}}" wx:for-item="movie">
<template is="movieTemplate" data="{{...movie}}"/>
</block>
<!--<template is="movieTemplate" />
<template is="movieTemplate" />-->
</view>
</view>
</view>
</template>
@import "../movie/movie-template.wxss";
.movie-list-container {
background-color: #fff;
display: flex;
flex-direction: column;
}
.innet-container{
margin: 0 auto 20rpx;
}
.movie-head {
padding: 30rpx 20rpx 22rpx;
}
.slogan {
font-size: 24rpx;
}
.more {
float: right;
}
.more-text {
vertical-align: middle;
margin-right: 10rpx;
color: #1f4ba5;
}
.more-img {
width: 9rpx;
height: 16rpx;
vertical-align: middle;
}
.movies-container {
display: flex;
flex-direction: row;
}
pages/movies/movies-grid/movies-grid-template.wxml.wxss
电影搜索页面
<import src="../movie/movie-template.wxml" />
<template name="movieGridTemplate">
<view class="grid-contaioner" >
<block wx:for="{{movies}}" wx:for-item="movie">
<view class="sing-view-contaioner">
<template is="movieTemplate" data="{{...movie}}" />
</view>
</block>
</view>
</template>
@import "../movie/movie-template.wxss";
.sing-view-contaioner {
float: left;
margin-bottom: 40rpx;
}
.grid-contaioner {
height: 1300rpx;
margin: 40rpx 0 40rpx 6rpx;
}
pages/movies/movies/movies-template.wxml.wxss
电影简章,如红框图
<import src="../stars/stars-template.wxml" />
<template name="movieTemplate">
<view class="movie-container" catchtap="onMovieTap" data-movieId="{{movieId}}">
<image class="movie-img" src="{{coveragUrl}}"></image>
<text class="movie-title">{{title}}</text>
<template is="starsTemplate" data="{{stars:stars, score:average}}" />
</view>
</template>
@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;
}