编辑代码

seatTypeCodeForName = {
    "1": "硬座",
    "2": "软座",
    "3": "硬卧",
    "4": "软卧",
    "6": "高级软卧",
    "9": "商务座",
    "P": "特等座",
    "A": "高级动卧",
    "D": "优选一等座",
    "M": "一等座",
    "O": "二等座",
    "I": "一等卧",
    "J": "二等卧",
    "F": "动卧",
    "H": "其他",
    "WZ": "无座",
    "W": "无座"
}

train_no = '39000K144008';
dw_flag = '0#0#0#0#z#0#43#z';
seat_types = '3411';
yp_ex = '304010W0';
yp_info_new = '3006550016400995000310019500211001953043';

var dh = function (du, dt) {
    this.value = du;
    this.key = dt
};

var dr = new Array();
var dc = {};


if (seat_types && seat_types.length > 0) {
    for (var dl = 0; dl < seat_types.length; dl++) {
        var dg = seat_types.substring(dl, dl + 1);
        var de = seatTypeCodeForName[dg];
        if (!de) {
            continue
        }
        if (!dc[dg]) {
            dr.push(new dh(de, dg));
            dc[dg] = true
        }
    }
}

console.log(dr, dc)

var dq = "9ADMO6IJF4321";
var c9 = new Array();
for (var dp = 0; dp < dq.length; dp++) {
    var dk = dq.substring(dp, dp + 1);
    for (var dl = 0; dl < dr.length; dl++) {
        if (dr[dl].key == dk) {
            c9.push(dr[dl]);
            break
        }
    }
}

console.log(c9)

function e(dj, di, dg) {
    var da = dg.seat_types;
    var dh = dg.station_train_code + "次列车,";
    var db = dj.length / 10;
    for (var dd = 0; dd < db; dd++) {
        var dc = dj.substring(10 * dd, 10 * (dd + 1));
        var c9 = dc.substring(0, 1);
        var df = dc.substring(1, 6) / 10;
        var de = dc.substring(6, 10);
        if ("SWZ_" == di) {
            if (c9 == "9") {
                dh += "商务座票价" + df + "元";
                return dh
            }
        }
        if ("TZ_" == di) {
            if (c9 == "P") {
                dh += "特等座票价" + df + "元";
                return dh
            }
        }
        if ("ZY_" == di) {
            if (c9 == "M") {
                dh += "一等座票价" + df + "元";
                return dh
            }
        }
        if ("ZE_" == di) {
            if (c9 == "O") {
                dh += "二等座票价" + df + "元";
                return dh
            }
            if (c9 == "S") {
                dh += "二等包座票价" + df + "元";
                return dh
            }
        }
        if ("GR_" == di) {
            if (c9 == "6") {
                dh += "高级软卧票价" + df + "元";
                return dh
            }
            if (c9 == "A") {
                dh += "高级动卧票价" + df + "元";
                return dh
            }
        }
        if ("RW_" == di) {
            if (c9 == "4") {
                dh += "软卧票价" + df + "元";
                return dh
            }
            if (c9 == "I") {
                dh += "一等卧票价" + df + "元";
                return dh
            }
        }
        if ("SRRB_" == di) {
            if (c9 == "F") {
                dh += "动卧票价" + df + "元";
                return dh
            }
        }
        if ("YW_" == di) {
            if (c9 == "3") {
                dh += "硬卧票价" + df + "元";
                return dh
            }
            if (c9 == "J") {
                dh += "二等卧票价" + df + "元";
                return dh
            }
        }
        if ("RZ_" == di) {
            if (c9 == "2") {
                dh += "软座票价" + df + "元";
                return dh
            }
        }
        if ("YZ_" == di) {
            if (c9 == "1") {
                dh += "硬座票价" + df + "元";
                return dh
            }
        }
        if ("WZ_" == di) {
            if (de >= 3000) {
                dh += "无座票价" + df + "元";
                return dh
            }
        }
        if ("QT_" == di) {
            if (c9 != "9" && c9 != "P" && c9 != "M" && c9 != "O" && c9 != "S" && c9 != "6" && c9 != "4" && c9 != "I" && c9 != "F" && c9 != "3" && c9 != "J" && c9 != "2" && c9 != "1" && de < 3000) {
                dh += "其他席位票价" + df + "元";
                return dh
            }
        }
    }
    return ""
}

function dw(da) {
    var tags = new Array();
    if ("5" == da.split("#")[0]) {
        tags.push("智能动车组");
    }
    if (da.split("#").length > 1 && "1" == da.split("#")[1]) {
        tags.push("复兴号");
    }
    if (da.split("#").length > 2 && "Q" == da.split("#")[2].substring(0, 1)) {
        tags.push("静音车厢");
    }
    if (da.split("#").length > 2 && "R" == da.split("#")[2].substring(0, 1)) {
        tags.push("温馨动卧");
    }
    if (da.split("#").length > 5 && "D" == da.split("#")[5]) {
        tags.push("动感号");
    }
    if (da.split("#").length > 6 && "z" != da.split("#")[6]) {
        tags.push("支持选铺");
    }
    if (da.split("#").length > 7 && "z" != da.split("#")[7]) {
        tags.push("老年优惠");
    }
    return tags;
}

console.log(dw(dw_flag))