首页 > 小程序教程 > 微信小程序生鲜蔬菜类商城首页设计制作开发教程

微信小程序生鲜蔬菜类商城首页设计制作开发教程

上一篇 下一篇
本文给大家带来的是微信小程序生鲜蔬菜类商城首页设计制作开发教程,制作好以后效果图如下:
一、wxml页面代码如下:
<!--index.wxml-->
<import src="../../template/item-template.wxml"/>
<view class="container">

    <view class="section section_gap swiper_box">
        <template is="index_index_scroll_tmpl" data="{{...index_index_scroll_tmpl}}"/>
    </view>
    
    <view class="section index-nav">
       <template is="index_index_navs_tmpl" data="{{...index_index_navs_tmpl}}"/>
    </view>

    <view class="text">
        <view class="line_y"></view>
        <text>精品特价</text>
    </view>

    <template is="index_index_items_tmpl" data="{{...index_index_items_tmpl}}"/>

</view>
 
二、wxss样式文件代码如下:
.container {
  background-color: #F2f2f2;
}

view.section {
  /*display: block;*/
  /*width: 100%;*/
}

/*轮播*/
.swiper_box {
  /*width: 100%;*/
  height: 187.5px;
}
swiper.swiper {
  height: 100%;
}
.swiper-item {
    display: block;
    height: 100%;
}
.slide-image {
  height: 100%;
  width: 100%;
  display: inline-block;
  overflow: hidden;
}

/*分类*/
.index-nav {
  height: 80px;
  /*background: red;*/
  display: flex;
  flex-direction: row;
  /*align-items: center;*/
  background-color: #fff;
  color: #646464;
}
.index-nav view {
  flex: 1;
  flex-direction: column;
  border-right: 1px solid #F2f2f2;
}
.index-nav image {
  width: 38px;
  height: 38px;
}
.index-nav text {
  font-size: 16px;
}


view.text {
  display: flex;
  align-items: center;
  position: relative;
  padding: 10px 10px 10px 12px;
  font-size: 15px;
  color: #656565;
}

view.text:before {
    position: absolute;
    display: block;
    content: ' ';
    left: -5px;
    width: 2px;
    height: 100%;
    background-color: #09bb07;
}
.line_y {
  width: 3px;
  height: 100%;
  height: 18px;
  display: inline-block;
  background-color: #09bb07;
}
view.text text {
  margin-left: 10px;
  line-height: 18px;
}

.item {
  margin-bottom: 7px;
  height: 126px;
}
三、js页面代码如下:
//index.js
//获取应用实例
var app = getApp()
Page( {
  data: {
    //向模板传入数据
    // 轮播
    index_index_scroll_tmpl: {
      images: [
        'https://hamlet.b0.upaiyun.com/1609/19171/2788065f96c04ad38c8db50ad723bc37.jpg!/fwfh/640x352/quality/80',
        'https://hamlet.b0.upaiyun.com/1609/23150/4cc74e62833e4cdaaec79f3a2ef256e5.jpg!/fwfh/640x352/quality/80',
        'https://hamlet.b0.upaiyun.com/1609/23150/4cc74e62833e4cdaaec79f3a2ef256e5.jpg!/fwfh/640x352/quality/80',
        'https://hamlet.b0.upaiyun.com/1609/20180/934270f1be264c63bfaf85b37e545928.jpg!/fwfh/640x352/quality/80',
        'https://hamlet.b0.upaiyun.com/1609/20171/77f7a3c93fd641bf95150501ef9a7cad.jpg!/fwfh/640x352/quality/80',
        'https://hamlet.b0.upaiyun.com/1609/19171/2788065f96c04ad38c8db50ad723bc37.jpg!/fwfh/640x352/quality/80',
        'https://hamlet.b0.upaiyun.com/1609/23171/70065cf9e45d46729ca51dec55d5f650.jpg!/fwfh/640x352/quality/80'
      ],
      indicatorDots: true,
      vertical: false,
      autoplay: true,
      interval: 3000,
      duration: 1200
    },
    // nav
    index_index_navs_tmpl: {
      navs: [
        {
          image: 'https://m.youcai.xin/static/img/gravida.png',
          text: '孕妇'
        }, {
          image: 'https://m.youcai.xin/static/img/confinement.png',
          text: '月子'
        }, {
          image: 'https://m.youcai.xin/static/img/baby.png',
          text: '幼儿'
        }, {
          image: 'https://m.youcai.xin/static/img/old.png',
          text: '老人'
        }
      ]
    },
    
    // item
    index_index_items_tmpl: {
      items: [
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/84439174cad04497beda3a076663beb4.jpg'},
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/1987d8eb8b1748368b7f2382332c9718.jpg'},
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'},
        {image: 'https://hamlet.b0.upaiyun.com/1609/22111/fe8765fa7f2f48cd87760c10ddd20ae6.jpg'}
      ]
    }
    
  },

  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo( {
      url: '../logs/logs'
    })
  },
  swiperchange: function(e) {
    //FIXME: 当前页码
    //console.log(e.detail.current)
  },

  onLoad: function() {
    console.log( 'onLoad' )
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo( function( userInfo ) {
      //更新数据
      that.setData( {
        userInfo: userInfo
      })
    })
  },
  go: function(event) {
    wx.navigateTo({
      url: '../list/index?type=' + event.currentTarget.dataset.type
    })
  }
})

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

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