king_kong_district.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view>
  3. <!--components/banner/banner.wxml-->
  4. <!-- 顶部banner -->
  5. <template name="ad">
  6. <view class="bgfff pdlr20 sat">
  7. <block v-if="!districtTemplate">
  8. <view class="nav dflex" v-if="categoryList.length>0">
  9. <swiper :class="districtTemplate.content.lines==1&&districtTemplate.lineNumber==3?'swiper2':districtTemplate.content.lines==2&&districtTemplate.lineNumber==3?'swiper3':districtTemplate.content.lines==1&&districtTemplate.lineNumber==4?'swiper4':districtTemplate.content.lines==1&&districtTemplate.lineNumber==5?'swiper5':'swiper1'" :style="'height:' + swiperHeight" @change="swiperGridFun"
  10. :current="swiperGridcurrent">
  11. <block v-for="(item, index) in categoryList" :key="index">
  12. <swiper-item autoplay="true" class="dflex grid">
  13. <block v-for="(it, idx) in item" :key="idx">
  14. <navigator :url="'/product/list/list?id=' + it.id + '&title=' + it.title + web"
  15. hover-class="none" :class="districtTemplate.lineNumber == 3 ? 'li3' : districtTemplate.lineNumber == 5 ? 'li5' : 'li'">
  16. <image lazy-load="true" :src="it.icon"></image>{{it.title}}
  17. </navigator>
  18. </block>
  19. </swiper-item>
  20. </block>
  21. </swiper>
  22. <view class="dots1 dflex">
  23. <block v-for="(item, index) in categoryList" :key="index">
  24. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  25. :data-current="index" @tap="dotGrid"></view>
  26. </block>
  27. </view>
  28. </view>
  29. </block>
  30. <block v-else>
  31. <view class="nav dflex" v-if="districtTemplate.content.selectDataKingLength.length>0">
  32. <swiper
  33. :class="districtTemplate.content.lines==1&&districtTemplate.lineNumber==3?'swiper2':districtTemplate.content.lines==2&&districtTemplate.lineNumber==3?'swiper3':districtTemplate.content.lines==1&&districtTemplate.lineNumber==4?'swiper4':districtTemplate.content.lines==1&&districtTemplate.lineNumber==5?'swiper5':'swiper1'"
  34. :style="'height:'+swiperHeight" @change="swiperGridFun" :current="swiperGridcurrent">
  35. <block v-for="(item, ine) in districtTemplate.content.selectDataKingLength" :key="ine">
  36. <swiper-item autoplay="true" class="dflex grid">
  37. <block v-for="(it, idx) in item" :key="idx">
  38. <!-- #ifdef H5 -->
  39. <block v-for="(el, ids) in it" :key="idx+'_'+ids" v-if="el.bannerType!=''">
  40. <view :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'" v-if="el.bannerType == 8">
  41. <contact-button :img-url="el.picUrl" :button-text="el.bannerTitle"></contact-button>
  42. </view>
  43. <view @tap="getUrl2" :data-type="el.bannerType"
  44. :data-content="el.bannerContent" :data-merchant="url" :data-web="web"
  45. :data-title="el.bannerContentName"
  46. :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'" v-else>
  47. <image lazy-load="true" :src="el.picUrl"></image>{{el.bannerTitle}}
  48. </view>
  49. </block>
  50. <!-- #endif -->
  51. <!-- #ifndef H5 -->
  52. <block v-for="(el, ids) in it" :key="ids" v-if="el.bannerType!=''">
  53. <view :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'" v-if="el.bannerType == 8">
  54. <contact-button :img-url="el.picUrl" :button-text="el.bannerTitle"></contact-button>
  55. </view>
  56. <view @tap="getUrl2" :data-type="el.bannerType"
  57. :data-content="el.bannerContent" :data-merchant="url" :data-web="web"
  58. :data-title="el.bannerContentName"
  59. :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'" v-else>
  60. <image lazy-load="true" :src="el.picUrl"></image>{{el.bannerTitle}}
  61. </view>
  62. </block>
  63. <!-- #endif -->
  64. </block>
  65. </swiper-item>
  66. </block>
  67. </swiper>
  68. <view class="dots1 dflex" v-if="districtTemplate.content.selectDataKingLength.length>1">
  69. <!-- #ifdef H5 -->
  70. <block v-for="(item, index) in districtTemplate.content.selectDataKingLength"
  71. :key="'item_'+index">
  72. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  73. :data-current="index" @tap="dotGrid"></view>
  74. </block>
  75. <!-- #endif -->
  76. <!-- #ifndef H5 -->
  77. <block v-for="(item, index) in districtTemplate.content.selectDataKingLength" :key="index">
  78. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  79. :data-current="index" @tap="dotGrid"></view>
  80. </block>
  81. <!-- #endif -->
  82. </view>
  83. </view>
  84. </block>
  85. </view>
  86. <!-- <coupons :couponList="couponList" v-if="couponList.length>0"></coupons> -->
  87. </template>
  88. </view>
  89. </template>
  90. <script>
  91. // components/banner/banner.js
  92. // 走马灯,广告
  93. const app = getApp();
  94. const req = require("../../utils/request.js");
  95. const api = require("../../utils/api.js");
  96. const route = require("../../utils/route.js");
  97. import coupons from '../../template/coupons/index.vue';
  98. export default {
  99. data() {
  100. return {
  101. swiperGridcurrent: 0,
  102. swiperHeight: String
  103. };
  104. },
  105. components: {
  106. coupons
  107. },
  108. props: {
  109. web: String, //跳转地址
  110. url: String, //跳转地址
  111. districtTemplate: Object ,//金刚区模板配置
  112. couponList: Array,//优惠券
  113. },
  114. mounted() {
  115. // console.log(this.districtTemplate, this.districtTemplate.content.selectDataKingLength.length, this.web, this
  116. // .url)
  117. this.getSwiperHeight();
  118. },
  119. watch: {
  120. },
  121. beforeMount() {},
  122. methods: {
  123. getUrl2(e) {
  124. var dt = e.currentTarget.dataset;
  125. var url = "";
  126. var id = "";
  127. var acid = "";
  128. if (dt.content != "") {
  129. let conunt = dt.content.split("_");
  130. id = conunt[1];
  131. acid = conunt[0];
  132. }
  133. if (dt.type * 1 == 2 && dt.content != "") {
  134. url = "product/detail/detail?id=" + dt.content;
  135. } else if (dt.type * 1 == 3) {
  136. url = dt.content;
  137. console.log('urlgetUrl2===',url)
  138. if(!url){
  139. req.msg('功能待接入')
  140. return false
  141. }
  142. if(url=='pages/index/index'||url=='pages/matchList/index'||url=='pages/interactive/index'||url=='pages/found/found'||url=='pages/user/user'){
  143. app.globalData.switchTab(url)
  144. return false
  145. }else{
  146. if(url.indexOf('http')!=-1){
  147. app.globalData.openPage('pages/web/web?url='+url);
  148. return false
  149. }
  150. }
  151. } else if (dt.type * 1 == 4) {
  152. url = "product/groupDetail/groupDetail?acid=" + acid + "&id=" + id;
  153. } else if (dt.type * 1 == 5) {
  154. url = "product/coupon/coupon";
  155. } else if (dt.type * 1 == 6) {
  156. url = "pages/live/live";
  157. } else if (dt.type * 1 == 7) {
  158. url = "product/groupList/groupList" + dt.merchant;
  159. } else if (dt.type * 1 == 9 && dt.content != "") {
  160. url = "product/list/list?id=" + dt.content + '&title=' + dt.title + this.web;
  161. } else if (dt.type * 1 == 10) {
  162. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + dt.content;
  163. // console.log(
  164. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  165. } else if (dt.type * 1 == 11) {
  166. url = "activity/group/index/index" + dt.merchant;
  167. } else if (dt.type * 1 == 12) {
  168. url = "activity/seckill/seckill" + dt.merchant;
  169. } else if (dt.type * 1 == 13) {
  170. url = "activity/bargain/index/index" + dt.merchant;
  171. } else if (dt.type * 1 == 14) {
  172. url = "activity/newbornZone/newbornZone" + dt.merchant;
  173. } else if (dt.type * 1 == 15 && dt.content != "") {
  174. url = "activity/newbornDetails/newbornDetails?acid=" + acid + "&id=" + id;
  175. } else if (dt.type * 1 == 16 && dt.content != "") {
  176. url = "activity/seckillDetails/seckillDetails?acid=" + acid + "&id=" + id;
  177. } else if (dt.type * 1 == 17 && dt.content != "") {
  178. url = "activity/bargain/detail/detail?acid=" + acid + "&id=" + id;
  179. } else if (dt.type * 1 == 18 && dt.content != "") {
  180. url = "activity/group/detail/detail?acid=" + acid + "&id=" + id;
  181. } else if (dt.type * 1 == 19 && dt.content != "") {//文章内容
  182. url = "topic/content/content?id=" + dt.content + "&type=" + 1;//1为普通文章内容
  183. } else if (dt.type * 1 == 21 && dt.content != "") {//专题类型
  184. url = "pages/topic/topic?id=" + dt.content;
  185. } else if (dt.type * 1 == 27 && dt.content != "") {
  186. url = "match/activityDetail/activityDetail?id=" + dt.content;
  187. } else{
  188. url = "";
  189. }
  190. if (dt.type * 1 == 6) app.globalData.switchTab(url);
  191. else app.globalData.openPage(url);
  192. this.hideAd();
  193. },
  194. hideAd() {
  195. //关闭广告
  196. // if(this.data.first==false){
  197. this.setData({
  198. isLayerAd: false
  199. }); // }
  200. },
  201. swiperGridFun({
  202. detail
  203. }) {
  204. let that = this
  205. if (detail.source !== "touch") return;
  206. if (that.districtTemplate.content.lines == 2) {
  207. if (that.districtTemplate.lineNumber == 3) {
  208. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  209. Infinity).length <= 3) {
  210. that.setData({
  211. swiperHeight: '120px'
  212. })
  213. } else {
  214. that.setData({
  215. swiperHeight: '432rpx'
  216. })
  217. }
  218. }
  219. // console.log(that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  220. // Infinity).filter(it => it.bannerType != ''))
  221. if (that.districtTemplate.lineNumber == 4) {
  222. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  223. Infinity).filter(it => it.bannerType != '').length <= 4) {
  224. that.setData({
  225. swiperHeight: '100px'
  226. })
  227. } else {
  228. that.setData({
  229. swiperHeight: '200px'
  230. })
  231. }
  232. }
  233. }
  234. this.setData({
  235. swiperGridcurrent: detail.current
  236. });
  237. // console.log('swiperHeight', this.swiperHeight);
  238. },
  239. getSwiperHeight(){
  240. let that = this;
  241. console.log('that.districtTemplate.content.lines==',that.districtTemplate.content.lines)
  242. if (that.districtTemplate.content.lines == 1) {
  243. that.swiperHeight = '150rpx'
  244. }
  245. if (that.districtTemplate.content.lines == 2) {
  246. if (that.districtTemplate.lineNumber == 3) {
  247. that.setData({
  248. swiperHeight: '432rpx'
  249. })
  250. }
  251. if (that.districtTemplate.lineNumber == 4) {
  252. that.setData({
  253. swiperHeight: '200px'
  254. })
  255. }
  256. }
  257. this.$forceUpdate();
  258. },
  259. // 九宫格
  260. dotGrid(e) {
  261. let that = this
  262. if (that.districtTemplate.content.lines == 2) {
  263. if (that.districtTemplate.lineNumber == 3) {
  264. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  265. .current].flat(
  266. Infinity).length <= 3) {
  267. that.setData({
  268. swiperHeight: '120px'
  269. })
  270. } else {
  271. that.setData({
  272. swiperHeight: '432rpx'
  273. })
  274. }
  275. }
  276. if (that.districtTemplate.lineNumber == 4) {
  277. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  278. .current].flat(
  279. Infinity).filter(it => it.bannerType != '').length <= 4) {
  280. that.setData({
  281. swiperHeight: '100px'
  282. })
  283. } else {
  284. that.setData({
  285. swiperHeight: '200px'
  286. })
  287. }
  288. }
  289. }
  290. this.setData({
  291. swiperGridcurrent: e.currentTarget.dataset.current
  292. });
  293. },
  294. }
  295. };
  296. </script>
  297. <style>
  298. @import "./king_kong_district.css";
  299. </style>