popAd.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <view>
  3. <!--components/popAd/popAd.wxml-->
  4. <template name="home_pop_up_ads">
  5. <block v-if="!first&&!iscouponAd&&!storeShow&&isAppLayerAd">
  6. <view class="layer" v-if="popAdTemplate&&popAdTemplate.state==0&&isLayerAd&&popAdList.pic">
  7. <image lazy-load="true" :src="popAdList.pic" mode="aspectFit" @tap="getUrl2" :data-type="popAdList.type" :data-content="popAdList.content"></image>
  8. <image class="close" src="/static/pages/images/ad_close_w.png" @tap="hideAd"></image>
  9. </view>
  10. </block>
  11. </template>
  12. </view>
  13. </template>
  14. <script>
  15. const req = require("../../utils/request");
  16. const utils = require("../../utils/util");
  17. const app = getApp();
  18. export default {
  19. data() {
  20. return {
  21. isAppLayerAd:app.globalData.isLayerAd
  22. };
  23. },
  24. components: {},
  25. props: {
  26. first:Boolean,
  27. popAdTemplate:Object,
  28. isLayerAd:Boolean,
  29. popAdList:Object,
  30. iscouponAd:Boolean,
  31. storeShow:Boolean
  32. },
  33. options: {
  34. addGlobalClass: true
  35. },
  36. // created(){
  37. // console.log(this.data.merchant)
  38. // req.getRequest('/api/merchant/getMerchantList',{}, res => {
  39. // res = res.filter(it=>it.isDefault==1)
  40. // this.setData({merchant:res[0]})
  41. // })
  42. // },
  43. mounted() {
  44. // console.log(this.iscouponAd,this.first,this.storeShow)
  45. },
  46. methods: {
  47. getUrl2(e) {
  48. console.log(e)
  49. var dt = e.currentTarget.dataset;
  50. var url = "";
  51. var id = "";
  52. var acid = "";
  53. if (dt.content != "") {
  54. let conunt = dt.content.split("_");
  55. id = conunt[1];
  56. acid = conunt[0];
  57. }
  58. if (dt.type * 1 == 2 && dt.content != "") {
  59. url = "product/detail/detail?id=" + dt.content;
  60. } else if (dt.type * 1 == 3) {
  61. url = dt.content;
  62. console.log('urlgetUrl2===',url)
  63. if(!url){
  64. req.msg('功能待接入')
  65. return false
  66. }
  67. if(url=='pages/index/index'||url=='pages/matchList/index'||url=='pages/interactive/index'||url=='pages/found/found'||url=='pages/user/user'){
  68. app.globalData.switchTab(url)
  69. return false
  70. }else{
  71. if(url.indexOf('http')!=-1){
  72. app.globalData.openPage('pages/web/web?url='+url);
  73. return false
  74. }
  75. }
  76. } else if (dt.type * 1 == 4) {
  77. url = "product/groupDetail/groupDetail?acid=" + acid + "&id=" + id;
  78. } else if (dt.type * 1 == 5) {
  79. url = "product/coupon/coupon";
  80. } else if (dt.type * 1 == 6) {
  81. url = "pages/live/live";
  82. } else if (dt.type * 1 == 7) {
  83. url = "product/groupList/groupList" + dt.merchant;
  84. } else if (dt.type * 1 == 9 && dt.content != "") {
  85. url = "product/list/list?id=" + dt.content + '&title=' + dt.title + this.web;
  86. } else if (dt.type * 1 == 10) {
  87. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + dt.content;
  88. // console.log(
  89. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  90. } else if (dt.type * 1 == 11) {
  91. url = "activity/group/index/index" + dt.merchant;
  92. } else if (dt.type * 1 == 12) {
  93. url = "activity/seckill/seckill" + dt.merchant;
  94. } else if (dt.type * 1 == 13) {
  95. url = "activity/bargain/index/index" + dt.merchant;
  96. } else if (dt.type * 1 == 14) {
  97. url = "activity/newbornZone/newbornZone" + dt.merchant;
  98. } else if (dt.type * 1 == 15 && dt.content != "") {
  99. url = "activity/newbornDetails/newbornDetails?acid=" + acid + "&id=" + id;
  100. } else if (dt.type * 1 == 16 && dt.content != "") {
  101. url = "activity/seckillDetails/seckillDetails?acid=" + acid + "&id=" + id;
  102. } else if (dt.type * 1 == 17 && dt.content != "") {
  103. url = "activity/bargain/detail/detail?acid=" + acid + "&id=" + id;
  104. } else if (dt.type * 1 == 18 && dt.content != "") {
  105. url = "activity/group/detail/detail?acid=" + acid + "&id=" + id;
  106. } else if (dt.type * 1 == 19 && dt.content != "") {//文章内容
  107. url = "topic/content/content?id=" + dt.content + "&type=" + 1;//1为普通文章内容
  108. } else if (dt.type * 1 == 21 && dt.content != "") {//专题类型
  109. url = "pages/topic/topic?id=" + dt.content;
  110. } else if (dt.type * 1 == 27 && dt.content != "") {
  111. url = "match/activityDetail/activityDetail?id=" + dt.content;
  112. } else{
  113. url = "";
  114. }
  115. if (dt.type * 1 == 6) app.globalData.switchTab(url);
  116. else app.globalData.openPage(url);
  117. this.hideAd();
  118. },
  119. hideAd() {
  120. //关闭广告
  121. // if(this.data.first==false){
  122. this.setData({
  123. isLayerAd: false
  124. }); // }
  125. },
  126. }
  127. };
  128. </script>
  129. <style>
  130. @import "./popAd.css";
  131. </style>