group.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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="p-12-24 box-border-box class-b">
  8. <view class="display-flex p-24 box-border-box nav-list bgc-f b-rad-16 mb-12">
  9. <view class="text-align-center nav-item" v-for="(item,i) in navList" :key="i"
  10. @click="selectType(item.id)">
  11. <image class="nav-img" :src="item.img" mode="scaleToFill"></image>
  12. <view class="fs-24 w-96" :class="navId == item.id?'fw-600 fc-41ABF5':'fw-400'">{{item.name}}
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="p-12-24 box-border-box sift-box align-items-center" :class="siftType?'bgc-f':''">
  18. <view class="mr-20 sift-item align-items-center flex-justify-center"
  19. :class="[{'bgc-F5F5F6':siftType},{'bgc-f':!siftType},{'siftClass':siftClassID === 1}]"
  20. @click="siftClick(1)">
  21. <view class="" :class="[{'fc-41ABF5':siftClassID === 1}]">
  22. {{siftDistance}}
  23. </view>
  24. </view>
  25. <view class="mr-12 sift-item align-items-center flex-justify-center"
  26. :class="[{'bgc-F5F5F6':siftType},{'bgc-f':!siftType},{'siftClass':siftClassID === 2}]"
  27. @click="siftClick(2)">
  28. <view class="" :class="[{'fc-41ABF5':siftClassID === 2}]">
  29. {{siftSort}}
  30. </view>
  31. </view>
  32. </view>
  33. <view class="pop-box" :style="[{'top': pop_top + 'px'}]" :class="[{'pop-box-z':pop_type}]">
  34. <view class="pop-content" :class="pop_type?'pop-box-true':'pop-box-false'">
  35. <view class="">
  36. 1111111111111111111000000000000000000000000000000000000000000000000000000000
  37. </view>
  38. </view>
  39. <view v-show="pop_type" class="pop-mask" @click="pop_type = !pop_type"></view>
  40. </view>
  41. <view class="p-12-24 box-border-box">
  42. <view class="h-200" v-for="(item,index) in 10">
  43. </view>
  44. </view>
  45. </view>
  46. </scroll-view>
  47. </view>
  48. </template>
  49. <script>
  50. import {
  51. groupList
  52. } from '@/api/groupOrder.js';
  53. import tools from "@/service/tools";
  54. import EnBlank from "@/components/en-utils/en-blank/en-blank";
  55. import {
  56. getGroup
  57. } from "@/api/category.js"
  58. export default {
  59. components: {
  60. EnBlank
  61. },
  62. data() {
  63. return {
  64. navId: 0,
  65. navList: [{
  66. name: "全部",
  67. id: 0,
  68. img: require('@/static/img/buy/t-all.png')
  69. }],
  70. siftType: false, // 粘性状态
  71. siftClassID: 0, // 粘性样式Id
  72. scrollTopNum: 0, //当前滚动条高度
  73. scroll_top: 0, //滚动条高度
  74. pop_top: 0, // pop距头部距离
  75. pop_type: false,
  76. pop_type_two: false,
  77. navListHeight: '', //头部模块高度
  78. siftDistance: '附近', //距离筛选
  79. siftSort: '距离优先', //排序筛选
  80. page: 1,
  81. total: 0,
  82. list: []
  83. }
  84. },
  85. onReachBottom() {
  86. if (this.list.length < this.total) {
  87. this.page += 1;
  88. this.getList();
  89. }
  90. },
  91. onShow() {
  92. this.getGroup()
  93. this.page = 1;
  94. this.list = [];
  95. this.getList();
  96. },
  97. onLoad() {},
  98. mounted() {
  99. this.getHeight()
  100. },
  101. methods: {
  102. siftClick(num) {
  103. this.scroll_top = this.scrollTopNum
  104. this.$nextTick(function() {
  105. this.scroll_top = this.navListHeight
  106. });
  107. setTimeout(() => {
  108. this.siftClassID = num
  109. this.pop_type = true
  110. }, 400)
  111. },
  112. scroll(e) {
  113. this.scrollTopNum = e.detail.scrollTop
  114. if (e.detail.scrollTop > (this.navListHeight - 1)) {
  115. this.siftType = true
  116. } else {
  117. this.siftType = false
  118. }
  119. },
  120. getHeight() {
  121. const query = uni.createSelectorQuery().in(this);
  122. query.select('.class-b').boundingClientRect(data => {
  123. if (data) {
  124. // data.height 就是元素的高度
  125. this.navListHeight = data.height
  126. }
  127. }).exec()
  128. let Hone = 0
  129. uni.getSystemInfo({
  130. success: (e) => {
  131. let statusBarH = e.statusBarHeight + 10
  132. let custom = 0;
  133. custom = wx.getMenuButtonBoundingClientRect()
  134. let customBarH = custom.height;
  135. Hone = statusBarH + customBarH;
  136. }
  137. })
  138. let HTwo = 0
  139. const navT = uni.createSelectorQuery().in(this);
  140. navT.select('.sift-box').boundingClientRect(data => {
  141. if (data) {
  142. // data.height 就是元素的高度
  143. HTwo = data.height
  144. console.log(HTwo, '222222222');
  145. }
  146. }).exec();
  147. setTimeout(() => {
  148. this.pop_top = Number(Hone) + Number(HTwo)
  149. console.log(this.pop_top, '-----------');
  150. }, 500)
  151. },
  152. scrolltolower(e) {
  153. console.log(e);
  154. },
  155. getGroup() {
  156. let operate_id = uni.getStorageSync('operate_id');
  157. let school_id = uni.getStorageSync('school_id');
  158. getGroup({
  159. operate_id: operate_id,
  160. school_id: school_id
  161. }).then((res) => {
  162. if (res.code === 1) {
  163. this.navList = [...this.navList, ...res.data]
  164. }
  165. })
  166. },
  167. getList() {
  168. let school_id = uni.getStorageSync('school_id');
  169. groupList({
  170. school_id: school_id,
  171. page: this.page
  172. }).then((res) => {
  173. if (res.code === 1) {
  174. this.list = [...this.list, ...res.data.items];
  175. this.total = res.data.total;
  176. }
  177. })
  178. },
  179. todet(item) {
  180. uni.navigateTo({
  181. url: '/pages-buy/group-det?id=' + item.id
  182. })
  183. }
  184. },
  185. }
  186. </script>
  187. <style scoped lang="scss">
  188. .pop-box {
  189. width: 100%;
  190. // height: 100vh;
  191. height: 84rpx;
  192. position: fixed;
  193. left: 0;
  194. top: 0;
  195. overflow: hidden;
  196. // z-index: -1;
  197. // transition: all 0.3s ease-in-out;
  198. }
  199. // .pop-box-z {
  200. // z-index: 2;
  201. // transition: all 0.3s ease-in-out;
  202. // }
  203. .pop-box-true {
  204. // display: block;
  205. // transition: all .3s inherit;
  206. /* 定义过渡效果 */
  207. transition: transform 0.3s ease-in-out;
  208. transform: translateY(0);
  209. }
  210. .pop-box-false {
  211. // display: none;
  212. transition: transform 0.3s ease-in-out;
  213. transform: translateY(-100%);
  214. }
  215. .pop-content {
  216. width: 100%;
  217. height: 500rpx;
  218. background: #fff;
  219. border-radius: 0 0 20rpx 20rpx;
  220. position: absolute;
  221. left: 0;
  222. // top: var(--pop_top)px;
  223. z-index: 10;
  224. // transition: all .3s inherit;
  225. /* 定义过渡效果 */
  226. /* 初始平移状态 */
  227. }
  228. .pop-mask {
  229. width: 100%;
  230. height: 100%;
  231. background: rgba(0, 0, 0, .5);
  232. position: absolute;
  233. left: 0;
  234. // top: 0;
  235. }
  236. .siftClass {
  237. color: #41ABF5;
  238. border: 1rpx solid #41ABF5;
  239. background: #deeffb;
  240. box-sizing: border-box;
  241. }
  242. .h-200 {
  243. width: 100%;
  244. height: 200px;
  245. margin-bottom: 20px;
  246. background: rebeccapurple;
  247. }
  248. .scroll-view-box {
  249. overflow: auto;
  250. }
  251. .sift-box {
  252. position: sticky;
  253. top: 0;
  254. left: 0;
  255. z-index: 200;
  256. overflow-x: scroll;
  257. }
  258. .sift-content-box {
  259. width: 100%;
  260. height: 300rpx;
  261. position: absolute;
  262. top: 74rpx;
  263. left: 0;
  264. }
  265. .sift-item {
  266. min-width: 150rpx;
  267. max-width: 280rpx;
  268. height: 60rpx;
  269. line-height: 60rpx;
  270. border-radius: 8rpx;
  271. transition: all .5s ease;
  272. }
  273. .group-box {}
  274. .nav-list {
  275. overflow-x: scroll;
  276. }
  277. .nav-item {
  278. width: 96rpx;
  279. height: 126rpx;
  280. margin-right: 48rpx;
  281. }
  282. .nav-img {
  283. width: 80rpx;
  284. height: 80rpx;
  285. border-radius: 5px;
  286. margin: 0 auto 12rpx auto;
  287. }
  288. .w-96 {
  289. // width: 96rpx;
  290. }
  291. </style>