king_kong_district.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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
  10. :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'"
  11. @change="swiperGridFun" :current="swiperGridcurrent">
  12. <block v-for="(item, index) in categoryList" :key="index">
  13. <swiper-item autoplay="true" class="dflex grid">
  14. <block v-for="(it, idx) in item" :key="idx">
  15. <navigator :url="'/product/list/list?id=' + it.id + '&title=' + it.title + web"
  16. hover-class="none"
  17. :class="districtTemplate.lineNumber == 3 ? 'li3' : districtTemplate.lineNumber == 5 ? 'li5' : 'li'">
  18. <image lazy-load="true" :src="it.icon"></image>{{it.title}}
  19. </navigator>
  20. </block>
  21. </swiper-item>
  22. </block>
  23. </swiper>
  24. <view class="dots1 dflex">
  25. <block v-for="(item, index) in categoryList" :key="index">
  26. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  27. :data-current="index" @tap="dotGrid"></view>
  28. </block>
  29. </view>
  30. </view>
  31. </block>
  32. <block v-else>
  33. <view class="nav dflex" v-if="districtTemplate.content.selectDataKingLength.length>0">
  34. <swiper
  35. :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'"
  36. @change="swiperGridFun" :current="swiperGridcurrent">
  37. <block v-for="(item, ine) in districtTemplate.content.selectDataKingLength" :key="ine">
  38. <swiper-item autoplay="true" class="dflex grid">
  39. <block v-for="(it, idx) in item" :key="idx">
  40. <!-- #ifdef H5 -->
  41. <block v-for="(el, ids) in it" :key="idx+'_'+ids" v-if="el.bannerType!=''">
  42. <button open-type="contact" hover-class="none"
  43. :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'"
  44. v-if="el.bannerType == 8">
  45. <image lazy-load="true" :src="el.picUrl"></image>{{el.bannerTitle}}
  46. <view class="btn-tag">专属药师</view>
  47. </button>
  48. <view @tap="getUrl2" :data-type="el.bannerType"
  49. :data-content="el.bannerContent" :data-merchant="url" :data-web="web"
  50. :data-title="el.bannerContentName"
  51. :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'"
  52. v-else>
  53. <image lazy-load="true" :src="el.picUrl"></image>{{el.bannerTitle}}
  54. </view>
  55. </block>
  56. <!-- #endif -->
  57. <!-- #ifndef H5 -->
  58. <block v-for="(el, ids) in it" :key="ids" v-if="el.bannerType!=''">
  59. <button open-type="contact" hover-class="none"
  60. :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'"
  61. v-if="el.bannerType == 8">
  62. <image lazy-load="true" :src="el.picUrl"></image>{{el.bannerTitle}}
  63. <view class="btn-tag">专属药师</view>
  64. </button>
  65. <view @tap="getUrl2" :data-type="el.bannerType"
  66. :data-content="el.bannerContent" :data-merchant="url" :data-web="web"
  67. :data-title="el.bannerContentName"
  68. :class="districtTemplate.lineNumber==3?'li3':districtTemplate.lineNumber==5?'li5':'li'"
  69. v-else>
  70. <image lazy-load="true" :src="el.picUrl"></image>{{el.bannerTitle}}
  71. </view>
  72. </block>
  73. <!-- #endif -->
  74. </block>
  75. </swiper-item>
  76. </block>
  77. </swiper>
  78. <view class="dots1 dflex" v-if="districtTemplate.content.selectDataKingLength.length>1">
  79. <!-- #ifdef H5 -->
  80. <block v-for="(item, index) in districtTemplate.content.selectDataKingLength"
  81. :key="'item_'+index">
  82. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  83. :data-current="index" @tap="dotGrid"></view>
  84. </block>
  85. <!-- #endif -->
  86. <!-- #ifndef H5 -->
  87. <block v-for="(item, index) in districtTemplate.content.selectDataKingLength" :key="index">
  88. <view :class="'dot1 ' + (index == swiperGridcurrent ? ' active' : '')"
  89. :data-current="index" @tap="dotGrid"></view>
  90. </block>
  91. <!-- #endif -->
  92. </view>
  93. </view>
  94. </block>
  95. <view class="column ddflex" v-if="columnList&&columnList.length>0">
  96. <block v-for="(item,index) in columnList" :key="index">
  97. <button open-type="share" hover-class="none" class="li" v-if="item.content == '邀请'">
  98. <image :src="item.pic" mode="aspectFill"></image>
  99. </button>
  100. <view class="li" @click="jumpUrlColumn(item)" v-else>
  101. <image :src="item.pic" mode="aspectFill"></image>
  102. </view>
  103. </block>
  104. </view>
  105. <!-- 套餐 -->
  106. <view class="box" v-if="mergeList&&mergeList.length>0">
  107. <view class="b-titles ddflex">
  108. <view class="b-title">
  109. <text>活动套餐</text>
  110. </view>
  111. <navigator url="/product/merge/list" hover-class="none" class="more ddflex">更多<image
  112. src="../../static/pages/images/more.png"></image>
  113. </navigator>
  114. </view>
  115. <view class="product-list ddflex">
  116. <view class="li" v-for="(item,index) in mergeList" :key="index"
  117. @click="jumpUrl('/product/mergeDetail/detail?id=' + item.id)">
  118. <image :src="item.pic" mode="aspectFill" class="pro-img"></image>
  119. <view class="pro-info">
  120. <view class="pro-tit tovers">{{item.title}}</view>
  121. <view class="yishou">{{item.sellQuantity}}件已售</view>
  122. <view class="pro-sta ddflex">
  123. <view class="money"><text>¥</text>{{item.minSalePrice}}<text></text></view>
  124. <image src="/static/pages/images/jia.png" class="pro-cart"></image>
  125. </view>
  126. </view>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </template>
  132. </view>
  133. </template>
  134. <script>
  135. // components/banner/banner.js
  136. // 走马灯,广告
  137. const app = getApp();
  138. const req = require("../../utils/request.js");
  139. const api = require("../../utils/api.js");
  140. const route = require("../../utils/route.js");
  141. export default {
  142. data() {
  143. return {
  144. swiperGridcurrent: 0,
  145. swiperHeight: String,
  146. columnList: [],
  147. mergeList: [], //套餐
  148. };
  149. },
  150. components: {},
  151. props: {
  152. web: String, //跳转地址
  153. url: String, //跳转地址
  154. districtTemplate: Object //金刚区模板配置
  155. },
  156. mounted() {
  157. // console.log(this.districtTemplate, this.districtTemplate.content.selectDataKingLength.length, this.web, this
  158. // .url)
  159. this.getColumn();
  160. this.getMergeList();
  161. },
  162. watch: {
  163. },
  164. beforeMount() {},
  165. methods: {
  166. jumpUrlColumn(item) {
  167. app.globalData.clickBanner(item);
  168. },
  169. jumpUrl(url) {
  170. uni.navigateTo({
  171. url: url
  172. })
  173. },
  174. getColumn() {
  175. req.getRequest('/api/banner', {
  176. code: 'column'
  177. }, data => {
  178. this.columnList = data;
  179. })
  180. },
  181. // 套餐
  182. getMergeList() { //组合产品
  183. let form = {
  184. page: 1,
  185. limit: 3
  186. }
  187. req.getRequest('/api/v3/merge/list', form, data => {
  188. this.mergeList = data;
  189. })
  190. },
  191. getUrl2(e) {
  192. var dt = e.currentTarget.dataset;
  193. var url = "";
  194. var id = "";
  195. var acid = "";
  196. if (dt.content != "") {
  197. let conunt = dt.content.split("_");
  198. id = conunt[1];
  199. acid = conunt[0];
  200. }
  201. if (dt.type * 1 == 2 && dt.content != "") {
  202. url = "product/detail/detail?id=" + dt.content;
  203. } else if (dt.type * 1 == 3) {
  204. url = dt.content;
  205. console.log('url===', url)
  206. } else if (dt.type * 1 == 4) {
  207. url = "product/groupDetail/groupDetail?acid=" + acid + "&id=" + id;
  208. } else if (dt.type * 1 == 5) {
  209. url = "product/coupon/coupon";
  210. } else if (dt.type * 1 == 6) {
  211. url = "service/live/live";
  212. } else if (dt.type * 1 == 7) {
  213. url = "product/groupList/groupList" + dt.merchant;
  214. } else if (dt.type * 1 == 9 && dt.content != "") {
  215. url = "product/list/list?id=" + dt.content + '&title=' + dt.title + this.web;
  216. } else if (dt.type * 1 == 10) {
  217. url = "plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=" + dt.content;
  218. // console.log(
  219. // url); // url=`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${dt.content}`
  220. } else if (dt.type * 1 == 11) {
  221. url = "activity/group/index/index" + dt.merchant;
  222. } else if (dt.type * 1 == 12) {
  223. url = "activity/seckill/seckill" + dt.merchant;
  224. } else if (dt.type * 1 == 13) {
  225. url = "activity/bargain/index/index" + dt.merchant;
  226. } else if (dt.type * 1 == 14) {
  227. url = "activity/newbornZone/newbornZone" + dt.merchant;
  228. } else if (dt.type * 1 == 15 && dt.content != "") {
  229. url = "activity/newbornDetails/newbornDetails?acid=" + acid + "&id=" + id;
  230. } else if (dt.type * 1 == 16 && dt.content != "") {
  231. url = "activity/seckillDetails/seckillDetails?acid=" + acid + "&id=" + id;
  232. } else if (dt.type * 1 == 17 && dt.content != "") {
  233. url = "activity/bargain/detail/detail?acid=" + acid + "&id=" + id;
  234. } else if (dt.type * 1 == 18 && dt.content != "") {
  235. url = "activity/group/detail/detail?acid=" + acid + "&id=" + id;
  236. }
  237. if (url) {
  238. if (dt.type * 1 == 6) {
  239. app.globalData.switchTab(url);
  240. } else {
  241. app.globalData.openPage(url);
  242. }
  243. }
  244. this.hideAd();
  245. },
  246. hideAd() {
  247. //关闭广告
  248. // if(this.data.first==false){
  249. this.setData({
  250. isLayerAd: false
  251. }); // }
  252. },
  253. swiperGridFun({
  254. detail
  255. }) {
  256. let that = this
  257. if (detail.source !== "touch") return;
  258. if (that.districtTemplate.content.lines == 2) {
  259. if (that.districtTemplate.lineNumber == 3) {
  260. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  261. Infinity).length <= 3) {
  262. that.setData({
  263. swiperHeight: '120px'
  264. })
  265. } else {
  266. that.setData({
  267. swiperHeight: '432rpx'
  268. })
  269. }
  270. }
  271. // console.log(that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  272. // Infinity).filter(it => it.bannerType != ''))
  273. if (that.districtTemplate.lineNumber == 4) {
  274. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[detail.current].flat(
  275. Infinity).filter(it => it.bannerType != '').length <= 4) {
  276. that.setData({
  277. swiperHeight: '100px'
  278. })
  279. } else {
  280. that.setData({
  281. swiperHeight: '200px'
  282. })
  283. }
  284. }
  285. }
  286. this.setData({
  287. swiperGridcurrent: detail.current
  288. });
  289. // console.log('swiperHeight', this.swiperHeight);
  290. },
  291. // 九宫格
  292. dotGrid(e) {
  293. let that = this
  294. if (that.districtTemplate.content.lines == 2) {
  295. if (that.districtTemplate.lineNumber == 3) {
  296. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  297. .current].flat(
  298. Infinity).length <= 3) {
  299. that.setData({
  300. swiperHeight: '120px'
  301. })
  302. } else {
  303. that.setData({
  304. swiperHeight: '432rpx'
  305. })
  306. }
  307. }
  308. if (that.districtTemplate.lineNumber == 4) {
  309. if (that.swiperHeight, that.districtTemplate.content.selectDataKingLength[e.currentTarget.dataset
  310. .current].flat(
  311. Infinity).filter(it => it.bannerType != '').length <= 4) {
  312. that.setData({
  313. swiperHeight: '100px'
  314. })
  315. } else {
  316. that.setData({
  317. swiperHeight: '200px'
  318. })
  319. }
  320. }
  321. }
  322. this.setData({
  323. swiperGridcurrent: e.currentTarget.dataset.current
  324. });
  325. },
  326. }
  327. };
  328. </script>
  329. <style>
  330. @import "./king_kong_district.css";
  331. </style>