group.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="group-box iPhone-bottom box-border-box flex-common-css">
  3. <Nav class="nav-b" title='团购专区'></Nav>
  4. <scroll-view :scroll-y="true" class="scroll-view-box" @scroll='scroll' @scrolltolower="scrolltolower"
  5. :scroll-top='scroll_top' :scroll-with-animation="false">
  6. <view class="">
  7. <view class="box-border-box p-12-24 search-box">
  8. <view class="head-search align-items-center">
  9. <!-- <uni-icons class="s-icon" type="search" size="19"></uni-icons> -->
  10. <image class="wh-32" src="@/static/img/index/ss.png" mode=""></image>
  11. <input class="input" v-model="search" type="text" placeholder="搜一搜带你玩周边">
  12. <view class="head-search-buttom text-align-center fs-28 fw-500 fc-f" @click="searchFun()">搜索
  13. </view>
  14. </view>
  15. </view>
  16. <view class="p-12-24 box-border-box class-b">
  17. <view class="display-flex p-24 box-border-box nav-list bgc-f b-rad-16 mb-12">
  18. <view class="text-align-center nav-item" v-for="(item,i) in navList" :key="i"
  19. @click="selectType(item.id)">
  20. <image class="nav-img" :src="item.img" mode="scaleToFill"></image>
  21. <view class="fs-24 w-96" :class="navId == item.id?'fw-600 fc-41ABF5':'fw-400'">{{item.name}}
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. <view class="p-12-24 box-border-box sift-box align-items-center" :class="siftType?'bgc-f':''"
  27. @touchmove.stop.prevent="stopScroll">
  28. <view class="mr-20 sift-item align-items-center flex-justify-center"
  29. :class="[{'bgc-F5F5F6':siftType},{'bgc-f':!siftType},{'siftClass':siftClassID === 1 && pop_type}]"
  30. @click="siftClick(1)">
  31. <view class="" :class="[{'fc-41ABF5':siftClassID === 1 && pop_type}]">
  32. {{siftDistance}}
  33. </view>
  34. </view>
  35. <view class="mr-12 sift-item align-items-center flex-justify-center"
  36. :class="[{'bgc-F5F5F6':siftType},{'bgc-f':!siftType},{'siftClass':siftClassID === 2 && pop_type}]"
  37. @click="siftClick(2)">
  38. <view class="" :class="[{'fc-41ABF5':siftClassID === 2 && pop_type}]">
  39. {{siftSort}}
  40. </view>
  41. </view>
  42. <view class="pop-content" :style="[{'top': pop_top + 'px'}]"
  43. :class="pop_type?'pop-box-true':'pop-box-false'" @click="gbPopType">
  44. <view class="pop-select-box" @click.stop="noPopType">
  45. <view class="">
  46. 1111111111111111111000000000000000000000000000000000000000000000000000000000
  47. </view>
  48. <view class="" v-for="(item,index) in 2">
  49. 电风扇电风扇
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. <view v-show="pop_type" :style="[{'top': pop_top + 'px'}]" class="pop-mask" @click="gbPopType"
  55. @touchmove.stop.prevent="stopScroll"></view>
  56. <view class="p-12-24 box-border-box">
  57. <view class="h-200" v-for="(item,index) in 10">
  58. </view>
  59. </view>
  60. </view>
  61. </scroll-view>
  62. </view>
  63. </template>
  64. <script>
  65. import {
  66. groupList
  67. } from '@/api/groupOrder.js';
  68. import tools from "@/service/tools";
  69. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  70. import {
  71. getGroup
  72. } from "@/api/category.js"
  73. export default {
  74. components: {
  75. EnBlank
  76. },
  77. data() {
  78. return {
  79. navId: 0,
  80. navList: [{
  81. name: "全部",
  82. id: 0,
  83. img: require('@/static/img/buy/t-all.png')
  84. }],
  85. siftType: false, // 粘性状态
  86. siftClassID: 0, // 粘性样式Id
  87. scrollTopNum: 0, //当前滚动条高度
  88. scroll_top: 0, //滚动条高度
  89. pop_top: 0, // pop距头部距离
  90. pop_type: false,
  91. navListHeight: '', //头部模块高度
  92. siftDistance: '附近', //距离筛选
  93. siftSort: '距离优先', //排序筛选
  94. page: 1,
  95. total: 0,
  96. list: [],
  97. search: ''
  98. }
  99. },
  100. onReachBottom() {
  101. if (this.list.length < this.total) {
  102. this.page += 1;
  103. this.getList();
  104. }
  105. },
  106. onShow() {
  107. this.getGroup()
  108. this.page = 1;
  109. this.list = [];
  110. this.getList();
  111. },
  112. onLoad() {},
  113. mounted() {
  114. this.getHeight()
  115. },
  116. methods: {
  117. noPopType() {},
  118. stopScroll(event) {
  119. // 阻止默认的滑动行为
  120. event.preventDefault();
  121. },
  122. siftClick(num) {
  123. this.scroll_top = this.scrollTopNum
  124. if (this.scrollTopNum < this.navListHeight) {
  125. this.$nextTick(function() {
  126. this.scroll_top = this.navListHeight
  127. });
  128. }
  129. setTimeout(() => {
  130. this.siftClassID = num
  131. this.pop_type = true
  132. }, 200)
  133. },
  134. gbPopType() {
  135. this.pop_type = !this.pop_type
  136. },
  137. scroll(e) {
  138. this.scrollTopNum = e.detail.scrollTop
  139. if (e.detail.scrollTop > (this.navListHeight - 1)) {
  140. this.siftType = true
  141. } else {
  142. this.siftType = false
  143. }
  144. },
  145. getHeight() {
  146. this.$nextTick(() => {
  147. let HThree = 0
  148. const navH = uni.createSelectorQuery().in(this);
  149. navH.select('.search-box').boundingClientRect(data => {
  150. if (data) {
  151. // data.height 就是元素的高度
  152. HThree = data.height
  153. console.log(HThree, '333333333');
  154. }
  155. }).exec();
  156. const query = uni.createSelectorQuery().in(this);
  157. query.select('.class-b').boundingClientRect(data => {
  158. if (data) {
  159. // data.height 就是元素的高度
  160. this.navListHeight = Number(data.height) + Number(HThree)
  161. }
  162. }).exec()
  163. let Hone = 0
  164. uni.getSystemInfo({
  165. success: (e) => {
  166. let statusBarH = e.statusBarHeight + 10
  167. let custom = 0;
  168. custom = wx.getMenuButtonBoundingClientRect()
  169. let customBarH = custom.height;
  170. Hone = statusBarH + customBarH;
  171. }
  172. })
  173. let HTwo = 0
  174. const navT = uni.createSelectorQuery().in(this);
  175. navT.select('.sift-box').boundingClientRect(data => {
  176. if (data) {
  177. // data.height 就是元素的高度
  178. HTwo = data.height
  179. console.log(HTwo, '222222222');
  180. }
  181. }).exec();
  182. setTimeout(() => {
  183. this.pop_top = Number(Hone) + Number(HTwo)
  184. console.log(this.pop_top, '-----------');
  185. }, 500)
  186. })
  187. },
  188. scrolltolower(e) {
  189. console.log(e);
  190. },
  191. getGroup() {
  192. let operate_id = uni.getStorageSync('operate_id');
  193. let school_id = uni.getStorageSync('school_id');
  194. this.navList = {
  195. name: "全部",
  196. id: 0,
  197. img: require('@/static/img/buy/t-all.png')
  198. }
  199. getGroup({
  200. operate_id: operate_id,
  201. school_id: school_id
  202. }).then((res) => {
  203. if (res.code === 1) {
  204. this.navList = [this.navList, ...res.data]
  205. }
  206. })
  207. },
  208. getList() {
  209. let school_id = uni.getStorageSync('school_id');
  210. groupList({
  211. school_id: school_id,
  212. page: this.page
  213. }).then((res) => {
  214. if (res.code === 1) {
  215. this.list = [...this.list, ...res.data.items];
  216. this.total = res.data.total;
  217. }
  218. })
  219. },
  220. todet(item) {
  221. uni.navigateTo({
  222. url: '/pages-buy/group-det?id=' + item.id
  223. })
  224. }
  225. },
  226. }
  227. </script>
  228. <style scoped lang="scss">
  229. .pop-box-true {
  230. // display: block;
  231. // transition: all .3s inherit;
  232. /* 定义过渡效果 */
  233. height: 500rpx;
  234. // height: 200rpx;
  235. // min-height: 200rpx;
  236. transition: height 0.3s ease-in-out;
  237. // transform: translateY(0);
  238. }
  239. .pop-box-false {
  240. // display: none;
  241. height: 0px;
  242. transition: height 0.3s ease-in-out;
  243. // transform: translateY(-250px);
  244. }
  245. .pop-content {
  246. width: 100%;
  247. // height: 500rpx;
  248. background: transparent;
  249. position: fixed;
  250. left: 0;
  251. // top: var(--pop_top)px;
  252. z-index: 10;
  253. overflow: auto;
  254. // transition: all .3s inherit;
  255. /* 定义过渡效果 */
  256. /* 初始平移状态 */
  257. }
  258. .pop-select-box {
  259. position: relative;
  260. z-index: 15;
  261. background: #fff;
  262. border-radius: 0 0 20rpx 20rpx;
  263. }
  264. .pop-mask {
  265. width: 100%;
  266. height: 100vh;
  267. background: rgba(0, 0, 0, .5);
  268. position: fixed;
  269. left: 0;
  270. z-index: 10;
  271. // top: 0;
  272. }
  273. .siftClass {
  274. color: #41ABF5;
  275. border: 1rpx solid #41ABF5;
  276. background: #deeffb;
  277. box-sizing: border-box;
  278. }
  279. .h-200 {
  280. width: 100%;
  281. height: 200px;
  282. margin-bottom: 20px;
  283. background: rebeccapurple;
  284. }
  285. .scroll-view-box {
  286. overflow: auto;
  287. position: relative;
  288. }
  289. .sift-box {
  290. position: sticky;
  291. top: 0;
  292. left: 0;
  293. z-index: 200;
  294. overflow-x: scroll;
  295. }
  296. .sift-content-box {
  297. width: 100%;
  298. height: 300rpx;
  299. position: absolute;
  300. top: 74rpx;
  301. left: 0;
  302. }
  303. .sift-item {
  304. min-width: 150rpx;
  305. max-width: 280rpx;
  306. height: 60rpx;
  307. line-height: 60rpx;
  308. border-radius: 8rpx;
  309. transition: all .5s ease;
  310. }
  311. .group-box {}
  312. .nav-list {
  313. overflow-x: scroll;
  314. }
  315. .nav-item {
  316. width: 96rpx;
  317. height: 126rpx;
  318. margin-right: 48rpx;
  319. }
  320. .nav-img {
  321. width: 80rpx;
  322. height: 80rpx;
  323. border-radius: 5px;
  324. margin: 0 auto 12rpx auto;
  325. }
  326. .head-search {
  327. width: 100%;
  328. position: relative;
  329. }
  330. .s-icon {
  331. position: absolute;
  332. left: 24rpx;
  333. top: 20rpx;
  334. }
  335. .input {
  336. width: 100%;
  337. height: 72rpx;
  338. background: #FFFFFF;
  339. border-radius: 200rpx;
  340. box-sizing: border-box;
  341. padding: 0 130rpx 0 68rpx;
  342. font-size: 32rpx;
  343. }
  344. .head-search-buttom {
  345. width: 120rpx;
  346. height: 60rpx;
  347. background: linear-gradient(90deg, #2CE6F8 0%, #41ABF5 100%);
  348. border-radius: 200rpx;
  349. line-height: 60rpx;
  350. position: absolute;
  351. right: 6rpx;
  352. top: 6rpx;
  353. }
  354. .wh-32 {
  355. position: absolute;
  356. left: 24rpx;
  357. top: 20rpx;
  358. width: 32rpx;
  359. height: 32rpx;
  360. }
  361. </style>