Commit 06db973e authored by zhengke's avatar zhengke

修改排序

parent 9f27ab19
<template>
<view class="good-list">
<view class="sortbox">
<view
class="item"
@click="change(0)"
:style="{ color: msg.OrderBy == 0 ? mainColor : '#222' }"
>综合</view
>
<view
class="item"
@click="change(1)"
:style="{ color: msg.OrderBy == 1 ? mainColor : '#222' }"
>最新</view
>
<view
class="item"
:style="{ color: msg.OrderBy == 2 || msg.OrderBy==3 ? mainColor : '#222' }"
style="display: flex; justify-content: center;"
@click="change(2,1)"
>
<view class="item" @click="change(0,0)" :style="{ color: msg.OrderBy == 0 || msg.OrderBy==7 ? mainColor : '#222' }"
style="display: flex; justify-content: center;">
<text>综合</text>
<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 class="item" @click="change(1,1)" :style="{ color: msg.OrderBy == 1 || msg.OrderBy == 5 ? mainColor : '#222' }"
style="display: flex; justify-content: center;">
<text>时间</text>
<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>
</view>
<view class="item" :style="{ color: msg.OrderBy == 2 || msg.OrderBy==3 ? mainColor : '#222' }" style="display: flex; justify-content: center;"
@click="change(2,2)">
<text>价格</text>
<u-icon
:name="msg.OrderBy == 2 ? 'descending' : 'ascending'"
size="36"
:color="msg.OrderBy == 2 || msg.OrderBy==3 ? mainColor : '#222'"
></u-icon>
<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>
</view>
<view
class="item"
@click="change(4)"
:style="{ color: msg.OrderBy == 4 ? mainColor : '#222' }"
>销量</view
>
<view class="item" @click="change(4,3)" :style="{ color: msg.OrderBy == 4 || msg.OrderBy == 6 ? mainColor : '#222' }"
style="display: flex; justify-content: center;">
<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>
</view>
<view
v-if="g.length > 0"
style="
</view>
<view v-if="g.length > 0" style="
height: calc(100vh - 50px);
width: calc(100vw - 20px);
margin-left: 10px;
overflow: hidden;
padding-top: 10px;
"
>
<scroll-view
:scroll-y="true"
@scrolltolower="lower"
:enable-back-to-top="true"
:enable-flex="true"
:scroll-top="scrollTop"
@scroll="scroll"
style="height: 100%; padding-bottom: 0px;"
>
">
<scroll-view :scroll-y="true" @scrolltolower="lower" :enable-back-to-top="true" :enable-flex="true" :scroll-top="scrollTop"
@scroll="scroll" style="height: 100%; padding-bottom: 0px;">
<goodlist :list="g"></goodlist>
<u-loadmore
v-if="showLoading"
:status="status"
:load-text="loadText"
:font-size="24"
:margin-top="20"
:margin-bottom="20"
bg-color="#F5F5F5"
/>
<u-loadmore v-if="showLoading" :status="status" :load-text="loadText" :font-size="24" :margin-top="20"
: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>
<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" />
......@@ -82,8 +49,8 @@
</template>
<script>
import goodlist from '@/components/goods/list'
export default {
import goodlist from '@/components/goods/list'
export default {
data() {
return {
status: "loadmore",
......@@ -108,78 +75,97 @@ export default {
old: {
scrollTop: 0,
},
coupon_id:0,
msg:{
pageIndex:1,
pageSize:14,
Name:'',
GoodsType:0,
CategoryIds:'',
OrderBy:0,
coupon_id: 0,
msg: {
pageIndex: 1,
pageSize: 14,
Name: '',
GoodsType: 0,
CategoryIds: '',
OrderBy: 0,
},
newsortType:1,
newsortType: 1,
};
},
components:{
components: {
goodlist
},
onLoad(option) {
console.log("option",option)
this.mainColor = this.$uiConfig.mainColor;
this.catId = option.cat_id;
if(option.coupon_id!=undefined){
if (option.coupon_id != undefined) {
this.coupon_id = option.coupon_id //优惠券带过来的参数
}
if(option.CategoryIds){
this.msg.CategoryIds=option.CategoryIds;
if (option.CategoryIds) {
this.msg.CategoryIds = option.CategoryIds;
}
},
mounted() {
this.init();
},
methods: {
scroll: function (e) {
scroll: function(e) {
this.old.scrollTop = e.detail.scrollTop;
},
goTop: function (e) {
goTop: function(e) {
this.scrollTop = this.old.scrollTop;
this.$nextTick(function () {
this.$nextTick(function() {
this.scrollTop = 0;
});
},
change(sort, t) {
if(t){
if(this.msg.OrderBy==2){
this.msg.OrderBy=3;
}else{
this.msg.OrderBy=2;
//综合
if (t == 0) {
if (this.msg.OrderBy == 7) {
this.msg.OrderBy = 0; //升序
} else {
this.msg.OrderBy = 7; //降序
}
}
//时间
if (t == 1) {
if (this.msg.OrderBy == 1) {
this.msg.OrderBy = 5; //升序
} else {
this.msg.OrderBy = 1; //降序
}
}
//价格
if (t == 2) {
if (this.msg.OrderBy == 3) {
this.msg.OrderBy = 2; //升序
} else {
this.msg.OrderBy = 3; //降序
}
}
//销量
if (t == 3) {
if (this.msg.OrderBy == 4) {
this.msg.OrderBy = 6; //升序
} else {
this.msg.OrderBy = 4; //降序
}
}else{
this.msg.OrderBy=sort;
}
this.g = [];
this.msg.pageIndex=1
this.msg.pageIndex = 1
this.init();
},
init() {
this.isover = false;
this.loading = true;
this.showLoading = this.msg.pageIndex != 1;
this.request2(
{
this.request2({
url: '/api/AppletGoods/GetAppletGoodsPageListForZY',
data: this.msg
},
res => {
console.log("res",res);
this.isloading = false;
if(res.resultCode==1){
res.data.pageData.forEach(x=>{
if (res.resultCode == 1) {
res.data.pageData.forEach(x => {
x.marketingLogo = JSON.parse(x.marketingLogo)
x.totalStock = 0;
x.attr.forEach(j=>{
x.totalStock+=j.stock
x.attr.forEach(j => {
x.totalStock += j.stock
})
})
this.g = this.g.concat(res.data.pageData);
......@@ -239,21 +225,23 @@ export default {
});
},
},
};
};
</script>
<style>
.good-list {
.good-list {
height: 100%;
background: #f5f5f5;
position: relative;
}
.good-list .quick {
}
.good-list .quick {
right: 50rpx;
bottom: 50rpx;
position: absolute;
}
.good-list .quick .item {
}
.good-list .quick .item {
background: #fff;
border: 1px solid #aaa;
height: 90rpx;
......@@ -264,16 +252,17 @@ export default {
display: flex;
align-items: center;
justify-content: center;
}
.good-list .sortbox {
}
.good-list .sortbox {
display: flex;
background: #fff;
}
.good-list .sortbox .item {
}
.good-list .sortbox .item {
height: 40px;
line-height: 40px;
flex: 1;
text-align: center;
}
}
</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