cu-shop-coupon-wallet
卡券包面板:可使用 / 已使用 / 已过期三态分栏(标签带数量)、券卡片列表(左侧金额与门槛、右侧名称 / 角标 / 临期标 / 有效期 / 不可用原因、尾部操作按钮)、加载更多与空态重试行;可用券按到期时间升序,非可用券置灰并把按钮改成「查看详情」。
实时预览
演示页:/pages/shop-order/coupon-wallet。右侧的预览由站点脚本把 H5 演示页装进 iframe;数据与交互在演示页内操作,不在此处留静态截图。
依赖
- 基础件:
cu-button、cu-tag、cu-empty、cu-loading-icon - Shop 共享件:
locale/index.uts(cuShopT/cuShopTf)、utils/price.uts(formatFen)、utils/account.uts(isExpiringSoon)、store/shop-config.uts(shopCurrencySymbol)
全量契约
props
| 参数 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| coupons | 当前栏的券列表,元素按 ShopUserCoupon 读外层 status / expiresAt / reason 与内层 coupon.title / amountFen / thresholdFen / tagText | Array | [] |
| activeStatus | 当前分栏,受控值;认 available / used / expired,只影响高亮、排序与空态文案 | string | 'available' |
| counts | 分栏数量,读 available / used / expired 三个键;缺失记 0 | Object | {} |
| hasMore | 是否还有下一页(非加载中时才出按钮) | boolean | false |
| loading | 加载中只替换券列表区,分栏行仍渲染 | boolean | false |
| customStyle | 根节点自定义样式 | Object | {} |
| customClass | 根节点自定义类名 | string | '' |
| url | 透传字段,本件未接线 | string | '' |
| linkType | 透传字段,本件未接线 | string | 'navigateTo' |
events
| 事件 | 说明 | 载荷 |
|---|---|---|
| @change-status | 点分栏;status 为 available / used / expired,宿主回写 activeStatus 并换列表才切栏 | { status } |
| @use | 可用券点「去使用」;coupon 为该条 ShopUserCoupon 原对象 | { coupon } |
| @click | 点券卡正文区,或不可用券点「查看详情」 | { coupon } |
| @load-more | 点「加载更多」 | 无 |
| @retry | 点空态里的「重新加载」 | 无 |
slots
| 插槽 | 作用域 | 说明 |
|---|---|---|
| empty | 无 | 空态位,默认显示 cu-empty + 「重新加载」行 |
| footer | 无 | 列表底部(加载更多之后) |
代码示例
<cu-shop-coupon-wallet :coupons="coupons" :activeStatus="activeStatus" :counts="counts"
:hasMore="hasMore" :loading="loading"
@change-status="onChangeStatus" @use="onUse" @click="onClick" @load-more="onLoadMore" @retry="onRetry">
<template #empty><text>暂无可用卡券</text></template>
<template #footer><text>更多券请前往活动中心领取</text></template>
</cu-shop-coupon-wallet>
注意事项
组件不按 activeStatus 过滤 coupons:分栏只决定高亮、排序方向与空态文案,各栏数据由宿主分次传入。
置灰、按钮文案与临期标识都按每条券自身的 status 判,不按当前分栏判:available 走「去使用」发 use,locked / used / expired 一律置灰、走「查看详情」发 click。
临期标识只对 status=available 生效,阈值 isExpiringSoon(expiresAt, Date.now(), 3)(≤3 天);expiresAt 解析不出毫秒时不标临期。
排序:activeStatus=available 时按 expiresAt 升序(选择排序,取最早到期),其余分栏保持传入顺序;expiresAt 只取 YYYY-MM-DD 段换算毫秒。
金额一律走 utils/price.uts 的 formatFen + store/shop-config.uts 的货币符号,不自行拼符号;门槛同理。
门槛文案:coupon.thresholdFen <= 0 显示「无门槛」,避免拼出「满 ¥0 可用」;否则用 {amount} 占位显示「满 ¥99.00 可用」。
有效期行 = 词条「有效期至」+ 空格 + expiresAt 前 10 位,长度不足 10 不渲染该行。
分栏标签的数量用全角括号「(N)」追加,N 经 toFixed(0) 取整。
coupon.tagText 非空时渲染券角标;isBest 本件不渲染(卡面未定义推荐角标),isSelected / isUsable / discountFen 也不读。
reason 非空时单独一行显示不可用原因,不做长度截断。
不请求接口、不持久化、不弹 toast;换栏、使用、加载更多与重试只 emit。
安装 colorui-shop 全量包与安装任意 cu-shop-* 单件包二选一,不要同时装。单件包的前提是已安装完整 colorui-x。