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

98 lines
1.8 KiB

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