当前位置: 首页 > article >正文

开发微信小程序 案例01-本地生活首页页面

1---home.wxml 区域 (页面整体的标签)

<!-- 轮播图区域 -->

<swiper indicator-dots circular autoplay>

  <swiper-item wx:for="{{SwiperArr}}" wx:key="id">

    <image src="{{item.image}}"></image>

  </swiper-item>

</swiper>

<!-- 九宫格区域 -->

<view class="grid-Arr">  

    <view class="grid-item" wx:for="{{GridArr}}" wx:key="id">

      <image src = "{{item.icon}}"></image>

      <text>{{item.name}}</text>

    </view>

</view>

<!-- 图片区域 -->

<view class="imgBox">

    <image src="/images/link-01.png" mode="widthFix"></image>

    <image src="/images/link-02.png" mode="widthFix"></image>

</view>

2---app.json区域 (全局配置文件)

{

  "pages": [  

    "pages/home/home",

    "pages/message/message",

    "pages/contact/contact"

  ],

  "window": {

    "navigationBarTextStyle": "white",

    "navigationBarTitleText": "本地生活",

    "navigationBarBackgroundColor": "#2b4b6b"

  },

  "tabBar": {

    "list": [{

      "pagePath": "pages/home/home",

      "text": "首页",

      "iconPath": "/images/首页-置灰.png",

      "selectedIconPath": "/images/1_导航-默认 .png"

    },{

      "pagePath": "pages/message/message",

      "text": "消息",

      "iconPath": "/images/消息-置灰.png",

      "selectedIconPath": "/images/即时聊天.png"

    },{

      "pagePath": "pages/contact/contact",

      "text": "联系人",

      "iconPath": "/images/填选购人.png",

      "selectedIconPath": "/images/1_用户管理.png"

    }]

  },

  "style": "v2",

  "componentFramework": "glass-easel",

  "sitemapLocation": "sitemap.json",

  "lazyCodeLoading": "requiredComponents"

}

3-home.js 区域 (存放home页面的数据)

Page({

  /**

   * 页面的初始数据

   */

  data: {

    //轮播图数组SwiperArr : [],

    //九宫格 数组GridArr : [],

  },

  /**

   * 生命周期函数--监听页面加载

   */

  onLoad(options) {

    this.getSwiperArr()

    this.getGridArr()

  },

  //获取轮播图数据

  getSwiperArr(){

    wx.request({

      // https://applet-base-api-t.itheima.net/slides

      url: 'https://applet-base-api-t.itheima.net/slides',

      method :'GET',

      success: (res) => {

        this.setData({

          SwiperArr: res.data

        })

      }

    })

  },

  // 获取九宫格数据

  getGridArr(){

    wx.request({

      url: 'https://applet-base-api-t.itheima.net/categories',

      method : "GET",

      success : (res) => {

        this.setData({

          GridArr :res.data

        })

      }

    })

  },

 4--home.wxss ( home页面的渲染)

/*  轮播图区域start*/

swiper{

  height: 350rpx;

}

swiper image {

  width: 100%; 

  height: 100%;

}

/* 轮播图区域end */

/*九宫格区域start*/

.grid-Arr{

  display: flex;

  flex-wrap: wrap; /*换行*/

}

.grid-item{

  width: 33.33%;

  height: 200rpx;

  display: flex;

  flex-direction: column;/*主轴纵向*/

  /*居中*/

  align-items: center;

  justify-content: center; 

  border-bottom: 1px solid #ededde;

  border-right: 1px solid #ededde;

  box-sizing: border-box;

}

.grid-item image{

  width: 60rpx;

  height: 60rpx ;

}

.grid-item text{

  font-size: 24rpx;

  margin-top: 10rpx;

  color: gray;

}

/*九宫格区域end*/

/*图片区域start*/

.imgBox{

  display: flex;

  justify-content: space-around;

  padding-top: 20rpx;

}

.imgBox image{

  width: 45%;

  height: 200rpx;

}

/* 图片区域 end*/

 5--效果展示


http://www.kler.cn/news/328350.html

相关文章:

  • 【北京迅为】《STM32MP157开发板嵌入式开发指南》- 第十四章 Linux 目录结构讲解
  • 【DRAM存储器四十一】LPDDR5介绍--特性、引脚、基本结构简介
  • 交通场景多目标检测系统源码分享
  • 数据结构-3.10.队列的应用
  • Qt界面优化——绘图API
  • 【网络安全】身份认证
  • <STC32G12K128入门第十三步>驱动W5500进行TCP_Client通信
  • LeetCode: 1971. 寻找图中是否存在路径
  • 滚雪球学Oracle[4.1讲]:PL/SQL编程
  • 【开源免费】基于SpringBoot+Vue.JS美容院管理系统(JAVA毕业设计)
  • C0008.Clion利用C++开发Qt界面,使用OpenCV时,配置OpenCV方法
  • Sharding-JDBC笔记03-分库分表代码示例
  • redis01
  • 高级java每日一道面试题-2024年9月27日-数据库篇-性别是否适合做索引?
  • Leetcode45. 跳跃游戏 II
  • 「安装」 Windows下安装CUDA和Pytorch
  • linux如何与网络时间对齐(雪花算法ID重复)
  • 【AAOS】CarService -- Android汽车服务
  • 【Web】Electron:第一个桌面程序
  • Python与C#关于switch的使用区别
  • [python][pipenv]pipenv的使用
  • 输出 / 目录下所有目录文件的大小并排序
  • 如何改变音频声音大小?关于改变音频大小的方法介绍
  • NLP任务之文本分类(情感分析)
  • 简单vue指令实现 el-table 可拖拽表格功能
  • Qt C++设计模式->享元模式
  • Windows远程Kylin系统-xrdp
  • CTF中文件包含
  • 【优选算法】(第三篇)
  • IDEA 系列产品 下载