myAd.vue 779 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <template>
  2. <view>
  3. <view v-if="id != ''" style="width:100%">
  4. <ad :unit-id="id" :ad-type="ad_type" ad-theme="white" grid-count="5"></ad>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. import {
  10. mapState
  11. } from 'vuex';
  12. export default {
  13. name: "myAd",
  14. props: {
  15. type: {
  16. type: String,
  17. default: ''
  18. }
  19. },
  20. data(){
  21. return {
  22. list:[],
  23. id:'',
  24. ad_type:'banner'
  25. }
  26. },
  27. mounted() {
  28. this.getAd();
  29. },
  30. methods:{
  31. async getAd(){
  32. let res = await this.$myHttp.post({
  33. url:this.$myHttp.urlMap.getAd,
  34. data:{},
  35. needLogin:false,
  36. })
  37. if(res.code == 1){
  38. this.list = res.data
  39. this.id = this.list[this.type-1].advert
  40. this.ad_type = this.list[this.type-1].advert_type
  41. }
  42. },
  43. }
  44. }
  45. </script>
  46. <style>
  47. </style>