四零语境前端代码仓库
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.

325 lines
7.8 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="discount-container">
  3. <!-- 顶部tab切换 -->
  4. <uv-subsection
  5. :list="tabList"
  6. :current="currentTab"
  7. @change="onTabChange"
  8. :activeColor="tabStyle.activeColor"
  9. :inactiveColor="tabStyle.inactiveColor"
  10. :fontSize="tabStyle.fontSize"
  11. :height="tabStyle.height"
  12. custom-style="height: 80rpx;border-radius: 70rpx;position: sticky; left: 0; top: 0;right: 0;zIndex: 999"
  13. custom-item-style="border-radius: 60rpx;"
  14. ></uv-subsection>
  15. <!-- 优惠券列表 -->
  16. <view class="coupon-list">
  17. <view
  18. v-for="(coupon, index) in currentCoupons"
  19. :key="index"
  20. class="coupon-item"
  21. :class="{
  22. 'used-coupon': coupon.status === 'used',
  23. 'expired-coupon': coupon.status === 'expired'
  24. }"
  25. >
  26. <!-- 左侧金额区域 -->
  27. <view class="coupon-left">
  28. <text class="coupon-symbol">¥</text>
  29. <text class="coupon-amount">{{ coupon.amount }}</text>
  30. <!-- 状态盖章 -->
  31. <image
  32. v-if="coupon.status !== 'available'"
  33. class="status-stamp"
  34. :src="coupon.status === 'used' ? '/static/已使用盖章.png' : '/static/已过期盖章.png'"
  35. mode="aspectFit"
  36. ></image>
  37. </view>
  38. <!-- 右侧信息区域 -->
  39. <view class="coupon-right">
  40. <view class="coupon-title">{{ coupon.title }}</view>
  41. <view class="coupon-expire">有效期至 {{ coupon.expireDate }}</view>
  42. <!-- 使用按钮或状态 -->
  43. <view class="coupon-action">
  44. <uv-button
  45. v-if="coupon.status === 'available'"
  46. :customStyle="buttonStyle"
  47. text="去使用"
  48. @click="useCoupon(coupon)"
  49. ></uv-button>
  50. <view
  51. v-else
  52. class="coupon-status"
  53. :class="{
  54. 'used-status': coupon.status === 'used',
  55. 'expired-status': coupon.status === 'expired'
  56. }"
  57. >
  58. {{ coupon.status === 'used' ? '已使用' : '已过期' }}
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 空状态 -->
  64. <uv-empty
  65. v-if="currentCoupons.length === 0"
  66. text="暂无优惠券"
  67. :textColor="emptyStyle.textColor"
  68. :textSize="emptyStyle.textSize"
  69. :marginTop="emptyStyle.marginTop"
  70. ></uv-empty>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import ListMixins from '@/mixins/list'
  76. export default {
  77. mixins: [ListMixins],
  78. data() {
  79. return {
  80. mixinListApi: 'member.getCouponList',
  81. currentTab: 0,
  82. tabList: [
  83. { name: '待使用' },
  84. { name: '已使用' },
  85. { name: '已过期' }
  86. ],
  87. // tab样式配置
  88. tabStyle: {
  89. activeColor: '#06DADC',
  90. inactiveColor: '#999',
  91. bgColor: '#f8f8f8',
  92. fontSize: '28rpx',
  93. height: '80rpx'
  94. },
  95. // 按钮样式配置
  96. buttonStyle: {
  97. backgroundColor: '#06DADC',
  98. borderRadius: '99rpx',
  99. width: '140rpx',
  100. height: '60rpx',
  101. fontSize: '30rpx',
  102. color: '#fff'
  103. },
  104. // 空状态样式配置
  105. emptyStyle: {
  106. textColor: '#999',
  107. textSize: '28rpx',
  108. marginTop: '200rpx'
  109. },
  110. // 优惠券数据
  111. coupons: {
  112. available: [
  113. {
  114. id: 1,
  115. title: '专属福利】20元红包',
  116. amount: 20,
  117. expireDate: '2026-04-28',
  118. status: 'available'
  119. },
  120. {
  121. id: 2,
  122. title: '专属福利】400元红包',
  123. amount: 400,
  124. expireDate: '2026-04-28',
  125. status: 'available'
  126. },
  127. {
  128. id: 3,
  129. title: '专属福利】400元红包',
  130. amount: 400,
  131. expireDate: '2026-04-28',
  132. status: 'available'
  133. },
  134. {
  135. id: 1,
  136. title: '专属福利】20元红包',
  137. amount: 20,
  138. expireDate: '2026-04-28',
  139. status: 'available'
  140. },
  141. {
  142. id: 2,
  143. title: '专属福利】400元红包',
  144. amount: 400,
  145. expireDate: '2026-04-28',
  146. status: 'available'
  147. },
  148. {
  149. id: 3,
  150. title: '专属福利】400元红包',
  151. amount: 400,
  152. expireDate: '2026-04-28',
  153. status: 'available'
  154. },
  155. ],
  156. used: [
  157. {
  158. id: 4,
  159. title: '专属福利】20元红包',
  160. amount: 20,
  161. expireDate: '2026-04-28',
  162. status: 'used'
  163. }
  164. ],
  165. expired: [
  166. {
  167. id: 5,
  168. title: '专属福利】20元红包',
  169. amount: 20,
  170. expireDate: '2026-04-28',
  171. status: 'expired'
  172. }
  173. ]
  174. }
  175. }
  176. },
  177. computed: {
  178. currentCoupons() {
  179. const statusMap = ['available', 'used', 'expired']
  180. return this.coupons[statusMap[this.currentTab]] || []
  181. }
  182. },
  183. methods: {
  184. onTabChange(index) {
  185. this.currentTab = index
  186. },
  187. useCoupon(coupon) {
  188. uni.showToast({
  189. title: '跳转到使用页面',
  190. icon: 'none'
  191. })
  192. }
  193. }
  194. }
  195. </script>
  196. <style lang="scss" scoped>
  197. .discount-container {
  198. min-height: 100vh;
  199. background-color: #f8f8f8;
  200. padding-bottom: 50rpx;
  201. .coupon-list {
  202. padding: 40rpx 30rpx;
  203. .coupon-item {
  204. display: flex;
  205. background-color: #fff;
  206. border-radius: 24rpx;
  207. margin-bottom: 24rpx;
  208. overflow: hidden;
  209. position: relative;
  210. padding: 8rpx;
  211. // box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
  212. &.used-coupon,
  213. &.expired-coupon {
  214. .coupon-left {
  215. background-color: #E3E3E3;
  216. .coupon-symbol,
  217. .coupon-amount {
  218. color: #FBFBFB;
  219. }
  220. }
  221. }
  222. .coupon-left {
  223. width: 180rpx;
  224. background-color: #FFF2F2;
  225. display: flex;
  226. // flex-direction: column;
  227. align-items: center;
  228. justify-content: center;
  229. border-radius: 16rpx;
  230. position: relative;
  231. .coupon-symbol {
  232. font-size: 24rpx;
  233. color: #FF4800;
  234. font-weight: bold;
  235. margin-bottom: 10rpx;
  236. }
  237. .coupon-amount {
  238. font-size: 48rpx;
  239. color: #FF4800;
  240. font-weight: 500;
  241. line-height: 1.4;
  242. }
  243. .status-stamp {
  244. position: absolute;
  245. bottom: 0rpx;
  246. right: 0rpx;
  247. width: 100rpx;
  248. height: 100rpx;
  249. // opacity: 0.8;
  250. }
  251. }
  252. .coupon-right {
  253. flex: 1;
  254. margin-left: 20rpx;
  255. padding: 40rpx 30rpx 20rpx;
  256. position: relative;
  257. width: 0px;
  258. border-left: 2rpx dashed #DADADA;
  259. .coupon-title {
  260. font-size: 32rpx;
  261. color: #181818;
  262. font-weight: bold;
  263. margin-bottom: 16rpx;
  264. }
  265. .coupon-expire {
  266. font-size: 28rpx;
  267. color: #9B9B9B;
  268. margin-bottom: 16rpx;
  269. }
  270. .coupon-action {
  271. display: flex;
  272. justify-content: flex-start;
  273. .coupon-status {
  274. padding: 10rpx 30rpx;
  275. border-radius: 40rpx;
  276. font-size: 30rpx;
  277. text-align: center;
  278. &.used-status {
  279. background-color: #E3E3E3;
  280. color: #fff;
  281. }
  282. &.expired-status {
  283. background-color: #E3E3E3;
  284. color: #fff;
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. }
  292. </style>