首页 > 小程序教程 > 微信小程序吃喝玩乐纯图标导航设计制作开发教程

微信小程序吃喝玩乐纯图标导航设计制作开发教程

上一篇 下一篇
本文给大家带来的是微信小程序带幻灯切换精品商品图文列表页设计制作开发教程,制作好以后效果图如下:
一、wxml页面代码如下:
<!--pages/shenghuo/SelectedGoods/SelectedGoods.wxml-->
<!--<text>pages/shenghuo/SelectedGoods/SelectedGoods.wxml</text>-->

<import src="SelectedGoodsGridCell/SelectedGoodsGridCell.wxml" />

<view class="top-container">
  <scroll-view class="scroll-view_container selected" scroll-x="true" bindscroll="scroll">
    <block wx:for="{{prdFirstCategoryList}}" wx:for-item="item" wx:key="key">
      <view class="flex-sub-box-5 {{ currentTabIndex == item.id ? 'active' : '' }}" bindtap="clickOrderTab" data-index="{{item.id}}">{{item.cateName}}</view>
    </block>
  </scroll-view>
  <image class="search_lb" src="/images/icon/search_lb.png"></image>
</view>

<scroll-view class="scroll-Goods-list-container" scroll-y="true">

  <swiper catchtap="onSwiperTap" vertical="{{false}}" indicator-dots="true" autoplay="true" interval="5000">

    <block wx:for="{{advertCaroucelsAr}}" wx:for-item="item" wx:for-index="index" wx:key="key">
      <swiper-item>
        <image class="caroucels" src="http://m.jointem.com/{{item.imageUrl}}" data-postId="{{id}}"></image>
      </swiper-item>
    </block>
  </swiper>

  <view class="selectGoods-list">
    <block wx:for="{{prdSearchList}}" wx:for-item="item" wx:for-index="index" wx:key="key">
      <template is="SelectedGoodsGridCell" data="{{...item}}"></template>
    </block>
  </view>

</scroll-view>
 
二、wxss样式文件代码如下:
/* pages/shenghuo/SelectedGoods/SelectedGoods.wxss */
@import "SelectedGoodsGridCell/SelectedGoodsGridCell.wxss";

.top-container {
  top: 0px;
  width: 100%;
  height: 40px;
  flex-direction: row;
  display: flex;
  background: #0164a6;
  position: fixed;
  z-index: 99;
}

.scroll-view_container {
  position: fixed;
  margin-right: 120rpx;
  margin-top: 0;
  white-space: nowrap;
  background-color: white;
  line-height: 40px;
  height: 40px;
  width: 630rpx;
  background: #0164a6;
  text-align: center;
  font-size: 30rpx;
}

.search_lb {
  width: 40px;
  height: 30px;
  position: absolute;
  right: 0px;
  top: 5px;
}

.selected {
  color: #fff;
}

.selected view {
  color: #fff;
}

.selected view.active {
  color: #fff;
  border-bottom: 2px solid #fff;
}

.flex-sub-box-5 {
  display: inline-block;
  width: 25%;
  height: 36px;
  align-items: center;
}

/******************** 列表数据  ********************/

.scroll-Goods-list-container {
  display: block;
  margin-top: 40px;
  width: 100%;
  height: 100% - 40px;

}

.caroucels {
  width: 100%;
  height: 300rpx;
}

.selectGoods-list {
  background: #efefef;
  padding-bottom: 8px;
}
三、js页面代码如下:
// pages/shenghuo/SelectedGoods/SelectedGoods.js

const config = require('../../../config')
var util = require('../../../utils/util.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    prdFirstCategoryList: [], /** 分类种类数据 */
    advertCaroucelsAr: [], /** 轮播数据 */
    prdSearchList: [], /** 好商品搜索列表 */
    currentTabIndex: 0,
  },
  clickOrderTab: function (e) {
    //data = {};
    var index = parseInt(e.target.dataset.index)

    this.setData({ currentTabIndex: index })

    // /** 选中的分类名字 */
    // selectedCategoryName = this.data.couponCategoryList[index]["CategoryName"];
    // /** 选中的具体类型名字 */
    // selectedfcName = this.data.couponCategoryList[index]["cateName"];


    // if (this.data.couponSearchList[index]) {
    //   //有数据
    //   //nothing
    // } else {
    //   //没有数据
    //   /** 网络请求: 按条件搜索 */
    //   this.loadNewData(selectedCategoryName, selectedfcName, this.data.localCtiyName)
    // }

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.requestprdFirstCategoryList()
    this.requestAdvertCaroucels()
    this.requestPrdSearchList()
  },
  /**获取好商品所有一级分类*/
  requestprdFirstCategoryList: function () {
    var that = this;
    let url = config.PrdFirstCategoryUrl

    var para = {}

    wx.showLoading({ title: '加载中...' })

    util.RequestManager(url, para, function (res, fail) {

      wx.hideLoading()

      var tempAr = res.data[0].facetValues;
      var resultAr = new Array();
      var index = 0;
      for (var i = 0; i < tempAr.length; i++ ){
        var model = tempAr[i];
        var dic = {};
        dic["id"] = index;
        dic["count"] = model["count"];
        dic["cateName"] = model["name"];
        
        resultAr.push(dic)

        index++;
      }

      that.setData({ prdFirstCategoryList: resultAr })

    })

  },
  /**获取广告轮播 */
  requestAdvertCaroucels: function (e) {
    var that = this;
    let url = config.AdvertCaroucelsUrl

    var para = {
      "category": 4
    }

    wx.showLoading({ title: '加载中...' })

    util.RequestManager(url, para, function (res, fail) {

      wx.hideLoading()
      that.setData({ advertCaroucelsAr: res.data })

    })
  },
  /**获取好商品搜索数据 */
  requestPrdSearchList: function () {
    var that = this;
    let url = config.PrdSearchListUrl

    var para = {
      "pageNum": 1,
      "pageSize": 20,
      "doorCateId": ["13285", "13286", "13619"],
      "fcName": "生活美食"
    }

    wx.showLoading({ title: '加载中...' })

    util.RequestManager(url, para, function (res, fail) {

      wx.hideLoading()
      that.setData({ prdSearchList: res.data.dataList })

    })

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

  },

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

  },

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

  },

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

  },

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

  },

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

  },

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

  }
})

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

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