struggler-uniapp-add-tip.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <view>
  3. <!-- #ifdef MP-WEIXIN -->
  4. <view class="uni-add-tips-box" v-if="showTip">
  5. <view class="uni-add-tips-content" @tap="hideTip">
  6. <view class="clearfix" style="width: 100%;">
  7. 点击
  8. <image src="https://onlineimg.qianniao.vip/wxdot.jpg" class="wxdot" mode="aspectFill"></image>
  9. 添加到我的小程序,微信首页下拉即可快速访问
  10. <text class="ibonfont ibonguanbi close-icon" @click="hideTip"></text>
  11. </view>
  12. </view>
  13. </view>
  14. <!-- #endif -->
  15. </view>
  16. </template>
  17. <script>
  18. const SHOW_TIP = 'SHOW_TIP';
  19. export default {
  20. data() {
  21. return {
  22. showTip: false
  23. };
  24. },
  25. mounted() {
  26. this.showTip = !uni.getStorageInfoSync().keys.includes(SHOW_TIP);
  27. // setTimeout(()=>{
  28. // this.showTip = false
  29. // },this.duration*1000)
  30. },
  31. props: {
  32. tip: {
  33. type: String,
  34. default: '点击 ··· 添加到我到小程序,微信首页下拉即可快速访问'
  35. },
  36. duration: {
  37. type: Number,
  38. default: 10
  39. }
  40. },
  41. methods: {
  42. hideTip() {
  43. uni.setStorageSync(SHOW_TIP, true);
  44. this.showTip = false;
  45. }
  46. }
  47. };
  48. </script>
  49. <style lang="scss" scoped>
  50. .wxdot {
  51. width: 60upx;
  52. height: 30upx;
  53. // transform: translateY(-20upx);
  54. margin-right: 8upx;
  55. display: inline-block;
  56. }
  57. .close-icon {
  58. font-size: 32upx;
  59. position: absolute;
  60. top: 22upx;
  61. right: 12upx;
  62. }
  63. $themeColor: #ffffff; //主题色
  64. .uni-add-tips-box {
  65. position: fixed;
  66. top: 128upx;
  67. right: 0;
  68. z-index: 99999;
  69. opacity: 0.8;
  70. width: 600upx;
  71. animation: opacityC 1s linear infinite;
  72. }
  73. .uni-add-tips-content::before {
  74. content: '';
  75. position: absolute;
  76. width: 0;
  77. height: 0;
  78. top: -38upx;
  79. right: 80upx;
  80. border-width: 20upx;
  81. border-style: solid;
  82. display: block;
  83. border-color: transparent transparent $themeColor transparent;
  84. }
  85. .uni-add-tips-content {
  86. border-width: 0upx;
  87. margin-top: 20upx;
  88. position: relative;
  89. background-color: $themeColor;
  90. box-shadow: 0 10upx 20upx -10upx #ccc;
  91. border-radius: 12upx;
  92. padding: 18upx 26upx;
  93. margin-right: 40upx;
  94. color: #333;
  95. font-size: 28upx;
  96. font-weight: 400;
  97. }
  98. @keyframes opacityC {
  99. 0% {
  100. opacity: 0.8;
  101. }
  102. 50% {
  103. opacity: 1;
  104. }
  105. }
  106. </style>