king_kong_district.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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. :data-page="el.pageUrl"
  60. :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'" v-else>
  61. <image lazy-load="true" :src="el.picUrl"></image>{{el.bannerTitle}}
  62. </view>
  63. </block>
  64. <!-- #endif -->
  65. </block>
  66. </swiper-item>
  67. </block>
  68. </swiper>
  69. <view class="dots1 dflex" v-if="districtTemplate.content.selectDataKingLength.length>1">
  70. <!-- #ifdef H5 -->
  71. <block v-for="(item, index) in districtTemplate.content.selectDataKingLength"
  72. :key="'item_'+index">
  73. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  74. :data-current="index" @tap="dotGrid"></view>
  75. </block>
  76. <!-- #endif -->
  77. <!-- #ifndef H5 -->
  78. <block v-for="(item, index) in districtTemplate.content.selectDataKingLength" :key="index">
  79. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  80. :data-current="index" @tap="dotGrid"></view>
  81. </block>
  82. <!-- #endif -->
  83. </view>
  84. </view>
  85. </block>
  86. </view>
  87. <!-- <coupons :couponList="couponList" v-if="couponList.length>0"></coupons> -->
  88. </template>
  89. </view>
  90. </template>
  91. <script>
  92. // components/banner/banner.js
  93. // 走马灯,广告
  94. const app = getApp();
  95. const req = require("../../utils/request.js");
  96. const api = require("../../utils/api.js");
  97. const route = require("../../utils/route.js");
  98. import coupons from '../../template/coupons/index.vue';
  99. export default {
  100. data() {
  101. return {
  102. swiperGridcurrent: 0,
  103. swiperHeight: String
  104. };
  105. },
  106. components: {
  107. coupons
  108. },
  109. props: {
  110. web: String, //跳转地址
  111. url: String, //跳转地址
  112. districtTemplate: Object ,//金刚区模板配置
  113. couponList: Array,//优惠券
  114. },
  115. mounted() {
  116. // console.log(this.districtTemplate, this.districtTemplate.content.selectDataKingLength.length, this.web, this
  117. // .url)
  118. this.getSwiperHeight();
  119. },
  120. watch: {
  121. },
  122. beforeMount() {},
  123. methods: {
  124. async getUrl2(e) {
  125. var dt = e.currentTarget.dataset;
  126. var url = "";
  127. var id = "";
  128. var acid = "";
  129. if (dt.content != "") {
  130. let conunt = dt.content.split("_");
  131. id = conunt[1];
  132. acid = conunt[0];
  133. }
  134. if (dt.type * 1 == 2 && dt.content != "") {
  135. url = "product/detail/detail?id=" + dt.content;
  136. } else if (dt.type * 1 == 3) {
  137. url = dt.content;
  138. console.log('urlgetUrl2===',url)
  139. if(!url){
  140. req.msg('功能待接入')
  141. return false
  142. }
  143. if(url=='pages/index/index'||url=='pages/matchList/index'||url=='pages/interactive/index'||url=='pages/found/found'||url=='pages/user/user'){
  144. app.globalData.switchTab(url)
  145. return false
  146. }else{
  147. if(url.indexOf('http')!=-1){
  148. if(url.indexOf('${salesno}')!=-1){
  149. // 如果打开的分享的销售员微页
  150. if(req.getStorage('shareId')){
  151. url = url.replace(/\${salesno}/g,'salesno='+req.getStorage('shareId'))
  152. }else{
  153. // 如果自己是销售员
  154. if(req.getStorage('userInfo').saleNo){
  155. url = url.replace(/\${salesno}/g,'salesno='+req.getStorage('userInfo').saleNo)
  156. }else{
  157. //当前绑定的微页或推荐的微页
  158. let salesno = await new Promise((r,j)=>{
  159. req.getLocation(res => {
  160. const to = {
  161. latitude: res.latitude,
  162. longitude: res.longitude
  163. };
  164. req.getRequest('/api/visiting/card/recommendCardInfo', to, res => {
  165. r(res.jobNumber?res.jobNumber:'')
  166. })
  167. });
  168. })
  169. url = url.replace(/\${salesno}/g,'salesno='+salesno)
  170. }
  171. }
  172. }
  173. app.globalData.openPage('pages/web/web?url='+encodeURIComponent(url));
  174. return false
  175. }
  176. }
  177. } else if (dt.type * 1 == 4) {
  178. url = "product/groupDetail/groupDetail?acid=" + acid + "&id=" + id;
  179. } else if (dt.type * 1 == 5) {
  180. url = "product/coupon/coupon";
  181. } else if (dt.type * 1 == 6) {
  182. url = "pages/live/live";
  183. } else if (dt.type * 1 == 7) {
  184. url = "product/groupList/groupList" + dt.merchant;
  185. } else if (dt.type * 1 == 9 && dt.content != "") {
  186. url = "product/list/list?id=" + dt.content + '&title=' + dt.title + this.web;
  187. } else if (dt.type * 1 == 10) {
  188. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + dt.content;
  189. // console.log(
  190. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  191. } else if (dt.type * 1 == 11) {
  192. url = "activity/group/index/index" + dt.merchant;
  193. } else if (dt.type * 1 == 12) {
  194. url = "activity/seckill/seckill" + dt.merchant;
  195. } else if (dt.type * 1 == 13) {
  196. url = "activity/bargain/index/index" + dt.merchant;
  197. } else if (dt.type * 1 == 14) {
  198. url = "activity/newbornZone/newbornZone" + dt.merchant;
  199. } else if (dt.type * 1 == 15 && dt.content != "") {
  200. url = "activity/newbornDetails/newbornDetails?acid=" + acid + "&id=" + id;
  201. } else if (dt.type * 1 == 16 && dt.content != "") {
  202. url = "activity/seckillDetails/seckillDetails?acid=" + acid + "&id=" + id;
  203. } else if (dt.type * 1 == 17 && dt.content != "") {
  204. url = "activity/bargain/detail/detail?acid=" + acid + "&id=" + id;
  205. } else if (dt.type * 1 == 18 && dt.content != "") {
  206. url = "activity/group/detail/detail?acid=" + acid + "&id=" + id;
  207. } else if (dt.type * 1 == 19 && dt.content != "") {//文章内容
  208. url = "topic/content/content?id=" + dt.content + "&type=" + 1;//1为普通文章内容
  209. } else if (dt.type * 1 == 21 && dt.content != "") {//专题类型
  210. url = "pages/topic/topic?id=" + dt.content;
  211. } else if (dt.type * 1 == 27 && dt.content != "") {
  212. url = "match/activityDetail/activityDetail?id=" + dt.content;
  213. } else if (dt.type * 1 == 1 && dt.content != "") {
  214. console.log('dt.content',dt.content,dt.page)
  215. uni.navigateToMiniProgram({
  216. appId: dt.content, // 目标小程序appid
  217. path: dt.page?dt.page:'', // 目标路径,例如‘pages/billManage/index’
  218. extraData: {}, // 跳转传参,例如'orderNo': 'xxx......'
  219. success(res) {
  220. uni.showToast({
  221. title: '跳转成功'
  222. })
  223. }
  224. })
  225. } else{
  226. url = "";
  227. }
  228. if (dt.type * 1 == 6) app.globalData.switchTab(url);
  229. else app.globalData.openPage(url);
  230. this.hideAd();
  231. },
  232. hideAd() {
  233. //关闭广告
  234. // if(this.data.first==false){
  235. this.setData({
  236. isLayerAd: false
  237. }); // }
  238. },
  239. swiperGridFun({
  240. detail
  241. }) {
  242. let that = this
  243. if (detail.source !== "touch") return;
  244. if (that.districtTemplate.content.lines == 2) {
  245. if (that.districtTemplate.lineNumber == 3) {
  246. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  247. Infinity).length <= 3) {
  248. that.setData({
  249. swiperHeight: '120px'
  250. })
  251. } else {
  252. that.setData({
  253. swiperHeight: '432rpx'
  254. })
  255. }
  256. }
  257. // console.log(that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  258. // Infinity).filter(it => it.bannerType != ''))
  259. if (that.districtTemplate.lineNumber == 4) {
  260. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  261. Infinity).filter(it => it.bannerType != '').length <= 4) {
  262. that.setData({
  263. swiperHeight: '100px'
  264. })
  265. } else {
  266. that.setData({
  267. swiperHeight: '200px'
  268. })
  269. }
  270. }
  271. }
  272. this.setData({
  273. swiperGridcurrent: detail.current
  274. });
  275. // console.log('swiperHeight', this.swiperHeight);
  276. },
  277. getSwiperHeight(){
  278. let that = this;
  279. console.log('that.districtTemplate.content.lines==',that.districtTemplate.content.lines)
  280. if (that.districtTemplate.content.lines == 1) {
  281. that.swiperHeight = '150rpx'
  282. if (that.districtTemplate.lineNumber == 3) {
  283. that.swiperHeight = '200rpx'
  284. }
  285. if (that.districtTemplate.lineNumber == 4) {
  286. that.swiperHeight = '150rpx'
  287. }
  288. if (that.districtTemplate.lineNumber == 5) {
  289. that.swiperHeight = '130rpx'
  290. }
  291. }
  292. if (that.districtTemplate.content.lines == 2) {
  293. if (that.districtTemplate.lineNumber == 3) {
  294. that.setData({
  295. swiperHeight: '432rpx'
  296. })
  297. }
  298. if (that.districtTemplate.lineNumber == 4) {
  299. that.setData({
  300. swiperHeight: '380rpx'
  301. })
  302. }
  303. if (that.districtTemplate.lineNumber == 5) {
  304. that.setData({
  305. swiperHeight: '320rpx'
  306. })
  307. }
  308. }
  309. this.$forceUpdate();
  310. },
  311. // 九宫格
  312. dotGrid(e) {
  313. let that = this
  314. if (that.districtTemplate.content.lines == 2) {
  315. if (that.districtTemplate.lineNumber == 3) {
  316. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  317. .current].flat(
  318. Infinity).length <= 3) {
  319. that.setData({
  320. swiperHeight: '120px'
  321. })
  322. } else {
  323. that.setData({
  324. swiperHeight: '432rpx'
  325. })
  326. }
  327. }
  328. if (that.districtTemplate.lineNumber == 4) {
  329. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  330. .current].flat(
  331. Infinity).filter(it => it.bannerType != '').length <= 4) {
  332. that.setData({
  333. swiperHeight: '100px'
  334. })
  335. } else {
  336. that.setData({
  337. swiperHeight: '200px'
  338. })
  339. }
  340. }
  341. }
  342. this.setData({
  343. swiperGridcurrent: e.currentTarget.dataset.current
  344. });
  345. },
  346. }
  347. };
  348. </script>
  349. <style>
  350. @import "./king_kong_district.css";
  351. </style>