group.vue 12 KB

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