Example #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);


            initGetImage();


            cell = e.Parameter as chePiaoCellInfo;

            labForCheCi.Text        = cell.checi + "(" + cell.qishiAddress + "-" + cell.jieshuAddress + ")";
            labForShiJian.Text      = cell.train_date + "(" + cell.qishiTime + "-" + cell.jieshuTime + ")";
            labForChePiaoXinXi.Text = cell.yuPiao;

            char[] charSeatArr = cell.cell.queryLeftNewDTO.seat_feature.ToCharArray();
            for (int i = 0; i < charSeatArr.Length; i = i + 2)
            {
                zuoType a = new zuoType();
                a.nameForm = getSeatType(charSeatArr[i].ToString());
                a.seattype = charSeatArr[i].ToString();
                zuoArr.Add(a);
            }

            if (cell != null)
            {
            }
            geiUserInfo();
        }
Example #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            chePiaoCellInfo cell = e.Parameter as chePiaoCellInfo;

            if (cell != null)
            {
                labForCheCi.Text = cell.checi;


                labForLiCheng.Text = cell.liShiShiJian + cell.jieshuTime + "到达";

                chePiaoCell obj           = cell.cell;
                string      qishiAddress  = obj.queryLeftNewDTO.from_station_name + (obj.queryLeftNewDTO.start_station_name.Equals(obj.queryLeftNewDTO.from_station_name) ? "[始发]" : "[路过]");
                string      jieshuAddress = obj.queryLeftNewDTO.to_station_name + (obj.queryLeftNewDTO.end_station_name.Equals(obj.queryLeftNewDTO.to_station_name) ? "[终到]" : "[路过]");
                labForFaDaoZhan.Text = qishiAddress + "-" + jieshuAddress;

                labForKaiCheShiJian.Text = cell.train_date + " " + cell.qishiTime;
                labForLiCheng.Text       = "历时" + obj.queryLeftNewDTO.lishi + "," + (obj.queryLeftNewDTO.day_difference.Equals("0") ? "当天" : "第" + ((int.Parse(obj.queryLeftNewDTO.day_difference) + 1) + "天")) + cell.jieshuTime + "到达";

                //string jieguo =   getYuPiao(obj.queryLeftNewDTO.yp_info);
                //添加预定车票信息
                addYuPiao(obj.queryLeftNewDTO.yp_info, cell);
                HTTPRequest.init().getTouken(true);
                //查询这个车次的时刻表
                string shiKeUri = "https://kyfw.12306.cn/otn/czxx/queryByTrainNo";
                Dictionary <string, string> dicShiKe = new Dictionary <string, string>();
                dicShiKe.Add("train_no", obj.queryLeftNewDTO.train_no);
                dicShiKe.Add("from_station_telecode", obj.queryLeftNewDTO.from_station_telecode);
                dicShiKe.Add("to_station_telecode", obj.queryLeftNewDTO.to_station_telecode);
                dicShiKe.Add("depart_date", cell.train_date);
                HTTPRequest.init().sendGet(shiKeUri, dicShiKe, (JsonObject json) =>
                {
                    Debug.WriteLine(json.ToString());
                    JsonObject data   = json["data"].GetObject();
                    JsonArray dataArr = data["data"].GetArray();
                    for (int i = -1; i < dataArr.Count; i++)
                    {
                        if (i >= 0)
                        {
                            JsonObject cellshike               = dataArr[i].GetObject();
                            shiKeCell cellMode                 = JsonHelper <shiKeCell> .Deserialize(cellshike.ToString(), typeof(shiKeCell)) as shiKeCell;
                            JYHuoCheShiKeCell huocheview       = new JYHuoCheShiKeCell();
                            huocheview.labForZhanMing.Text     = cellMode.station_name;
                            huocheview.labForDaoShi.Text       = cellMode.arrive_time;
                            huocheview.labForFaShi.Text        = cellMode.start_time;
                            huocheview.LabForTingLiu.Text      = cellMode.stopover_time;
                            huocheview.labForShiGuo.Visibility = cellMode.isEnabled.Equals("true") ? Visibility.Visible : Visibility.Collapsed;
                            stackPanel.Children.Add(huocheview);
                        }
                        else if (i == -1)
                        {
                            JYHuoCheShiKeCell huocheview   = new JYHuoCheShiKeCell();
                            huocheview.labForZhanMing.Text = "站名";
                            huocheview.labForDaoShi.Text   = "到达时间(到站)";
                            huocheview.labForFaShi.Text    = "发车时间(离站)";
                            huocheview.LabForTingLiu.Text  = "停留时间";
                            huocheview.labForShiGuo.Text   = "是否驶过";
                            stackPanel.Children.Add(huocheview);
                        }
                    }
                }, (string err) =>
                {
                    Debug.WriteLine(err.ToString());
                });
            }
        }
Example #3
0
        void addYuPiao(string code, chePiaoCellInfo cellinfo)
        {
            //  string kaiTou = cheCi.Substring(0, 1);
            string jieguo = "";

            // string[] nameArr = new string[3] { "二等", "一等", "无座" };
            for (int i = 0; i < (code.Length / 10); i++)
            {
                double jiage             = getNumberJiaGe(i, code) * 0.1;
                int    shuliang          = getNumberShuLiang(i, code);
                JYChePiaoYuDingCell cell = new JYChePiaoYuDingCell();
                cell.labForDengJi.Text   = getZuoWei(i, code);
                cell.labForJiaQian.Text  = "¥" + jiage;
                cell.labForShuLiang.Text = shuliang + " 张 ";
                stackPanel.Children.Add(cell);
                cell.btnForYuDing.Click += (System.Object sender, RoutedEventArgs e) => {
                    //检查是否需要登录
                    string uriLogin = "******";
                    Dictionary <string, string> dicLogin = new Dictionary <string, string>();
                    dicLogin.Add("_json_att", "");
                    HTTPRequest.init().sendPOST(uriLogin, dicLogin, (JsonObject json) =>
                    {
                        JsonObject data = json["data"].GetObject();
                        string flag     = data["flag"].ToString();
                        //是否登陆
                        if (flag.Equals("true"))
                        {
                            //提交检查 看看是否能下单
                            string uriRequstDingDna = "https://kyfw.12306.cn/otn/leftTicket/submitOrderRequest";
                            Dictionary <string, string> dicRequest = new Dictionary <string, string>();
                            dicRequest.Add("secretStr", System.Net.WebUtility.UrlDecode(cellinfo.cell.secretStr));
                            dicRequest.Add("train_date", cellinfo.train_date);
                            dicRequest.Add("back_train_date", cellinfo.back_train_date);
                            dicRequest.Add("tour_flag", "dc");
                            dicRequest.Add("purpose_codes", "ADULT");
                            dicRequest.Add("query_from_station_name", cellinfo.cell.queryLeftNewDTO.from_station_name);
                            dicRequest.Add("query_to_station_name", cellinfo.cell.queryLeftNewDTO.to_station_name);
                            dicRequest.Add("undefined", "");
                            dicRequest.Add("myversion", "undefined");
                            HTTPRequest.init().sendPOST(uriRequstDingDna, dicRequest, (JsonObject jsonRequest) => {
                                Debug.WriteLine(jsonRequest.ToString());

                                if (jsonRequest["status"].GetBoolean())
                                {
                                    Debug.WriteLine("申请订单成功,确定订单可以继续");
                                    this.Frame.Navigate(typeof(JYDingDanXinXiTiJiao), cellinfo);
                                }
                                else
                                {
                                    Regex rege = new Regex("[\u4E00-\u9FFF]+");
                                    string me  = "";
                                    foreach (Match NextMatch in rege.Matches(jsonRequest["messages"].ToString()))
                                    {
                                        me += "," + NextMatch.Value.ToString();
                                    }

                                    Debug.WriteLine(me);
                                    MessageDialog message = new MessageDialog(me);


                                    message.ShowAsync();
                                }
                            }, (string err) => {
                                Debug.WriteLine(err.ToString());
                            });
                        }
                        else
                        {
                            //需要重新登陆
                            this.Frame.Navigate(typeof(MainPage), "购买车票验证");
                        }
                    }, (string err) => {
                    });
                };
                //jieguo += getZuoWei(i, code) + ":  ¥" + jiage + ", " + shuliang + " 张。 ";
            }
        }
        void freashData(int days)
        {
            DateTime datePicker = Convert.ToDateTime(train_date);

            datePicker = datePicker.AddDays(days);
            train_date = datePicker.Date.Year + "-" + datePicker.Date.Month.ToString("00") + "-" + datePicker.Date.Day.ToString("00");
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("leftTicketDTO.train_date", train_date);
            dic.Add("leftTicketDTO.from_station", from_station);
            dic.Add("leftTicketDTO.to_station", to_station);
            dic.Add("purpose_codes", "ADULT");

            string uristr = "https://kyfw.12306.cn/otn/leftTicket/queryT";

            HTTPRequest.init().sendGet(uristr, dic, (JsonObject json) => {
                Debug.WriteLine(json.ToString());
                if (json["data"].GetArray().Count == 0)
                {
                    MessageDialog mes = new MessageDialog("没有相关车次");
                    mes.ShowAsync();
                    return;
                }
                JsonArray arr = json["data"].GetArray();
                bindingInfo.Clear();
                titleName.Text = train_date + "(" + arr.Count + "趟)";
                for (uint i = 0; i < arr.Count; i++)
                {
                    JsonObject jsonObj   = arr.GetObjectAt(i);
                    chePiaoCell obj      = JsonHelper <chePiaoCell> .Deserialize(jsonObj.ToString(), typeof(chePiaoCell)) as chePiaoCell;
                    chePiaoCellInfo info = new chePiaoCellInfo();
                    info.train_date      = train_date;

                    info.back_train_date = DateTime.Now.Date.Year + "-" + DateTime.Now.Date.Month.ToString("00") + "-" + DateTime.Now.Date.Day.ToString("00");
                    info.cell            = obj;
                    info.checi           = obj.queryLeftNewDTO.station_train_code;


                    info.qishiAddress  = (obj.queryLeftNewDTO.start_station_name.Equals(obj.queryLeftNewDTO.from_station_name) ? "始" : "过") + obj.queryLeftNewDTO.from_station_name;
                    info.jieshuAddress = (obj.queryLeftNewDTO.end_station_name.Equals(obj.queryLeftNewDTO.to_station_name) ? "终" : "过") + obj.queryLeftNewDTO.to_station_name;
                    info.qishiTime     = obj.queryLeftNewDTO.start_time + "开";
                    info.jieshuTime    = obj.queryLeftNewDTO.arrive_time + "到";
                    info.yuPiao        = obj.queryLeftNewDTO.yw_num;
                    info.liShiShiJian  = "历时:" + obj.queryLeftNewDTO.lishi + "(" + obj.queryLeftNewDTO.day_difference + "天)";

                    string yuPiao = "【余票】";
                    //if (!obj.queryLeftNewDTO.gr_num.Equals("--"))
                    //{
                    //    yuPiao += "  高级软卧:" + obj.queryLeftNewDTO.gr_num;
                    //}
                    //if (!obj.queryLeftNewDTO.qt_num.Equals("--"))
                    //{
                    //    yuPiao += "  其他:" + obj.queryLeftNewDTO.qt_num;
                    //}
                    //if (!obj.queryLeftNewDTO.rw_num.Equals("--"))
                    //{
                    //    yuPiao += "  软卧:" + obj.queryLeftNewDTO.rw_num;
                    //}
                    //if (!obj.queryLeftNewDTO.rz_num.Equals("--"))
                    //{
                    //    yuPiao += "  软座:" + obj.queryLeftNewDTO.rz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.tz_num.Equals("--"))
                    //{
                    //    yuPiao += "  特等座:" + obj.queryLeftNewDTO.tz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.wz_num.Equals("--"))
                    //{
                    //    yuPiao += "  无座:" + obj.queryLeftNewDTO.wz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.yw_num.Equals("--"))
                    //{
                    //    yuPiao += "  硬卧:" + obj.queryLeftNewDTO.yw_num;
                    //}
                    //if (!obj.queryLeftNewDTO.yz_num.Equals("--"))
                    //{
                    //    yuPiao += "  硬座:" + obj.queryLeftNewDTO.yz_num;
                    //}
                    //if (!obj.queryLeftNewDTO.ze_num.Equals("--"))
                    //{
                    //    yuPiao += "  二等座:" + obj.queryLeftNewDTO.ze_num;
                    //}
                    //if (!obj.queryLeftNewDTO.zy_num.Equals("--"))
                    //{
                    //    yuPiao += "  一等座:" + obj.queryLeftNewDTO.zy_num;
                    //}
                    //if (!obj.queryLeftNewDTO.swz_num.Equals("--"))
                    //{
                    //    yuPiao += "  商务座:" + obj.queryLeftNewDTO.swz_num;
                    //}
                    yuPiao += getYuPiao(obj.queryLeftNewDTO.yp_info);
                    if (obj.buttonTextInfo.Equals("预订"))
                    {
                        info.yuPiao = yuPiao;
                    }
                    else
                    {
                        info.yuPiao = obj.buttonTextInfo;
                    }

                    bindingInfo.Add(info);
                }
            }, (string err) => {
                Debug.WriteLine(err);
            });
        }