微信小程序实战–集阅读与电影于一体的小程序项目(八)
31.电影详情页面
movie-template.wxml
<view class="movie-container" catchtap="onMovieTap" data-movieId="{{movieId}}">
movie.js
onMovieTap:function(event) {
var movieId = event.currentTarget.dataset.movieid;
wx.navigateTo({
url: "movie-detail/movie-detail?id=" + movieId
})
},
util.js
function convertToCastString(casts) {
var castsjoin = "";
for (var idx in casts) {
castsjoin = castsjoin + casts[idx].name + " / ";
}
return castsjoin.substring(0, castsjoin.length - 2);
}
function convertToCastInfos(casts) {
var castsArray = []
for (var idx in casts) {
var cast = {
img: casts[idx].avatars ? casts[idx].avatars.large : "",
name: casts[idx].name
}
castsArray.push(cast);
}
return castsArray;
}
module.exports = {
convertToStarArray: convertToStarArray,
http: http,
convertToCastString: convertToCastString,
convertToCastInfos: convertToCastInfos
};
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.g_baseUrl +
"/v2/movie/subject/" + movieId;
util.http(url,this.processDoubanData);
},
processDoubanData:function(data){
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.convertToStarArray(data.rating.stars),
score: data.rating.average,
director: director,
casts: util.convertToCastString(data.casts),
castsInfo: util.convertToCastInfos(data.casts),
summary: data.summary
}
console.log(movie)
this.setData({
movie:movie
})
}
})
movie-detail.wxml
<import src="../stars/stars-template.wxml" />
<view class="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"/>
<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>
movie-detail.wxss
@import "../stars/stars-template.wxss";
.container{
display:flex;
flex-direction: column;
}
.head-img{
width:100%;
height: 320rpx;
}
.head-img-hover{
width: 100%;
height: 320rpx;
position:absolute;
top:0;
left:0;
display:flex;
flex-direction: column;
}
.main-title{
font-size: 19px;
color:#fff;
font-weight:bold;
margin-top: 50rpx;
margin-left: 40rpx;
letter-spacing: 2px;
}
.sub-title{
font-size: 28rpx;
color:#fff;
margin-left: 40rpx;
margin-top: 30rpx;
}
.like{
display:flex;
flex-direction: row;
margin-top: 30rpx;
margin-left: 40rpx;
}
.highlight-font{
color: #f21146;
font-size:22rpx;
margin-right: 10rpx;
}
.plain-font{
color: #666;
font-size:22rpx;
margin-right: 30rpx;
}
.movie-img{
height:238rpx;
width: 175rpx;
position: absolute;
top:160rpx;
right: 30rpx;
}
.summary{
margin-left:40rpx;
margin-top: 40rpx;
color: #777777;
}
.original-title{
color: #1f3463;
font-size: 24rpx;
font-weight: bold;
margin-bottom: 40rpx;
}
.flex-row{
display:flex;
flex-direction: row;
margin-bottom: 10rpx;
}
.mark{
margin-right: 30rpx;
white-space:nowrap;
color: #999999;
}
.hr{
margin-top:45rpx;
height:1px;
width: 100%;
background-color: #d9d9d9;
}
.synopsis{
margin-left:40rpx;
display:flex;
flex-direction: column;
margin-top: 50rpx;
}
.synopsis-font{
color:#999;
}
.summary-content{
margin-top: 20rpx;
margin-right: 40rpx;
line-height:40rpx;
letter-spacing: 1px;
}
.cast{
margin-left:40rpx;
display:flex;
flex-direction: column;
margin-top:50rpx;
}
.cast-font{
color: #999;
margin-bottom: 40rpx;
}
.cast-container{
display:inline-flex;
flex-direction: column;
margin-bottom: 50rpx;
margin-right: 40rpx;
width: 170rpx;
text-align:center;
white-space: normal;
}
.cast-imgs{
white-space: nowrap;
}
.cast-img{
width: 170rpx;
height: 210rpx;
}
.cast-name{
margin: 10rpx auto 0;
}
结果

微信小程序实战–集阅读与电影于一体的小程序项目(八)的更多相关文章
- 微信小程序实战--集阅读与电影于一体的小程序项目(一)
1.首页欢迎界面 项目目录结构 新建项目ReaderMovie,然后新建文件,结构如下 welcome.wxml <view class='container'> <image cl ...
- [转]微信小程序之购物车 —— 微信小程序实战商城系列(5)
本文转自:http://blog.csdn.net/michael_ouyang/article/details/70755892 续上一篇的文章:微信小程序之商品属性分类 —— 微信小程序实战商城 ...
- [转]微信小程序之购物数量加减 —— 微信小程序实战商城系列(3)
本文转自:http://blog.csdn.net/michael_ouyang/article/details/70194144 我们在购买宝贝的时候,购物的数量,经常是我们需要使用的,如下所示: ...
- WordPress 网站开发“微信小程序“实战(三)
本文是"WordPress 开发微信小程序"系列的第三篇,本文记录的是开发"DeveWork+"小程序1.2 版本的过程.建议先看完第一篇.第二篇再来阅读本文. ...
- 微信小程序全面实战,架构设计 && 躲坑攻略(小程序入门捷径教程)
最近集中开发了两款微信小程序,分别是好奇心日历(每天一条辞典+一个小投票)和好奇心日报(轻量版),直接上图: Paste_Image.png 本文将结合具体的实战经验,主要介绍微信小程序的基础知识.开 ...
- 微信小程序编写新闻阅读列表
微信小程序编写新闻阅读列表 不忘初心,方得始终:初心易得,始终难守. 本篇学习主要内容 Swiper 组件(轮播图) App.json 里的关于导航栏.标题的配置. Page 页面与应用程序的生命周期 ...
- [转]微信小程序之加载更多(分页加载)实例 —— 微信小程序实战系列(2)
本文转自;http://blog.csdn.net/michael_ouyang/article/details/56846185 loadmore 加载更多(分页加载) 当用户打开一个页面时,假设后 ...
- 【微信小程序】转载:微信小程序实战篇-下拉刷新与加载更多
下拉刷新 实现下拉刷新目前能想到的有两种方式 1. 调用系统的API,系统有提供下拉刷新的API接口 当然,你可以直接在全局变量app.json的window里面配置上面这个属性,这样整个项目都允许下 ...
- 微信小程序实战篇:商品属性联动选择(案例)
本期的微信小程序实战篇来做一个电商网站经常用到的-商品属性联动选择的效果,素材参考了一点点奶茶. 效果演示: 商品属性联动.gif 代码示例 1.commodity.xml <!-- < ...
随机推荐
- SQL反模式学习笔记4 建立主键规范【需要ID】
目标:建立主键规范 反模式:每个数据库中的表都需要一个伪主键Id 在表中,需要引入一个对于表的域模型无意义的新列来存储一个伪值,这一列被用作这张表的主键, 从而通过它来确定表中的一条记录,即便其他的列 ...
- pygame学习之绘制移动的矩形
import pygame from pygame.locals import * pygame.init() screen = pygame.display.set_mode((600, 500)) ...
- SVM原理 (转载)
1. 线性分类SVM面临的问题 有时候本来数据的确是可分的,也就是说可以用 线性分类SVM的学习方法来求解,但是却因为混入了异常点,导致不能线性可分,比如下图,本来数据是可以按下面的实线来做超平面分离 ...
- 关于二进制枚举-计蒜客-得到整数X
某君有 n个互不相同的正整数,现在他要从这 n 个正整数之中无重复地选取任意个数,并仅通过加法凑出整数 X.求某君有多少种不同的方案来凑出整数 X. 输入格式 第一行,输入两个整数 n,X(1≤n≤2 ...
- I - Infinite Improbability Drive
I - Infinite Improbability Drivehttp://codeforces.com/gym/241750/problem/I不断构造,先填n-1个0,然后能放1就放1,最后这个 ...
- 爬虫之requests模块
requests模块 什么是requests模块 requests模块是python中原生的基于网络请求的模块,其主要作用是用来模拟浏览器发起请求.功能强大,用法简洁高效.在爬虫领域中占据着半壁江山的 ...
- DCDC设计指南1
DC/DC电源设计指导:一 在设计电源模块的时候,第一时间要把该电源IC的datasheet资料下载好,查看里面的说明: 下面以一款DC/DC转换IC为例: 开始布局前先看下IC的特性说明,图1: 图 ...
- 加固后,上传play store, 在 google play store 下载应用安装后,打开签名校验失败
在Google Play Console. (Google Play App Signing )签署您的应用 在创建应用时: 会有个“ Google Play App Signing” 的东西,提示使 ...
- 查看mac系统版本
打开终端, 输入命令 uname -a 回车 x86_64 表示系统为64位 i686 表示系统32位的
- 【自动化测试】robotframework中一些建议可能需要掌握的关键字
这是2019年的第一篇文章,因公司事情较多,导致更新缓慢.这次主要推荐一些可能在使用rf工具的时候需要掌握的关键字. 1. @{cloose_ele} get webelements xpath= ...