group.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <view class="group-box iPhone-bottom box-border-box flex-common-css">
  3. <Nav class="nav-b" title='团购专区' bgckgroundBox='transparent' leftColor='#fff' titleColor='#fff'></Nav>
  4. <image class="group-bg" src="@/static/img/group/bg.png" mode=""></image>
  5. <scroll-view :scroll-y="true" class="scroll-view-box" @scroll='scroll' @scrolltolower="scrolltolower"
  6. :scroll-top='scroll_top' :scroll-with-animation="false">
  7. <view class="">
  8. <view class="box-border-box p-12-24 search-box">
  9. <view class="head-search align-items-center">
  10. <!-- <uni-icons class="s-icon" type="search" size="19"></uni-icons> -->
  11. <image class="wh-32" src="@/static/img/group/ss.png" mode=""></image>
  12. <input class="input" v-model="fromData.search" type="text" placeholder="请输入搜索关键字"
  13. placeholder-class="fs-24">
  14. <view class="head-search-buttom text-align-center fs-28 fw-400 fc-f" @click="searchFun()">搜索
  15. </view>
  16. </view>
  17. </view>
  18. <view class="p-12-30 box-border-box class-b">
  19. <view class="class-bg-box">
  20. <image class="class-bg" src="@/static/img/group/fl-bg.png" mode=""></image>
  21. <view class="align-items-center box-border-box class-box-head">
  22. <image class="qbfl mr-18" src="@/static/img/group/qbfl.png" mode=""></image>
  23. <view class="fs-24 fc-FF5022 fw-400">
  24. 特价拼团尽您选择!
  25. </view>
  26. </view>
  27. <view class="class-list-box box-border-box">
  28. <view class="class-list align-items-center flex-wrap-wrap">
  29. <view class="mr-30 mb-30" v-for="(item,i) in navList" :key="i"
  30. @click="selectType(item.id)">
  31. <image class="nav-img mb-18" :src="item.img" mode="scaleToFill"></image>
  32. <view class="fs-24 fc-0 text-align-center">
  33. {{item.name}}
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="p-12-24 box-border-box sift-box align-items-center flex-justify-center"
  41. @touchmove.stop.prevent="stopScroll">
  42. <view class="mr-20 sift-item align-items-center flex-justify-center"
  43. @click="siftClick(1)">
  44. <view class="fs-28 fc-FCFBF8">
  45. {{siftDistance}}
  46. </view>
  47. </view>
  48. <view class="mr-12 sift-item align-items-center flex-justify-center "
  49. @click="siftClick(2)">
  50. <view class="fs-28 fc-FCFBF8">
  51. {{siftSort}}
  52. </view>
  53. </view>
  54. <view class="pop-content" :style="[{'top': pop_top + 'px'}]"
  55. :class="pop_type?'pop-box-true':'pop-box-false'" @click="gbPopType">
  56. <view class="pop-select-box" @click.stop="noPopType">
  57. <view class="select-box p-24 box-border-box">
  58. <view class="distance-box" v-show="siftClassID === 1">
  59. <view class="mb-16 fs-30 fc-3 fw-500">
  60. 我的附近
  61. </view>
  62. <view class="align-items-center flex-wrap-wrap">
  63. <view class="distance-label text-align-center mb-12"
  64. v-for="(item,index) in distance_label" :key="item.id"
  65. :class="fromData.distance===item.id?'siftClass':'bgc-F5F5F6'"
  66. @click="distanceClick(item)">
  67. {{item.name}}
  68. </view>
  69. </view>
  70. </view>
  71. <view class="sort-box" v-show="siftClassID === 2">
  72. <view class="sort-select-box text-align-left" v-for="(item,index) in sort_label"
  73. :key="item.id" @click="sortSelectClick(item)"
  74. :class="fromData.orderBy===item.id?'fc-41ABF5':''">
  75. {{item.name}}
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. <view v-show="pop_type" :style="[{'top': pop_top + 'px'}]" class="pop-mask" @click="gbPopType"
  83. @touchmove.stop.prevent="stopScroll"></view>
  84. <view class="p-12-24 box-border-box">
  85. <shopListVue ref="shopListRef"></shopListVue>
  86. </view>
  87. </view>
  88. </scroll-view>
  89. </view>
  90. </template>
  91. <script>
  92. import {
  93. groupList
  94. } from '@/api/groupOrder.js';
  95. import tools from "@/service/tools";
  96. import shopListVue from './group-mod/shop-list.vue';
  97. import {
  98. getGroup
  99. } from "@/api/category.js"
  100. export default {
  101. components: {
  102. shopListVue
  103. },
  104. data() {
  105. return {
  106. fromData: {
  107. operate_id: '',
  108. lat: '',
  109. lon: '',
  110. search: '',
  111. category_id: 0,
  112. distance: 0,
  113. orderBy: 0,
  114. page: 1
  115. },
  116. navList: [],
  117. siftType: false, // 粘性状态
  118. siftClassID: 0, // 粘性样式Id
  119. scrollTopNum: 0, //当前滚动条高度
  120. scroll_top: 0, //滚动条高度
  121. pop_top: 0, // pop距头部距离
  122. pop_type: false,
  123. navListHeight: '', //头部模块高度
  124. siftDistance: '附近', //距离筛选
  125. siftSort: '默认排序', //排序筛选
  126. distance_label: [{
  127. name: '附近',
  128. id: 0
  129. }, {
  130. name: '500m',
  131. id: 0.5
  132. }, {
  133. name: '1km',
  134. id: 1
  135. }, {
  136. name: '3km',
  137. id: 3
  138. }, {
  139. name: '5km',
  140. id: 5
  141. }, {
  142. name: '10km',
  143. id: 10
  144. }],
  145. sort_label: [{
  146. name: '默认排序',
  147. id: 0
  148. }, {
  149. name: '距离优先',
  150. id: 1
  151. }, {
  152. name: '销量优先',
  153. id: 2
  154. }]
  155. }
  156. },
  157. onShow() {
  158. this.getGroup()
  159. this.fromData.page = 1;
  160. this.getList();
  161. },
  162. onLoad() {},
  163. mounted() {
  164. setTimeout(()=> {
  165. this.getHeight()
  166. },500)
  167. },
  168. methods: {
  169. distanceClick(item) {
  170. // 距离筛选
  171. if (this.fromData.distance === item.id) {
  172. this.gbPopType()
  173. } else {
  174. this.fromData.distance = item.id
  175. this.siftDistance = item.name
  176. this.fromData.page = 1;
  177. this.getList()
  178. this.gbPopType()
  179. }
  180. },
  181. sortSelectClick(item) {
  182. // 排序筛选
  183. if (this.fromData.orderBy === item.id) {
  184. this.gbPopType()
  185. } else {
  186. this.fromData.orderBy = item.id
  187. this.siftSort = item.name
  188. this.fromData.page = 1;
  189. this.getList()
  190. this.gbPopType()
  191. }
  192. },
  193. selectType(num) {
  194. if (this.fromData.category_id === num) {
  195. return
  196. }
  197. this.fromData.category_id = num
  198. this.fromData.page = 1;
  199. this.getList()
  200. },
  201. noPopType() {},
  202. stopScroll(event) {
  203. // 阻止默认的滑动行为
  204. event.preventDefault();
  205. },
  206. siftClick(num) {
  207. this.scroll_top = this.scrollTopNum
  208. if (this.scrollTopNum < this.navListHeight) {
  209. this.$nextTick(function() {
  210. this.scroll_top = this.navListHeight
  211. });
  212. }
  213. if (this.pop_type && this.siftClassID === num) {
  214. this.pop_type = false
  215. } else {
  216. setTimeout(() => {
  217. this.siftClassID = num
  218. this.pop_type = true
  219. }, 200)
  220. }
  221. },
  222. gbPopType() {
  223. this.pop_type = !this.pop_type
  224. },
  225. scroll(e) {
  226. this.scrollTopNum = e.detail.scrollTop
  227. if (e.detail.scrollTop > (this.navListHeight - 1)) {
  228. this.siftType = true
  229. } else {
  230. this.siftType = false
  231. }
  232. },
  233. getHeight() {
  234. this.$nextTick(() => {
  235. let HThree = 0
  236. const navH = uni.createSelectorQuery().in(this);
  237. navH.select('.search-box').boundingClientRect(data => {
  238. if (data) {
  239. // data.height 就是元素的高度
  240. HThree = data.height
  241. console.log(HThree, '333333333');
  242. }
  243. }).exec();
  244. const query = uni.createSelectorQuery().in(this);
  245. query.select('.class-b').boundingClientRect(data => {
  246. if (data) {
  247. // data.height 就是元素的高度
  248. console.log(Number(data.height),Number(HThree),'**********************');
  249. this.navListHeight = Number(data.height) + Number(HThree)
  250. }
  251. }).exec()
  252. let Hone = 0
  253. uni.getSystemInfo({
  254. success: (e) => {
  255. let statusBarH = e.statusBarHeight + 10
  256. let custom = 0;
  257. custom = wx.getMenuButtonBoundingClientRect()
  258. let customBarH = custom.height;
  259. Hone = statusBarH + customBarH;
  260. }
  261. })
  262. let HTwo = 0
  263. const navT = uni.createSelectorQuery().in(this);
  264. navT.select('.sift-box').boundingClientRect(data => {
  265. if (data) {
  266. // data.height 就是元素的高度
  267. HTwo = data.height
  268. console.log(HTwo, '222222222');
  269. }
  270. }).exec();
  271. setTimeout(() => {
  272. this.pop_top = Number(Hone) + Number(HTwo)
  273. console.log(this.pop_top, '-----------');
  274. }, 500)
  275. })
  276. },
  277. scrolltolower(e) {
  278. ++this.fromData.page
  279. this.getList()
  280. },
  281. getGroup() {
  282. let operate_id = uni.getStorageSync('operate_id');
  283. let school_id = uni.getStorageSync('school_id');
  284. getGroup({
  285. operate_id: operate_id,
  286. school_id: school_id
  287. }).then((res) => {
  288. if (res.code === 1) {
  289. this.navList = [...res.data]
  290. }
  291. })
  292. },
  293. searchFun() {
  294. if (this.fromData.search) {
  295. this.fromData.page = 1;
  296. this.getList()
  297. } else {
  298. tools.error("请输入搜索内容")
  299. }
  300. },
  301. getList() {
  302. this.fromData.operate_id = uni.getStorageSync('operate_id');
  303. this.fromData.lon = uni.getStorageSync('lon');
  304. this.fromData.lat = uni.getStorageSync('lat');
  305. console.log(this.fromData);
  306. this.$refs.shopListRef.groupShop(this.fromData)
  307. }
  308. },
  309. }
  310. </script>
  311. <style scoped lang="scss">
  312. .class-box-head {
  313. position: relative;
  314. // z-index: 2;
  315. padding: 30rpx 27rpx 22rpx;
  316. }
  317. .class-list-box {
  318. padding: 0 20rpx;
  319. }
  320. .class-list {
  321. position: relative;
  322. padding: 36rpx 8rpx 8rpx 38rpx;
  323. border-radius: 20rpx;
  324. box-sizing: border-box;
  325. background: linear-gradient(to bottom, white, rgba(255, 255, 255, 0.95));
  326. }
  327. .qbfl {
  328. width: 140rpx;
  329. height: 28rpx;
  330. }
  331. .class-b {
  332. width: 100%;
  333. min-height: 510rpx;
  334. }
  335. .class-bg-box {
  336. width: 100%;
  337. position: relative;
  338. }
  339. .class-bg {
  340. width: 100%;
  341. height: 471rpx;
  342. position: absolute;
  343. left: 0;
  344. top: 0;
  345. }
  346. .group-bg {
  347. width: 100%;
  348. height: 188rpx;
  349. position: absolute;
  350. left: 0;
  351. top: 0;
  352. }
  353. .distance-label {
  354. width: 32%;
  355. height: 60rpx;
  356. line-height: 60rpx;
  357. border-radius: 8rpx;
  358. margin-right: 1%;
  359. }
  360. .sort-select-box {
  361. width: 100%;
  362. height: 40rpx;
  363. line-height: 40rpx;
  364. padding: 15rpx 0;
  365. }
  366. .pop-box-true {
  367. // display: block;
  368. // transition: all .3s inherit;
  369. /* 定义过渡效果 */
  370. height: 500rpx;
  371. // height: 200rpx;
  372. // min-height: 200rpx;
  373. transition: height 0.3s ease-in-out;
  374. // transform: translateY(0);
  375. }
  376. .pop-box-false {
  377. // display: none;
  378. height: 0px;
  379. transition: height 0.3s ease-in-out;
  380. // transform: translateY(-250px);
  381. }
  382. .pop-content {
  383. width: 100%;
  384. // height: 500rpx;
  385. background: transparent;
  386. position: fixed;
  387. left: 0;
  388. // top: var(--pop_top)px;
  389. z-index: 10;
  390. overflow: auto;
  391. // transition: all .3s inherit;
  392. /* 定义过渡效果 */
  393. /* 初始平移状态 */
  394. }
  395. .pop-select-box {
  396. position: relative;
  397. z-index: 15;
  398. background: #fff;
  399. border-radius: 0 0 20rpx 20rpx;
  400. }
  401. .pop-mask {
  402. width: 100%;
  403. height: 100vh;
  404. background: rgba(0, 0, 0, .5);
  405. position: fixed;
  406. left: 0;
  407. z-index: 10;
  408. // top: 0;
  409. }
  410. .siftClass {
  411. color: #41ABF5;
  412. border: 1rpx solid #41ABF5;
  413. background: #deeffb;
  414. box-sizing: border-box;
  415. }
  416. .h-200 {
  417. width: 100%;
  418. height: 200px;
  419. margin-bottom: 20px;
  420. background: rebeccapurple;
  421. }
  422. .scroll-view-box {
  423. overflow: auto;
  424. position: relative;
  425. }
  426. .sift-box {
  427. position: sticky;
  428. top: 0;
  429. left: 0;
  430. z-index: 200;
  431. overflow-x: scroll;
  432. background: #FF3D19;
  433. }
  434. .sift-content-box {
  435. width: 100%;
  436. height: 300rpx;
  437. position: absolute;
  438. top: 74rpx;
  439. left: 0;
  440. }
  441. .sift-item {
  442. // min-width: 150rpx;
  443. // max-width: 280rpx;
  444. width: 50%;
  445. height: 60rpx;
  446. line-height: 60rpx;
  447. // border-radius: 8rpx;
  448. transition: all .5s ease;
  449. }
  450. .group-box {
  451. background: #FF3D19;
  452. }
  453. .nav-list {
  454. overflow-x: scroll;
  455. }
  456. .nav-item {
  457. width: 96rpx;
  458. height: 126rpx;
  459. margin-right: 48rpx;
  460. }
  461. .nav-img {
  462. width: 120rpx;
  463. height: 120rpx;
  464. border-radius: 50%;
  465. }
  466. .head-search {
  467. width: 100%;
  468. height: 80rpx;
  469. position: relative;
  470. }
  471. .s-icon {
  472. position: absolute;
  473. left: 24rpx;
  474. top: 20rpx;
  475. }
  476. .input {
  477. width: 100%;
  478. height: 72rpx;
  479. background: #FFFFFF;
  480. border-radius: 200rpx;
  481. box-sizing: border-box;
  482. padding: 0 130rpx 0 68rpx;
  483. font-size: 32rpx;
  484. }
  485. .head-search-buttom {
  486. width: 120rpx;
  487. height: 60rpx;
  488. background: linear-gradient(-90deg, #FF7D2D, #F54F1D);
  489. border-radius: 30rpx;
  490. line-height: 60rpx;
  491. position: absolute;
  492. right: 12rpx;
  493. top: 10rpx;
  494. }
  495. .wh-32 {
  496. position: absolute;
  497. left: 31rpx;
  498. top: 27rpx;
  499. width: 26rpx;
  500. height: 26rpx;
  501. }
  502. </style>