popAd.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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-page="el.pageUrl" :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. async 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. if(url.indexOf('${salesno}')!=-1){
  73. // 如果打开的分享的销售员微页
  74. if(req.getStorage('shareId')){
  75. url = url.replace(/\${salesno}/g,'salesno='+req.getStorage('shareId'))
  76. }else{
  77. // 如果自己是销售员
  78. if(req.getStorage('userInfo').saleNo){
  79. url = url.replace(/\${salesno}/g,'salesno='+req.getStorage('userInfo').saleNo)
  80. }else{
  81. //当前绑定的微页或推荐的微页
  82. let salesno = await new Promise((r,j)=>{
  83. req.getLocation(res => {
  84. const to = {
  85. latitude: res.latitude,
  86. longitude: res.longitude
  87. };
  88. req.getRequest('/api/visiting/card/recommendCardInfo', to, res => {
  89. r(res.jobNumber?res.jobNumber:'')
  90. })
  91. });
  92. })
  93. url = url.replace(/\${salesno}/g,'salesno='+salesno)
  94. }
  95. }
  96. }
  97. app.globalData.openPage('pages/web/web?url='+encodeURIComponent(url));
  98. return false
  99. }
  100. }
  101. } else if (dt.type * 1 == 4) {
  102. url = "product/groupDetail/groupDetail?acid=" + acid + "&id=" + id;
  103. } else if (dt.type * 1 == 5) {
  104. url = "product/coupon/coupon";
  105. } else if (dt.type * 1 == 6) {
  106. url = "pages/live/live";
  107. } else if (dt.type * 1 == 7) {
  108. url = "product/groupList/groupList" + dt.merchant;
  109. } else if (dt.type * 1 == 9 && dt.content != "") {
  110. url = "product/list/list?id=" + dt.content + '&title=' + dt.title + this.web;
  111. } else if (dt.type * 1 == 10) {
  112. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + dt.content;
  113. // console.log(
  114. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  115. } else if (dt.type * 1 == 11) {
  116. url = "activity/group/index/index" + dt.merchant;
  117. } else if (dt.type * 1 == 12) {
  118. url = "activity/seckill/seckill" + dt.merchant;
  119. } else if (dt.type * 1 == 13) {
  120. url = "activity/bargain/index/index" + dt.merchant;
  121. } else if (dt.type * 1 == 14) {
  122. url = "activity/newbornZone/newbornZone" + dt.merchant;
  123. } else if (dt.type * 1 == 15 && dt.content != "") {
  124. url = "activity/newbornDetails/newbornDetails?acid=" + acid + "&id=" + id;
  125. } else if (dt.type * 1 == 16 && dt.content != "") {
  126. url = "activity/seckillDetails/seckillDetails?acid=" + acid + "&id=" + id;
  127. } else if (dt.type * 1 == 17 && dt.content != "") {
  128. url = "activity/bargain/detail/detail?acid=" + acid + "&id=" + id;
  129. } else if (dt.type * 1 == 18 && dt.content != "") {
  130. url = "activity/group/detail/detail?acid=" + acid + "&id=" + id;
  131. } else if (dt.type * 1 == 19 && dt.content != "") {//文章内容
  132. url = "topic/content/content?id=" + dt.content + "&type=" + 1;//1为普通文章内容
  133. } else if (dt.type * 1 == 21 && dt.content != "") {//专题类型
  134. url = "pages/topic/topic?id=" + dt.content;
  135. } else if (dt.type * 1 == 27 && dt.content != "") {
  136. url = "match/activityDetail/activityDetail?id=" + dt.content;
  137. } else if (dt.type * 1 == 1 && dt.content != "") {
  138. console.log('dt.content',dt.content)
  139. uni.navigateToMiniProgram({
  140. appId: dt.content, // 目标小程序appid
  141. path: dt.page?dt.page:'', // 目标路径,例如‘pages/billManage/index’
  142. extraData: {}, // 跳转传参,例如'orderNo': 'xxx......'
  143. success(res) {
  144. uni.showToast({
  145. title: '跳转成功'
  146. })
  147. }
  148. })
  149. } else{
  150. url = "";
  151. }
  152. if (dt.type * 1 == 6) app.globalData.switchTab(url);
  153. else app.globalData.openPage(url);
  154. this.hideAd();
  155. },
  156. hideAd() {
  157. //关闭广告
  158. // if(this.data.first==false){
  159. this.setData({
  160. isLayerAd: false
  161. }); // }
  162. },
  163. }
  164. };
  165. </script>
  166. <style>
  167. @import "./popAd.css";
  168. </style>