king_kong_district.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. async 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. if(url.indexOf('${salesno}')!=-1){
  148. // 如果打开的分享的销售员微页
  149. if(req.getStorage('shareId')){
  150. url = url.replace(/\${salesno}/g,'salesno='+req.getStorage('shareId'))
  151. }else{
  152. // 如果自己是销售员
  153. if(req.getStorage('userInfo').saleNo){
  154. url = url.replace(/\${salesno}/g,'salesno='+req.getStorage('userInfo').saleNo)
  155. }else{
  156. //当前绑定的微页或推荐的微页
  157. let salesno = await new Promise((r,j)=>{
  158. req.getLocation(res => {
  159. const to = {
  160. latitude: res.latitude,
  161. longitude: res.longitude
  162. };
  163. req.getRequest('/api/visiting/card/recommendCardInfo', to, res => {
  164. r(res.jobNumber?res.jobNumber:'')
  165. })
  166. });
  167. })
  168. url = url.replace(/\${salesno}/g,'salesno='+salesno)
  169. }
  170. }
  171. }
  172. app.globalData.openPage('pages/web/web?url='+encodeURIComponent(url));
  173. return false
  174. }
  175. }
  176. } else if (dt.type * 1 == 4) {
  177. url = "product/groupDetail/groupDetail?acid=" + acid + "&id=" + id;
  178. } else if (dt.type * 1 == 5) {
  179. url = "product/coupon/coupon";
  180. } else if (dt.type * 1 == 6) {
  181. url = "pages/live/live";
  182. } else if (dt.type * 1 == 7) {
  183. url = "product/groupList/groupList" + dt.merchant;
  184. } else if (dt.type * 1 == 9 && dt.content != "") {
  185. url = "product/list/list?id=" + dt.content + '&title=' + dt.title + this.web;
  186. } else if (dt.type * 1 == 10) {
  187. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + dt.content;
  188. // console.log(
  189. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  190. } else if (dt.type * 1 == 11) {
  191. url = "activity/group/index/index" + dt.merchant;
  192. } else if (dt.type * 1 == 12) {
  193. url = "activity/seckill/seckill" + dt.merchant;
  194. } else if (dt.type * 1 == 13) {
  195. url = "activity/bargain/index/index" + dt.merchant;
  196. } else if (dt.type * 1 == 14) {
  197. url = "activity/newbornZone/newbornZone" + dt.merchant;
  198. } else if (dt.type * 1 == 15 && dt.content != "") {
  199. url = "activity/newbornDetails/newbornDetails?acid=" + acid + "&id=" + id;
  200. } else if (dt.type * 1 == 16 && dt.content != "") {
  201. url = "activity/seckillDetails/seckillDetails?acid=" + acid + "&id=" + id;
  202. } else if (dt.type * 1 == 17 && dt.content != "") {
  203. url = "activity/bargain/detail/detail?acid=" + acid + "&id=" + id;
  204. } else if (dt.type * 1 == 18 && dt.content != "") {
  205. url = "activity/group/detail/detail?acid=" + acid + "&id=" + id;
  206. } else if (dt.type * 1 == 19 && dt.content != "") {//文章内容
  207. url = "topic/content/content?id=" + dt.content + "&type=" + 1;//1为普通文章内容
  208. } else if (dt.type * 1 == 21 && dt.content != "") {//专题类型
  209. url = "pages/topic/topic?id=" + dt.content;
  210. } else if (dt.type * 1 == 27 && dt.content != "") {
  211. url = "match/activityDetail/activityDetail?id=" + dt.content;
  212. } else{
  213. url = "";
  214. }
  215. if (dt.type * 1 == 6) app.globalData.switchTab(url);
  216. else app.globalData.openPage(url);
  217. this.hideAd();
  218. },
  219. hideAd() {
  220. //关闭广告
  221. // if(this.data.first==false){
  222. this.setData({
  223. isLayerAd: false
  224. }); // }
  225. },
  226. swiperGridFun({
  227. detail
  228. }) {
  229. let that = this
  230. if (detail.source !== "touch") return;
  231. if (that.districtTemplate.content.lines == 2) {
  232. if (that.districtTemplate.lineNumber == 3) {
  233. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  234. Infinity).length <= 3) {
  235. that.setData({
  236. swiperHeight: '120px'
  237. })
  238. } else {
  239. that.setData({
  240. swiperHeight: '432rpx'
  241. })
  242. }
  243. }
  244. // console.log(that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  245. // Infinity).filter(it => it.bannerType != ''))
  246. if (that.districtTemplate.lineNumber == 4) {
  247. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  248. Infinity).filter(it => it.bannerType != '').length <= 4) {
  249. that.setData({
  250. swiperHeight: '100px'
  251. })
  252. } else {
  253. that.setData({
  254. swiperHeight: '200px'
  255. })
  256. }
  257. }
  258. }
  259. this.setData({
  260. swiperGridcurrent: detail.current
  261. });
  262. // console.log('swiperHeight', this.swiperHeight);
  263. },
  264. getSwiperHeight(){
  265. let that = this;
  266. console.log('that.districtTemplate.content.lines==',that.districtTemplate.content.lines)
  267. if (that.districtTemplate.content.lines == 1) {
  268. that.swiperHeight = '150rpx'
  269. if (that.districtTemplate.lineNumber == 3) {
  270. that.swiperHeight = '200rpx'
  271. }
  272. if (that.districtTemplate.lineNumber == 4) {
  273. that.swiperHeight = '150rpx'
  274. }
  275. if (that.districtTemplate.lineNumber == 5) {
  276. that.swiperHeight = '130rpx'
  277. }
  278. }
  279. if (that.districtTemplate.content.lines == 2) {
  280. if (that.districtTemplate.lineNumber == 3) {
  281. that.setData({
  282. swiperHeight: '432rpx'
  283. })
  284. }
  285. if (that.districtTemplate.lineNumber == 4) {
  286. that.setData({
  287. swiperHeight: '380rpx'
  288. })
  289. }
  290. if (that.districtTemplate.lineNumber == 5) {
  291. that.setData({
  292. swiperHeight: '320rpx'
  293. })
  294. }
  295. }
  296. this.$forceUpdate();
  297. },
  298. // 九宫格
  299. dotGrid(e) {
  300. let that = this
  301. if (that.districtTemplate.content.lines == 2) {
  302. if (that.districtTemplate.lineNumber == 3) {
  303. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  304. .current].flat(
  305. Infinity).length <= 3) {
  306. that.setData({
  307. swiperHeight: '120px'
  308. })
  309. } else {
  310. that.setData({
  311. swiperHeight: '432rpx'
  312. })
  313. }
  314. }
  315. if (that.districtTemplate.lineNumber == 4) {
  316. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  317. .current].flat(
  318. Infinity).filter(it => it.bannerType != '').length <= 4) {
  319. that.setData({
  320. swiperHeight: '100px'
  321. })
  322. } else {
  323. that.setData({
  324. swiperHeight: '200px'
  325. })
  326. }
  327. }
  328. }
  329. this.setData({
  330. swiperGridcurrent: e.currentTarget.dataset.current
  331. });
  332. },
  333. }
  334. };
  335. </script>
  336. <style>
  337. @import "./king_kong_district.css";
  338. </style>