123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395 |
- <template>
- <view class='productSort copy-data' :style="{height:pageHeight}">
- <!-- #ifdef APP-PLUS || MP -->
- <!-- <view class="sys-head" :style="{height:sysHeight}"></view> -->
- <!-- #endif -->
- <view class='header acea-row row-center-wrapper'>
- <view class='acea-row row-between-wrapper input'>
- <text class='iconfont icon-sousuo'></text>
- <input type='text' :placeholder="$t('搜索商品名称')" @confirm="searchSubmitValue" confirm-type='search'
- name="search" placeholder-class='placeholder'></input>
- </view>
- </view>
- <view class="scroll-box">
- <view class='aside'>
- <scroll-view scroll-y="true" scroll-with-animation='true' style="height: calc(100% - 100rpx)">
- <view class='item acea-row row-center-wrapper' :class='index==navActive?"on":""'
- v-for="(item,index) in productList" :key="index" @click='tap(index,"b"+index)'>
- <text>{{$t(item.cate_name)}}</text>
- </view>
- <!-- #ifdef APP-PLUS -->
- <view class="item" v-if="newData.status && newData.status.status"></view>
- <!-- #endif -->
- </scroll-view>
- </view>
- <view class='conter'>
- <scroll-view scroll-y="true" :scroll-into-view="toView" @scroll="scroll" scroll-with-animation='true'
- style="height: 100%;" class="conterScroll">
- <block v-for="(item,index) in productList" :key="index">
- <view class='listw' :id="'b'+index">
- <view class='title acea-row row-center-wrapper'>
- <view class='line'></view>
- <view class='name'>{{$t(item.cate_name)}}</view>
- <view class='line'></view>
- </view>
- <view class='list acea-row'>
- <block v-for="(itemn,indexn) in item.children" :key="indexn">
- <navigator hover-class='none'
- :url='"/pages/goods/goods_list/index?sid="+itemn.id+"&title="+itemn.cate_name'
- class='item acea-row row-column row-middle'>
- <view class='picture'>
- <easy-loadimage mode="widthFix" :image-src="itemn.pic"></easy-loadimage>
- <!-- <image src="/static/images/sort-img.png" v-else></image> -->
- </view>
- <view class='name line1'>{{$t(itemn.cate_name)}}</view>
- </navigator>
- </block>
- </view>
- </view>
- </block>
- <view :style='"height:"+(height-300)+"rpx;"' v-if="number<15"></view>
- </scroll-view>
- </view>
- </view>
- <tabBar v-if="!is_diy" :pagePath="'/pages/goods_cate/goods_cate'"></tabBar>
- <pageFooter v-else></pageFooter>
- </view>
- </template>
- <script>
- let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
- import {
- getCategoryList
- } from '@/api/store.js';
- import {
- mapState,
- mapGetters
- } from "vuex"
- import {
- getNavigation
- } from '@/api/public.js'
- import pageFooter from '@/components/pageFooter/index.vue'
- import tabBar from "@/pages/index/visualization/components/tabBar.vue";
- const app = getApp();
- export default {
- components: {
- pageFooter,
- tabBar
- },
- data() {
- return {
- navlist: [],
- productList: [],
- navActive: 0,
- number: "",
- is_diy: uni.getStorageSync('is_diy'),
- height: 0,
- hightArr: [],
- toView: "",
- tabbarH: 0,
- footH: 0,
- windowHeight: 0,
- newData: {},
- activeRouter: '',
- pageHeight: '100%',
- sysHeight: sysHeight,
- // #ifdef APP-PLUS
- pageHeight: app.globalData.windowHeight,
- // #endif
- lock: false
- }
- },
- computed: {
- ...mapState({
- cartNum: state => state.indexData.cartNum
- })
- },
- mounted() {
- let that = this
- // #ifdef H5
- uni.getSystemInfo({
- success: function(res) {
- that.pageHeight = res.windowHeight + 'px'
- }
- });
- // #endif
- let routes = getCurrentPages();
- let curRoute = routes[routes.length - 1].route
- this.activeRouter = '/' + curRoute
- this.getAllCategory();
- },
- methods: {
- getNav() {
- getNavigation().then(res => {
- this.newData = res.data
- })
- },
- goRouter(item) {
- var pages = getCurrentPages();
- var page = (pages[pages.length - 1]).$page.fullPath;
- if (item.link == page) return
- uni.switchTab({
- url: item.link,
- fail(err) {
- uni.redirectTo({
- url: item.link
- })
- }
- })
- },
- footHeight(data) {
- this.footH = data
- },
- infoScroll: function() {
- let that = this;
- let len = that.productList.length;
- this.number = that.productList[len - 1].children.length;
- //设置商品列表高度
- uni.getSystemInfo({
- success: function(res) {
- that.height = (res.windowHeight) * (750 / res.windowWidth) - 98;
- },
- });
- let height = 0;
- let hightArr = [];
- for (let i = 0; i < len; i++) {
- //获取元素所在位置
- let query = uni.createSelectorQuery().in(this);
- let idView = "#b" + i;
- query.select(idView).boundingClientRect();
- query.exec(function(res) {
- let top = res[0].top;
- hightArr.push(top);
- that.hightArr = hightArr
- });
- };
- },
- tap: function(index, id) {
- this.toView = id;
- this.navActive = index;
- this.$set(this, 'lock', true);
- },
- getAllCategory: function() {
- let that = this;
- getCategoryList().then(res => {
- that.productList = res.data;
- that.$nextTick(res => {
- that.infoScroll();
- })
- })
- },
- scroll: function(e) {
- let scrollTop = e.detail.scrollTop;
- let scrollArr = this.hightArr;
- if (this.lock) {
- this.$set(this, 'lock', false);
- return;
- }
- for (let i = 0; i < scrollArr.length; i++) {
- if (scrollTop >= 0 && scrollTop < scrollArr[1] - scrollArr[0]) {
- this.navActive = 0
- } else if (scrollTop >= scrollArr[i] - scrollArr[0] && scrollTop < scrollArr[i + 1] - scrollArr[
- 0]) {
- this.navActive = i
- } else if (scrollTop >= scrollArr[scrollArr.length - 1] - scrollArr[0]) {
- this.navActive = scrollArr.length - 1
- }
- }
- uni.$emit('scroll');
- },
- searchSubmitValue: function(e) {
- if (this.$util.trim(e.detail.value).length > 0)
- uni.navigateTo({
- url: '/pages/goods/goods_list/index?searchValue=' + e.detail.value
- })
- else
- return this.$util.Tips({
- title: this.$t(`搜索商品名称`)
- });
- },
- }
- }
- </script>
- <style>
- page {
- height: 100%;
- }
- </style>
- <style scoped lang="scss">
- /deep/uni-scroll-view {
- padding-bottom: 0 !important;
- }
- .sys-title {
- z-index: 10;
- position: relative;
- height: 40px;
- line-height: 40px;
- font-size: 30rpx;
- color: #333;
- background-color: #fff;
- // #ifdef APP-PLUS
- text-align: center;
- // #endif
- // #ifdef MP
- text-align: left;
- padding-left: 30rpx;
- // #endif
- }
- .sys-head {
- background-color: #fff;
- }
- .productSort {
- display: flex;
- flex-direction: column;
- //#ifdef MP
- height: calc(100vh - var(--window-top)) !important;
- //#endif
- //#ifndef MP
- height: 100vh //#endif
- }
- .productSort .header {
- width: 100%;
- height: 96rpx;
- background-color: #fff;
- border-bottom: 1rpx solid #f5f5f5;
- }
- .productSort .header .input {
- width: 700rpx;
- height: 60rpx;
- background-color: #f5f5f5;
- border-radius: 50rpx;
- box-sizing: border-box;
- padding: 0 25rpx;
- }
- .productSort .header .input .iconfont {
- font-size: 35rpx;
- color: #555;
- }
- .productSort .header .input .placeholder {
- color: #999;
- }
- .productSort .header .input input {
- font-size: 26rpx;
- height: 100%;
- width: 597rpx;
- }
- .productSort .scroll-box {
- flex: 1;
- overflow: hidden;
- display: flex;
- }
- // #ifndef MP
- uni-scroll-view {
- padding-bottom: 100rpx;
- }
- // #endif
- .productSort .aside {
- width: 180rpx;
- height: 100%;
- overflow: hidden;
- background-color: #f7f7f7;
- }
- .productSort .aside .item {
- height: 100rpx;
- width: 100%;
- font-size: 26rpx;
- color: #424242;
- text-align: center;
- }
- .productSort .aside .item.on {
- background-color: #fff;
- border-left: 4rpx solid var(--view-theme);
- width: 100%;
- color: var(--view-theme);
- font-weight: bold;
- }
- .productSort .conter {
- flex: 1;
- height: 100%;
- overflow: hidden;
- padding: 0 14rpx;
- background-color: #fff;
- position: relative;
- }
- .productSort .conter .listw {
- padding-top: 20rpx;
- }
- .productSort .conter .listw .title {
- height: 90rpx;
- }
- .productSort .conter .listw .title .line {
- width: 100rpx;
- height: 2rpx;
- background-color: #f0f0f0;
- }
- .productSort .conter .listw .title .name {
- font-size: 28rpx;
- color: #333;
- margin: 0 30rpx;
- font-weight: bold;
- }
- .productSort .conter .list {
- flex-wrap: wrap;
- }
- .productSort .conter .list .item {
- width: 177rpx;
- margin-top: 26rpx;
- }
- .productSort .conter .list .item .picture {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- }
- // .productSort .conter .list .item .picture image {
- // width: 100%;
- // height: 100%;
- // border-radius: 50%;
- // }
- .productSort .conter .list .item .picture {
- /deep/,
- /deep/image,
- /deep/.easy-loadimage,
- /deep/uni-image {
- width: 120rpx;
- height: 120rpx;
- border-radius: 50%;
- }
- }
- .productSort .conter .list .item .name {
- font-size: 24rpx;
- color: #333;
- height: 56rpx;
- line-height: 56rpx;
- width: 120rpx;
- text-align: center;
- }
- </style>
|