Commit 93df788d authored by ziyu's avatar ziyu

feat: 代码暂存

parent dbfc7724
function computClass (current,index,length) {
function computClass (current,index,length,circular) {
var allclass = "";
// 无限循环当current为最后一个的时候,select就应该是0 例如长度为10,当current为9时,select就应该是0
// if(current+1==index || (current==length-1 && index==0) ) allclass = "select";
// 无限循环当current为最后一个/两个的时候的时候,例如长度为10,当current为8/9时,select就应该是1/0
//if(current+2 == index|| (current>=length-2 && index==current-length+2))
//allclass='subright';
if(current-1 == index||(current == 0&&index==length-1))
//只有当无限循环的时候,才需要考虑末端的情况就是当current为0时,length-1在他的左边
if(current-1 == index || ( circular && current == 0 && index==length-1))
allclass='subleft';
if(current==index)
allclass='select';
if(current+1==index || (current==length-1 && index==0) )
if(current+1==index || ( circular && current==length-1 && index==0) )
allclass = "subright";
return allclass;
};
......
......@@ -18,7 +18,7 @@
data-itemid="{{index}}"
bindtap="toViewPage"
data-item="{{item}}"
class="list-item {{item.select?'delete':''}} {{tools.computClass(currentIndex,index,list.length)}}"
class="list-item {{item.select?'delete':''}} {{tools.computClass(currentIndex,index,list.length,circular)}}"
bindtouchstart="touchStart"
bindtouchend="touchEnd"
>
......@@ -44,8 +44,8 @@
},
data: {
swiperItem: 2,
current: 5,
currentIndex: 5, // 商品当前滑动到第几个
current: 1,
currentIndex: 1, // 商品当前滑动到第几个
circular: false, // 商品是否无限循环
topPage: 0,
lastPage: 0,
......@@ -65,7 +65,7 @@
{value: 14, text: '白色条纹马克杯,马克吐温同款14', imgsrc: '/static/images/peo2.jpg', price: '¥599.20', people: 2200, sku: '100004549235'},
{value: 15, text: '白色条纹马克杯,马克吐温同款15', imgsrc: '/static/images/peo3.jpg', price: '¥2399.01', people: 2200, sku: '100004549235'},{value: 11, text: '白色条纹马克杯,马克吐温同款11', imgsrc: '/static/images/test1.jpg', price: '¥9.89', people: 2200, sku: '100004549235'},
{value: 12, text: '白色条纹马克杯,马克吐温同款12', imgsrc: '/static/images/test2.png', price: '¥19.20', people: '2200', sku: '100004549235'},
]
];
},
methods: {
moveSwiper(e) {
......@@ -200,18 +200,22 @@
if (list.length <= 4) {
this.circular = false;
}
console.log(current.itemid,this.currentIndex,this.current,111)
if (current.itemid >= list.length - 1) {
this.current = this.currentIndex - 1;
}
setTimeout(function() {
let newlist = that.list.filter((item, index) => index !== +current.itemid);
// that.current = Math.max(that.current - 1, 0);
// 正常情况下,current.itemid都会比current大一个,当相等或小于的时候就有问题,要重新设置current,最小不能超过0
if(newlist.length <= that.swiperItem) {
that.swiperItem = newlist.length;
}
that.list = newlist;
if (current.itemid - that.current !==1 ) {
that.current = Math.max(that.current - 1, 0);
}
console.log(that.current,current.itemid,11)
//删除完成之后
console.log(current.itemid,that.currentIndex,that.current,222)
}, 500);
}
}
......
......@@ -168,7 +168,7 @@
<shared-popup v-if="showModal === 1" :inviteinfo="mainInfo && mainInfo.inviteRecord" @getSharedGold="getSharedGold"/>
<popup @showMenu="showMenu" :showMenus="showModal === 3"/>
<!--商品推荐列表-->
<goods-list></goods-list>
<!--<goods-list></goods-list>-->
<van-dialog id="van-dialog"/>
<van-notify id="van-notify"/>
<van-popup show="{{ cornModal }}" bind:close="cornModalClose" custom-style="background-color:transparent">
......
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