• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

微信小程序“豆瓣电影”

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

代码

  1. app.json
  2. {
  3. "pages":[
  4. "pages/index/index",
  5. "pages/movie/movie",
  6. "pages/search/search",
  7. "pages/profile/profile"
  8. ],
  9. "window":{
  10. "navigationBarBackgroundColor": "#35495e",
  11. "navigationBarTextStyle": "white",
  12. "navigationBarTitleText": "豆瓣电影",
  13. "backgroundColor": "#fff",
  14. "backgroundTextStyle": "dark",
  15. "enablePullDownRefresh": true
  16. },
  17. "tabBar":{
  18. "list":[
  19. {
  20. "text":"推荐电影",
  21. "iconPath":"images/board.png",
  22. "selectedIconPath":"images/board-actived.png",
  23. "pagePath":"pages/index/index"
  24. },
  25. {
  26. "text":"发现电影",
  27. "iconPath":"images/search.png",
  28. "selectedIconPath":"images/search_black.png",
  29. "pagePath":"pages/search/search"
  30. },
  31. {
  32. "text":"我的电影",
  33. "iconPath":"images/profile.png",
  34. "selectedIconPath":"images/profile-actived.png",
  35. "pagePath":"pages/profile/profile"
  36. }
  37. ]
  38. }
  39. }
  40. app.wxss
  41. page{
  42. font-family: "Microsoft YaHei";
  43. background-color: #fff;
  44. display: flex;
  45. /*纵向排列*/
  46. flex-direction: column;
  47. }
  48. .page-header{
  49. display: flex;
  50. /*横向居中对齐*/
  51. justify-content: center;
  52. border-bottom: 2rpx solid #ccc;
  53. margin-bottom: 10rpx;
  54. }
  55. .page-header-text{
  56. padding: 20rpx 40rpx;
  57. color: #999;
  58. font-size: 40rpx;
  59. text-align: center;
  60. }
  61. .page-body{
  62. display: flex;
  63. flex: 1;
  64. flex-direction: column;
  65. }
  66. .item{
  67. display: flex;
  68. padding: 20rpx 40rpx;
  69. border-bottom: 2rpx solid #eee;
  70. }
  71. .poster{
  72. width: 130rpx;
  73. height: 160rpx;
  74. margin-right: 20rpx;
  75. }
  76. .meta{
  77. flex:1;
  78. }
  79. .item.title,.item.sub-title{
  80. display: block;
  81. margin-bottom: 14rpx;
  82. }
  83. .title{
  84. font-size: 35rpx;
  85. }
  86. .sub-title{
  87. font-size: 25rpx;
  88. color:#c0c0c0;
  89. }
  90. .artists{
  91. font-size: 26rpx;
  92. color: #999;
  93. }
  94. .rating{
  95. font-size: 28rpx;
  96. font-weight: bold;
  97. color: red;
  98. }
  1. index.wxml
  2. <view class="page-header">
  3. <text class="page-header-text">{{title}}</text>
  4. </view>
  5. <scroll-view class="page-body" scorll-y="true">
  6. <navigator url="../movie/movie?id={{item.id}}" wx:for="{{movies}}">
  7. <view class="item">
  8. <image class="poster"src="{{item.images.small}}"></image>
  9. <view class="meta">
  10. <text class="title">{{item.title}}</text>
  11. <text class="sub-title">
  12. {{item.original_title}} ({{item.year}})</text>
  13. <text class="artists">
  14. <text wx:for="{{item.directors}}">
  15. {{item.name}}
  16. </text>
  17. </text>
  18. </view>
  19. <view class="rating">
  20. <text>{{item.rating.average}}</text>
  21. </view>
  22. </view>
  23. </navigator>
  24. </scroll-view>
  25. index.wxss
  26. /**index.wxss**/
  27. .userinfo {
  28. display: flex;
  29. flex-direction: column;
  30. align-items: center;
  31. }
  32. .userinfo-avatar {
  33. width: 128rpx;
  34. height: 128rpx;
  35. margin: 20rpx;
  36. border-radius: 50%;
  37. }
  38. .userinfo-nickname {
  39. color: #aaa;
  40. }
  41. .usermotto {
  42. margin-top: 200px;
  43. }
  44. index.js
  45. var API_URL =\'https://api.douban.com/v2/movie/top250\'
  46. Page({
  47. data: {
  48. title:"加载中...",
  49. movies:[]
  50. } ,
  51. onLoad:function(){
  52. var that =this;
  53. wx.showToast({
  54. title:"加载中...",
  55. icon:"loading",
  56. duration:10000
  57. });
  58. //发出的请求必须是HTTPS的
  59. wx.request({
  60. url: API_URL,
  61. data:{},
  62. header:{
  63. //进行网络数据请求出现400 是因为请求header的Content-type变了
  64. \'content-type\': \'json\'
  65. },
  66. success:function(res){
  67. //隐藏消息提示框
  68. wx.hideToast();
  69. var data = res.data;
  70. console.log(data);
  71. that.setData({
  72. title:data.title,
  73. movies:data.subjects
  74. });
  75. }
  76. });
  77. }
  78. })

 

  1. movie.wxml
  2. <scroll-view scroll-y="true">
  3. <view class="meta">
  4. <image class="poster" src="{{movie.images.large}}" background-size="cover"></image>
  5. <text class="title">{{movie.title}}({{movie.year}})</text>
  6. <text class="info">评分:{{movie.rating.average}}</text>
  7. <text class="info">导演:<block wx:for="{{movie.directors}}">{{item.name}}</block></text>
  8. <text class="info">主演:<block wx:for="{{movie.casts}}">{{item.name}}</block></text>
  9. </view>
  10. <view class="summary">
  11. <text class="label">摘要:</text>
  12. <text class="content">{{movie.summary}}</text>
  13. </view>
  14. </scroll-view>
  15. movie.wxss
  16. .meta{
  17. display: flex;
  18. flex-direction: column;
  19. align-items: center;
  20. height: 1000rpx;
  21. padding: 50rpx 40rpx;
  22. }
  23. .poster{
  24. width: 80%;
  25. height: 80%;
  26. margin: 20rpx;
  27. }
  28. .title{
  29. font-style: 42prx;
  30. color: #444;
  31. }
  32. .info{
  33. font-size: 18rpx;
  34. color: #888;
  35. margin-top: 20rpx;
  36. width: 80%;
  37. }
  38. .summary{
  39. width: 80%;
  40. margin: 30rpx auto;
  41. }
  42. .label{
  43. display: block;
  44. }
  45. .content{
  46. color: #666;
  47. font-size: 20rpx;
  48. padding: 10rpx;
  49. }
  50. movie.js
  51. var API_URL = \'https://api.douban.com/v2/movie/subject/\'
  52. Page({
  53. data: {
  54. movie:{}
  55. },
  56. onLoad: function (params) {
  57. // console.log(params);
  58. var that = this;
  59. wx.request({
  60. url: API_URL+params.id,
  61. data: {},
  62. header: {
  63. \'content-type\': \'json\' // 默认值
  64. },
  65. success: function (res) {
  66. // console.log(res.data)
  67. that.setData({
  68. movie:res.data
  69. });
  70. }
  71. })
  72. },
  73. })

 

  1. profile.wxml
  2. <view class="container">
  3. <view bindtap="bindViewTap" class="userinfo">
  4. <image class="userinfo-avatar" src="{{userInfo.avatarUrl}}" background-size="cover"></image>
  5. </view>
  6. <view class="infohead">电影</view>
  7. <view class="infolist" wx:for="{{infoList}}">
  8. <view class="infoitem">{{item.text}}</view>
  9. </view>
  10. <view class="infohead">其他</view>
  11. <view bindtap="bindViewTap" class="infolist" wx:for="{{other}}">
  12. <view class="infoitem">{{item.text}}</view>
  13. </view>
  14. </view>
  15. profile.wxss
  16. .container {
  17. height: 100%;
  18. display: flex;
  19. flex-direction: column;
  20. box-sizing: border-box;
  21. padding: 10px;
  22. }
  23. .userinfo {
  24. display: flex;
  25. flex-direction: column;
  26. align-items: center;
  27. }
  28. .userinfo-avatar {
  29. width: 128rpx;
  30. height: 128rpx;
  31. border-radius: 50%;
  32. }
  33. .userinfo-nickname {
  34. color: #aaa;
  35. font-size: 6px;
  36. }
  37. .infohead{
  38. font-size: 16px;
  39. border-bottom: 1px solid #dadada;
  40. padding-top: 30px;
  41. padding-bottom: 15px;
  42. }
  43. .infoitem{
  44. position: relative;
  45. padding: 15px;
  46. -webkit-box-align: center;
  47. -ms-flex-align: center;
  48. align-items: center;
  49. border-bottom: 1px solid #dadada;
  50. }
  51. profile.js
  52. var app =getApp()
  53. Page({
  54. data: {
  55. text:"Page profiles",
  56. infoList:[
  57. {
  58. text:"我的电影票"
  59. },
  60. {
  61. text:"我的兑奖券"
  62. },
  63. {
  64. text:"我的优惠券"
  65. },
  66. {
  67. text:"想看、看过的电影"
  68. }
  69. ],
  70. other:[

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap