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.

119 lines
2.4 KiB

  1. <template>
  2. <view class="new-user-coupon" v-if="showPopup">
  3. <view class="mask" @click="closePopup"></view>
  4. <view class="coupon-container">
  5. <view class="coupon-content">
  6. <image class="coupon-image" src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/coupon/new-user-coupon.png" mode="widthFix"></image>
  7. <view class="coupon-btn" @click="getCoupon">立即领取</view>
  8. </view>
  9. <view class="close-btn" @click="closePopup">
  10. <text class="close-icon">×</text>
  11. </view>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import { getToken } from '@/utils/auth'
  17. export default {
  18. name: 'NewUserCoupon',
  19. data() {
  20. return {
  21. showPopup: true
  22. }
  23. },
  24. methods: {
  25. closePopup() {
  26. this.showPopup = false
  27. this.$emit('close')
  28. },
  29. getCoupon() {
  30. // 检查用户是否已登录
  31. if (!getToken()) {
  32. // 未登录,跳转到登录页面
  33. uni.navigateTo({
  34. url: '/pages/login/index'
  35. })
  36. } else {
  37. // 已登录,触发领券事件
  38. this.$emit('getCoupon')
  39. this.closePopup()
  40. }
  41. }
  42. }
  43. }
  44. </script>
  45. <style lang="scss">
  46. .new-user-coupon {
  47. position: fixed;
  48. top: 0;
  49. left: 0;
  50. width: 100%;
  51. height: 100%;
  52. z-index: 999;
  53. display: flex;
  54. align-items: center;
  55. justify-content: center;
  56. .mask {
  57. position: absolute;
  58. top: 0;
  59. left: 0;
  60. width: 100%;
  61. height: 100%;
  62. background-color: rgba(0, 0, 0, 0.6);
  63. }
  64. .coupon-container {
  65. position: relative;
  66. width: 560rpx;
  67. z-index: 1000;
  68. display: flex;
  69. flex-direction: column;
  70. align-items: center;
  71. }
  72. .coupon-content {
  73. display: flex;
  74. flex-direction: column;
  75. align-items: center;
  76. }
  77. .coupon-image {
  78. width: 560rpx;
  79. border-radius: 20rpx;
  80. }
  81. .coupon-btn {
  82. margin-top: -80rpx;
  83. width: 300rpx;
  84. height: 80rpx;
  85. background: #FFB13F;
  86. color: #FFFFFF;
  87. font-size: 32rpx;
  88. font-weight: bold;
  89. border-radius: 40rpx;
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. }
  94. .close-btn {
  95. margin-top: 40rpx;
  96. width: 60rpx;
  97. height: 60rpx;
  98. background: rgba(255, 255, 255, 0.8);
  99. border-radius: 50%;
  100. display: flex;
  101. align-items: center;
  102. justify-content: center;
  103. .close-icon {
  104. color: #666;
  105. font-size: 40rpx;
  106. font-weight: bold;
  107. }
  108. }
  109. }
  110. </style>