diff --git a/homepage.html b/homepage.html index 69167b2..c8f8969 100644 --- a/homepage.html +++ b/homepage.html @@ -310,6 +310,17 @@ }) goodsArr.push(obj); }); + /*商品自定义排序:0-100,降序排列,100第一个展示,0最后一个展示*/ + var objectArraySort =(keyName)=>{ + return (objectN, objectM)=>{ + var valueN = objectN[keyName] + var valueM = objectM[keyName] + if (valueN < valueM) return 1 + else if (valueN > valueM) return -1 + else return 0 + } + } + goodsArr.sort(objectArraySort('weight')) self.swiperDataList = goodsArr; self.goodsShow = goodsArr.length > 1; sessionStorage.setItem('goodsCount', goodsArr.length);