小程序coffee项目

1.新建一个项目,将需要的图片文件放到项目根目录中

 

2.在 app.json文件中的pages中,添加项目需要的路由,添加完成后文件目录会自动生成

 3.在app.json中添加底部tapBar


  "tabBar": {
    "list": [
      {
      "pagePath": "pages/home/home",
      "text": "首页",
      "iconPath": "/images/bar/bar1_1.png",
      "selectedIconPath": "/images/bar/bar1.png"
    },
    {
      "pagePath": "pages/menu/menu",
      "text": "菜单",
      "iconPath": "/images/bar/bar2_2.png",
      "selectedIconPath": "/images/bar/bar2.png"
    },
    {
      "pagePath": "pages/new/new",
      "text": "新品",
      "iconPath": "/images/bar/bar3_3.png",
      "selectedIconPath": "/images/bar/bar3.png"
    },
    {
      "pagePath": "pages/service/service",
      "text": "小二",
      "iconPath": "/images/bar/bar4_4.png",
      "selectedIconPath": "/images/bar/bar4.png"
    }
  ]
  },

 刷新后即可显示

 4.在tapBar中添加选中的文字样式和未选中的文字样式

 "color":"#ccc",
 "selectedColor": "#333999",

 5.将图片路径放入data数组中,在wxml文件中使用for循环进行遍历,运行后即可显示图片

 wxml文件

<!--pages/home/home.wxml-->
<swiper>
  <swiper-item wx:for="{{backgroundArr}}" wx:key="*this">
  <!-- 使用data中的数组代替图片路径 -->
    <image src="{{item}}"></image>
    <!-- <image src="/images/banner/baner1.jpg"></image> -->
  </swiper-item>
</swiper>

 js文件中

  data: {
    backgroundArr: [
      "/images/banner/baner1.jpg",
      "/images/banner/baner2.jpg",
      "/images/banner/baner3.jpg",
      "/images/banner/baner4.jpg"
    ]

  },

 6.给轮播图设置样式

wxml文件中

<!--pages/home/home.wxml-->
<!-- indicator-dots="true" 显示小圆点 -->
<!-- indicator-active-color="#333999" 设置小圆点颜色 -->
<!-- autoplay="true" 设置轮播图自动轮播 -->
<swiper indicator-dots="true" indicator-active-color="#333999" autoplay="true">
  <swiper-item wx:for="{{backgroundArr}}" wx:key="*this">
  <!-- 使用data中的数组代替图片路径 -->
  <!-- mode="widthFix" 宽度不变高度自适应 -->
    <image mode="widthFix" src="{{item}}"></image>
    <!-- <image src="/images/banner/baner1.jpg"></image> -->
  </swiper-item>
</swiper>

wxss文件中

 

swiper image{
width: 100%;
}
/* 加上calc()可在括号内进行计算 */
swiper{
  height: calc(100vw*720/1080);
}

 

7.通过组件的方式添加标题

在home文件夹中添加一个tem.wxml文件

<template name="title">
  <view class="title">
    <!-- <text>咖啡的故事</text> -->
    <text>{{content}}</text>
  </view>
</template>

在home.wxml文件夹中进行引用

<import src="./tem.wxml"></import>
<template is="title" data="{{content:'咖啡的故事'}}"></template>

<template is="title" data="{{content:'新品展示'}}"></template>

home.wxss样式


.title {
  height: 100rpx;
  position: relative;
}

.title::before {
  content: "";
  width: 40%;
  position: absolute;
  height: 4rpx;
  background-color: #ccc;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
}

.title text {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin:0 auto;
  width: 30%;
  height: 100rpx;
  line-height: 100rpx;
  text-align: center;
  background-color: #fff;
} 

 

咖啡厅-微信小程序源码+项目说明简介本资源为一套完整的咖啡微信小程序源码,包含详细的项目说明文档。该小程序旨在提供便捷的咖啡、促销信息查看以及会员服务等功能,适合用于咖啡厅的日常运营管理和顾客互动。项目完整源码:包括前后端所有代码,可直接在微信开发者工具中运行和测试。详细项目说明:提供全面的文档说明,包括功能介绍、界面设计、数据交互等,方便二次开发和定制。多模块支持:涵盖商品展示、在线、订管理、会员系统等多个核心功能模块,满足咖啡店运营需求。用户体验优化:界面简洁友好,操作便捷,提升用户使用体验。适用人群初学者:学习小程序开发的基础实例。高校学生:课程设计、毕业设计或大作业的理想选择。企业员工:初期项目立项演示或参考。个人开发者:学习和实战练习微信小程序开发的优质资源。功能概述首页:展示最新活动和推荐商品。菜:浏览并选择咖啡及相关产品。购物车:添加商品到购物车并进行结算。我的:查看订历史、优惠券和个人信息。会员系统:积分累积与兑换,提升顾客忠诚度。技术栈前端:微信小程序原生框架、WXML、WXSS、JavaScript后端:可选Python Flask/Django或其他语言实现API接口数据库:MySQL或其他关系型数据库(根据需要配置)注意事项确保已安装最新版本的微信开发者工具。仔细阅读项目说明文档,了解各模块的功能和使用方法。根据实际需求调整样式和功能,以满足个性化需求。此资源是学习微信小程序开发的优秀案例,不仅有助于掌握小程序的基本开发流程,还能深入理解如何通过小程序提升商业效率和用户体验。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值