赞
踩
配置页面
"pages":[
"pages/movie/movie",
"pages/my/my",
"pages/datails/datails"
],
配置 tabBar
"tabBar": { "selectedColor": "#fb5268", "list": [ { "pagePath": "pages/movie/movie", "text": "电影", "iconPath": "./icon/movie2.png", "selectedIconPath": "./icon/movie1.png" }, { "pagePath": "pages/my/my", "text": "我的", "iconPath": "./icon/me2.png", "selectedIconPath": "./icon/me1.png" } ] },
// pages/movie/movie.js Page({ // 页面的初始数据 data: { navList:["正在热映","即将上映"], select:[true,false], imageList:[ "../../image/1.jpg", "../../image/2.jpg", "../../image/3.jpg", "../../image/4.jpg" ] }, // 切换顶部导航 navClick:function(e) { // 控制导航样式 let index = e.currentTarget.dataset.index; let select = [false,false]; select[index] = true; this.setData({ select:select }) // 获取第二页面数据 if(index == 1) { let list = this.data.list; let futureList = []; for(let prop in list) { if(prop > 12) { futureList.push(list[prop]) } } this.setData({ futureList:futureList }) } }, // 跳转详情页 jumpDetails:function(e) { let id = e.currentTarget.dataset.id; wx.navigateTo({ url: '../datails/datails?id='+id, }) }, // 页面加载 onLoad: function (options) { this.request() }, // 封装函数,请求接口数据 request:function() { wx.request({ url: 'https://m.douban.com/rexxar/api/v2/subject_collection/movie_showing/items', method:"GET", success:(res) => { let data = res.data.subject_collection_items; let movieList = []; for(let prop of data) { let movie = {}; movie.title = prop.title; movie.image = prop.cover.url; movie.director = this.toStr(prop.directors); movie.actors = this.toStr(prop.actors); movie.id = prop.id; movie.year = prop.year + "年"; movie.type = prop.card_subtitle; movieList.push(movie); } this.setData({ list:movieList }) } }) }, // 封装函数,将数组转为字符串 toStr:function(arr) { let str = ""; for(let prop of arr) { str += prop + " "; } return str; } })
<view class="model"> <!-- 顶部导航 --> <view class="nav"> <view class="nav_list {{select[index] ? 'select' : ''}}" wx:for="{{navList}}" bindtap="navClick" data-index="{{index}}">{{item}}</view> </view> <!-- 正在热映页面 --> <view class="now" wx:if="{{select[0]}}"> <!-- 轮播图 --> <swiper indicator-dots autoplay circular indicator-color="rgba(255,255,255,.3)" indicator-active-color="#FFFFFF" interval="3000" class="swiper"> <swiper-item wx:for="{{imageList}}"><image src="{{item}}"></image></swiper-item> </swiper> <!-- 影片列表 --> <view class="movie"> <view class="movie_list" wx:for="{{list}}" bindtap="jumpDetails" data-id="{{item.id}}"> <image src="{{item.image}}"></image> <view class="movie_info"> <view class="title">{{item.title}}</view> <view class="info_item">导演:{{item.director}}</view> <view class="info_item">主演:{{item.actors}}</view> <view class="info_item">上映时间:{{item.year}}</view> </view> <view class="purchase">购票</view> </view> </view> </view> <!-- 即将上映页面 --> <view class="future" wx:if="{{select[1]}}"> <view class="type_title">星推荐</view> <scroll-view scroll-x="{{true}}" class="scroll_view"> <block wx:for="{{futureList}}"> <view class="future_list"> <image src="{{item.image}}"></image> <view class="future_info"> <view class="future_title">{{item.title}}</view> <view>{{item.year}}</view> </view> </view> </block> </scroll-view> <view class="type_title">影片列表</view> <view class="movie"> <view class="movie_list" wx:for="{{list}}" bindtap="jumpDetails" data-id="{{item.id}}"> <image src="{{item.image}}"></image> <view class="movie_info"> <view class="title">{{item.title}}</view> <view class="info_item">导演:{{item.director}}</view> <view class="info_item">主演:{{item.actors}}</view> <view class="info_item">上映时间:{{item.year}}</view> </view> <view class="purchase">购票</view> </view> </view> </view> </view>
.model { width: 100vw; height: auto; padding: 10rpx 30rpx; box-sizing: border-box; } .nav { width: 100%; height: 100rpx; line-height: 100rpx; display: flex; text-align: center; } .nav_list { width: 50%; } .select { border-bottom: 4rpx solid #fb4e64; color: #fb4e64; } .now, .future { width: 100%; height: auto; padding: 20rpx 0rpx; } .swiper { width: 100%; height: 320rpx; } .swiper image { width: 100%; height: 100%; } .movie { width: 100%; height: auto; padding: 20rpx 0rpx; } .movie_list { width: 100%; height: auto; padding: 30rpx 0rpx; /* font-size: 20rpx; */ display: flex; border-bottom: 2rpx solid #cacaca; } .movie_list image { width: 200rpx; height: 300rpx; margin-right: 30rpx; } .movie_info { width: 380rpx; } .title { font-weight: bold; } .info_item { line-height: 60rpx; } .purchase { width: 100rpx; height: 60rpx; text-align: center; line-height: 60rpx; border: 2rpx solid #fb5368; border-radius: 10rpx; color: #fb5368; margin-top: 120rpx; margin-left: 10rpx; } .type_title { width: 100%; line-height: 80rpx; padding: 0rpx 20rpx; box-sizing: border-box; color: #fb5166; border-left: 10rpx solid #fb5166; } .scroll_view { width: 100%; height: 360rpx; white-space: nowrap; margin: 20rpx 0rpx; } .future_list { width: 210rpx; height: 360rpx; display: inline-block; margin: 0rpx 20rpx; } .future_list image { width: 210rpx; height: 260rpx; border-radius: 10rpx; } .future_info { text-align: center; } .future_title { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
// pages/datails/datails.js Page({ // 页面的初始数据 data: { }, // 页面加载 onLoad: function (options) { let id = options.id; let dataUrl = "https://m.douban.com/rexxar/api/v2/movie/"+id; let labelUrl = "https://m.douban.com/rexxar/api/v2/movie/"+id+"/tags?count=8"; let commentUrl = "https://m.douban.com/rexxar/api/v2/movie/"+id+"/interests"; // 请求影片详细数据 wx.request({ url: dataUrl, method:"GET", success:(res) => { let data = { title:res.data.title, timeLong:this.toStr(res.data.durations), typeLabel:this.toStr(res.data.genres), year:res.data.year, dire:res.data.directors[0].name, actors:res.data.actors, image:res.data.cover.image.small.url } this.setData({ movieData:data }) } }) // 请求影片标签数据 wx.request({ url: labelUrl, method:"GET", success:(res) => { this.setData({ labelData:res.data.tags }) } }) // 请求评论数据 wx.request({ url: commentUrl, method:"GET", success:(res) => { this.setData({ commentData:res.data.interests }) } }) }, // 封装函数,将数组转为字符串 toStr:function(arr) { let str = ""; for(let prop of arr) { str += prop + " "; } return str; } })
<view class="details"> <!-- 影片详细数据 --> <view class="movie"> <view class="movie_pictex"> <view class="movie_text"> <view class="movie_title">{{movieData.title}}</view> <view class="movie_info">影片时长:{{movieData.timeLong}}</view> <view class="movie_info">上映时间:{{movieData.year}}</view> <view class="movie_info">类型:{{movieData.typeLabel}}</view> <view class="movie_info">导演:{{movieData.dire}}</view> <view class="movie_info">演员列表:</view> </view> <image class="movie_pic" src="{{movieData.image}}"></image> </view> <!-- 演员列表 --> <scroll-view scroll-x="{{true}}" class="scroll_view"> <block wx:for="{{movieData.actors}}"> <view class="actors"> <image src="{{item.cover_url}}"></image> <view>{{item.name}}</view> </view> </block> </scroll-view> </view> <!-- 影片标签数据 --> <view class="label"> <view class="label_title">影片标签</view> <view class="label_content"> <view class="label_item" wx:for="{{labelData}}">{{item}}</view> </view> </view> <!-- 影片短评数据 --> <view class="comment"> <view class="label_title">影片热评</view> <view wx:for="{{commentData}}"> <view class="comment_list"> <image src="{{item.user.avatar}}" class="user_head"></image> <view class="comment_info"> <view class="user_name">{{item.user.name}}</view> <view class="create_time">{{item.create_time}}</view> <view>{{item.comment}}</view> </view> </view> <image src="../../image/分割线.png" class="line"></image> </view> </view> </view>
.details { width: 100vw; height: auto; padding: 10rpx 30rpx; box-sizing: border-box; } .movie { width: 100%; height: auto; } .movie_pictex { display: flex; } .movie_text { width: 390rpx; } .movie_pic { width: 300rpx; height: 420rpx; } .movie_title { line-height: 100rpx; font-weight: bold; font-size: 54rpx; } .movie_info { line-height: 80rpx; } .scroll_view { width: 100%; height: 210rpx; white-space: nowrap; margin: 20rpx 0rpx; } .actors { width: 200rpx; height: 220rpx; display: inline-block; margin: 0rpx 20rpx; } .actors image { width: 100rpx; height: 100rpx; border-radius: 100rpx; margin: 10rpx 50rpx; } .actors view { white-space: normal; text-align: center; } .label_title { font-weight: bold; line-height: 80rpx; border-left: 10rpx solid #fb5166; padding-left: 10rpx; box-sizing: border-box; margin: 20rpx 0rpx; } .label_content { display: flex; flex-wrap: wrap; } .label_item { padding: 10rpx 20rpx; margin: 10rpx; background-color: #f0f0f0; border-radius: 10rpx; } .comment_list { width: 100%; height: auto; display: flex; margin-top: 20rpx; } .user_head { width: 100rpx; height: 100rpx; border-radius: 100rpx; margin-right: 20rpx; } .comment_info { width: 550rpx; } .user_name { color: #fb5166; font-weight: bold; } .create_time { margin: 10rpx 0rpx 30rpx 0rpx; } .line { width: 100%; height: 10rpx; }
Page({ // 页面的初始数据 data: { modelList:[ { text:"电影票", icon:"../../icon/model1.png" }, { text:"演出票", icon:"../../icon/model2.png" }, { text:"优惠卷", icon:"../../icon/model3.png" }, { text:"影城卡", icon:"../../icon/model4.png" } ], funList:[ ["我的会员"], ["想看的电影","看过的电影"], ["帮助中心-咨询票小蜜","设置"], ["银行卡特惠"], ] }, // 获取用户信息 getUserInfo:function(e) { let userInfo = e.detail.userInfo; if(userInfo) { let user = { userImage : userInfo.avatarUrl, userName : userInfo.nickName } wx.setStorage({ data: user, key: 'userInfo', }) this.setData({ userInfo:user }) } }, onLoad:function() { wx.getSetting({ success:(res) => { if(res.authSetting['scope.userInfo']) { wx.getStorage({ key: 'userInfo', success:(res) => { this.setData({ userInfo:res.data }) } }) } } }) } })
<view class="my"> <!-- 顶部登录 --> <view class="login"> <image src="{{userInfo ? userInfo.userImage : '../../image/head.jpg'}}"></image> <view class="user_name"> <button wx:if="{{!userInfo}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo" style="width: 530rpx;padding: 0rpx;">点击登录</button> <view wx:else>{{userInfo.userName}}</view> </view> </view> <!-- 活动模块 --> <view class="model"> <view class="model_list" wx:for="{{modelList}}"> <image src="{{item.icon}}"></image> <view>{{item.text}}</view> </view> </view> <!-- 功能入口列表 --> <view class="fun"> <view class="funlist" wx:for="{{funList}}"> <view class="item" wx:for="{{item}}" wx:for-item="itema"> <view>{{itema}}</view> <image src="../../icon/right.png"></image> </view> </view> </view> </view>
page { background-color: #f4f4f4; } .login { width: 100vw; height: 200rpx; display: flex; margin-top: 20rpx; background-color: white; } .login image { width: 120rpx; height: 120rpx; border-radius: 160rpx; margin: 40rpx; } .user_name { line-height: 200rpx; font-weight: bold; } .user_name button { text-align: left; height: 200rpx; line-height: 200rpx; background-color: white; } .model { width: 100%; height: auto; margin-top: 20rpx; display: flex; justify-content: space-around; background-color: white; } .model_list { width: 100rpx; height: 140rpx; } .model_list image { width: 60rpx; height: 60rpx; margin: 10rpx 20rpx; border-radius: 100rpx; } .fun { width: 100%; height: auto; margin-top: 20rpx; } .funlist { width: 100%; height: auto; margin-bottom: 20rpx; background-color: white; } .item { width: 100%; height: 100rpx; line-height: 100rpx; padding: 0rpx 20rpx; box-sizing: border-box; border-bottom: 2rpx solid #f4f4f4; display: flex; justify-content: space-between; } .item image { width: 60rpx; height: 60rpx; margin: 20rpx; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。