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

99 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.num = Number(res.data.data.full.duration) || 5;
  37. this.startTime();
  38. }else{
  39. this.next();
  40. }
  41. }).catch(rej => {
  42. this.next();
  43. })
  44. },
  45. startTime(){
  46. this.timer = setInterval(() => {
  47. this.num--;
  48. if(this.num <= 0){
  49. clearInterval(this.timer);
  50. this.timer = null;
  51. this.next();
  52. }
  53. }, 1000);
  54. },
  55. next(){
  56. this.$url('/pages/index/index/index', {type: 'redirect'});
  57. },
  58. clickAd(){
  59. this.$url(this.full.url, {type: 'redirect'});
  60. }
  61. }
  62. }
  63. </script>
  64. <style>
  65. page{
  66. overflow: hidden;
  67. }
  68. </style>
  69. <style lang="scss" scoped="scoped">
  70. .content{
  71. position: relative;
  72. width: 100vw;
  73. height: 100vh;
  74. .img{
  75. width: 100%;
  76. height: 100%;
  77. position: absolute;
  78. z-index: 9;
  79. }
  80. .tips{
  81. position: absolute;
  82. right: 32rpx;
  83. // top: 132rpx;
  84. // top: 10vh;
  85. width: 144rpx;
  86. height: 55rpx;
  87. background-color: rgba(0,0,0,0.5);
  88. color: #FFFFFF;
  89. font-size: 26rpx;
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. border-radius: 28rpx;
  94. z-index: 999;
  95. }
  96. }
  97. </style>