this.QUERY.betline(this.order_id, this.lottery_type, this.agentId, this.flag).subscribe(data => {
if (data.data != null) {
this.Nodata1 = false;
//this.betline = data.data;
console.log(data.data);
this.arr = data.data.betline.split("/");
var jsonArr = new Array();

for (var i = 0; i < this.arr.length; i++) {
this.arra = this.arr[i].split(">");
var a = new Array(); //拆分
var jso = new Array(); //几串几
var an = new Array(); //多少场
var jsonObj = {}; //几串几赋值对象

for (var j = 0; j < this.arra.length; j++) {
if (j >= 2) {
var json = {};
json['jack'] = this.arra[j].substring(this.arra[j].indexOf("*") + 1);
json['a'] = json['jack'].split("&");
for (var b = 0; b < json['a'].length; b++) {
var jj = {};
jj["jackpot"] = json['a'][b].split("|")[0]
jj["option"] = json['a'][b].substring(json['a'][b].indexOf("|") + 1)
jj["mhcode"] = this.arra[j].split("*")[0];
a.push(jj)
}
} else {
jsonObj["e" + j] = this.arra[j]
}
}
jsonArr.push({ jsonObj, data: a });
}

for (var q = 0; q < jsonArr.length; q++) {
for (var e = 0; e < jsonArr[q].data.length; e++) {
var matchCode = jsonArr[q].data[e];
var chua = jsonArr[q].jsonObj;
var isExist = false;
var isC = false;
//去重多少场次
for (var m = 0; m < an.length; m++) {
if (jsonArr[q].data[e].mhcode == an[m].mhcode && jsonArr[q].data[e].jackpot == an[m].jackpot &&
jsonArr[q].data[e].option == an[m].option) {
isExist = true;
break;
}
}
//去重几串几
for (var r = 0; r < jso.length; r++) {
if (jsonArr[q].jsonObj.e0 == jso[r].e0 && jsonArr[q].jsonObj.e1 == jso[r].e1) {

isC = true;
break;
}
}
if (!isExist) {
an.push(matchCode);
}
if (!isC) {
jso.push(chua);
}

}
}
//去重合并
var c = new Array();
for (var e = 0; e < jso.length; e++) {
var quc = jso[e];
var isExist = false;
for (var m = 0; m < c.length; m++) {
if (quc.e1 == c[m].e1) {
c[m].e0 += "," + quc.e0;
isExist = true;
break;
}
}
if (!isExist) {
c.push(quc);
}
}
this.way=c;
// console.log(c, "aaa")
//去重合并多少场比赛
var s = new Array();
for (var e = 0; e < an.length; e++) {
var matchCode = an[e];
var isExist = false;
for (var m = 0; m < s.length; m++) {
if (matchCode.mhcode == s[m].mhcode && matchCode.jackpot == s[m].jackpot) {
s[m].option += "," + matchCode.option;
isExist = true;
break;
}
}
if (!isExist) {
s.push(matchCode);
}
}
//@strat分组
var map = {},
dest = [];

for (var i = 0; i < s.length; i++) {
var ai = s[i];
if (!map[ai.mhcode]) {
dest.push({
mhcode: ai.mhcode,
jk: ai.jackpot,
data: [ai]
});
map[ai.mhcode] = ai;
} else {
for (var j = 0; j < dest.length; j++) {
var dj = dest[j];
if (dj.mhcode == ai.mhcode) {
dj.data.push(ai);
break;
}
}
}
}
//@end
this.betline = dest; //获取多少场比赛数据
// console.log(dest);

} else {
this.betline = data.data;
this.Nodata1 = true;
this.data1 = "暂无新数据";
}
}, error => {
this.Nodata1 = true;
this.data1 = "数据异常请联系开发人员";
});
posted on 2018-03-09 15:21  happiness木木  阅读(335)  评论(0编辑  收藏  举报