[解读小程序]购物车DEMO

[解读小程序]购物车DEMO

分析的程序来源:
https://github.com/SeptemberMaples/wechat-weapp-demo
作者: SeptemberMaples

购物车DEMO 比较像是项目中的一个模块了. 代码写的很好,一看就出自老司机之手. 感谢作者的开源精神!

效果图

微菜单页面

点菜页面

展示的数据为纯静态数据,只为熟悉组件和基本用法。
注:仅【堂食】这个类别下有demo数据

app配置

{
  "pages":[
    "pages/index/index",
    "pages/components/dishes/dishes",
    "pages/components/take/take"
  ],
  "window":{
    "backgroundColor":"#f4f4f4",//背景色
    "backgroundTextStyle":"light", //背景文本样式
    "navigationBarBackgroundColor": "orange", //导航栏背景色
    "navigationBarTitleText": "美食汇微菜单",//导航栏文本
    "navigationBarTextStyle":"white"//导航栏文本颜色
  }
}

page数组记录中记录了小程序中的页面数量, 其中take页面没有代码.

这里直接借鉴的是app.wxss中的写法

/**app.wxss**/
.container {
  height: 100%;
  box-sizing: border-box;
  background-color: #f4f4f4;
}
.flex-wrap{
    display: flex;
}
.flex-item{
    flex: 1;
}
.flex-wrap.flex-direction-col{
    flex-direction: column;
}
.flex-wrap.flex-direction-row{
    flex-direction: row;
}

定义了最常用的一些样式. 可以很方便的进行样式的组合.
app.js中就是helloworld的小程序的代码. 没什么好说的.

微菜单页面 index

index.wxml

从页面上来看, 头部是一个swiper, 下面是一些动态排列的view或者button.

<view class="container flex-wrap flex-direction-col">
  <view class="my-swiper">
      <swiper indicator-dots="{
   {
   indicatorDots}}"
    autoplay="{
   {
   autoplay}}" interval="{
   {
   interval}}" duration="{
   {
   duration}}">
    <block wx:for="{
   {
   imgUrls}}">
      <swiper-item>
        <image src="{
   {
   item}}" class="slide-image" height="150"/>
      </swiper-item>
    </block>
  </swiper>
  </view>

    <!-- 分类导航 -->
  <view class="nav-block wrap">
    <block wx:for="{
   {
   navItems}}"> 
      <view class="wrap-item {
   {
   item.isSplot ? 'exp' : ''}}">  
        <navigator url="../components/<
  • 7
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值