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.

211 lines
4.6 KiB

3 months ago
  1. <template>
  2. <view class="coupon-list">
  3. <view v-for="(item,index) in couponData" style="padding:20rpx;" :key="index">
  4. <view>
  5. <view class="card">
  6. <view class="card-left">{{switchType(item.stockType)}}</view>
  7. <view class="card-center">
  8. <view class="card-center-top"></view>
  9. <view class="card-center-bottom"></view>
  10. </view>
  11. <view class="card-right">
  12. <view class="card-content">
  13. <view class="card-info">{{item.stockName}}</view>
  14. <view class="card-type">可用于
  15. <text class="card-type-text">专业喂养</text>
  16. <text class="card-type-text">专业遛狗</text>
  17. </view>
  18. <view class="card-time">有效期至: {{item.availableEndTime.slice(0, 16)}}</view>
  19. </view>
  20. <!-- <view style="width: 22%;">
  21. <u-button @click="receiveCoupon(item.id)" shape="circle" size="mini" color="#ffaa48" text="立即领取"></u-button>
  22. </view> -->
  23. <view style="width: 132rpx;height: 52rpx;background-color: #FFAA48; display: flex;align-items: center;justify-content: center;border-radius: 56rpx;">
  24. <text @click="receiveCoupon(item.id)" style="font-size: 24rpx; font-weight: 500; color: #FFFFFF;">立即领取</text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="card-bottom">
  29. <view class="card-bottom-text">
  30. 优惠券不可兑换现金
  31. </view>
  32. <view class="card-bottom-text">
  33. 查看详细规则>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import {
  42. getCouponList,
  43. receiveCoupon,
  44. } from "@/api/system/user"
  45. export default {
  46. data() {
  47. return {
  48. couponData: [],
  49. }
  50. },
  51. onLoad() {
  52. // this.openIdStr = this.$globalData.openIdStr;
  53. this.getCouponListAuth()
  54. },
  55. methods: {
  56. getCouponListAuth() {
  57. getCouponList().then(res => {
  58. if (res.code == 200) {
  59. this.couponData = res.data
  60. console.log("this.couponData", this.couponData)
  61. } else {
  62. this.$modal.showToast('获取优惠券失败')
  63. }
  64. })
  65. },
  66. switchType(type) {
  67. if (type == 'PNORMAL') {
  68. return '满减券'
  69. }
  70. if (type == 'PDISCOUNT') {
  71. return '折扣券'
  72. }
  73. if (type == 'PTRAIL') {
  74. return '体验券'
  75. }
  76. return '优惠券'
  77. },
  78. receiveCoupon (id) {
  79. let data = {
  80. stockId: id
  81. }
  82. receiveCoupon(data).then(res => {
  83. console.log("this.receiveCoupon", res)
  84. if (res.code == 200) {
  85. this.$modal.showToast('优惠券领取成功')
  86. } else {
  87. this.$modal.showToast('领取优惠券失败')
  88. }
  89. })
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss">
  95. .coupon-list {
  96. .card {
  97. display: flex;
  98. align-items: center;
  99. width: 100%;
  100. padding: 10px 0;
  101. background: #fff;
  102. border-radius: 8px 8px 0 0;
  103. }
  104. .card-bottom {
  105. display: flex;
  106. background-color: #FFF1E0;
  107. height: 50rpx;
  108. align-items: center;
  109. justify-content: space-between;
  110. padding: 0 20rpx 0 20rpx;
  111. border-radius: 0 0 8px 8px;
  112. .card-bottom-text {
  113. color: #AAAAAA;
  114. font-size: 24rpx;
  115. font-weight: 400;
  116. }
  117. }
  118. .card-left {
  119. width: 88px;
  120. text-align: center;
  121. color: #FF530A;
  122. font-size: 28rpx;
  123. font-weight: 900;
  124. }
  125. .card-center {
  126. display: flex;
  127. flex-direction: column;
  128. // align-items: center;
  129. .card-center-top {
  130. width: 40rpx;
  131. height: 20rpx;
  132. border-radius: 0 0 20rpx 20rpx;
  133. background-color: #F5F5F7;
  134. line-height: 20rpx;
  135. // border-bottom: 1px solid #FDA714;
  136. // border-left: 1px solid #FDA714;
  137. // border-right: 1px solid #FDA714;
  138. margin-top: -22rpx;
  139. margin-bottom: 20rpx;
  140. margin-left: -19rpx;
  141. }
  142. .card-center-bottom {
  143. border-right: 1px dashed #AAAAAA;
  144. width: 1px;
  145. height: 120rpx;
  146. }
  147. }
  148. .card-right {
  149. padding: 0px 12px;
  150. display: flex;
  151. flex: 1;
  152. /* flex-direction: column; */
  153. justify-content: space-between;
  154. align-items: center;
  155. height: 60px;
  156. .card-content {
  157. width: 77%;
  158. }
  159. .card-icon {
  160. position: relative;
  161. right: -10px;
  162. top: -10px;
  163. }
  164. }
  165. .card-info {
  166. margin: 0;
  167. font-size: 28rpx;
  168. line-height: 28rpx;
  169. color: #333333;
  170. font-weight: 500;
  171. }
  172. .card-type {
  173. font-size: 24rpx;
  174. font-weight: 400;
  175. line-height: 24rpx;
  176. font-weight: 400;
  177. color: #AAAAAA;
  178. margin-top: 10rpx;
  179. .card-type-text {
  180. color: #FFAA48;
  181. font-size: 24rpx;
  182. font-weight: 400;
  183. line-height: 24rpx;
  184. border: #FFAA48 1px solid;
  185. border-radius: 7rpx;
  186. margin-left: 8rpx;
  187. }
  188. }
  189. .card-time {
  190. font-size: 24rpx;
  191. font-weight: 400;
  192. line-height: 24rpx;
  193. font-weight: 400;
  194. color: #AAAAAA;
  195. margin-top: 10rpx;
  196. }
  197. }
  198. </style>