| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543 |
- <template>
- <view class="group-box iPhone-bottom box-border-box flex-common-css">
- <Nav class="nav-b" title='团购专区' bgckgroundBox='transparent' leftColor='#fff' titleColor='#fff'></Nav>
- <image class="group-bg" src="@/static/img/group/bg.png" mode=""></image>
- <scroll-view :scroll-y="true" class="scroll-view-box" @scroll='scroll' @scrolltolower="scrolltolower"
- :scroll-top='scroll_top' :scroll-with-animation="false">
- <view class="">
- <view class="box-border-box p-12-24 search-box">
- <view class="head-search align-items-center">
- <!-- <uni-icons class="s-icon" type="search" size="19"></uni-icons> -->
- <image class="wh-32" src="@/static/img/group/ss.png" mode=""></image>
- <input class="input" v-model="fromData.search" type="text" placeholder="请输入搜索关键字"
- placeholder-class="fs-24">
- <view class="head-search-buttom text-align-center fs-28 fw-400 fc-f" @click="searchFun()">搜索
- </view>
- </view>
- </view>
- <view class="p-12-30 box-border-box class-b">
- <view class="class-bg-box">
- <image class="class-bg" src="@/static/img/group/fl-bg.png" mode=""></image>
- <view class="align-items-center box-border-box class-box-head">
- <image class="qbfl mr-18" src="@/static/img/group/qbfl.png" mode=""></image>
- <view class="fs-24 fc-FF5022 fw-400">
- 特价拼团尽您选择!
- </view>
- </view>
- <view class="class-list-box box-border-box">
- <view class="class-list align-items-center flex-wrap-wrap">
- <view class="mr-30 mb-30" v-for="(item,i) in navList" :key="i"
- @click="selectType(item.id)">
- <image class="nav-img mb-18" :src="item.img" mode="scaleToFill"></image>
- <view class="fs-24 fc-0 text-align-center">
- {{item.name}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="p-12-24 box-border-box sift-box align-items-center flex-justify-center"
- @touchmove.stop.prevent="stopScroll">
- <view class="mr-20 sift-item align-items-center flex-justify-center"
- @click="siftClick(1)">
- <view class="align-items-center">
- <view class="fs-28 fc-FCFBF8 mr-12">
- {{siftDistance}}
- </view>
- <image class="bottom-icon" src="@/static/img/group/bottom.png" mode=""></image>
- </view>
- </view>
- <view class="mr-12 sift-item align-items-center flex-justify-center "
- @click="siftClick(2)">
- <view class="align-items-center">
- <view class="fs-28 fc-FCFBF8 mr-12">
- {{siftSort}}
- </view>
- <image class="bottom-icon" src="@/static/img/group/bottom.png" mode=""></image>
- </view>
- </view>
- <view class="pop-content" :style="[{'top': pop_top + 'px'}]"
- :class="pop_type?'pop-box-true':'pop-box-false'" @click="gbPopType">
- <view class="pop-select-box" @click.stop="noPopType">
- <view class="select-box p-24 box-border-box">
- <view class="distance-box" v-show="siftClassID === 1">
- <view class="mb-16 fs-30 fc-3 fw-500">
- 我的附近
- </view>
- <view class="align-items-center flex-wrap-wrap">
- <view class="distance-label text-align-center mb-12"
- v-for="(item,index) in distance_label" :key="item.id"
- :class="fromData.distance===item.id?'siftClass':'bgc-F5F5F6'"
- @click="distanceClick(item)">
- {{item.name}}
- </view>
- </view>
- </view>
- <view class="sort-box" v-show="siftClassID === 2">
- <view class="sort-select-box text-align-left" v-for="(item,index) in sort_label"
- :key="item.id" @click="sortSelectClick(item)"
- :class="fromData.orderBy===item.id?'fc-41ABF5':''">
- {{item.name}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view v-show="pop_type" :style="[{'top': pop_top + 'px'}]" class="pop-mask" @click="gbPopType"
- @touchmove.stop.prevent="stopScroll"></view>
- <view class="p-12-24 box-border-box">
- <shopListVue ref="shopListRef"></shopListVue>
- </view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import {
- groupList
- } from '@/api/groupOrder.js';
- import tools from "@/service/tools";
- import shopListVue from './group-mod/shop-list.vue';
- import {
- getGroup
- } from "@/api/category.js"
- export default {
- components: {
- shopListVue
- },
- data() {
- return {
- fromData: {
- operate_id: '',
- lat: '',
- lon: '',
- search: '',
- category_id: 0,
- distance: 0,
- orderBy: 0,
- page: 1
- },
- navList: [],
- siftType: false, // 粘性状态
- siftClassID: 0, // 粘性样式Id
- scrollTopNum: 0, //当前滚动条高度
- scroll_top: 0, //滚动条高度
- pop_top: 0, // pop距头部距离
- pop_type: false,
- navListHeight: '', //头部模块高度
- siftDistance: '附近', //距离筛选
- siftSort: '默认排序', //排序筛选
- distance_label: [{
- name: '附近',
- id: 0
- }, {
- name: '500m',
- id: 0.5
- }, {
- name: '1km',
- id: 1
- }, {
- name: '3km',
- id: 3
- }, {
- name: '5km',
- id: 5
- }, {
- name: '10km',
- id: 10
- }],
- sort_label: [{
- name: '默认排序',
- id: 0
- }, {
- name: '距离优先',
- id: 1
- }, {
- name: '销量优先',
- id: 2
- }]
- }
- },
- onShow() {
- this.getGroup()
- this.fromData.page = 1;
- this.getList();
- },
- onLoad() {},
- mounted() {
- setTimeout(()=> {
- this.getHeight()
- },500)
- },
- methods: {
- distanceClick(item) {
- // 距离筛选
- if (this.fromData.distance === item.id) {
- this.gbPopType()
- } else {
- this.fromData.distance = item.id
- this.siftDistance = item.name
- this.fromData.page = 1;
- this.getList()
- this.gbPopType()
- }
- },
- sortSelectClick(item) {
- // 排序筛选
- if (this.fromData.orderBy === item.id) {
- this.gbPopType()
- } else {
- this.fromData.orderBy = item.id
- this.siftSort = item.name
- this.fromData.page = 1;
- this.getList()
- this.gbPopType()
- }
- },
- selectType(num) {
- if (this.fromData.category_id === num) {
- return
- }
- this.fromData.category_id = num
- this.fromData.page = 1;
- this.getList()
- },
- noPopType() {},
- stopScroll(event) {
- // 阻止默认的滑动行为
- event.preventDefault();
- },
- siftClick(num) {
- this.scroll_top = this.scrollTopNum
- if (this.scrollTopNum < this.navListHeight) {
- this.$nextTick(function() {
- this.scroll_top = this.navListHeight
- });
- }
- if (this.pop_type && this.siftClassID === num) {
- this.pop_type = false
- } else {
- setTimeout(() => {
- this.siftClassID = num
- this.pop_type = true
- }, 200)
- }
- },
- gbPopType() {
- this.pop_type = !this.pop_type
- },
- scroll(e) {
- this.scrollTopNum = e.detail.scrollTop
- if (e.detail.scrollTop > (this.navListHeight - 1)) {
- this.siftType = true
- } else {
- this.siftType = false
- }
- },
- getHeight() {
- this.$nextTick(() => {
- let HThree = 0
- const navH = uni.createSelectorQuery().in(this);
- navH.select('.search-box').boundingClientRect(data => {
- if (data) {
- // data.height 就是元素的高度
- HThree = data.height
- console.log(HThree, '333333333');
- }
- }).exec();
- const query = uni.createSelectorQuery().in(this);
- query.select('.class-b').boundingClientRect(data => {
- if (data) {
- // data.height 就是元素的高度
- console.log(Number(data.height),Number(HThree),'**********************');
- this.navListHeight = Number(data.height) + Number(HThree)
- }
- }).exec()
- let Hone = 0
- uni.getSystemInfo({
- success: (e) => {
- let statusBarH = e.statusBarHeight + 10
- let custom = 0;
- custom = wx.getMenuButtonBoundingClientRect()
- let customBarH = custom.height;
- Hone = statusBarH + customBarH;
- }
- })
- let HTwo = 0
- const navT = uni.createSelectorQuery().in(this);
- navT.select('.sift-box').boundingClientRect(data => {
- if (data) {
- // data.height 就是元素的高度
- HTwo = data.height
- console.log(HTwo, '222222222');
- }
- }).exec();
- setTimeout(() => {
- this.pop_top = Number(Hone) + Number(HTwo)
- console.log(this.pop_top, '-----------');
- }, 500)
- })
- },
- scrolltolower(e) {
- ++this.fromData.page
- this.getList()
- },
- getGroup() {
- let operate_id = uni.getStorageSync('operate_id');
- let school_id = uni.getStorageSync('school_id');
- getGroup({
- operate_id: operate_id,
- school_id: school_id
- }).then((res) => {
- if (res.code === 1) {
- this.navList = [...res.data]
- }
- })
- },
- searchFun() {
- if (this.fromData.search) {
- this.fromData.page = 1;
- this.getList()
- } else {
- tools.error("请输入搜索内容")
- }
- },
- getList() {
- this.fromData.operate_id = uni.getStorageSync('operate_id');
- this.fromData.lon = uni.getStorageSync('lon');
- this.fromData.lat = uni.getStorageSync('lat');
- console.log(this.fromData);
- this.$refs.shopListRef.groupShop(this.fromData)
- }
- },
- }
- </script>
- <style scoped lang="scss">
- .bottom-icon{
- width: 16rpx;
- height: 10rpx;
- }
- .class-box-head {
- position: relative;
- // z-index: 2;
- padding: 30rpx 27rpx 22rpx;
- }
- .class-list-box {
- padding: 0 20rpx;
- }
- .class-list {
- position: relative;
- padding: 36rpx 8rpx 8rpx 38rpx;
- border-radius: 20rpx;
- box-sizing: border-box;
- background: linear-gradient(to top, white, rgba(255, 255, 255, 0.65));
- }
- .qbfl {
- width: 140rpx;
- height: 28rpx;
- }
- .class-b {
- width: 100%;
- min-height: 510rpx;
- }
- .class-bg-box {
- width: 100%;
- position: relative;
- }
- .class-bg {
- width: 100%;
- height: 471rpx;
- position: absolute;
- left: 0;
- top: 0;
- }
- .group-bg {
- width: 100%;
- height: 188rpx;
- position: absolute;
- left: 0;
- top: 0;
- }
- .distance-label {
- width: 32%;
- height: 60rpx;
- line-height: 60rpx;
- border-radius: 8rpx;
- margin-right: 1%;
- }
- .sort-select-box {
- width: 100%;
- height: 40rpx;
- line-height: 40rpx;
- padding: 15rpx 0;
- }
- .pop-box-true {
- // display: block;
- // transition: all .3s inherit;
- /* 定义过渡效果 */
- height: 500rpx;
- // height: 200rpx;
- // min-height: 200rpx;
- transition: height 0.3s ease-in-out;
- // transform: translateY(0);
- }
- .pop-box-false {
- // display: none;
- height: 0px;
- transition: height 0.3s ease-in-out;
- // transform: translateY(-250px);
- }
- .pop-content {
- width: 100%;
- // height: 500rpx;
- background: transparent;
- position: fixed;
- left: 0;
- // top: var(--pop_top)px;
- z-index: 10;
- overflow: auto;
- // transition: all .3s inherit;
- /* 定义过渡效果 */
- /* 初始平移状态 */
- }
- .pop-select-box {
- position: relative;
- z-index: 15;
- background: #fff;
- border-radius: 0 0 20rpx 20rpx;
- }
- .pop-mask {
- width: 100%;
- height: 100vh;
- background: rgba(0, 0, 0, .5);
- position: fixed;
- left: 0;
- z-index: 10;
- // top: 0;
- }
- .siftClass {
- color: #41ABF5;
- border: 1rpx solid #41ABF5;
- background: #deeffb;
- box-sizing: border-box;
- }
- .h-200 {
- width: 100%;
- height: 200px;
- margin-bottom: 20px;
- background: rebeccapurple;
- }
- .scroll-view-box {
- overflow: auto;
- position: relative;
- }
- .sift-box {
- position: sticky;
- top: 0;
- left: 0;
- z-index: 200;
- overflow-x: scroll;
- background: #FF3D19;
- }
- .sift-content-box {
- width: 100%;
- height: 300rpx;
- position: absolute;
- top: 74rpx;
- left: 0;
- }
- .sift-item {
- // min-width: 150rpx;
- // max-width: 280rpx;
- width: 50%;
- height: 60rpx;
- line-height: 60rpx;
- // border-radius: 8rpx;
- transition: all .5s ease;
- }
- .group-box {
- background: #FF3D19;
- }
- .nav-list {
- overflow-x: scroll;
- }
- .nav-item {
- width: 96rpx;
- height: 126rpx;
- margin-right: 48rpx;
- }
- .nav-img {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- }
- .head-search {
- width: 100%;
- height: 80rpx;
- position: relative;
- }
- .s-icon {
- position: absolute;
- left: 24rpx;
- top: 20rpx;
- }
- .input {
- width: 100%;
- height: 72rpx;
- background: #FFFFFF;
- border-radius: 200rpx;
- box-sizing: border-box;
- padding: 0 130rpx 0 68rpx;
- font-size: 32rpx;
- }
- .head-search-buttom {
- width: 120rpx;
- height: 60rpx;
- background: linear-gradient(-90deg, #FF7D2D, #F54F1D);
- border-radius: 30rpx;
- line-height: 60rpx;
- position: absolute;
- right: 12rpx;
- top: 10rpx;
- }
- .wh-32 {
- position: absolute;
- left: 31rpx;
- top: 27rpx;
- width: 26rpx;
- height: 26rpx;
- }
- </style>
|