guide.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="content">
  3. <view v-if="guideShow">
  4. <u-image :src="img" :height="guideHeight"></u-image>
  5. <u-button :custom-style="customStyle" shape="circle" class="jump-over" @click="handleGo" size="mini">跳过 {{countdown}}</u-button>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data() {
  12. return {
  13. customStyle:{
  14. color:"#ffffff",
  15. backgroundColor: 'rgba(0, 0, 0,0.4)'
  16. },
  17. guideShow:true,
  18. guideHeight:0,
  19. img:'https://szsq.nxzhsq.cn/community/miniofile/app/guide.png',
  20. countdown:3,
  21. timeout:null,
  22. timer:null,
  23. }
  24. },
  25. onLoad() {
  26. this.getImg()
  27. this.guideHeight = uni.getSystemInfoSync().windowHeight * ( 750 / uni.getSystemInfoSync().windowWidth);
  28. this.init();
  29. },
  30. methods: {
  31. getImg(){
  32. if(!this.$isEmpty(uni.getStorageSync("guideImg"))){
  33. this.img=uni.getStorageSync("guideImg")
  34. }
  35. },
  36. /**
  37. * 下载图片
  38. */
  39. downloadFile(){
  40. let that=this
  41. uni.downloadFile({
  42. url: 'http://139.9.103.171:1888/img/image/guide.png', //仅为示例,并非真实的资源
  43. success: (res) => {
  44. uni.saveFile({
  45. tempFilePath: res.tempFilePath,
  46. success: function (res) {
  47. var savedFilePath = res.savedFilePath;
  48. that.img=savedFilePath
  49. uni.setStorage({
  50. key:"guideImg",
  51. data:savedFilePath
  52. })
  53. }
  54. });
  55. }
  56. });
  57. },
  58. init() {
  59. this.timeout = setTimeout(function () {
  60. this.guideShow = false;
  61. uni.reLaunch({
  62. url:"/pages/index/index?isFlush=true"
  63. })
  64. },3500)
  65. this.timer = setInterval(() =>{
  66. this.countdown--;
  67. if(this.countdown === 0) {
  68. clearInterval(this.timer);
  69. }
  70. }, 1000);
  71. },
  72. handleGo(){
  73. clearInterval(this.timer);
  74. clearTimeout(this.timeout);
  75. uni.showLoading({
  76. title: '加载中'
  77. });
  78. setTimeout(function () {
  79. uni.hideLoading();
  80. this.guideShow=false
  81. uni.reLaunch({
  82. url:"/pages/index/index?isFlush=true"
  83. })
  84. }, 500);
  85. },
  86. }
  87. }
  88. </script>
  89. <style>
  90. page,
  91. .content{
  92. width: 100%;
  93. height: 100%;
  94. background-size: 100% auto ;
  95. padding: 0;
  96. }
  97. .jump-over{
  98. position: absolute;
  99. right: 30rpx;
  100. bottom: 200rpx;
  101. z-index: 999;
  102. }
  103. </style>