exchange.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="sub-base-container">
  3. <view class="exchange-card">
  4. <view class="tabs">
  5. <view :class="['tab-item',{active:active === index}]" @click="handleTab(index)"
  6. v-for="(item,index) in tabs" :key="index">{{item}}</view>
  7. </view>
  8. <view class="list" v-show="active === 0">
  9. <template v-if="giftData.length">
  10. <view class="item" v-for="(item,index) in giftData" :key="index">
  11. <view class="item-info">
  12. <image class="img" :src="item.icon"></image>
  13. <view class="cont">
  14. <up-text bold :text="item.remark"></up-text>
  15. <up-text size="12" color="#999999"
  16. :text="`有限期:${item.startDate}至${item.endDate}`"></up-text>
  17. </view>
  18. </view>
  19. <view class="button">去兑换</view>
  20. </view>
  21. </template>
  22. <up-empty v-else mode="list" marginTop="50"></up-empty>
  23. </view>
  24. <view class="list" v-show="active === 1">
  25. <template v-if="couponData.length">
  26. <view class="item" v-for="(item,index) in couponData" :key="index">
  27. <view class="item-info">
  28. <view class="money">
  29. <view class="sum"><text class="unit">¥</text>50</view>
  30. <view class="tips">满100可用</view>
  31. </view>
  32. <view class="cont">
  33. <up-text bold text="仙桃荔全场优惠券"></up-text>
  34. <up-text bold text="满100减50"></up-text>
  35. <up-text size="12" color="#999999" text="有限期:2025.06.05至2025.06.23"></up-text>
  36. </view>
  37. </view>
  38. <view class="button">去使用</view>
  39. </view>
  40. </template>
  41. <up-empty v-else mode="coupon" marginTop="50"></up-empty>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script setup>
  47. import config from "@/api/config.js"
  48. import {
  49. ref
  50. } from 'vue';
  51. import {
  52. onLoad
  53. } from '@dcloudio/uni-app'
  54. import MINE from '@/api/mine.js'
  55. onLoad(({
  56. type
  57. }) => {
  58. active.value = Number(type)
  59. handleTab(active.value)
  60. })
  61. const giftData = ref([])
  62. const getMyGift = () => {
  63. MINE.myGift({
  64. farmId: 766
  65. }).then((res => {
  66. giftData.value = res.data.useList.filter(item => item.use === 0)
  67. }))
  68. }
  69. const couponData = ref([])
  70. const getCouponList = () => {
  71. MINE.couponList({
  72. farmId: 766
  73. }).then((res => {
  74. couponData.value = res.data || []
  75. }))
  76. }
  77. const active = ref(0)
  78. const tabs = ["守护兑换", "优惠券"]
  79. const handleTab = (index) => {
  80. active.value = index
  81. if (index) {
  82. getCouponList()
  83. } else {
  84. getMyGift()
  85. }
  86. }
  87. </script>
  88. <style lang="scss" scoped>
  89. @import "@/static/style/mixin.scss";
  90. .sub-base-container {
  91. @include ossBg("subTreePage/exchange-bg.png");
  92. min-height: 750rpx;
  93. .exchange-card {
  94. width: 100%;
  95. box-sizing: border-box;
  96. padding: 26rpx 20rpx;
  97. height: calc(100vh - 14vh);
  98. border-radius: 40rpx 40rpx 0 0;
  99. background: #fff;
  100. position: absolute;
  101. top: 14vh;
  102. left: 0;
  103. .tabs {
  104. display: flex;
  105. align-items: center;
  106. justify-content: center;
  107. .tab-item {
  108. color: rgba(0, 0, 0, 0.2);
  109. padding: 10rpx 12rpx;
  110. &.active {
  111. font-size: 36rpx;
  112. color: #000;
  113. font-weight: 500;
  114. }
  115. }
  116. .tab-item+.tab-item {
  117. margin-left: 24rpx;
  118. }
  119. }
  120. .button {
  121. font-size: 24rpx;
  122. padding: 14rpx 32rpx;
  123. border-radius: 50rpx;
  124. background: #FFD95E;
  125. font-weight: 500;
  126. }
  127. .list {
  128. .item {
  129. margin-top: 30rpx;
  130. display: flex;
  131. align-items: center;
  132. justify-content: space-between;
  133. .item-info {
  134. display: flex;
  135. .img {
  136. width: 160rpx;
  137. height: 160rpx;
  138. border-radius: 16rpx;
  139. margin-right: 24rpx;
  140. }
  141. .money {
  142. background-image: linear-gradient(120deg, #ffe3c9, #eebd8f);
  143. border-radius: 16rpx;
  144. padding: 20rpx 30rpx 30rpx;
  145. text-align: center;
  146. color: #322802;
  147. margin-right: 24rpx;
  148. .sum {
  149. font-size: 64rpx;
  150. font-weight: bold;
  151. .unit {
  152. font-size: 30rpx;
  153. margin-right: 6rpx;
  154. }
  155. }
  156. .tips {
  157. color: #000000;
  158. font-size: 24rpx;
  159. margin-top: -12rpx;
  160. }
  161. }
  162. .cont {
  163. line-height: 46rpx;
  164. }
  165. }
  166. }
  167. }
  168. }
  169. /* #ifdef H5 */
  170. .exchange-card {
  171. height: calc(100vh - 14vh - 88rpx);
  172. }
  173. /* #endif */
  174. }
  175. </style>