引导添加到桌面添加到我的小程序

<template>
  <view class="add-applet" v-if="isShow" @click="close" :style="'top:'+topHeight+'px'">
    <view class="triangle"></view>
    <view class="content">点击"添加到我的小程序"方便您快速查看</view>
    <!-- <view class="content">点击"添加到桌面"无需打开微信快速访问</view> -->
  </view>
</template>

<script>
  export default {
    data() {
      return {
        isShow: true,
        topHeight: 0,
      };
    },
    mounted() {
      let menuButton = uni.getMenuButtonBoundingClientRect();
      if (menuButton) {
        this.topHeight = menuButton.height + menuButton.top + 10;
      }
      this.show();
    },
    methods: {
      show() {
        let currentDate = new Date().setDate(new Date().getDate()-7);
        let addAppletDate = uni.getStorageSync('addAppletDate');
        if (!addAppletDate || currentDate >= addAppletDate) {
          this.isShow = true;
          setTimeout(res => {
            this.close();
          }, 10000)
        }
      },
      close() {
        this.isShow = false;
        uni.setStorageSync('addAppletDate', new Date().getTime());
      },
    },
  };
</script>

<style scoped lang="scss">
  .add-applet {
    border-radius: 10rpx;
    background: rgba(5, 5, 5, 0.5);
    padding: 16rpx 20rpx;
    position: fixed;
    z-index: 3;
    top: 180rpx;
    right: 100rpx;
    display: flex;
    align-items: center;
    .triangle{
      position: absolute;
      top: -15rpx;
      right: 30rpx;
      width: 0;
      height: 0;
      border-left: 15rpx solid transparent;
      border-right: 15rpx solid transparent;
      border-bottom: 15rpx solid rgba(5, 5, 5, 0.5);
    }
    .content{
      color: #ffffff;
      font-size: 22rpx;
    }
  }
</style>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值