var flag = false; function showArrylist (typeFlag){ var hisHtml = ""; var list = [{"currentTime":"2018-12-28","data":[{"date":"2018-12-28 09:42:14","dateStr":"2018-12-28","msg":"你的Uni给你带来了6点积分奖励","timeStr":"09:42:14","type":1},{"date":"2018-12-28 09:42:14","dateStr":"2018-12-28","msg":"你喂食了你的Uni120g甜甜圈","timeStr":"09:42:14","type":0},{"date":"2018-12-27 18:12:55","dateStr":"2018-12-27","msg":"你喂食了你的Uni40g甜甜圈","timeStr":"18:12:55","type":0},{"date":"2018-12-27 14:16:38","dateStr":"2018-12-27","msg":"你喂食了你的Uni11g甜甜圈","timeStr":"14:16:38","type":0},{"date":"2018-12-27 13:11:06","dateStr":"2018-12-27","msg":"你喂食了你的Uni23g甜甜圈","timeStr":"13:11:06","type":0},{"date":"2018-12-27 10:48:30","dateStr":"2018-12-27","msg":"你喂食了你的Uni12g甜甜圈","timeStr":"10:48:30","type":0},{"date":"2018-12-27 09:36:33","dateStr":"2018-12-27","msg":"你的Uni给你带来了17点积分奖励","timeStr":"09:36:33","type":1},{"date":"2018-12-27 09:36:33","dateStr":"2018-12-27","msg":"你喂食了你的Uni23g甜甜圈","timeStr":"09:36:33","type":0},{"date":"2018-12-27 07:20:55","dateStr":"2018-12-27","msg":"你喂食了你的Uni86g甜甜圈","timeStr":"07:20:55","type":0}],"code":0}] var newArr = []; var timeArr = []; $(".uniDateshow").html(days); list.forEach(function(item,index){ timeArr.push(item.dateStr) }); timeArr = timeArr.filter(function(item,index,self){ return self.indexOf(item) == index }); // console.log(timeArr.length); for(var i=0; i< timeArr.length; i++) { var newJson = list.filter(function (item, index, array) { return item.dateStr == timeArr[i]; }); newArr.push(newJson); };
if(list.length > 0){ for(var i = 0; i < newArr.length; i++){ var msg = ""; var otype = ""; for(var j=0; j<newArr[i].length; j++) { if(newArr[i][j]["type"] === 0){ otype = "喂养" }else if(newArr[i][j]["type"] === 1){ otype = "积分奖励" }else if(newArr[i][j]["type"] === 2){ otype = "特别奖励" } msg += '
'+ newArr[i][j]["msg"] + '
hisHtml += '<div class="recordlistMsg"><div class="recordlistData">' + newArr[i][0]["dateStr"]+'</div>' + msg +'</div></div>';
};
复制代码
}else{ if(list.length === 0 && !flag){ hisHtml = "
近期您还没有喂养过Uni
只展示最近2周喂养记录![(".recordlistType").last().addClass("dropload-noData"); } }; if(typeFlag){](https://i-blog.csdnimg.cn/blog_migrate/7e88f8790dfb48d589adf8d408cdd2d4.png)