123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533 |
- <template>
- <view class="zaiui-home-box show" >
- <bar-title bgColor='bg-red' :isBack="false" :title="place.name">
- <block slot="content">{{place.name}}</block>
- <block slot="right">
-
- </block>
- </bar-title>
- <view class="zaiui-head-search-box" :class="headInfo.Class">
- <!--搜索框-->
- <view class="cu-bar search zaiui-search-box">
- <form @submit="search">
- <view class="search-form round">
- <text class="cuIcon-search"/>
- <input type="search" />
- </view>
- </form>
- <view class="action text-white"></view>
- </view>
-
- <!--选项卡-->
- <view class="zaiui-flex-tab show">
- <view class="flex text-white">
- <view class="basis-xxl">
- <scroll-view scroll-x class="nav z" scroll-with-animation :scroll-left="headTab.scrollLeft">
- <block v-for="(item,index) in headTab.list" :key="item.id">
- <view class="cu-item" :class="item.id==headTab.TabCur?'select':''" @tap="tabSelect" :data-id="item.id">
- <view>{{item.name}}</view>
- <view class="tab-dot bg-white"/>
- </view>
- </block>
- </scroll-view>
- </view>
- <!-- <view class="basis-xxs">
- <view class="sort-icon" @tap="sortVueTap">
- <text class="cuIcon-sort"/>
- </view>
- </view> -->
- </view>
- </view>
- </view>
-
- <!--中间内容区域-->
- <view class="zaiui-view-content" :class="[headTab.TabCur==0?'show':'']">
- <!--滑动菜单-->
- <grid-menu-list v-if="gridMenuData.length" :list_data='gridMenuData' @listTap='gridMenuTap'/>
-
- <!--红包块-->
- <!-- <view class="bg-red margin radius padding-sm">
- <image class="red-envelopes" src="/static/images/home/sundry/2.png" mode="widthFix"/>
- </view> -->
-
- <!--免费鉴别-->
- <!-- <identify-list :list_data='identifyData' @listTap='identifyTap'/> -->
-
- <!--省心快卖-->
- <!-- <sell-quickly-list :list_data='quickly' @listTap='quicklyTap'/> -->
-
- <!--活动区域-->
- <!-- <activity-list :list_data='activity' @listTap='activityTap'/> -->
-
- <!--商品tab-->
- <!-- <view class="zaiui-goods-tab-box">
- <scroll-view scroll-x class="nav z margin-tb-sm">
- <view class="flex text-center">
- <block v-for="(item,index) in goodsTabData.list" :key="index">
- <view class="cu-item flex-sub nf" :class="index==goodsTabData.TabCur?'select':''" @tap="goodsTab" :data-id="index">
- <view class="cu-tag badge z bg-gradual-pink" v-if="item.tag">{{item.tag}}</view>
- <view :class="index == goodsTabData.TabCur?'text-red':''">{{item.title}}</view>
- <view class="tab-dot bg-red"/>
- </view>
- </block>
- </view>
- </scroll-view>
- </view> -->
-
- <view class="zaiui-tab-list">
- <!--商品列表-->
- <goods-list :list_data="goodsData" @listTap="goodsListTap" :show="goodsTabData.TabCur!=2 && goodsTabData.TabCur!=4?true:false"/>
-
- <!--直播列表-->
- <!-- <live-list :list_data="liveData" @listTap="liveListTap" :show="goodsTabData.TabCur==2?true:false"/> -->
-
- <!--视频列表-->
- <!-- <video-list :list_data="videoData" @listTap="videoListTap" :show="goodsTabData.TabCur==4?true:false"/> -->
- </view>
-
- <!--占位底部距离-->
- <view class="cu-tabbar-height"/>
- </view>
-
- <!--中间内容区域-分类-->
- <view class="zaiui-view-content" :class="headTab.TabCur!=0?'show':''">
-
- <!--宫格分类-->
- <grid-sort-list v-if="gridSortData.length" :list_data="gridSortData" @listTap="gridSortTap"/>
-
- <!--广告-->
-
- <!-- <view class="margin">
- <image class="zaiui-ad-img" src="/static/images/home/swiper/swiper-1.png" mode="widthFix"/>
- </view> -->
-
- <!--标题-->
- <!-- <view class="margin-bottom-sm zaiui-tab-list-title">
- <view class="flex flex-wrap">
- <view class="basis-sm text-right">
- <image class="img-aau" src="/static/zaiui/img/aau.png" lazy-load mode="widthFix"/>
- </view>
- <view class="basis-xs text-center">
- <text class="text-black text-xl text-bold">为您推荐</text>
- </view>
- <view class="basis-sm text-left">
- <image class="img-aau" src="/static/zaiui/img/aau.png" lazy-load mode="widthFix"/>
- </view>
- </view>
- </view> -->
-
- <!--商品列表-->
- <goods-list :list_data="goodsData" @listTap="goodsListTap"/>
-
- <!--占位底部距离-->
- <view class="cu-tabbar-height"/>
- </view>
-
- <!--弹出框-->
- <modal-img :show="modalShow" src="/static/images/home/sundry/reward.png" @imgTap="imgTap" @closeTap="closeTap"/>
-
- </view>
- </template>
- <script>
- //加载组件
- import welcomeTip from '@/components/zaiui-common/basics/welcome-tip';
- import swiperBackground from '@/components/zaiui-common/basics/swiper-background';
- import gridMenuList from '@/components/zaiui-common/list/grid-menu-list';
- import identifyList from '@/components/zaiui-common/list/identify-list';
- import sellQuicklyList from '@/components/zaiui-common/list/sell-quickly-list';
- import activityList from '@/components/zaiui-common/list/activity-list';
- import goodsList from '@/components/zaiui-common/list/goods-list';
- import liveList from '@/components/zaiui-common/list/live-list';
- import videoList from '@/components/zaiui-common/list/video-list';
- import footerTabbar from '@/components/zaiui-common/footer/footer-tabbar';
- import gridSortList from '@/components/zaiui-common/list/grid-sort-list';
- import modalImg from '@/components/zaiui-common/basics/modal-img';
- //======================================================================
- import _home_data from '@/static/zaiui/data/home.js'; //虚拟数据
- import _tool from '@/static/zaiui/util/tools.js';
- import barTitle from '@/components/zaiui-common/basics/bar-title';
-
-
- export default {
- name: 'home',
- components: {
- welcomeTip, swiperBackground, gridMenuList, identifyList, sellQuicklyList, activityList, goodsList, liveList, videoList, footerTabbar,
- gridSortList, modalImg,barTitle
- },
- data() {
- return {
- swiperInfo: {index: 0, show: true, welcome: true, list: []}, headInfo: {Class: "", opacity: 0,}, goodsShow: true,
- headTab: {TabCur: 0, scrollLeft: 0, list: []}, viewContent: {welcome: false,}, gridMenuData: [], identifyData: [],
- quickly: {}, activity: [], goodsTabData: {TabCur: 0, list: []}, goodsData: [], liveData: [], videoData: [],
- gridSortData: [], modalShow: false,
- place: {}
- }
- },
- props: {
- show: {
- type: Boolean,
- default: true
- },
- scrollY: {
- type: Number,
- default: 0
- },
- scrollBottom: {
- type: Number,
- default: 0
- }
- },
- watch: {
- scrollY() {
- //通知他妈的滚动了。
- this.setPageScroll(this.scrollY);
- },
- scrollBottom() {
- if(this.scrollBottom != 0) {
- //通知他妈的触底了
- this.setReachBottom();
- }
- },
- },
- created() {
-
-
- //加载虚拟数据
- // this.headTab.list = _home_data.tab();
- this.swiperInfo.list = _home_data.swiper();
- // this.gridMenuData = _home_data.nav();
- // this.identifyData = _home_data.live();
- // this.quickly.swiper = _home_data.earn();
- // this.quickly.list = _home_data.sellQuickly();
- // this.activity = _home_data.activity();
- // this.goodsTabData.list = _home_data.goodsTab();
- //商品列表数据
- // let GoodsData = _home_data.goodsList();
- //推荐感兴趣数据
- // let recommendData = _home_data.recommend();
- //把推荐感兴趣的数据,添加到商品数据里,可扩展为随机位置显示。
- // GoodsData.splice(1, 0, recommendData);
- // this.goodsData = GoodsData;
- this.headInfo.Class = '';
- this.welcomeClose(true)
-
- this.getListByCate('')
- },
- mounted() {
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 0
- });
- //次级虚拟数据加载
- this.liveData = _home_data.liveData();
- this.videoData = _home_data.videoData();
- // this.gridSortData = _home_data.gridSortData();
- },
- methods: {
- search() {
- console.log('ddddd')
- },
- getListByCate(cate_id) {
- this.req({
- url: '?l=resource.home',
- data: {type: 3, cate_id},
- success: res => {
- if(res.data.status == 1) {
- console.log(res.data.data)
- if(!cate_id) {
- this.headTab.list = [{name: '全部', id: ''},...res.data.data.cate_parent];
- this.gridMenuData = res.data.data.cate_child
- } else {
- this.gridSortData = res.data.data.cate_child
- }
- this.goodsData = res.data.data.list;
- this.place = res.data.data.place;
- }else {
- this.error = res.data.msg
- }
- }
- })
- },
- //页面被滚动
- setPageScroll(scrollTop) {
- //console.log(scrollTop);
- if(this.headTab.TabCur == 0) {
- if(scrollTop <= 100) {
- let num = scrollTop / 100;
- this.headInfo.opacity = num;
- } else if(scrollTop > 100) {
- this.headInfo.opacity = 1;
- }
- }
- },
- //触底了
- setReachBottom() {
- console.log('触底了');
- },
- //欢迎提示关闭事件
- welcomeClose(bol) {
- this.swiperInfo.welcome = bol;
- this.headTab.welcome = bol;
- let Class = this.headInfo.Class;
- this.headInfo.Class = Class.replace(/welcome/g, '');
- this.viewContent.welcome = bol;
- //设置颜色
- _tool.setBarColor(false);
- console.log(bol);
- },
- //搜索框下的tab菜单被点击
- tabSelect(e) {
- let index = e.currentTarget.dataset.id;
- this.headTab.TabCur = index;
- this.headTab.scrollLeft = (index - 1) * 60;
- if(index == 0) {
- this.swiperInfo.show = true;
- this.headInfo.opacity = 0;
- } else {
- this.swiperInfo.show = false;
- this.headInfo.opacity = 1;
- }
- uni.pageScrollTo({
- scrollTop: 0,
- duration: 0
- });
- this.getListByCate(index)
- },
- swiperChange(e) {
- this.swiperInfo.index = e.detail.current;
- },
- gridMenuTap(e) {
- console.log(e);
- uni.navigateTo({
- url: "/pages/home/sort_list"
- });
- },
- identifyTap(e) {
- console.log(e);
- },
- quicklyTap(e) {
- console.log(e);
- },
- activityTap(e) {
- console.log(e);
- },
- //商品列表上的分类tab被点击
- goodsTab(e) {
- this.goodsTabData.TabCur = e.currentTarget.dataset.id;
- // #ifdef H5
- uni.pageScrollTo({
- scrollTop: 1060,
- duration: 200
- });
- // #endif
-
- // #ifdef APP-PLUS
- uni.pageScrollTo({
- scrollTop: 1010,
- duration: 200
- });
- // #endif
- },
- goodsListTap(e) {
- console.log(e);
- // if(e.index==0) {
- uni.navigateTo({
- url: '/pages/goods/goods?id='+e.data.id
- });
- // } else if(e.index == 2) {
- // uni.navigateTo({
- // url: '/pages/goods/second_hand'
- // });
- // } else if(e.index == 3) {
- // uni.navigateTo({
- // url: '/pages/goods/second_terrace'
- // });
- // } else {
-
- // }
- },
- liveListTap(e) {
- console.log(e);
- },
- videoListTap(e) {
- console.log(e);
- },
- gridSortTap(e) {
- console.log(e);
- },
- rewardTap() {
- uni.navigateTo({
- url: "/pages/goods/reward"
- });
- },
- imgTap() {
- this.modalShow = false;
- uni.navigateTo({
- url: "/pages/goods/reward"
- });
- console.log('图片被点击');
- },
- closeTap() {
- this.modalShow = false;
- console.log('点击了关闭');
- },
- sortVueTap() {
- uni.navigateTo({
- url: "/pages/home/sort"
- });
- },
- searchTap() {
- uni.navigateTo({
- url: "/pages/home/search"
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .zaiui-head-search-box {
- // position: fixed;
- width: 100%;
- // top: 0;
- z-index: 999;
- background-color: rgb(229, 77, 66);
- // padding-top: var(--status-bar-height);
- transition: top .25s;
- padding-bottom: 10upx;
- .zaiui-search-box {
- position: relative;
- }
- .zaiui-flex-tab {
- position: relative;
- transition: opacity .25s;
- .flex {
- .basis-xxl {
- flex-basis: 90%;
- width: 90%;
- z-index: 1;
- }
- .basis-xxs {
- flex-basis: 10%;
- z-index: 1;
- width: 10%;
- }
- .sort-icon {
- font-size: 55upx;
- height: 64upx;
- line-height: 64upx;
- text-align: center;
- }
- }
- }
- }
- .zaiui-head-search-box.welcome {
- top: calc(var(--status-bar-height) + 101upx);
- transition: top .25s;
- }
- .zaiui-view-content {
- display: none;
- width: 100%;
-
- .zaiui-tab-list {
- position: relative;
- width: 100%;
- }
- }
- .zaiui-view-content.welcome {
- /* #ifdef APP-PLUS */
- margin-top: calc(var(--status-bar-height) + 180upx);
- /* #endif */
-
- /* #ifdef H5 */
- margin-top: calc(var(--status-bar-height) + 220upx);
- /* #endif */
-
- /* #ifdef MP */
- margin-top: calc(var(--status-bar-height) + 220upx);
- /* #endif */
-
- transition: all .25s;
- }
- .zaiui-view-content.show {
- display: block;
- }
- .zaiui-swiper-box {
- width: 100%;
- .screen-swiper {
- height: 230upx;
- min-height: 230upx;
- .swiper-padding {
- padding: 0 25upx;
- }
- }
- }
- .red-envelopes {
- width: 100%;
- }
- .zaiui-goods-tab-box {
- position: sticky;
- padding: 2upx 0;
- transition: all .25s;
- z-index: 999;
- background: #fff;
-
- /* #ifndef MP */
- top: calc(var(--status-bar-height) + 101upx);
- /* #endif */
-
- /* #ifdef MP */
- top: calc(var(--status-bar-height) + 161upx);
- /* #endif */
-
- .cu-tag.z {
- top: 0px;
- right: -32.72upx;
- font-size: 20upx;
- padding: 19upx 6upx;
- transform: scale(0.8);
- }
- }
- .zaiui-ad-img {
- width: 100%;
- }
- .zaiui-tab-list-title {
- .img-aau {
- width: 101.81upx;
- margin-top: 12.72upx;
- }
- .text-right {
- .img-aau {
- margin-right: 14.54upx;
- }
- }
- .text-left {
- .img-aau {
- margin-left: 14.54upx;
- }
- }
- }
- .zaiui-add-btn-view-box {
- position: fixed;
- z-index: 999;
- bottom: 181.81upx;
- right: 27.27upx;
- .cu-btn {
- margin: auto;
- width: 81.81upx;
- height: 81.81upx;
- font-weight: 800;
- border-radius: 50%;
- font-size: 36.36upx;
- border: 9.09upx solid #fff;
- box-shadow: 0 0 14.54upx 7.27upx #d0d0d0;
- }
- }
- .zaiui-home-box {
- display: none;
- }
- .zaiui-home-box.show {
- display: block;
- }
- </style>
|