金诚优选前端代码
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.6 KiB

  1. <template>
  2. <view class="content">
  3. <block v-if="$isRight(full)">
  4. <image class="img" :src="full.image" mode="widthFix" @click="clickAd"></image>
  5. <view class="tips" @click="next">跳过 {{ num }}s</view>
  6. </block>
  7. </view>
  8. </template>
  9. <script>
  10. export default {
  11. data(){
  12. return {
  13. num: 5,
  14. timer: null,
  15. full: {}
  16. }
  17. },
  18. onLoad(){
  19. this.getAd();
  20. },
  21. onUnload(){
  22. if(this.timer){
  23. clearInterval(this.timer);
  24. this.timer = null;
  25. }
  26. },
  27. methods: {
  28. getAd(){
  29. this.$http.get({
  30. api: '/api/ad'
  31. }).then(res => {
  32. this.full = res.data.data.full;
  33. if(this.$isRight(res.data.data.full)){
  34. this.startTime();
  35. }else{
  36. this.next();
  37. }
  38. }).catch(rej => {
  39. this.next();
  40. })
  41. },
  42. startTime(){
  43. this.timer = setInterval(() => {
  44. this.num--;
  45. if(this.num <= 0){
  46. clearInterval(this.timer);
  47. this.timer = null;
  48. this.next();
  49. }
  50. }, 1000);
  51. },
  52. next(){
  53. this.$url('/pages/index/index/index', {type: 'redirect'});
  54. },
  55. clickAd(){
  56. this.$url(this.full.url, {type: 'redirect'});
  57. }
  58. }
  59. }
  60. </script>
  61. <style>
  62. page{
  63. overflow: hidden;
  64. }
  65. </style>
  66. <style lang="scss" scoped="scoped">
  67. .content{
  68. position: relative;
  69. width: 100vw;
  70. height: 100vh;
  71. .img{
  72. width: 100%;
  73. height: 100%;
  74. position: absolute;
  75. z-index: 9;
  76. }
  77. .tips{
  78. position: absolute;
  79. right: 32rpx;
  80. top: 132rpx;
  81. width: 144rpx;
  82. height: 55rpx;
  83. background-color: rgba(0,0,0,0.5);
  84. color: #FFFFFF;
  85. font-size: 26rpx;
  86. display: flex;
  87. justify-content: center;
  88. align-items: center;
  89. border-radius: 28rpx;
  90. z-index: 999;
  91. }
  92. }
  93. </style>