Commit 06db973e authored by zhengke's avatar zhengke

修改排序

parent 9f27ab19
<template> <template>
<view class="good-list"> <view class="good-list">
<view class="sortbox"> <view class="sortbox">
<view <view class="item" @click="change(0,0)" :style="{ color: msg.OrderBy == 0 || msg.OrderBy==7 ? mainColor : '#222' }"
class="item" style="display: flex; justify-content: center;">
@click="change(0)" <text>综合</text>
:style="{ color: msg.OrderBy == 0 ? mainColor : '#222' }" <u-icon v-if="msg.OrderBy==0||msg.OrderBy==7" :name="msg.OrderBy == 7 ? 'descending' : 'ascending'" size="36" :color="msg.OrderBy == 0 || msg.OrderBy == 7 ? mainColor : '#222'"></u-icon>
>综合</view </view>
> <view class="item" @click="change(1,1)" :style="{ color: msg.OrderBy == 1 || msg.OrderBy == 5 ? mainColor : '#222' }"
<view style="display: flex; justify-content: center;">
class="item" <text>时间</text>
@click="change(1)" <u-icon v-if="msg.OrderBy==1||msg.OrderBy==5" :name="msg.OrderBy == 1 ? 'descending' : 'ascending'" size="36" :color="msg.OrderBy == 1 || msg.OrderBy == 5 ? mainColor : '#222'"></u-icon>
:style="{ color: msg.OrderBy == 1 ? mainColor : '#222' }" </view>
>最新</view <view class="item" :style="{ color: msg.OrderBy == 2 || msg.OrderBy==3 ? mainColor : '#222' }" style="display: flex; justify-content: center;"
> @click="change(2,2)">
<view <text>价格</text>
class="item" <u-icon v-if="msg.OrderBy==2||msg.OrderBy==3" :name="msg.OrderBy == 3 ? 'descending' : 'ascending'" size="36" :color="msg.OrderBy == 2 || msg.OrderBy==3 ? mainColor : '#222'"></u-icon>
:style="{ color: msg.OrderBy == 2 || msg.OrderBy==3 ? mainColor : '#222' }" </view>
style="display: flex; justify-content: center;" <view class="item" @click="change(4,3)" :style="{ color: msg.OrderBy == 4 || msg.OrderBy == 6 ? mainColor : '#222' }"
@click="change(2,1)" style="display: flex; justify-content: center;">
> <text>销量</text>
<text>价格</text> <u-icon v-if="msg.OrderBy==4||msg.OrderBy==6" :name="msg.OrderBy == 4 ? 'descending' : 'ascending'" size="36" :color="msg.OrderBy == 4 || msg.OrderBy == 6 ? mainColor : '#222'"></u-icon>
<u-icon </view>
:name="msg.OrderBy == 2 ? 'descending' : 'ascending'" </view>
size="36" <view v-if="g.length > 0" style="
:color="msg.OrderBy == 2 || msg.OrderBy==3 ? mainColor : '#222'"
></u-icon>
</view>
<view
class="item"
@click="change(4)"
:style="{ color: msg.OrderBy == 4 ? mainColor : '#222' }"
>销量</view
>
</view>
<view
v-if="g.length > 0"
style="
height: calc(100vh - 50px); height: calc(100vh - 50px);
width: calc(100vw - 20px); width: calc(100vw - 20px);
margin-left: 10px; margin-left: 10px;
overflow: hidden; overflow: hidden;
padding-top: 10px; padding-top: 10px;
" ">
> <scroll-view :scroll-y="true" @scrolltolower="lower" :enable-back-to-top="true" :enable-flex="true" :scroll-top="scrollTop"
<scroll-view @scroll="scroll" style="height: 100%; padding-bottom: 0px;">
:scroll-y="true" <goodlist :list="g"></goodlist>
@scrolltolower="lower" <u-loadmore v-if="showLoading" :status="status" :load-text="loadText" :font-size="24" :margin-top="20"
:enable-back-to-top="true" :margin-bottom="20" bg-color="#F5F5F5" />
:enable-flex="true" </scroll-view>
:scroll-top="scrollTop" </view>
@scroll="scroll" <u-empty text="没有找到商品信息" font-size="36" mode="list" v-if="g.length == 0 && !loading"></u-empty>
style="height: 100%; padding-bottom: 0px;" <view class="quick" v-if="!loading">
> <view class="item">
<goodlist :list="g"></goodlist> <u-icon name="cart-o" size="48" color="#333" />
<u-loadmore </view>
v-if="showLoading" <view class="item" @click="goTop">
:status="status" <u-icon name="arrow-up" size="48" color="#333" />
:load-text="loadText" </view>
:font-size="24" </view>
:margin-top="20" </view>
:margin-bottom="20"
bg-color="#F5F5F5"
/>
</scroll-view>
</view>
<u-empty
text="没有找到商品信息"
font-size="36"
mode="list"
v-if="g.length == 0 && !loading"
></u-empty>
<view class="quick" v-if="!loading">
<view class="item">
<u-icon name="cart-o" size="48" color="#333" />
</view>
<view class="item" @click="goTop">
<u-icon name="arrow-up" size="48" color="#333" />
</view>
</view>
</view>
</template> </template>
<script> <script>
import goodlist from '@/components/goods/list' import goodlist from '@/components/goods/list'
export default { export default {
data() { data() {
return { return {
status: "loadmore", status: "loadmore",
sortStatus: 1, sortStatus: 1,
mainColor: "", mainColor: "",
isover: false, isover: false,
loading: false, loading: false,
page: 1, page: 1,
page_count: 1, page_count: 1,
g: [], g: [],
sort: 1, sort: 1,
sortType: -1, sortType: -1,
catId: 0, catId: 0,
loadText: { loadText: {
loadmore: "轻轻上拉,加载更多", loadmore: "轻轻上拉,加载更多",
loading: "努力加载中", loading: "努力加载中",
nomore: "没有更多商品了", nomore: "没有更多商品了",
}, },
showLoading: false, showLoading: false,
sortShowType: 1, sortShowType: 1,
scrollTop: 0, scrollTop: 0,
old: { old: {
scrollTop: 0, scrollTop: 0,
}, },
coupon_id:0, coupon_id: 0,
msg:{ msg: {
pageIndex:1, pageIndex: 1,
pageSize:14, pageSize: 14,
Name:'', Name: '',
GoodsType:0, GoodsType: 0,
CategoryIds:'', CategoryIds: '',
OrderBy:0, OrderBy: 0,
}, },
newsortType:1, newsortType: 1,
}; };
}, },
components:{ components: {
goodlist goodlist
}, },
onLoad(option) { onLoad(option) {
console.log("option",option) this.mainColor = this.$uiConfig.mainColor;
this.mainColor = this.$uiConfig.mainColor; this.catId = option.cat_id;
this.catId = option.cat_id; if (option.coupon_id != undefined) {
if(option.coupon_id!=undefined){ this.coupon_id = option.coupon_id //优惠券带过来的参数
this.coupon_id = option.coupon_id //优惠券带过来的参数 }
} if (option.CategoryIds) {
if(option.CategoryIds){ this.msg.CategoryIds = option.CategoryIds;
this.msg.CategoryIds=option.CategoryIds; }
} },
}, mounted() {
mounted() { this.init();
this.init(); },
}, methods: {
methods: { scroll: function(e) {
scroll: function (e) { this.old.scrollTop = e.detail.scrollTop;
this.old.scrollTop = e.detail.scrollTop; },
}, goTop: function(e) {
goTop: function (e) { this.scrollTop = this.old.scrollTop;
this.scrollTop = this.old.scrollTop; this.$nextTick(function() {
this.$nextTick(function () { this.scrollTop = 0;
this.scrollTop = 0; });
}); },
}, change(sort, t) {
change(sort, t) { //综合
if (t == 0) {
if(t){ if (this.msg.OrderBy == 7) {
if(this.msg.OrderBy==2){ this.msg.OrderBy = 0; //升序
this.msg.OrderBy=3; } else {
}else{ this.msg.OrderBy = 7; //降序
this.msg.OrderBy=2; }
} }
}else{ //时间
this.msg.OrderBy=sort; if (t == 1) {
} if (this.msg.OrderBy == 1) {
this.g = []; this.msg.OrderBy = 5; //升序
this.msg.pageIndex=1 } else {
this.init(); this.msg.OrderBy = 1; //降序
}, }
init() { }
this.isover = false; //价格
this.loading = true; if (t == 2) {
this.showLoading = this.msg.pageIndex != 1; if (this.msg.OrderBy == 3) {
this.request2( this.msg.OrderBy = 2; //升序
{ } else {
url: '/api/AppletGoods/GetAppletGoodsPageListForZY', this.msg.OrderBy = 3; //降序
data: this.msg }
}, }
res => { //销量
console.log("res",res); if (t == 3) {
this.isloading = false; if (this.msg.OrderBy == 4) {
if(res.resultCode==1){ this.msg.OrderBy = 6; //升序
res.data.pageData.forEach(x=>{ } else {
x.marketingLogo = JSON.parse(x.marketingLogo) this.msg.OrderBy = 4; //降序
x.totalStock = 0; }
x.attr.forEach(j=>{ }
x.totalStock+=j.stock this.g = [];
}) this.msg.pageIndex = 1
}) this.init();
this.g = this.g.concat(res.data.pageData); },
this.page_count = res.data.pageCount; init() {
if (this.page_count == 1) { this.isover = false;
this.isover = true; this.loading = true;
this.status = "nomore"; this.showLoading = this.msg.pageIndex != 1;
} else { this.request2({
this.status = "loadmore"; url: '/api/AppletGoods/GetAppletGoodsPageListForZY',
} data: this.msg
} },
res => {
uni.hideNavigationBarLoading(); this.isloading = false;
} if (res.resultCode == 1) {
); res.data.pageData.forEach(x => {
// this.request( x.marketingLogo = JSON.parse(x.marketingLogo)
// { x.totalStock = 0;
// url: "", x.attr.forEach(j => {
// data: { x.totalStock += j.stock
// r: "api/default/goods-list", })
// page: this.page, })
// cat_id: this.catId, this.g = this.g.concat(res.data.pageData);
// sort: this.sort, this.page_count = res.data.pageCount;
// sort_type: this.sortType, if (this.page_count == 1) {
// keyword: "", this.isover = true;
// coupon_id: this.coupon_id, this.status = "nomore";
// }, } else {
// }, this.status = "loadmore";
// (res) => { }
// this.showLoading = true; }
// this.g = this.g.concat(res.data.list);
// this.page_count = res.data.pagination.page_count; uni.hideNavigationBarLoading();
// if (this.page_count == 1) { }
// this.isover = true; );
// this.status = "nomore"; // this.request(
// } else { // {
// this.status = "loadmore"; // url: "",
// } // data: {
// this.loading = false; // r: "api/default/goods-list",
// } // page: this.page,
// ); // cat_id: this.catId,
}, // sort: this.sort,
lower(e) { // sort_type: this.sortType,
if (this.msg.pageIndex < this.page_count) { // keyword: "",
this.status = "loading"; // coupon_id: this.coupon_id,
this.msg.pageIndex++; // },
this.init(); // },
} else { // (res) => {
this.isover = true; // this.showLoading = true;
this.status = "nomore"; // this.g = this.g.concat(res.data.list);
} // this.page_count = res.data.pagination.page_count;
}, // if (this.page_count == 1) {
clickHandler(u) { // this.isover = true;
console.log(u) // this.status = "nomore";
uni.navigateTo({ // } else {
url: u, // this.status = "loadmore";
}); // }
}, // this.loading = false;
}, // }
}; // );
},
lower(e) {
if (this.msg.pageIndex < this.page_count) {
this.status = "loading";
this.msg.pageIndex++;
this.init();
} else {
this.isover = true;
this.status = "nomore";
}
},
clickHandler(u) {
console.log(u)
uni.navigateTo({
url: u,
});
},
},
};
</script> </script>
<style> <style>
.good-list { .good-list {
height: 100%; height: 100%;
background: #f5f5f5; background: #f5f5f5;
position: relative; position: relative;
} }
.good-list .quick {
right: 50rpx; .good-list .quick {
bottom: 50rpx; right: 50rpx;
position: absolute; bottom: 50rpx;
} position: absolute;
.good-list .quick .item { }
background: #fff;
border: 1px solid #aaa;
height: 90rpx;
width: 90rpx;
color: #333;
border-radius: 90rpx;
margin-top: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
.good-list .sortbox {
display: flex;
background: #fff;
}
.good-list .sortbox .item {
height: 40px;
line-height: 40px;
flex: 1;
text-align: center;
}
.good-list .quick .item {
background: #fff;
border: 1px solid #aaa;
height: 90rpx;
width: 90rpx;
color: #333;
border-radius: 90rpx;
margin-top: 40rpx;
display: flex;
align-items: center;
justify-content: center;
}
.good-list .sortbox {
display: flex;
background: #fff;
}
.good-list .sortbox .item {
height: 40px;
line-height: 40px;
flex: 1;
text-align: center;
}
</style> </style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment