| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- <template>
- <view class="pageBg">
- <DtCustomBar title="商品列表" showBack="true" :color="dt_custom_bar" :background="dt_custom_bgcolor"></DtCustomBar>
- <view class="top" v-if="!hideTop">
- <view class="condition">
- <view class="item" :class="{'active':curActive==0}" @tap="tapActive(0)">
- <view>默认</view>
- </view>
- <view class="item" :class="{'active':curActive==1}" @tap="tapActive(1)">
- <view>销量</view>
- <image v-if="curActive!=1" src="http://139.9.103.171:1888/img/image/sort_arrow_icon.png"></image>
- <block v-else>
- <image v-if="typeList[curActive].v==1" src="http://139.9.103.171:1888/img/image/sort_down_arrow.png"></image>
- <image v-else src="http://139.9.103.171:1888/img/image/sort_up_arrow.png"></image>
- </block>
- </view>
- <view class="item" :class="{'active':curActive==2}" @tap="tapActive(2)">
- <view>价格</view>
- <image v-if="curActive!=2" src="http://139.9.103.171:1888/img/image/sort_arrow_icon.png"></image>
- <block v-else>
- <image v-if="typeList[curActive].v==1" src="http://139.9.103.171:1888/img/image/sort_down_arrow.png"></image>
- <image v-else src="http://139.9.103.171:1888/img/image/sort_up_arrow.png"></image>
- </block>
- </view>
- </view>
- </view>
- <image
- v-if="hideTop"
- src="http://139.9.103.171:1888/img/image/goodlist_head_bg.png"
- mode="widthFix"
- style="
- width: 100vw;
- position: fixed;
- top: 0;
- left: 0;
- right: 0;">
- </image>
- <view v-if="hideTop" style="margin: 0 20upx;position: relative; ">
- <image :src="path" mode="widthFix" @load="imgload" style="width: 100%;border-radius: 20upx;position: relative;"></image>
- </view>
- <scroll-view class="swiper-wrapper" scroll-y="true" :style="swiperHeight" @scrolltolower="onReachLower">
- <view>
- <!-- <image v-if="hideTop&&theme!=1" :src="path" mode="widthFix" style="width: 100%;"></image> -->
- <view class="search_results">
- <view v-if="!hideTop" class="top_height"></view>
- <view v-if="emptyType==0" class="goods_list_result">
- <DtGoodsList v-if="!hideTop" :dataList="dataList" />
- <DtGoodsListHot v-else :dataList="dataList" :theme="theme" />
- </view>
- <DtNoMore v-if="isNoMore" />
- <DtEmpty :type="emptyType" />
- </view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- import DtGoodsList from '../comps/dt_goods_list.vue'
- import DtEmpty from '../comps/dt_empty.vue'
- import DtNoMore from '../comps/dt_no_more.vue'
- import DtCustomBar from '../comps/dt_custom_bar.vue'
- import DtGoodsListHot from "../comps/dt_goods_list_hot.vue"
- export default {
- components: {
- DtGoodsList,
- DtEmpty,
- DtNoMore,
- DtCustomBar,
- DtGoodsListHot
- },
- data() {
- return {
- path:'',
- theme:1,
- hideTop:false,
- memberId: '',
- productCategoryId: '',
- paramsList: [],
- dataList: [],
- curActive: 0,
- typeList: {
- 0: null,
- 1: {
- k: 'sales',
- t: 3,
- v: 1
- },
- 2: {
- k: 'price',
- t: 3,
- v: 1
- }
- },
- dt_custom_bar:'#000000',
- dt_custom_bgcolor:'transparent',
- winHeight:''
- }
- },
- onReady() {
- //swiper高度自适应
- this.getElementHeight('.swiper-wrapper')
- },
- computed: {
- swiperHeight() {
- return "height:" + this.winHeight + "px;";
- }
- },
- methods: {
- onReachLower(ev) {
- this.onReachBottomPage();
- },
- imgload(){
- this.getElementHeight('.swiper-wrapper')
- },
- getElementHeight(element) {
- let windowHeight = 0;
- uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
- success(res) { //成功回调函数
- windowHeight=res.windowHeight //windoHeight为窗口高度,主要使用的是这个
- }
- });
- setTimeout(()=>{
- // let query = uni.createSelectorQuery().in(this);
- // query.select(element).boundingClientRect();
- // query.exec((res) => {
- // if (!res) {//如果没获取到,再调一次
- // this.getElementHeight();
- // }else {
- // this.swiperHeight = (windowHeight-res[0][0].top)+'px';
- // console.log(res[0][0].top,res)
-
- // }
-
- // })
-
- const query = uni.createSelectorQuery().in(this);
- query.selectAll(element).boundingClientRect();
- query.exec((res) => {
- if (!res) {//如果没获取到,再调一次
- this.getElementHeight();
- }else {
- this.winHeight = windowHeight - res[0][0].top;
- }
- })
-
- },20)
- },
- // async getSearchProductFilter() {
- // let data = {};
- // data.productCategoryId = this.productCategoryId;
- // let res = await this.$api.getSearchProductFilter(data);
- // console.log(res);
- // },
-
- tapActive(idx) {
- this.curActive = idx
- if (idx == 1 || idx == 2) {
- let typeList = this.typeList
- if (typeList[idx].v == 1) {
- typeList[idx].v = -1
- } else {
- typeList[idx].v = 1
- }
- this.typeList = typeList
- }
- this.isNoMore = false
- this.pageIndex = 0
- this.dataList.length = 0
- this.queryDataList()
- },
- getParams() {
- let param = this.typeList[this.curActive]
- let paramsList = this.paramsList.slice(0)
- console.log(96, paramsList)
- if (this.productCategoryId) {
- paramsList.unshift({
- k: 'productCategoryId',
- t: 1,
- v: this.productCategoryId
- })
- }
- console.log(104, paramsList, param)
- if (param) {
- paramsList.unshift(param)
- }
- console.log(108, paramsList)
- return paramsList
- },
- // 搜索
- async queryDataList() {
- let params = this.getParams()
- console.log(112, params)
- let resp = await this.$api.searchProduct({
- _isShowLoading: true,
- pageNo: this.pageIndex,
- pageSize: this.pageSize,
- memberId: this.memberId,
- params: params
- })
- let list = this.getDataList(resp)
- this.dataList = this.dataList.concat(list)
- },
- onLoadPage(options) {
- wx.hideShareMenu();
- console.log(options);
- if (this.isLoad) {
- this.memberId = this.$auth.getMemberId()
- this.paramsList = options.params ? JSON.parse(options.params) : [];
- this.productCategoryId = options.id ? options.id : '';
- // this.getSearchProductFilter();
- if (options.name) {
- uni.setNavigationBarTitle({
- title: options.name
- })
- }
- if(options.hideTop){
- this.hideTop = options.hideTop;
- // if(options.theme==1){
- // uni.setNavigationBarColor({
- // frontColor: '#ffffff',
- // backgroundColor:'#ff1104'
- // })
- this.dt_custom_bar = '#ffffff'
- // }
- }else{
- this.dt_custom_bgcolor= "#ffffff"
- }
- if(options.theme){
- this.theme = options.theme;
- }
- if(options.path){
- this.path = options.path;
- }
- }
- this.queryDataList();
- },
- },
- onReachBottom() {
- this.onReachBottomPage()
- },
- }
- </script>
- <style lang="scss" scoped>
- .top {
- position: fixed;
- left: 0;
- width: 100%;
- z-index: 100;
- .condition {
- display: flex;
- flex-direction: row;
- align-items: center;
- height: 60upx;
- justify-content: space-around;
- border-bottom: 1upx solid rgb(238, 238, 238);
- background: #fff;
- .item {
- font-size: 28upx;
- color: #333333;
- display: flex;
- flex-direction: row;
- align-items: center;
- flex: 1;
- justify-content: center;
- height: 100%;
- image {
- width: 11upx;
- height: 15upx;
- margin-left: 10upx;
- }
- }
- .active {
- color: $dt-color-primary;
- }
- }
- }
- .search_results {
-
- .top_height {
- height: 60upx;
- }
- .goods_list_result {
- background: #fff;
- }
- .no_data_wrap {
- height: 100vh;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- }
- </style>
|