You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
<!--pages/index/index.wxml-->
|
|
<view class="container">
|
|
<!-- 页面标题 -->
|
|
<view class="header">
|
|
<text class="title">商品列表</text>
|
|
</view>
|
|
|
|
<!-- 加载状态 -->
|
|
<view wx:if="{{loading}}" class="loading-container">
|
|
<text>加载中...</text>
|
|
</view>
|
|
|
|
<!-- 错误状态 -->
|
|
<view wx:elif="{{hasError}}" class="error-container">
|
|
<text class="error-msg">{{errorMsg}}</text>
|
|
<button bindtap="getProductList" class="retry-btn">重新加载</button>
|
|
</view>
|
|
|
|
<!-- 商品列表 -->
|
|
<view wx:else class="product-list">
|
|
<view
|
|
wx:for="{{productList}}"
|
|
wx:key="id"
|
|
class="product-item"
|
|
bindtap="onProductTap"
|
|
data-product="{{item}}"
|
|
>
|
|
<image
|
|
src="{{item.imageUrl || 'https://via.placeholder.com/200x200'}}"
|
|
class="product-image"
|
|
mode="aspectFill"
|
|
lazy-load="{{true}}"
|
|
/>
|
|
<view class="product-info">
|
|
<text class="product-name">{{item.name}}</text>
|
|
<text class="product-price">¥{{item.price}}</text>
|
|
<text class="product-description">{{item.description}}</text>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 空状态 -->
|
|
<view wx:if="{{productList.length === 0}}" class="empty-state">
|
|
<text>暂无商品</text>
|
|
</view>
|
|
</view>
|
|
</view> |