|
|
- <template>
- <view class="new-user-coupon" v-if="showPopup">
- <view class="mask" @click="closePopup"></view>
- <view class="coupon-container">
- <view class="coupon-content">
- <image class="coupon-image" src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/coupon/new-user-coupon.png" mode="widthFix"></image>
- <view class="coupon-btn" @click="getCoupon">立即领取</view>
- </view>
- <view class="close-btn" @click="closePopup">
- <text class="close-icon">×</text>
- </view>
- </view>
- </view>
- </template>
-
- <script>
- import { getToken } from '@/utils/auth'
-
- export default {
- name: 'NewUserCoupon',
- data() {
- return {
- showPopup: true
- }
- },
- methods: {
- closePopup() {
- this.showPopup = false
- this.$emit('close')
- },
- getCoupon() {
- // 检查用户是否已登录
- if (!getToken()) {
- // 未登录,跳转到登录页面
- uni.navigateTo({
- url: '/pages/login/index'
- })
- } else {
- // 已登录,触发领券事件
- this.$emit('getCoupon')
- this.closePopup()
- }
- }
- }
- }
- </script>
-
- <style lang="scss">
- .new-user-coupon {
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- z-index: 999;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .mask {
- position: absolute;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background-color: rgba(0, 0, 0, 0.6);
- }
-
- .coupon-container {
- position: relative;
- width: 560rpx;
- z-index: 1000;
- display: flex;
- flex-direction: column;
- align-items: center;
- }
-
- .coupon-content {
- display: flex;
- flex-direction: column;
- align-items: center;
- }
-
- .coupon-image {
- width: 560rpx;
- border-radius: 20rpx;
- }
-
- .coupon-btn {
- margin-top: -80rpx;
- width: 300rpx;
- height: 80rpx;
- background: #FFB13F;
- color: #FFFFFF;
- font-size: 32rpx;
- font-weight: bold;
- border-radius: 40rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
-
- .close-btn {
- margin-top: 40rpx;
- width: 60rpx;
- height: 60rpx;
- background: rgba(255, 255, 255, 0.8);
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
-
- .close-icon {
- color: #666;
- font-size: 40rpx;
- font-weight: bold;
- }
- }
- }
- </style>
|