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.

95 lines
1.8 KiB

6 months ago
  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. required:true
  29. },
  30. duration:{
  31. type:Number,
  32. default:5,
  33. required:false
  34. }
  35. },
  36. methods:{
  37. hideTip(){
  38. uni.setStorageSync(SHOW_TIP,true)
  39. this.showTip = false
  40. }
  41. }
  42. }
  43. </script>
  44. <style lang="scss" scoped>
  45. $themeColor:#34b5e2; //主题色
  46. .uni-add-tips-box {
  47. position: fixed;
  48. top:0;
  49. right: 0;
  50. z-index: 99999;
  51. opacity: 0.8;
  52. display: flex;
  53. justify-content: flex-end;
  54. align-items: flex-end;
  55. flex-direction: column;
  56. width: 600upx;
  57. animation: opacityC 1s linear infinite;
  58. }
  59. .uni-add-tips-content::before{
  60. content: "";
  61. position: absolute;
  62. width: 0;
  63. height: 0;
  64. top:-38upx;
  65. right:105upx;
  66. border-width: 20upx;
  67. border-style: solid;
  68. display: block;
  69. border-color: transparent transparent $themeColor transparent;
  70. }
  71. .uni-add-tips-content {
  72. border-width: 0upx;
  73. margin-top: 20upx;
  74. position: relative;
  75. background-color: $themeColor;
  76. box-shadow: 0 10upx 20upx -10upx $themeColor;
  77. border-radius: 12upx;
  78. display: flex;
  79. align-items: center;
  80. justify-content: center;
  81. padding: 18upx 20upx;
  82. margin-right: 40upx;
  83. }
  84. .uni-add-tips-content > text {
  85. color: #fff;
  86. font-size: 28upx;
  87. font-weight: 400;
  88. }
  89. @keyframes opacityC{
  90. 0%{opacity: 0.8;}
  91. 50%{opacity: 1;}
  92. }
  93. </style>