敢为人鲜小程序前端代码仓库
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.

226 lines
7.1 KiB

  1. <template>
  2. <view class="new-coupon-popup">
  3. <uv-popup ref="popup" @change="change" min-height="400rpx" closeable :z-index="999999">
  4. <view class="coupon-content">
  5. <text class="coupon-title">优惠券列表</text>
  6. <view class="coupon-list">
  7. <view class="coupon-item" v-for="item in couponList" :key="item.id">
  8. <view class="coupon-left">
  9. <view class="coupon-amount">
  10. <text class="amount-symbol">¥</text>
  11. <text class="amount-value">{{item.amount}}</text>
  12. </view>
  13. <view class="coupon-info">
  14. <text class="coupon-name">{{item.title}}</text>
  15. <text class="coupon-type">{{item.type_dictText}}</text>
  16. <text class="coupon-desc">{{item.remark}}</text>
  17. </view>
  18. </view>
  19. <view class="coupon-right">
  20. <view class="fetch-btn" hover-class="fetch-btn-hover" @click="fetchCoupon(item.id)">
  21. <text class="fetch-btn-text">领取</text>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </uv-popup>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. name: 'NewCouponPopup',
  33. data() {
  34. return {
  35. couponList: []
  36. }
  37. },
  38. mounted() {
  39. if (uni.getStorageSync('token')){
  40. this.getCouponList()
  41. }
  42. },
  43. methods: {
  44. getCouponList() {
  45. this.$api('queryFetchCouponList', {}, res => {
  46. if (res.code === 200 && res.result.length > 0){
  47. this.couponList = res.result
  48. this.$refs.popup.open()
  49. }
  50. })
  51. },
  52. fetchCoupon(id) {
  53. this.$api('fetchCoupon', {
  54. couponId: id
  55. }, res => {
  56. uni.showToast({
  57. title: `${res.message}`,
  58. icon: 'success'
  59. })
  60. this.$refs.popup.close();
  61. })
  62. },
  63. change(e) {
  64. if(!e) {
  65. this.$emit('close')
  66. }
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss">
  72. .coupon-content{
  73. padding: 40rpx 20rpx;
  74. background-color: #fff;
  75. border-radius: 20rpx;
  76. display: flex;
  77. flex-direction: column;
  78. align-items: center;
  79. gap: 40rpx;
  80. position: relative;
  81. .coupon-title{
  82. color: black;
  83. text-align: center;
  84. font-size: 36rpx;
  85. font-weight: 600;
  86. margin-bottom: 10rpx;
  87. }
  88. .coupon-list{
  89. display: flex;
  90. flex-direction: column;
  91. align-items: center;
  92. gap: 20rpx;
  93. width: 100%;
  94. .coupon-item{
  95. width: 80vw;
  96. height: 180rpx;
  97. background: linear-gradient(135deg, $uni-color, #ff8a8a);
  98. border-radius: 16rpx;
  99. display: flex;
  100. align-items: center;
  101. justify-content: space-between;
  102. padding: 0 20rpx;
  103. position: relative;
  104. box-shadow: 0 6rpx 12rpx rgba(255, 99, 99, 0.2);
  105. overflow: hidden;
  106. &::before {
  107. content: '';
  108. position: absolute;
  109. left: -15rpx;
  110. top: 50%;
  111. transform: translateY(-50%);
  112. width: 30rpx;
  113. height: 30rpx;
  114. background-color: #fff;
  115. border-radius: 50%;
  116. }
  117. &::after {
  118. content: '';
  119. position: absolute;
  120. right: -15rpx;
  121. top: 50%;
  122. transform: translateY(-50%);
  123. width: 30rpx;
  124. height: 30rpx;
  125. background-color: #fff;
  126. border-radius: 50%;
  127. }
  128. .coupon-left {
  129. display: flex;
  130. align-items: center;
  131. gap: 20rpx;
  132. .coupon-amount {
  133. display: flex;
  134. align-items: baseline;
  135. color: #fff;
  136. .amount-symbol {
  137. font-size: 28rpx;
  138. font-weight: bold;
  139. }
  140. .amount-value {
  141. font-size: 48rpx;
  142. font-weight: bold;
  143. }
  144. }
  145. .coupon-info {
  146. display: flex;
  147. flex-direction: column;
  148. .coupon-name {
  149. font-size: 32rpx;
  150. color: #fff;
  151. font-weight: 600;
  152. margin-bottom: 4rpx;
  153. }
  154. .coupon-type {
  155. font-size: 24rpx;
  156. color: rgba(255, 255, 255, 0.9);
  157. background-color: rgba(255, 255, 255, 0.2);
  158. padding: 2rpx 10rpx;
  159. border-radius: 10rpx;
  160. display: inline-block;
  161. margin-bottom: 6rpx;
  162. }
  163. .coupon-desc {
  164. font-size: 24rpx;
  165. color: rgba(255, 255, 255, 0.8);
  166. }
  167. }
  168. }
  169. .coupon-right {
  170. .fetch-btn {
  171. width: 120rpx;
  172. height: 60rpx;
  173. background: rgba(255, 255, 255, 0.9);
  174. border-radius: 30rpx;
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. position: relative;
  179. overflow: hidden;
  180. &::before {
  181. content: '';
  182. position: absolute;
  183. top: 0;
  184. left: 0;
  185. right: 0;
  186. bottom: 0;
  187. background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.5), transparent);
  188. transform: translateX(-100%);
  189. transition: transform 0.6s;
  190. }
  191. &:active::before {
  192. transform: translateX(100%);
  193. }
  194. .fetch-btn-text {
  195. color: $uni-color;
  196. font-size: 26rpx;
  197. font-weight: bold;
  198. }
  199. }
  200. .fetch-btn-hover {
  201. transform: scale(0.95);
  202. opacity: 0.9;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. </style>