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

288 lines
6.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 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/used-stamp.png' : '/static/expired-stamp.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. fromPage: '', // 来源页面标识
  84. tabList: [
  85. { name: '待使用' },
  86. { name: '已使用' },
  87. { name: '已过期' }
  88. ],
  89. // tab样式配置
  90. tabStyle: {
  91. activeColor: '#06DADC',
  92. inactiveColor: '#999',
  93. bgColor: '#f8f8f8',
  94. fontSize: '28rpx',
  95. height: '80rpx'
  96. },
  97. // 按钮样式配置
  98. buttonStyle: {
  99. backgroundColor: '#06DADC',
  100. borderRadius: '99rpx',
  101. width: '140rpx',
  102. height: '60rpx',
  103. fontSize: '30rpx',
  104. color: '#fff'
  105. },
  106. // 空状态样式配置
  107. emptyStyle: {
  108. textColor: '#999',
  109. textSize: '28rpx',
  110. marginTop: '200rpx'
  111. }
  112. }
  113. },
  114. onLoad(options) {
  115. // 接收来源页面参数
  116. if (options.from) {
  117. this.fromPage = options.from
  118. }
  119. },
  120. computed: {
  121. },
  122. methods: {
  123. mixinSetParams() {
  124. return {
  125. status: String(this.currentTab)
  126. }
  127. },
  128. onTabChange(index) {
  129. this.currentTab = index
  130. this.list = []
  131. this.initPage()
  132. this.getList(true)
  133. },
  134. useCoupon(coupon) {
  135. // 如果是从充值页面跳转过来的,选择优惠券后返回
  136. if (this.fromPage === 'recharge') {
  137. console.log('被选中了');
  138. // 通过事件总线传递选中的优惠券数据
  139. uni.$emit('couponSelected', {
  140. id: coupon.id,
  141. name: coupon.name,
  142. money: coupon.money,
  143. endTime: coupon.endTime
  144. })
  145. uni.navigateBack()
  146. } else {
  147. // 其他情况的处理逻辑
  148. uni.showToast({
  149. title: '跳转到使用页面',
  150. icon: 'none'
  151. })
  152. }
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .discount-container {
  159. min-height: 100vh;
  160. background-color: #f8f8f8;
  161. padding-bottom: 50rpx;
  162. .coupon-list {
  163. padding: 40rpx 30rpx;
  164. .coupon-item {
  165. display: flex;
  166. background-color: #fff;
  167. border-radius: 24rpx;
  168. margin-bottom: 24rpx;
  169. overflow: hidden;
  170. position: relative;
  171. padding: 8rpx;
  172. // box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
  173. &.used-coupon,
  174. &.expired-coupon {
  175. .coupon-left {
  176. background-color: #E3E3E3;
  177. .coupon-symbol,
  178. .coupon-amount {
  179. color: #FBFBFB;
  180. }
  181. }
  182. }
  183. .coupon-left {
  184. width: 180rpx;
  185. background-color: #FFF2F2;
  186. display: flex;
  187. // flex-direction: column;
  188. align-items: center;
  189. justify-content: center;
  190. border-radius: 16rpx;
  191. position: relative;
  192. .coupon-symbol {
  193. font-size: 24rpx;
  194. color: #FF4800;
  195. font-weight: bold;
  196. margin-bottom: 10rpx;
  197. }
  198. .coupon-amount {
  199. font-size: 48rpx;
  200. color: #FF4800;
  201. font-weight: 500;
  202. line-height: 1.4;
  203. }
  204. .status-stamp {
  205. position: absolute;
  206. bottom: 0rpx;
  207. right: 0rpx;
  208. width: 100rpx;
  209. height: 100rpx;
  210. // opacity: 0.8;
  211. }
  212. }
  213. .coupon-right {
  214. flex: 1;
  215. margin-left: 20rpx;
  216. padding: 40rpx 30rpx 20rpx;
  217. position: relative;
  218. width: 0px;
  219. border-left: 2rpx dashed #DADADA;
  220. .coupon-title {
  221. font-size: 32rpx;
  222. color: #181818;
  223. font-weight: bold;
  224. margin-bottom: 16rpx;
  225. }
  226. .coupon-expire {
  227. font-size: 28rpx;
  228. color: #9B9B9B;
  229. margin-bottom: 16rpx;
  230. }
  231. .coupon-action {
  232. display: flex;
  233. justify-content: flex-start;
  234. .coupon-status {
  235. padding: 10rpx 30rpx;
  236. border-radius: 40rpx;
  237. font-size: 30rpx;
  238. text-align: center;
  239. &.used-status {
  240. background-color: #E3E3E3;
  241. color: #fff;
  242. }
  243. &.expired-status {
  244. background-color: #E3E3E3;
  245. color: #fff;
  246. }
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>