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.

169 lines
4.1 KiB

  1. <template>
  2. <view class="new-user-page">
  3. <!-- 背景图片 -->
  4. <image class="bg-image"
  5. src="https://image.hhlm1688.com/2025/08/08168577fd3c2c428785038ee249736e54Rectangle 9031@3x.png"
  6. mode="aspectFill" />
  7. <!-- 顶部标题图片 -->
  8. <image class="title-image" src="https://image.hhlm1688.com/2025/08/07767f2fc0a686433bb9e3f90bc6e60990Group%201000001612@3x.png"
  9. mode="widthFix" />
  10. <!-- 优惠券内容图片 -->
  11. <image class="coupon-content-image"
  12. :src="NewUserCoupon.couponPoster || image" mode="widthFix" />
  13. <!-- 立即领取/立即使用按钮 -->
  14. <view class="receive-btn" @click="handleButtonClick">
  15. {{ isReceived ? '立即使用' : '立即领取' }}
  16. </view>
  17. <!-- 下单方式选择弹窗 -->
  18. <order-type-select-popup ref="orderTypeSelectPopup" />
  19. </view>
  20. </template>
  21. <script>
  22. import { getToken } from '@/utils/auth'
  23. import OrderTypeSelectPopup from '@/pages_order/components/OrderTypeSelectPopup.vue'
  24. import { mapState } from 'vuex'
  25. import { receiveCoupon } from "@/api/system/user"
  26. export default {
  27. name: 'NewUserCouponPage',
  28. components: {
  29. OrderTypeSelectPopup
  30. },
  31. data() {
  32. return {
  33. isReceived: false, // 优惠券是否已领取
  34. image : '',
  35. }
  36. },
  37. computed : {
  38. ...mapState(['NewUserCoupon']),
  39. },
  40. methods: {
  41. // 处理按钮点击
  42. handleButtonClick() {
  43. if (this.isReceived) {
  44. // 已领取,点击立即使用,打开选择下单方式弹窗
  45. this.openOrderTypePopup()
  46. } else {
  47. // 未领取,点击立即领取
  48. this.receiveCoupon()
  49. }
  50. },
  51. // 领取优惠券
  52. receiveCoupon() {
  53. let data = {
  54. stockId: this.NewUserCoupon.id,
  55. }
  56. receiveCoupon(data).then(res => {
  57. if (res.code == 200) {
  58. uni.showToast({
  59. title: '领取成功!',
  60. icon: 'success',
  61. duration: 2000
  62. })
  63. // 更新状态为已领取
  64. this.isReceived = true
  65. }
  66. }).catch(err => {
  67. uni.showToast({
  68. title: '领取优惠券失败',
  69. icon: 'none'
  70. })
  71. })
  72. },
  73. // 打开下单方式选择弹窗
  74. openOrderTypePopup() {
  75. this.$refs.orderTypeSelectPopup.open()
  76. },
  77. // 暂不领取
  78. skipReceive() {
  79. uni.navigateBack()
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .new-user-page {
  86. position: relative;
  87. width: 100vw;
  88. height: 100vh;
  89. display: flex;
  90. flex-direction: column;
  91. align-items: center;
  92. justify-content: center;
  93. overflow: hidden;
  94. }
  95. .bg-image {
  96. position: absolute;
  97. top: 0;
  98. left: 0;
  99. width: 100%;
  100. height: 100%;
  101. z-index: 1;
  102. }
  103. .title-image {
  104. position: relative;
  105. z-index: 2;
  106. width: 280rpx;
  107. margin-bottom: 40rpx;
  108. margin-top: -200rpx;
  109. }
  110. .coupon-content-image {
  111. position: relative;
  112. z-index: 2;
  113. width: 600rpx;
  114. margin-bottom: 80rpx;
  115. }
  116. .receive-btn {
  117. position: relative;
  118. z-index: 2;
  119. width: 600rpx;
  120. height: 80rpx;
  121. background: linear-gradient(135deg, #FFB13F 0%, #FF8C00 100%);
  122. color: #FFFFFF;
  123. font-size: 32rpx;
  124. font-weight: bold;
  125. border-radius: 40rpx;
  126. display: flex;
  127. align-items: center;
  128. justify-content: center;
  129. box-shadow: 0 8rpx 20rpx rgba(255, 177, 63, 0.4);
  130. margin-bottom: 40rpx;
  131. &:active {
  132. transform: scale(0.95);
  133. transition: transform 0.1s;
  134. }
  135. }
  136. .skip-btn {
  137. position: relative;
  138. z-index: 2;
  139. width: 200rpx;
  140. height: 60rpx;
  141. background: rgba(255, 255, 255, 0.8);
  142. color: #666;
  143. font-size: 28rpx;
  144. border-radius: 30rpx;
  145. display: flex;
  146. align-items: center;
  147. justify-content: center;
  148. &:active {
  149. background: rgba(255, 255, 255, 0.6);
  150. transition: background 0.1s;
  151. }
  152. }
  153. </style>