小程序店铺列表页面

本文展示了微信小程序店铺列表页面的实现代码,包括WXML模板中使用wx:for循环渲染店铺图片、名称、电话、地址和营业时间,WXSS样式采用flex布局,以及JS中通过wx.request请求数据并更新页面的getShopList函数。适用于快速搭建商品或店铺列表场景。

作者:zhuge··预计阅读 39 分钟·593 阅读·0 评论
小程序店铺列表页面

<!--index.wxml-->

<view class="shop-itemwx:for="{{shopList}}" wx:if="id">

<view class ="thumb">

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

</view>

  <view class="info">

    <text class="shop-title">{{item.name}}</text>

    <text>电话:{{item.phone}}</text>

    <text>地址:{{item.addr}}</text>

    <text>营业时间:{{item.bhour}}</text>

  </view>

</view>


<!--index.wxss-->

.shop-item{

  display: flex;

  padding: 15rpx;

  border: 1rpx solid #efefef;

  border-radius: 8rpx;

  margin:15rpx;

  box-shadow:  1rpx 1rpx 15rpx #ddd;

}

.thumb image{

width: 250rpx;

height: 250rpx;

display: block;

margin-right: 15rpx;

}

.info{

  display: flex;

  flex-direction: column;

  justify-content: space-around;

  font-size: 24rpx;

}

.shop-title

{

  font-weight: bold;

}

可能要用到的,自动加载添加数据

getSHopList()

{

  wx.request({

    url: `https://www.abc.com/${this.data.id}/list`,

    method:'GET',

    data:{

      page:this.data.page,

      pagesize:this.data.pagesize,

    },success:(res)=>{

      this.setData({

        shopList:[...this.data.shopList,...res.data],

        total:res.header['xxx']-0

      })

    }

  })

}


相关文章

评论

加载中...