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

265 lines
6.2 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 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 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 list"
  19. :key="index"
  20. class="coupon-item"
  21. :class="{
  22. 'used-coupon': currentTab === 1,
  23. 'expired-coupon': currentTab === 2
  24. }"
  25. >
  26. <!-- 左侧金额区域 -->
  27. <view class="coupon-left">
  28. <text class="coupon-symbol">¥</text>
  29. <text class="coupon-amount">{{ coupon.money }}</text>
  30. <!-- 状态盖章 -->
  31. <image
  32. v-if="currentTab !== 0"
  33. class="status-stamp"
  34. :src="currentTab === 1 ? '/static/已使用盖章.png' : '/static/已过期盖章.png'"
  35. mode="aspectFit"
  36. ></image>
  37. </view>
  38. <!-- 右侧信息区域 -->
  39. <view class="coupon-right">
  40. <view class="coupon-title">{{ coupon.name }}</view>
  41. <view class="coupon-expire">有效期至 {{ coupon.endTime }}</view>
  42. <!-- 使用按钮或状态 -->
  43. <view class="coupon-action">
  44. <uv-button
  45. v-if="currentTab === 0"
  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': currentTab === 1,
  55. 'expired-status': currentTab === 2
  56. }"
  57. >
  58. {{ currentTab === 1 ? '已使用' : '已过期' }}
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <uv-loading-icon text="加载中" textSize="30rpx" v-if="isLoading"></uv-loading-icon>
  64. <!-- 空状态 -->
  65. <uv-empty
  66. v-else-if="list === 0"
  67. text="暂无优惠券"
  68. :textColor="emptyStyle.textColor"
  69. :textSize="emptyStyle.textSize"
  70. :marginTop="emptyStyle.marginTop"
  71. ></uv-empty>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import ListMixins from '@/mixins/list'
  77. export default {
  78. mixins: [ListMixins],
  79. data() {
  80. return {
  81. mixinListApi: 'member.getCouponList',
  82. currentTab: 0,
  83. tabList: [
  84. { name: '待使用' },
  85. { name: '已使用' },
  86. { name: '已过期' }
  87. ],
  88. // tab样式配置
  89. tabStyle: {
  90. activeColor: '#06DADC',
  91. inactiveColor: '#999',
  92. bgColor: '#f8f8f8',
  93. fontSize: '28rpx',
  94. height: '80rpx'
  95. },
  96. // 按钮样式配置
  97. buttonStyle: {
  98. backgroundColor: '#06DADC',
  99. borderRadius: '99rpx',
  100. width: '140rpx',
  101. height: '60rpx',
  102. fontSize: '30rpx',
  103. color: '#fff'
  104. },
  105. // 空状态样式配置
  106. emptyStyle: {
  107. textColor: '#999',
  108. textSize: '28rpx',
  109. marginTop: '200rpx'
  110. }
  111. }
  112. },
  113. computed: {
  114. },
  115. methods: {
  116. mixinSetParams() {
  117. return {
  118. status: String(this.currentTab)
  119. }
  120. },
  121. onTabChange(index) {
  122. this.currentTab = index
  123. this.list = []
  124. this.initPage()
  125. this.getList(true)
  126. },
  127. useCoupon(coupon) {
  128. uni.showToast({
  129. title: '跳转到使用页面',
  130. icon: 'none'
  131. })
  132. }
  133. }
  134. }
  135. </script>
  136. <style lang="scss" scoped>
  137. .discount-container {
  138. min-height: 100vh;
  139. background-color: #f8f8f8;
  140. padding-bottom: 50rpx;
  141. .coupon-list {
  142. padding: 40rpx 30rpx;
  143. .coupon-item {
  144. display: flex;
  145. background-color: #fff;
  146. border-radius: 24rpx;
  147. margin-bottom: 24rpx;
  148. overflow: hidden;
  149. position: relative;
  150. padding: 8rpx;
  151. // box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
  152. &.used-coupon,
  153. &.expired-coupon {
  154. .coupon-left {
  155. background-color: #E3E3E3;
  156. .coupon-symbol,
  157. .coupon-amount {
  158. color: #FBFBFB;
  159. }
  160. }
  161. }
  162. .coupon-left {
  163. width: 180rpx;
  164. background-color: #FFF2F2;
  165. display: flex;
  166. // flex-direction: column;
  167. align-items: center;
  168. justify-content: center;
  169. border-radius: 16rpx;
  170. position: relative;
  171. .coupon-symbol {
  172. font-size: 24rpx;
  173. color: #FF4800;
  174. font-weight: bold;
  175. margin-bottom: 10rpx;
  176. }
  177. .coupon-amount {
  178. font-size: 48rpx;
  179. color: #FF4800;
  180. font-weight: 500;
  181. line-height: 1.4;
  182. }
  183. .status-stamp {
  184. position: absolute;
  185. bottom: 0rpx;
  186. right: 0rpx;
  187. width: 100rpx;
  188. height: 100rpx;
  189. // opacity: 0.8;
  190. }
  191. }
  192. .coupon-right {
  193. flex: 1;
  194. margin-left: 20rpx;
  195. padding: 40rpx 30rpx 20rpx;
  196. position: relative;
  197. width: 0px;
  198. border-left: 2rpx dashed #DADADA;
  199. .coupon-title {
  200. font-size: 32rpx;
  201. color: #181818;
  202. font-weight: bold;
  203. margin-bottom: 16rpx;
  204. }
  205. .coupon-expire {
  206. font-size: 28rpx;
  207. color: #9B9B9B;
  208. margin-bottom: 16rpx;
  209. }
  210. .coupon-action {
  211. display: flex;
  212. justify-content: flex-start;
  213. .coupon-status {
  214. padding: 10rpx 30rpx;
  215. border-radius: 40rpx;
  216. font-size: 30rpx;
  217. text-align: center;
  218. &.used-status {
  219. background-color: #E3E3E3;
  220. color: #fff;
  221. }
  222. &.expired-status {
  223. background-color: #E3E3E3;
  224. color: #fff;
  225. }
  226. }
  227. }
  228. }
  229. }
  230. }
  231. }
  232. </style>