add-tip.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view>
  3. <view class="uni-add-tips-box" v-if="showTip">
  4. <view class='uni-add-tips-content' @tap='hideTip'>
  5. <text>{{tip}}</text>
  6. </view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. const SHOW_TIP = "SHOW_TIP"
  12. export default{
  13. data(){
  14. return{
  15. showTip:false,
  16. }
  17. },
  18. mounted() {
  19. this.showTip = !uni.getStorageInfoSync().keys.includes(SHOW_TIP)
  20. setTimeout(()=>{
  21. this.showTip = false
  22. },this.duration*1000)
  23. },
  24. props:{
  25. tip:{
  26. type:String,
  27. default:"点击「·•·」,添加至我的小程序"
  28. },
  29. duration:{
  30. type:Number,
  31. default:10
  32. }
  33. },
  34. methods:{
  35. hideTip(){
  36. uni.setStorageSync(SHOW_TIP,true)
  37. this.showTip = false
  38. }
  39. }
  40. }
  41. </script>
  42. <style lang="scss" scoped>
  43. $themeColor:rgba($color: #000000, $alpha: 0.8); //主题色
  44. .uni-add-tips-box {
  45. position: fixed;
  46. top: cal(44px + var(--status-bar-height));
  47. right: 0;
  48. z-index: 99999;
  49. opacity: 0.8;
  50. display: flex;
  51. justify-content: flex-end;
  52. align-items: flex-end;
  53. flex-direction: column;
  54. width: 600upx;
  55. animation: opacityC 1s linear infinite;
  56. }
  57. .uni-add-tips-content::before{
  58. content: "";
  59. position: absolute;
  60. width: 0;
  61. height: 0;
  62. top:-38upx;
  63. right:105upx;
  64. border-width: 20upx;
  65. border-style: solid;
  66. display: block;
  67. border-color: transparent transparent $themeColor transparent;
  68. }
  69. .uni-add-tips-content {
  70. border-width: 0upx;
  71. margin-top: 20upx;
  72. position: relative;
  73. background-color: $themeColor;
  74. box-shadow: 0 10upx 20upx -10upx $themeColor;
  75. border-radius: 12upx;
  76. display: flex;
  77. align-items: center;
  78. justify-content: center;
  79. padding: 18upx 20upx;
  80. margin-right: 40upx;
  81. }
  82. .uni-add-tips-content > text {
  83. color: #fff;
  84. font-size: 28upx;
  85. font-weight: 400;
  86. }
  87. @keyframes opacityC{
  88. 0%{opacity: 0.8;}
  89. 50%{opacity: 1;}
  90. }
  91. </style>