首页 > 小程序教程 > 微信小程序集思会精品图书图片展示页面样式设计制作开发教程

微信小程序集思会精品图书图片展示页面样式设计制作开发教程

上一篇 下一篇
本文给大家带来的是微信小程序集思会精品图书图片展示页面样式设计制作开发教程,制作好以后效果图如下:
一、wxml页面代码如下:
<!--home.wxml-->
<import src="menu/menu-template.wxml" />
<import src="book/book-template.wxml" />
<import src="header/header-template.wxml" />

<view class="container">
  <swiper indicator-dots="{{true}}" indicator-color="#fff" indicator-active-color="#FB7C58">
    <swiper-item wx:for="{{banners}}" >
      <image class="swiper-image" src="{{item.picUrl}}" mode="scaleToFill"></image>
    </swiper-item>
  </swiper>

  <view class="menu">
    <block wx:for="{{menus}}">
      <view catchtap="toHotPush" data-index="{{index}}">
        <template is="menu" data="{{...item}}"></template>
      </view>
    </block>
  </view>

  <view class="content">
    <block wx:for="{{books}}">
      <template is="header" data="{{...item.header}}"></template>
      <view wx:for="{{item.books}}" catchtap="toDetail" data-book="{{item}}">
        <template is="book" data="{{...item}}"></template>
      </view>
      <view class="separation"></view>
    </block>
  </view>
</view>
 
二、wxss样式文件代码如下:
/* home.wxss */
@import "menu/menu-template.wxss";
@import "book/book-template.wxss";
@import "header/header-template.wxss";

.container {
  height: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  background-color: #eee;
  padding: 0rpx;
}

swiper {
  width: 100%;
  height: 400rpx;
}

.swiper-image {
  width: 100%;
  height: 400rpx;
  padding: 0rpx;
}

.menu {
  width: 100%;
  height: 160rpx;
  background-color: #fff;
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  align-items: center;
  border-bottom: 1px solid #eee;
  margin-bottom: 20rpx;
}

.content {
  background-color: #fff;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: space-around;
}

.separation {
  width: 100%;
  height: 20rpx;
  background-color: #eee;
}
三、js页面代码如下:
// home.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    banners: [],
    books: [
      { header: {name: "精品图书"}, books: [] },
      { header: {name: "随便看看"}, books: [] },
      { header: {name: "最新上架"}, books: [] },
    ],
    menus: [
      { "imgUrl": "/images/menu/rank.png", "name": "榜单" },
      { "imgUrl": "/images/menu/category.png", "name": "分类" },
      { "imgUrl": "/images/menu/list.png", "name": "书单" },
      { "imgUrl": "/images/menu/active.png", "name": "活动" }
    ]
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

    this.requestData();
  },
  requestData: function () {
    var that = this;
    wx.request({
      url: 'http://www.kindlepush.com/app/getIndexInfo',
      success: function (res) {
        //console.log(res.data.hotBookList);
        // that.data.banners = res.data.pictureList;
        // that.data.books[0].books = res.data.goodBookList;
        // that.data.books[1].books = res.data.hotBookList;
        // that.data.books[2].books = res.data.newBookList;
        
        //以上方式不可以
        that.setData({
          banners: res.data.pictureList,
          'books[0].books': res.data.goodBookList,//注意加引号
          'books[1].books': res.data.hotBookList,
          'books[2].books': res.data.newBookList,
        });
      },
      fail: function (err) {
        console.log(err);
      }
    });
  },
  toDetail:function(event){
      var book = event.currentTarget.dataset.book;
      wx.navigateTo({
        url: '/pages/bookDetail/bookDetail?book='+JSON.stringify(book),
      })
  },
  toHotPush: function(event){
    var index=event.currentTarget.dataset.index;
    if (index==0){
      wx.navigateTo({
        url: '/pages/hotPush/hotPush',
      })
    }else{
      wx.showToast({
        title: '暂无此功能!',
        duration: 1000,

      })
    }
    
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})

模板简介:该模板名称为【微信小程序集思会精品图书图片展示页面样式设计制作开发教程】,大小是,文档格式为.,推荐使用打开,作品中的图片,文字等数据均可修改,图片请在作品中选中图片替换即可,文字修改直接点击文字修改即可,您也可以新增或修改作品中的内容,该模板来自用户分享,如有侵权行为请联系网站客服处理。欢迎来懒人模板【小程序教程】栏目查找您需要的精美模板。

相关搜索
  • 下载密码 lanrenmb
  • 下载次数 21,076次
  • 使用软件
  • 文件格式
  • 文件大小
  • 上传时间 06-28
  • 作者 网友投稿
  • 肖像权 人物画像及字体仅供参考
栏目分类 更多 >
热门推荐 更多 >
微信模板 单页式简历模板 微信图片 响应式 微信公众平台 自适应 微信文章 企业网站 微信素材 html5
您可能会喜欢的其他模板