• LoveTao项目源码共享


    设计不是很合理,但还可以实现不错的功能,只贴出部分代码,大家感兴趣的话,可以把源码发到你邮箱!

    代码分为Common\BLL\Model\UI

    代码:Common

    <1>.CommonHelp类

    View Code
    using System;
    using System.Text;
    using System.Collections.Generic;
    using System.Linq;

    namespace Common
    {
    publicclass ComHelper
    {
    publicstaticbyte[] postData;

    #region 创建签名
    ///<summary>
    /// 创建签名
    ///</summary>
    ///<param name="parameters"></param>
    ///<param name="secret"></param>
    ///<returns></returns>
    protectedstaticstring CreateSign(IDictionary<string, string> parameters, string secret)
    {
    parameters.Remove(
    "sign");
    IDictionary
    <string, string> d =new Dictionary<string, string>(); ;
    Dictionary
    <string, string> dict =new Dictionary<string, string>(parameters);
    var sortedDict
    = (from entry in dict orderby entry.Key ascending select entry);
    foreach (var k in sortedDict)
    {
    d.Add(k.Key, k.Value);
    }

    IDictionary
    <string, string> sortedParams = d;
    IEnumerator
    <KeyValuePair<string, string>> dem = sortedParams.GetEnumerator();
    StringBuilder query
    =new StringBuilder(secret);
    while (dem.MoveNext())
    {
    string key = dem.Current.Key;
    string value = dem.Current.Value;
    if (!string.IsNullOrEmpty(key) &&!string.IsNullOrEmpty(value))
    {
    query.Append(key).Append(value);
    }
    }
    query.Append(secret);

    MD5Helper md5
    = MD5Helper.Create();
    byte[] bytes = md5.ComputeHash(Encoding.UTF8.GetBytes(query.ToString()));
    StringBuilder result
    =new StringBuilder();
    for (int i =0; i < bytes.Length; i++)
    {
    string hex = bytes[i].ToString("X");
    if (hex.Length ==1)
    {
    result.Append(
    "0");
    }
    result.Append(hex);
    }
    return result.ToString();
    }
    #endregion

    #region 组装文本过程
    ///<summary>
    /// 组装文本过程
    ///</summary>
    ///<param name="parameters"></param>
    ///<returns></returns>
    protectedstaticstring PostData(IDictionary<string, string> parameters)
    {
    StringBuilder postData
    =new StringBuilder();
    bool hasParam =false;
    IEnumerator
    <KeyValuePair<string, string>> dem = parameters.GetEnumerator();
    while (dem.MoveNext())
    {
    string name = dem.Current.Key;
    string value = dem.Current.Value;
    // 忽略参数名或参数值为空的参数
    if (!string.IsNullOrEmpty(name) &&!string.IsNullOrEmpty(value))
    {
    if (hasParam)
    {
    postData.Append(
    "&");
    }
    postData.Append(name);
    postData.Append(
    "=");
    postData.Append(Uri.EscapeDataString(value));
    hasParam
    =true;
    }
    }
    return postData.ToString();
    }
    #endregion

    #region 获取数据
    ///<summary>
    /// 获取数据
    ///</summary>
    ///<param name="appkey">appKey</param>
    ///<param name="appSecret">appSecret</param>
    ///<param name="method">method</param>
    ///<param name="session">session</param>
    ///<param name="param">param</param>
    ///<returns></returns>
    publicstaticbyte[] GetData(string appkey, string appSecret, string method, string session, IDictionary<string, string> param)
    {
    #region -----API系统参数----
    param.Add(
    "app_key", appkey);
    param.Add(
    "method", method);
    param.Add(
    "session", session);
    param.Add(
    "timestamp", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
    param.Add(
    "format", "xml");
    param.Add(
    "v", "2.0");
    param.Add(
    "sign_method", "md5");
    param.Add(
    "sign", CreateSign(param, appSecret));
    #endregion
    postData
    = Encoding.UTF8.GetBytes(PostData(param));
    return postData;
    }
    #endregion
    }
    }

    <2>.ReaderXmlHelper.cs

    View Code
    using System;
    using System.IO;
    using System.Text;
    using System.Xml;
    using System.Collections.Generic;

    namespace Common
    {
    publicclass ReadXmlHelper
    {
    ///<summary>
    /// 对XML进行处理
    ///</summary>
    ///<param name="xml">xml</param>
    ///<returns>处理的字符串</returns>
    publicstaticstring ReadXml(string xml)
    {
    StringBuilder builder
    =new StringBuilder();

    using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
    {
    while (reader.Read())
    {
    switch (reader.NodeType)
    {
    //注意:此处对于结点,在节点前加分号,将所有节点断开(使用根节点)
    case XmlNodeType.EndElement: builder.Append(reader.Name +"|"); break;
    case XmlNodeType.Text: builder.Append(reader.Value +"#"); break;
    }

    }
    }
    return builder.ToString();
    }

    ///<summary>
    /// 对象集合写入字典(可以用多用户对象调试单用户)
    ///</summary>
    ///<param name="xml">XML文本</param>
    ///<param name="type">处理的类型,如:User</param>
    ///<returns>多用户字典</returns>
    publicstatic IDictionary<int, IDictionary<string, string>> GetDic(string xml, string type)
    {
    //try
    //{
    string content = ReadXml(xml).Replace("<span class=H>", "").Replace("</span>", "");
    IDictionary
    <int, IDictionary<string, string>> dits =new Dictionary<int, IDictionary<string, string>>();
    IDictionary
    <string, string> dit =new Dictionary<string, string>();
    int i =0;
    string[] arrays = content.Split('|');
    foreach (string item in arrays)
    {
    if (item == type)//最好是,根节点
    {
    if (dit.Count >0)
    { i
    ++; dits.Add(i, dit); dit =new Dictionary<string, string>(); }
    }
    if (!string.IsNullOrEmpty(item))
    {
    string[] param = item.Split('#');

    if (!string.IsNullOrEmpty(param[0]))//注意:必须key值不为空,但value值可以为空
    {
    dit.Add(param[param.Length
    -1], param[0]);
    }
    }
    }
    return dits;
    //}
    // catch(Exception)
    // {

    // }
    }
    }
    }

    代码:BLL

    <1>.CollectItemBLL.cs

    View Code
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Xml;
    using Model;

    namespace BLL
    {
    publicclass CollectItemBLL
    {
    publicstatic List<CollectItem> collects =null;
    publicstaticint CoTotalNum =0;
    publicstatic List<CollectItem> GetCollects(string xml)
    {
    collects
    =new List<CollectItem>();
    IDictionary
    <int, IDictionary<string, string>> dits = GetDic(xml, "collect_item");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    CollectItem collect
    =new CollectItem();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"item_numid": collect.Item_Numid = value; break;
    case"title": collect.Title = value; break;
    case"total_results": CoTotalNum = Convert.ToInt32(value); break;
    }
    }
    collects.Add(collect);
    }
    return collects;
    }

    #region CollectionDic
    protectedstaticstring ReadXml(string xml)
    {
    StringBuilder builder
    =new StringBuilder();

    using (XmlReader reader = XmlReader.Create(new StringReader(xml)))
    {
    while (reader.Read())
    {
    switch (reader.NodeType)
    {
    //注意:此处对于结点,在节点前加分号,将所有节点断开(使用根节点)
    case XmlNodeType.EndElement: builder.Append(reader.Name +"|"); break;
    case XmlNodeType.Text: builder.Append(reader.Value +"#"); break;
    }

    }
    }
    return builder.ToString();
    }
    publicstatic IDictionary<int, IDictionary<string, string>> GetDic(string xml, string type)
    {
    string content = ReadXml(xml).Replace("<span class=H>", "").Replace("</span>", "") + type;
    IDictionary
    <int, IDictionary<string, string>> dits =new Dictionary<int, IDictionary<string, string>>();
    IDictionary
    <string, string> dit =new Dictionary<string, string>();
    int i =0;
    string[] arrays = content.Split('|');
    foreach (string item in arrays)
    {
    if (item == type)//最好是,根节点
    {
    if (dit.Count >0)
    { i
    ++; dits.Add(i, dit); dit =new Dictionary<string, string>(); }
    }
    if (!string.IsNullOrEmpty(item))
    {
    string[] param = item.Split('#');

    if (!string.IsNullOrEmpty(param[0]))//注意:必须key值不为空,但value值可以为空
    {
    dit.Add(param[param.Length
    -1], param[0]);
    }
    }
    }
    return dits;
    }
    #endregion
    }
    }

    <2>.ItemCatsBLL.cs

    View Code
    using System;
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    publicclass ItemCatsBLL
    {
    ///<summary>
    /// 获取商品类目集合列表
    ///</summary>
    ///<param name="xml"></param>
    ///<returns></returns>
    publicstatic List<ItemCat> GetItemCats(string xml)
    {
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "item_cat");
    List
    <ItemCat> itemCats =new List<ItemCat>();
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    ItemCat item
    =new ItemCat();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    if (key =="cid") {item.Cid = value; }
    if (key =="name") {item.Name = value; }
    }
    itemCats.Add(item);
    }
    return itemCats;
    }
    }
    }

    <3>.LoadBLL.cs

    View Code
    using System;
    using System.Collections.Generic;

    namespace BLL
    {
    publicclass LoadBLL
    {
    publicstatic List<string> Load =new List<string>();
    ///<summary>
    /// 获取昵称和session
    ///</summary>
    ///<param name="nick">昵称</param>
    ///<param name="session">会话</param>
    ///<returns></returns>
    publicstatic List<string> GetLoad(string nick,string session)
    {
    Load
    =new List<string>();
    Load.Add(nick);
    Load.Add(session);
    return Load;
    }
    }
    }

    <4>.LogisticsBLL.cs

    View Code
    using Common;
    using Model;
    using System.Collections.Generic;

    namespace BLL
    {
    publicclass LogisticsBLL
    {
    publicstatic List<LogisticsCompany> GetLogistics(string xml)
    {
    List
    <LogisticsCompany> logistics =new List<LogisticsCompany>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "logistics_company");

    foreach (IDictionary<string, string> dic in dits.Values)
    {
    LogisticsCompany company
    =new LogisticsCompany();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"id": company.ID = value; break;
    case"code": company.Cod = value; break;
    case"name": company.Name = value; break;
    case"reg_mail_no": company.Reg_Mail_No = value; break;
    }
    }
    logistics.Add(company);
    }
    return logistics;
    }
    }
    }

    <5>.ProductsBLL.cs

    View Code
    using System;
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    publicclass ProductsBLL
    {
    publicstaticint currentIndex =0;
    publicstatic List<Product> products =null;

    ///<summary>
    /// 获取商品集合列表
    ///</summary>
    ///<param name="xml"></param>
    ///<returns></returns>
    publicstatic List<Product> GetProducts(string xml)
    {
    products
    =new List<Product>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "item");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    Product product
    =new Product();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"title": product.Title = value; break;
    case"nick": product.Nick = value; break;
    case"pic_url": product.Pic_url = value+"_sum.jpg"; break;
    case"price": product.Price = value; break;
    case"delist_time": product.Delist_time = value; break;
    case"post_fee": product.Post_fee = value; break;
    case"express_fee": product.Express_fee = value; break;
    case"ems_fee": product.Ems_fee = value; break;
    case"score": product.Score = (value); break;
    case"volume": product.Volume = (value); break;
    case"city": product.City = value; break;
    case"state": product.State = value; break;
    case"num": product.Num= value; break;
    case"num_iid": product.Num_iid = value; break;
    case"wap_detail_url": product.WapUrl = value; break;
    case"type":
    if (value =="fixed")
    {
    product.Type
    ="一口价";
    }
    if (value =="auction")
    {
    product.Type
    ="拍卖";
    }
    break;
    default: break;
    }
    }
    products.Add(product);
    }
    return products;
    }
    }
    }

    <6>.RateBLL.cs

    View Code
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    publicclass RateBLL
    {
    publicstatic List<TradeRate> rates =null;
    //tid,oid,role,nick,result,created,rated_nick,item_title,item_price,content,replay
    publicstatic List<TradeRate> GetRates(string xml)
    {
    rates
    =new List<TradeRate>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "trade_rate");

    foreach (IDictionary<string, string> dic in dits.Values)
    {
    TradeRate rate
    =new TradeRate();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"tid": rate.Tid = value; break;
    case"oid": rate.Oid = value; break;
    case"nick": rate.Nick = value; break;
    case"created": rate.Created = value; break;
    case"rated_nick": rate.Rated_Nick = value; break;
    case"item_title": rate.Item_Title = value; break;
    case"item_price": rate.Item_Price = value; break;
    case"content": rate.Content = value; break;
    case"replay": rate.Replay = value; break;
    case"role": if (value =="seller") { rate.Role ="卖家"; } else { rate.Role ="买家"; }break;
    case"result": switch (value)
    {
    case"good": rate.Result ="好评"; break;
    case"bad": rate.Result ="差评"; break;
    case"neutral": rate.Result ="中评"; break;
    }
    break;
    }
    }
    rates.Add(rate);
    }
    return rates;
    }
    }
    }

    <7>.SellerCatBLL.cs

    View Code
    using System.Collections.Generic;
    using Common;
    using Model;


    namespace BLL
    {
    publicclass SellerCatBLL
    {
    publicstatic List<SellerCat> sellerCats =null;

    publicstatic List<SellerCat> GetSellerCats(string xml)
    {
    sellerCats
    =new List<SellerCat>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "seller_cat");

    foreach (IDictionary<string, string> dic in dits.Values)
    {
    SellerCat sellerCat
    =new SellerCat();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"cid": sellerCat.Cid = value; break;
    case"name": sellerCat.Name = value; break;
    }
    }
    sellerCats.Add(sellerCat);
    }
    return sellerCats;
    }
    }
    }

    <8>.ShopBLL.cs

    View Code
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    publicclass ShopBLL
    {
    publicstaticint currentIndex =0;
    publicstatic List<Shop> shops =null;

    publicstatic List<Shop> GetShops(string xml)
    {
    List
    <Shop> shops =new List<Shop>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "shop");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    Shop shop
    =new Shop();
    ShopScore shopScore
    =new ShopScore();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"sid": shop.Sid = value; break;
    case"cid": shop.Cid = value; break;
    case"title": shop.Title = value; break;
    case"nick": shop.Nick = value; break;
    case"created": shop.Created = value; break;
    case"modified": shop.Modified = value; break;

    case"shop_score": shop.Shop_Score = shopScore; break;
    case"item_score":shopScore. Item_Score = value; break;
    case"service_score": shopScore.Service_Score = value; break;
    case"delivery_score":shopScore. Delivery_Score = value; break;
    }
    }
    shops.Add(shop);
    }
    return shops;
    }
    }
    }

    <9>.ShopCatsBLL.cs

    View Code
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    publicclass ShopCatsBLL
    {
    //cid,parent_cid,name,is_parent
    publicstatic List<ShopCat> shopCats =null;
    publicstatic List<ShopCat> GetShopCats(string xml)
    {
    shopCats
    =new List<ShopCat>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "shop_cat");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    ShopCat shopCat
    =new ShopCat();
    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"cid": shopCat.Cid = value; break;
    case"name": shopCat.Name = value; break;
    }
    }
    shopCats.Add(shopCat);
    }
    return shopCats;
    }
    }
    }

    <10>.TransitStepBLL.cs

    View Code
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    publicclass TransitStepBLL
    {
    publicstatic List<TransitStepInfo> GetTransitSteps(string xml)
    {
    List
    <TransitStepInfo> trans =new List<TransitStepInfo>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "transit_step_info");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    TransitStepInfo transitStep
    =new TransitStepInfo();

    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"status_time": transitStep.Status_Time = value; break;
    case"status_desc": transitStep.Status_Desc = value; break;
    }
    }
    trans.Add(transitStep);
    }
    return trans;
    }
    publicstatic Transit GetTransit(string xml)
    {
    Transit transit
    =new Transit();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "transit_step_info");
    IDictionary
    <string, string> dic = dits[0];

    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"tid": transit.Tid = value; break;
    case"status": transit.Status = value; break;
    case"out_sid": transit.Out_Sid = value; break;
    case"company_name": transit.Company_Name = value; break;
    }
    }
    return transit;
    }
    }
    publicclass Transit
    {
    privatestring out_sid;
    privatestring company_name;
    privatestring tid;
    privatestring status;

    publicstring Out_Sid
    {
    get { return out_sid; }
    set { out_sid = value; }
    }
    publicstring Company_Name
    {
    get { return company_name; }
    set { company_name = value; }
    }
    publicstring Tid
    {
    get { return tid; }
    set { tid = value; }
    }
    publicstring Status
    {
    get { return status; }
    set { status = value; }
    }
    }
    }

    <11>.UsersBLL.cs

    View Code
    using System;
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    publicclass UsersBLL
    {
    ///<summary>
    /// 获取用户集合列表
    ///</summary>
    ///<param name="xml"></param>
    ///<returns></returns>
    publicstatic List<User> GetUsers(string xml)
    {
    List
    <User> users =new List<User>();
    IDictionary
    <int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "user");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    User user
    =new User();
    UserCredit credit
    =new UserCredit();
    Location location
    =new Location();

    foreach (KeyValuePair<string, string> kvp in dic)
    {
    bool bo;
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case"user_id": user.UserId = value; break;
    case"uid": user.Uid = value; break;
    case"nick": user.Nick = value; break;
    case"avatar": user.Avatar = value; break;
    case"alipay_no": user.AlipayNo = value; break;
    case"birthday": user.Birthday = value; break;
    case"email": user.Email = value; break;
    case"created": user.Created = value; break;
    case"last_visit": user.Last_Visit = value; break;
    case"alipay_account": user.AlipayAccount = value; break;
    case"sex": if (value =="m") { user.Sex =""; } else { user.Sex =""; } break;

    case"zip": location.Zip = value; break;
    case"address": location.Address = value; break;
    case"city": location.City = value; break;
    case"state": location.Sate = value; break;
    case"country": location.Country = value; break;
    case"district": location.District = value; break;
    case"location": user.Location = location; break;

    case"level": credit.Level = Convert.ToInt64(value); break;
    case"score": credit.Score = Convert.ToInt64(value); break;
    case"total_num": credit.TotalNum = Convert.ToInt64(value); break;
    case"good_num": credit.GoodNum = Convert.ToInt64(value); break;
    case"seller_credit": user.SellerCredit = credit; break;
    case"buyer_credit": user.Buyer_Credit = credit; break;
    case"alipay_bind":
    if (value =="bind")
    {
    user.Alipay_Bind
    ="已绑定";
    }
    else
    {
    user.Alipay_Bind
    ="未绑定";
    }
    break;
    case"has_shop": bo = Convert.ToBoolean(value);
    if (bo)
    {
    user.Has_Shop
    ="开过店铺";
    }
    else
    {
    user.Has_Shop
    ="未开过店铺";
    }
    break;
    case"consumer_protection": bo = Convert.ToBoolean(value);
    if (bo)
    {
    user.ConsumerProtection
    ="已参加消保";
    }
    else
    {
    user.ConsumerProtection
    ="未参加消保";
    }
    break;
    case"promoted_type":
    if (value =="authentication")
    {
    user.PromotedType
    ="实名认证";
    }
    else
    {
    user.PromotedType
    ="没有实名认证";
    }
    break;
    case"magazine_subscribe": bo = Convert.ToBoolean(value);
    if (bo)
    {
    user.Magazine_Subscribe
    ="已订阅淘宝天下杂志";
    }
    else
    {
    user.Magazine_Subscribe
    ="未订阅淘宝天下杂志";
    }
    break;
    default: break;
    }
    }
    users.Add(user);
    }
    return users;
    }
    }
    }

    <12>.TradesBLL.cs

    View Code
    using System.Collections.Generic;
    using Common;
    using Model;

    namespace BLL
    {
    public class TradesBLL
    {
    public static List<Trade> trades = null;

    public static List<Trade> GetOrderTrades(string xml)
    {
    trades = new List<Trade>();
    IDictionary<int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "trade");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    Trade trade = new Trade();
    Order order = new Order();
    PromotionDetail promotion = new PromotionDetail();
    List<Order> orders = new List<Order>();
    List<PromotionDetail> promoyions = new List<PromotionDetail>();

    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case "cid": order.Cid = value; break;
    case "oid": order.Oid = value; break;
    case "num": order.Num = value; break;
    case "order": orders.Add(order); break;
    case "title": order.Title = value; break;
    case "price": order.Price = value; break;
    case "sku_id": order.Sku_ID = value; break;
    case "orders": trade.Orders = orders; break;
    case "num_iid": order.Num_iid = value; break;
    case "payment": order.Payment = value; break;
    case "modifed": order.Modifed = value; break;
    case "pic_path": order.Pic_Path = value; break;
    case "snapshot": order.Snapshot = value; break;
    case "refund_id": order.Refund_Id = value; break;
    case "total_fee": order.Total_Fee = value; break;
    case "buyer_nick": order.Buyer_Nick = value; break;
    case "adjust_fee": order.Adjust_Fee = value; break;
    case "seller_type": order.Seller_Type = value; break;
    case "discount_fee": order.Discount_Fee = value; break;
    case "item_meal_id": order.Item_Meal_id = value; break;
    case "snapshot_url": order.Snapshot_Url = value; break;
    case "refund_status": order.Refund_Status = value; break;
    case "item_meal_name": order.Item_Meal_Name = value; break;
    case "timeout_action_time": order.Timeout_Action_Time = value; break;
    case "sku_properties_name": order.Sku_Properties_Name = value; break;
    case "buyer_rate":if (value == "true") { order.Buyer_Rate = "已评论"; }
    else { order.Buyer_Rate = "未评论"; }break;
    case "seller_rate":if (value == "true") { order.Seller_Rate = "已评论"; }
    else { order.Seller_Rate = "未评论"; } break;
    case "status": string statue = value;
    switch (statue)
    {
    case "TRADE_CLOSED": statue = "交易关闭"; break;
    case "TRADE_FINISHED": statue = "交易成功"; break;
    case "WAIT_BUYER_PAY": statue = "等待买家付款"; break;
    case "TRADE_BUYER_SIGNED": statue = "买家已签收"; break;
    case "TRADE_CLOSED_BY_TAOBAO": statue = "交易关闭"; break;
    case "WAIT_SELLER_SEND_GOODS": statue = "买家已付款"; break;
    case "WAIT_BUYER_CONFIRM_GOODS": statue = "卖家已发货"; break;
    } order.Status = statue; break;

    case "tid": trade.Tid = value; break;
    case "created": trade.Created = value; break;
    case "code_fee": trade.Code_Fee = value; break;
    case "post_fee": trade.Post_Fee = value; break;
    case "modified": trade.Modified = value; break;
    case "end_time": trade.End_Time = value; break;
    case "pay_time": trade.Pay_Time = value; break;
    case "alipay_no": trade.Alipay_No = value; break;
    case "buyer_memo": trade.Buyer_Memo = value; break;
    case "seller_nick": trade.Seller_Nick = value; break;
    case "buyer_email": trade.Buyer_Email = value; break;
    case "seller_memo": trade.Seller_Memo = value; break;
    case "code_status": trade.Code_Status = value; break;
    case "seller_name": trade.Seller_Name = value; break;
    case "receiver_zip": trade.Receiver_Zip = value; break;
    case "seller_email": trade.Seller_Email = value; break;
    case "seller_phone": trade.Seller_Phone = value; break;
    case "buyer_cod_fee": trade.Buyer_Cod_Fee = value; break;
    case "receiver_name": trade.Receiver_Name = value; break;
    case "receiver_city": trade.Receiver_City = value; break;
    case "seller_mobile": trade.Seller_Mobile = value; break;
    case "commission_fee": trade.Commission_Fee = value; break;
    case "receiver_state": trade.Receiver_State = value; break;
    case "receiver_phone": trade.Receiver_Phone = value; break;
    case "seller_cod_fee": trade.Seller_Cod_Fee = value; break;
    case "receiver_mobile": trade.Receiver_Mobile = value; break;
    case "receiver_address": trade.Receiver_Address = value; break;
    case "received_payment": trade.Received_Payment = value; break;
    case "seller_alipay_no": trade.Seller_Alipay_No = value; break;
    case "receiver_district": trade.Receiver_District = value; break;
    case "express_agency_fee": trade.Express_Agency_Fee = value; break;
    case "available_confirm_fee": trade.Available_Confirm_Fee = value; break;
    case "has_post_fee":if (value== "true") { trade.Has_Post = "包含"; }
    else{ trade.Has_Post = "不包含"; }break;
    case "shipping_type": string shipping_type = value;
    switch (shipping_type)
    {
    case "ems": shipping_type = "EMS"; break;
    case "post": shipping_type = "平邮"; break;
    case "express": shipping_type = "快递"; break;
    case "free": shipping_type = "卖家包邮"; break;
    }trade.Shipping_Type = shipping_type; break;
    case "type": string type = value;
    switch (type)
    {
    case "ec": type = "直冲"; break;
    case "fixed": type = "一口价"; break;
    case "auction": type = "拍卖"; break;
    case "cod": type = "货到付款"; break;
    case "fenxiao": type = "分销"; break;
    case "netcn_trade": type = "万网交易"; break;
    case "auto_delivery": type = "自动发货"; break;
    case "game_equipment": type = "游戏装备"; break;
    case "shopex_trade": type = "ShopEX交易"; break;
    case "external_trade": type = "统一外部交易"; break;
    case "guarantee_trade": type = "一口价、拍卖"; break;
    case "independent_shop_trade": type = "旺店标准版交易"; break;
    case "independent_simple_trade": type = "旺店入门版交易"; break;
    }trade.Type = type; break;

    case "id": promotion.ID = value; break;
    case "promotion_detail": promoyions.Add(promotion); break;
    case "gift_item_name": promotion.Gift_Item_Name = value; break;
    case "promotion_name": promotion.Promotion_Name = value; break;
    case "promotion_details ": trade.Promotions = promoyions; break;
    }
    }
    trades.Add(trade);
    }
    return trades;
    }
    public static List<Trade> GetTrades(string xml)
    {//case "discount_fee": promotion.Discount_Fee = value; break;
    trades = new List<Trade>();
    IDictionary<int, IDictionary<string, string>> dits = ReadXmlHelper.GetDic(xml, "trade");
    foreach (IDictionary<string, string> dic in dits.Values)
    {
    Trade trade = new Trade();
    Order order = new Order();
    PromotionDetail promotion = new PromotionDetail();
    List<Order> orders = new List<Order>();
    List<PromotionDetail> promoyions = new List<PromotionDetail>();

    foreach (KeyValuePair<string, string> kvp in dic)
    {
    string key = kvp.Key;
    string value = kvp.Value;
    switch (key)
    {
    case "tid": trade.Tid = value; break;
    case "status": string statue = value;
    switch (statue)
    {
    case "TRADE_CLOSED": statue = "交易关闭"; break;
    case "TRADE_FINISHED": statue = "交易成功"; break;
    case "WAIT_BUYER_PAY": statue = "等待买家付款"; break;
    case "TRADE_BUYER_SIGNED": statue = "买家已签收"; break;
    case "TRADE_CLOSED_BY_TAOBAO": statue = "交易关闭"; break;
    case "WAIT_SELLER_SEND_GOODS": statue = "买家已付款"; break;
    case "WAIT_BUYER_CONFIRM_GOODS": statue = "卖家已发货"; break;
    }
    trade.Status = statue;
    break;
    case "snapshot_url": trade.Snapshot_Url = value; break;
    case "snapshot": trade.SnapShot = value; break;
    case "title": trade.Title = value; break;
    case "num": trade.Num = value; break;
    case "created": trade.Created = value; break;
    case "num_iid": trade.Num_iid = value; break;
    case "price": trade.Price = value; break;
    case "consign_time": trade.Consign_Time = value; break;
    case "pic_path": trade.Pic_Path = value; break;
    case "alipay_no": trade.Alipay_No = value; break;
    case "code_fee": trade.Code_Fee = value; break;
    case "code_status": trade.Code_Status = value; break;
    case "post_fee": trade.Post_Fee = value; break;
    case "modified": trade.Modified = value; break;
    case "end_time": trade.End_Time = value; break;
    case "express_agency_fee": trade.Express_Agency_Fee = value; break;
    case "pay_time": trade.Pay_Time = value; break;
    case "buyer_nick": trade.Buyer_Nick = value; break;
    case "buyer_memo": trade.Buyer_Memo = value; break;
    case "buyer_obtain_point_fee": trade.Buyer_Obtain_Point_Fee = value; break;
    case "point_fee": trade.Point_Fee = value; break;
    case "real_point_fee": trade.Real_Point_Fee = value; break;
    case "buyer_cod_fee": trade.Buyer_Cod_Fee = value; break;
    case "receiver_name": trade.Receiver_Name = value; break;
    case "receiver_state": trade.Receiver_State = value; break;
    case "receiver_city": trade.Receiver_City = value; break;
    case "receiver_district": trade.Receiver_District = value; break;
    case "receiver_address": trade.Receiver_Address = value; break;
    case "receiver_zip": trade.Receiver_Zip = value; break;
    case "receiver_mobile": trade.Receiver_Mobile = value; break;
    case "receiver_phone": trade.Receiver_Phone = value; break;
    case "buyer_email": if (value == "buyer_email") { trade.Buyer_Email = null; }
    else { trade.Buyer_Email = value; } break;
    case "seller_memo": trade.Seller_Memo = value; break;
    case "seller_cod_fee": trade.Seller_Cod_Fee = value; break;
    case "seller_nick": trade.Seller_Nick = value; break;
    case "received_payment": trade.Received_Payment = value; break;
    case "seller_alipay_no": trade.Seller_Alipay_No = value; break;
    case "seller_mobile": trade.Seller_Mobile = value; break;
    case "seller_phone": trade.Seller_Phone = value; break;
    case "seller_name": trade.Seller_Name = value; break;
    case "seller_email": trade.Seller_Email = value; break;
    case "available_confirm_fee": trade.Available_Confirm_Fee = value; break;
    case "buyer_rate":
    if (value == "true") { trade.Buyer_Rate = "已评论"; }
    else { trade.Buyer_Rate = "未评论"; } break;
    case "seller_rate":
    if (value == "true") { trade.Seller_Rate = "已评论"; }
    else{trade.Seller_Rate="未评论";} break;
    case "has_post_fee":
    if (value == "true") { trade.Has_Post= "包含"; }
    else { trade.Has_Post = "不包含"; } break;
    case "shipping_type": string shipping_type = value;
    switch (shipping_type)
    {
    case "ems": shipping_type = "EMS"; break;
    case "post": shipping_type = "平邮"; break;
    case "express": shipping_type = "快递"; break;
    case "free": shipping_type = "卖家包邮"; break;
    }
    trade.Shipping_Type = shipping_type; break;
    case "type": string type = value;
    switch (type)
    {
    case "ec": type = "直冲"; break;
    case "fixed": type = "一口价"; break;
    case "auction": type = "拍卖"; break;
    case "cod": type = "货到付款"; break;
    case "fenxiao": type = "分销"; break;
    case "netcn_trade": type = "万网交易"; break;
    case "auto_delivery": type = "自动发货"; break;
    case "game_equipment": type = "游戏装备"; break;
    case "shopex_trade": type = "ShopEX交易"; break;
    case "external_trade": type = "统一外部交易"; break;
    case "guarantee_trade": type = "一口价、拍卖"; break;
    case "independent_shop_trade": type = "旺店标准版交易"; break;
    case "independent_simple_trade": type = "旺店入门版交易"; break;
    }
    trade.Type = type; break;

    case "id": promotion.ID = value; break;
    case "discount_fee": promotion.Discount_Fee = value; break;
    case "gift_item_name": promotion.Gift_Item_Name = value; break;
    case "promotion_name": promotion.Promotion_Name = value; break;
    case "promotion_detail": promoyions.Add(promotion); break;
    case "promotion_details ": trade.Promotions = promoyions; break;
    }
    }
    trades.Add(trade);
    }
    return trades;
    }
    }
    }

    代码:UI

    <1>.MainPage.xaml

    <phone:PhoneApplicationPage
     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
     xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
     xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
        xmlns:ShaderEffectLibrary="clr-namespace:System.Windows.Media.Effects;assembly=System.Windows"
     mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="800"
     x:Class="LoveTao.MainPage"
     d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
     FontFamily="{StaticResource PhoneFontFamilyNormal}"
     FontSize="{StaticResource PhoneFontSizeNormal}"
     Foreground="{StaticResource PhoneForegroundBrush}"
     SupportedOrientations="Portrait" Orientation="Portrait"
     shell:SystemTray.IsVisible="False">
        <phone:PhoneApplicationPage.Resources>
         
        </phone:PhoneApplicationPage.Resources>
       
     <!--LayoutRoot is the root grid where all page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Yellow"  >
            <StackPanel Canvas.ZIndex="1"  Margin="0,-480,0,0" Width="468" Height="20">
                <ProgressBar Height="20"  Name="Progress" Foreground="Blue" BorderThickness="0"  IsIndeterminate="False" Background="Blue" Visibility="Collapsed" VerticalAlignment="Top"/>
            </StackPanel>
            <!--Pivot Control-->
                <controls:Pivot Name="MyPivot" Height="760" VerticalAlignment="Top"  Title="我爱我淘"  Foreground="Purple" SelectionChanged="MyPivot_SelectionChanged" FontFamily="Segoe WP Light" Opacity="1.2" >
                 <controls:Pivot.Background>
                  <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                   <GradientStop Color="Black" Offset="0"/>
                   <GradientStop Color="#FFEFE718" Offset="0.034"/>
                   <GradientStop Color="#FFE9F515"/>
                   <GradientStop Color="#FFE4EF18" Offset="0.996"/>
                   <GradientStop Color="#FF1FEF19" Offset="0.457"/>
                   <GradientStop Color="#FFD8EF18" Offset="0.843"/>
                  </LinearGradientBrush>
                 </controls:Pivot.Background>
                    <controls:Pivot.TitleTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                            <Image Source="Image/taobao.jpg" Margin="0,0,10,0" Stretch="UniformToFill"/>
                                <TextBlock FontSize="24" Text="我爱我淘"/>
                            </StackPanel>
                        </DataTemplate>
                    </controls:Pivot.TitleTemplate>
                    <!--Pivot item one-->
                    <controls:PivotItem Header="疯狂我淘" Background="Transparent" >
                        <!--Double line list with text wrapping-->
                        <Grid>
                            <StackPanel Orientation="Horizontal" >
                                <TextBox Name="txtSearch" Margin="-8,0,0,0" Width="350" Background="WhiteSmoke" HorizontalAlignment="Left" Opacity="2" VerticalAlignment="Top" BorderThickness="0"  GotFocus="txtSearch_GotFocus"  CacheMode="BitmapCache" Canvas.ZIndex="12">
                                <TextBox.Clip>
                                    <RectangleGeometry RadiusX="10" RadiusY="10" Rect="15,10,320,45"/>
                                </TextBox.Clip>
                            </TextBox>
                                <Button Name="btnSearch" Margin="-25,0,0,0" BorderThickness="0" Width="150" Height="70"  MouseLeave="btnSearch_MouseLeave" Content="搜宝贝"  VerticalAlignment="Top" Background="Yellow" Foreground="Blue" Click="btnSearch_Click" Opacity="0.9" ClickMode="Press">
                                <Button.Clip>
                                    <RectangleGeometry RadiusX="20" RadiusY="20" Rect="15,10,120,50"/>
                                </Button.Clip>                              
                                </Button>
                            </StackPanel>
                            <StackPanel Orientation="Vertical" >
                                <StackPanel Name="SPNick" Margin="0,60,0,0" Orientation="Horizontal" Visibility="Collapsed"  >
                                    <HyperlinkButton Name="HLBShowNick" Margin="40,0,120,0"  Content="欢迎你的使用" VerticalAlignment="Top"  FontSize="28" Foreground="Purple" Visibility="Visible"  NavigateUri="/ItemViews/MyTaoBao.xaml" />
                                    <HyperlinkButton Name="HLBBack" Content="退出" FontSize="28" Foreground="Blue" VerticalAlignment="Top" Click="HLBBack_Click"/>
                                </StackPanel>
                                <StackPanel Name="StPLoad" Visibility="Visible"  Orientation="Vertical" Margin="0,60,30,0" Height="70" VerticalAlignment="Top">
                                    <HyperlinkButton Name="HLBLoad" HorizontalAlignment="Right"  Content="登录" Height="35"  VerticalAlignment="Top" FontSize="26" Foreground="Blue" Click="HLBLoad_Click" />
                                    <HyperlinkButton Name="HLBRegister" HorizontalAlignment="Right" Content="注册" Height="35" FontSize="26" Foreground="Blue" Click="HLBRegister_Click"/>
                                </StackPanel>
                                <ListBox  Name="LBListsShow" Height="480" SelectionChanged="LBListsShow_SelectionChanged" >
                                    <ListBox.ItemTemplate>
                                        <DataTemplate>
                                            <StackPanel Orientation="Horizontal">
                                                <Image Name="image" Source="{Binding image}"  Width="160" Height="160" VerticalAlignment="Top" Stretch="UniformToFill"  >
                                                    <Image.Clip>
                                                        <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,160,160" />
                                                    </Image.Clip>
                                                </Image>
                                            <TextBlock  Text="{Binding content}"  TextDecorations="Underline"  Margin="5,0,0,0" VerticalAlignment="Top" FontSize="26" Foreground="Blue" />
                                        </StackPanel>
                                        </DataTemplate>
                                    </ListBox.ItemTemplate>
                                </ListBox>
                            </StackPanel>
                        </Grid>
                    </controls:PivotItem>
                    <!--Pivot item two-->
                    <controls:PivotItem Header="淘我所爱" >
                        <StackPanel Orientation="Vertical"  >
                            <StackPanel Orientation="Horizontal">
                            <TextBox Name="txtTrSearch" Margin="-8,-6,0,0" Height="70" Background="WhiteSmoke" VerticalAlignment="Top" HorizontalAlignment="Left" Opacity="2" BorderThickness="0" Width="340" GotFocus="txtTrSearch_GotFocus">
                                <TextBox.Clip>
                                    <RectangleGeometry RadiusX="10" RadiusY="10" Rect="15,10,310,50"/>
                                </TextBox.Clip>
                            </TextBox>
                            <Button Name="btnTrSearch" Margin="-25,-6,0,0" Height="70" Width="160" BorderBrush="Yellow" Content="搜宝贝" Click="btnTrSearch_Click" Foreground="Blue" MouseLeave="btnTrSearch_MouseLeave" ClickMode="Press" BorderThickness="0" RenderTransformOrigin="0.756,0.086" Background="Yellow">
                                <Button.Clip>
                                    <RectangleGeometry RadiusX="25" RadiusY="25" Rect="15,10,130,50"/>
                                </Button.Clip>
                            </Button>
                        </StackPanel>
                            <Border BorderBrush="Silver" BorderThickness="1" VerticalAlignment="Top" Height="130" Name="boder"  >
                                <StackPanel Orientation="Vertical">
                                    <StackPanel Orientation="Horizontal" >
                                        <CheckBox Name="cbMall" BorderThickness="0" Content="商城" Height="68" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="SeaGreen" Background="White" />
                                    <CheckBox Name="cbGenuine" BorderThickness="0" Content="正品保证" Height="68" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="SeaGreen" Background="White"/>
                                    <CheckBox Name="cbCod" BorderThickness="0" Content="货到付款" Height="68" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="SeaGreen" Background="White"/>
                                    </StackPanel>
                                    <StackPanel Orientation="Horizontal">
                                    <CheckBox Name="cbPost" BorderThickness="0" Content="免邮" Height="68" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="SeaGreen" Background="White"/>
                                    <CheckBox Name="cbWStatus" BorderThickness="0" Content="旺旺在线" Height="68" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="SeaGreen" Background="White"/>
                                    <CheckBox Name="cb3D" BorderThickness="0" Content="3D淘宝商品" Height="68" HorizontalAlignment="Left" VerticalAlignment="Top" Foreground="SeaGreen" Background="White"/>
                                    </StackPanel>
                                </StackPanel>
                            </Border>
                            <ListBox Name="LBTrProducts" Height="410" SelectionChanged="LBTrProducts_SelectionChanged">
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Name="image" Source="{Binding image}"   Width="160" Height="160" VerticalAlignment="Top" Stretch="UniformToFill" >
                                                <Image.Clip>
                                                    <RectangleGeometry RadiusX="10" RadiusY="10" Rect="0,0,160,160" />
                                                </Image.Clip>
                                            </Image>
                                        <TextBlock Text="{Binding content}" TextDecorations="Underline" Margin="5,0,0,0" VerticalAlignment="Top" FontSize="26" Foreground="Blue" />
                                    </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </StackPanel>
                    </controls:PivotItem>
                    <!--Pivot item three-->
                    <controls:PivotItem Header="淘宝分类">              
                    <StackPanel Orientation="Vertical" VerticalAlignment="Top">
                            <ListBox Name="LBItemCats" Height="610" SelectionChanged="LBItemCats_SelectionChanged" >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                    <StackPanel Margin="50,40,0,0"  Orientation="Horizontal">
                                        <RadioButton VerticalAlignment="Top" HorizontalAlignment="Left" Height="40" IsEnabled="False"/>
                                        <TextBlock  Text="{Binding content}" TextDecorations="Underline" HorizontalAlignment="Left" VerticalAlignment="Top" FontSize="28" Foreground="Blue" />
                                    </StackPanel>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </StackPanel>
                    </controls:PivotItem>
                    <controls:PivotItem Header="物流查询">
                        <StackPanel Orientation="Vertical">
                            <StackPanel Orientation="Horizontal">
                                <TextBlock Text="推荐物流公司:" FontSize="24" VerticalAlignment="Center"/>
                                <CheckBox Name="CBTLog" Content="是"  BorderThickness="0" Click="CBTLog_Click" Foreground="Blue" Background="WhiteSmoke"/>
                            <CheckBox Name="CBFLog" Content="否" BorderThickness="0" Click="CBFLog_Click" Foreground="Blue"  Background="WhiteSmoke"/>
                            <Button Name="btnSearchLog" Margin="-20,-15,0,0" Height="75" Width="140" Content="查找" BorderThickness="0" Background="Yellow" Foreground="Blue" Click="btnSearchLog_Click" MouseLeave="btnSearchLog_MouseLeave"  ClickMode="Press">
                                <Button.Clip>
                                    <RectangleGeometry RadiusX="25" RadiusY="25" Rect="12,15,110,50"/>
                                </Button.Clip>
                            </Button>
                        </StackPanel>
                            <StackPanel Orientation="Horizontal" Height="70">
                            <TextBlock Text="物流下单方式:" FontSize="24" VerticalAlignment="Center" />
                            <toolkit:ListPicker Name="LPStype" Margin="-10,0,0,0" VerticalContentAlignment="Stretch" Width="320" FontSize="28"  Background="WhiteSmoke" IsEnabled="False" ListPickerMode="Normal">
                                <sys:String>全部</sys:String>
                                <sys:String>在线下单</sys:String>
                                <sys:String></sys:String>
                                <sys:String></sys:String>
                                <sys:String></sys:String>
                                <sys:String>电话联系/自己联系</sys:String>
                                <toolkit:ListPicker.Clip>
                                    <RectangleGeometry RadiusX="25" RadiusY="25" Rect="10,10,280,50"/>
                                </toolkit:ListPicker.Clip>
                            </toolkit:ListPicker>
                        </StackPanel>
                            <ListBox Name="LBLogistic" Height="470" >
                                <ListBox.ItemTemplate>
                                    <DataTemplate>
                                        <Border Margin="10,0,0,0"  Width="440" BorderThickness="2" BorderBrush="Yellow">
                                            <TextBlock Margin="50,0,0,0" Text="{Binding content}" FontSize="24" Foreground="Blue" VerticalAlignment="Top" HorizontalAlignment="Left"/>
                                        </Border>
                                    </DataTemplate>
                                </ListBox.ItemTemplate>
                            </ListBox>
                        </StackPanel>
                    </controls:PivotItem>
                    <controls:PivotItem Header="关于产品">
                       
                    <StackPanel Margin="0,0,0,0" Orientation="Vertical" >
                        <TextBlock Margin="80,20,0,10" Text="欢迎使用本软件! " FontSize="35" Foreground="Yellow"/>
                        <TextBlock Text="软件介绍:" FontSize="30"/>
                        <TextBlock  Text="    本软件是由风行者团队开发的,一款基于Windows Phone 7平台的手机淘宝客户端。" Foreground="Blue" FontSize="28" TextWrapping="Wrap"/>
                        <TextBlock Text="     应用淘宝开放平台Open API和Windows Phone 7运行环境开发的手机软件。 " Foreground="Blue" TextWrapping="Wrap" FontSize="28"/>
                        <TextBlock Margin="0,10,0,140" Text="团队介绍:" FontSize="30"/>
                       
                       
                        <TextBlock Text="谢谢你对Wind Walker Team的支持!" Foreground="Blue" FontSize="28"/>
                    </StackPanel>
                </controls:PivotItem>
                </controls:Pivot>
            <StackPanel  Orientation="Horizontal" Name="SPUpOrDown" VerticalAlignment="Bottom" Height="35">
                    <HyperlinkButton Name="HLBUp"  Content="上一页" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="HLBUp_Click" FontSize="24" Foreground="Blue"/>
                    <TextBlock Name="txtPage" Text="当前是第0页,共0页" VerticalAlignment="Bottom" FontSize="25" Foreground="Purple" Margin="30,0,20,0"/>
                    <HyperlinkButton Name="HLBDown"  Content="下一页" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="HLBDown_Click" FontSize="24" Foreground="Blue"/>
                </StackPanel>
        </Grid>
        <toolkit:TransitionService.NavigationInTransition>
            <toolkit:NavigationInTransition>
                <toolkit:NavigationInTransition.Backward>
                    <toolkit:SlideTransition Mode="SlideDownFadeIn"/>
                </toolkit:NavigationInTransition.Backward>
                <toolkit:NavigationInTransition.Forward>
                    <toolkit:SlideTransition Mode="SlideDownFadeIn"/>
                </toolkit:NavigationInTransition.Forward >
            </toolkit:NavigationInTransition>
        </toolkit:TransitionService.NavigationInTransition>
        <toolkit:TransitionService.NavigationOutTransition>
            <toolkit:NavigationOutTransition>
                <toolkit:NavigationOutTransition.Backward>
                    <toolkit:RotateTransition Mode="Out180Counterclockwise"/>
                </toolkit:NavigationOutTransition.Backward>
                <toolkit:NavigationOutTransition.Forward>
                    <toolkit:RotateTransition Mode="Out180Counterclockwise"/>
                </toolkit:NavigationOutTransition.Forward>
            </toolkit:NavigationOutTransition>
        </toolkit:TransitionService.NavigationOutTransition>
    </phone:PhoneApplicationPage>

    <UI代码:>

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using BLL;
    using Common;
    using Microsoft.Phone.Controls;
    using Model;
    using LoveTao.ItemViews;
    using Microsoft.Phone.Tasks;

    namespace LoveTao
    {   
        public partial class MainPage : PhoneApplicationPage
        {
            // Constructor
            public MainPage()
            {
                InitializeComponent();

                // Set the data context of the listbox control to the sample data
                DataContext = App.ViewModel;
                this.Loaded += new RoutedEventHandler(MainPage_Loaded);
            }

            #region 私有字段
            private string appKey = "12315576";
            private string appSecret = "5734907fbdd9af8f23493a9411ba9805";
            private string session = "";//他用类型 且是获取私有数据的需要传递 sessionkey
            private int pageNo = 0;
            private int pageSize = 10;
            private int currentPage = 0;
            private int currentIndex = 0;
            private int flag = 0;
            private List<ItemCat> itemCats = null;
            private List<Product> products = null;
            private string isRecommand = null;
            private List<LogisticsCompany> logistics = null;
            private bool IsLoaded = true;
            #endregion

            /// <summary>
            /// 登录
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void HLBLoad_Click(object sender, RoutedEventArgs e)
            {
                try
                {
                    NavigationService.Navigate(new Uri("/ItemViews/Load.xaml", UriKind.RelativeOrAbsolute));
                }
                catch (Exception )
                {
                    MessageBox.Show("页面跳转有误!","温馨提示",MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 注册
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void HLBRegister_Click(object sender, RoutedEventArgs e)
            {
                try
                {
                    NavigationService.Navigate(new Uri("/ItemViews/Regist.xaml", UriKind.RelativeOrAbsolute));
                }
                catch (Exception )
                {
                    MessageBox.Show("页面跳转有误!","温馨提示",MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 退出按钮
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void HLBBack_Click(object sender, RoutedEventArgs e)
            {
                try
                {
                    NavigationService.Navigate(new Uri("/ItemViews/Back.xaml", UriKind.RelativeOrAbsolute));
                }
                catch (Exception)
                {
                    MessageBox.Show("页面跳转有误!","温馨提示",MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// Load事件
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void MainPage_Loaded(object sender, RoutedEventArgs e)
            {        
                if (!App.ViewModel.IsDataLoaded)
                {
                    App.ViewModel.LoadData();
                }
                if (LoadBLL.Load.Count != 0 && !string.IsNullOrEmpty(LoadBLL.Load[0]))
                {
                    session = LoadBLL.Load[1];
                    this.HLBShowNick.Content = "Hi," + LoadBLL.Load[0];
                    this.SPNick.Visibility = Visibility.Visible;
                    this.StPLoad.Visibility = Visibility.Collapsed;
                    this.LBListsShow.Height = 520;
                }
                else
                {
                    this.SPNick.Visibility = Visibility.Collapsed;
                    this.StPLoad.Visibility = Visibility.Visible;
                }
            }

            #region Common
            /// <summary>
            /// 在每次转换时,数据设为初值
            /// </summary>
            private void ClearValue()
            {
                pageNo = 0;
                pageSize = 10;
                currentPage = 1;
                currentIndex = 0;
                this.txtSearch.Text = string.Empty;
                this.txtTrSearch.Text = string.Empty;
                this.HLBUp.IsEnabled = true;
                this.HLBDown.IsEnabled = true;
                this.txtPage.Text = "当前是第0页,共0页";
             
                //物流
                LPStype.SelectedIndex = 0;
                CBTLog.IsChecked = false;
                CBFLog.IsChecked = false;
                //TrueSearch
                cb3D.IsChecked = false;
                cbCod.IsChecked = false;
                cbGenuine.IsChecked = false;
                cbMall.IsChecked = false;
                cbPost.IsChecked = false;
                cbWStatus.IsChecked = false;
           
            }
            private bool GetNum(int totalNum)
            {
                if (totalNum > 0)
                    return true;
                else
                {
                    MessageBox.Show("没有你要查找的数据!", "温馨提示", MessageBoxButton.OK);
                    return false;
                }
            }
            /// <summary>
            /// 分页
            /// </summary>
            /// <param name="totalNum">商品总数</param>
            private void GetPages(int totalNum)
            {          
                if (totalNum > 0)
                {              
                    if (totalNum % pageSize == 0)
                    {
                        pageNo = totalNum / pageSize;
                    }
                    else
                    {
                        pageNo = totalNum / pageSize + 1;
                    }
                }
                else
                {              
                    LBListsShow.ItemsSource = null;
                    LBTrProducts.ItemsSource = null;
                    MessageBox.Show("没有你要查找的数据!","温馨提示",MessageBoxButton.OK);
                }         
            }
            /// <summary>
            /// Post请求
            /// </summary>
            /// <param name="appKey">Key</param>
            /// <param name="appSecret">Secret</param>
            /// <param name="method">API</param>
            /// <param name="session">Session</param>
            /// <param name="param">应用参数</param>
            private void Post(string appKey, string appSecret, string method, string session, IDictionary<string, string> param)
            {
                this.Progress.IsIndeterminate = true;
                this.Progress.Visibility = Visibility.Visible;
                try
                {
                    ComHelper.GetData(appKey, appSecret, method, session, param);
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://gw.api.taobao.com/router/rest");
                    request.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
                    request.Method = "POST";
                    request.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), request);
                }
                catch (Exception )
                {
                    MessageBox.Show("远程连接有误!","温馨提示",MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 请求委托,流的写入
            /// </summary>
            /// <param name="asynchronousResult"></param>
            private void GetRequestStreamCallback(IAsyncResult asynchronousResult)
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                    Stream postStream = request.EndGetRequestStream(asynchronousResult);
                    byte[] byteArray = ComHelper.postData;
                    postStream.Write(byteArray, 0, ComHelper.postData.Length);
                    postStream.Close();
                    request.BeginGetResponse(new AsyncCallback(GetResponseCallback), request);
                }
                catch (Exception )
                {
                    MessageBox.Show("远程连接有误!", "温馨提示", MessageBoxButton.OK);
                }
            }      
            /// <summary>
            /// 回调委托,返回XML
            /// </summary>
            /// <param name="asynchronousResult"></param>
            private void GetResponseCallback(IAsyncResult asynchronousResult)
            {
                try
                {
                    HttpWebRequest request = (HttpWebRequest)asynchronousResult.AsyncState;
                    HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(asynchronousResult);
                    Stream streamResponse = response.GetResponseStream();
                    StreamReader streamRead = new StreamReader(streamResponse);
                    string xml = streamRead.ReadToEnd();

                    string content = ReadXmlHelper.ReadXml(xml);
                    bool bo = content.Contains("error_response");
                    if (bo)
                    {
                        flag = 8;
                        content = content.Substring(0, content.LastIndexOf('#'));
                        content = content.Substring(content.LastIndexOf('|') + 1);
                    }
                    else
                    {
                        switch (flag)
                        {
                            case 2: itemCats = ItemCatsBLL.GetItemCats(xml); break;
                            case 4: logistics = LogisticsBLL.GetLogistics(xml); break;
                            default: products = ProductsBLL.GetProducts(xml); break;
                        }
                    }
                    streamResponse.Close();
                    streamRead.Close();
                    response.Close();
                    Dispatcher.BeginInvoke(
                         () =>
                         {
                             switch (flag)
                             {   //-2,默认查衣服;-1,默认查手机;0,搜宝贝,跳到列表页;1,精确查询;2,商品分类;3,类目下的商品,跳到列表页;4.获取物流公司信息
                                 case -2: GetPages(products.Count); ShowProducts(currentPage, -2); break;
                                 case -1: GetPages(products.Count); ShowProducts(currentPage, -1); break;                                                         
                                 case 0: bo = GetNum(products.Count); if (bo)
                                     {
                                         try
                                         {
                                             NavigationService.Navigate(new Uri("/ItemViews/Products.xaml", UriKind.RelativeOrAbsolute)); Products.Flag = 0;
                                         }
                                         catch (Exception )
                                         {
                                             MessageBox.Show("页面跳转有误!","温馨提示",MessageBoxButton.OK);
                                         }
                                     } break;
                                 case 1: GetPages(products.Count); ShowProducts(currentPage, -1); break;
                                 case 2: GetPages(itemCats.Count); ShowCats(currentPage); break;
                                 case 3: bo = GetNum(products.Count); if (bo)
                                     {
                                         try
                                         {
                                             NavigationService.Navigate(new Uri("/ItemViews/Products.xaml", UriKind.RelativeOrAbsolute)); Products.Flag = 1;
                                             Products.Cid = itemCats[currentIndex].Cid;
                                         }
                                         catch (Exception )
                                         {
                                             MessageBox.Show("页面跳转有误!","温馨提示",MessageBoxButton.OK);
                                         }
                                     } break;//获取Cid,为排序准备
                                 case 4: GetPages(logistics.Count); ShowLogistics(currentPage); break;
                                 case 8: MessageBox.Show(content, "温馨提示", MessageBoxButton.OK); break;
                                 default: break;
                             }
                             this.Progress.IsIndeterminate = false;
                             this.Progress.Visibility = Visibility.Collapsed;
                             this.IsLoaded = true;
                         });
                }
                catch (Exception )
                {
                    Dispatcher.BeginInvoke(() =>
                        {
                            MessageBox.Show("远程连接有误!", "温馨提示", MessageBoxButton.OK);
                        });
                }
            }
            #endregion

            #region SearchProducts
            ///  /// <summary>
            /// 传入当前页数,显示商品
            /// </summary>
            /// <param name="currentPage">当前页</param>
            /// <param name="bo">是否为精确查询列表</param>
            private void ShowProducts(int currentPage, int newFlag)
            {          
                List<ListBinding> lists = new List<ListBinding>();
                for (int i = (currentPage - 1) * pageSize; i < currentPage * pageSize; i++)
                {
                    ListBinding list = new ListBinding();
                    if (i < products.Count)
                    {
                        list.image = new BitmapImage(new Uri(products[i].Pic_url, UriKind.RelativeOrAbsolute));
                        list.content = "商品标题:" + products[i].Title + "\n卖家昵称:" + products[i].Nick + "\n商品价格:" + products[i].Price
                            + "\n商品交易量:" + products[i].Volume + "\n商品下架时间:" + products[i].Delist_time;
                        lists.Add(list);
                    }
                }
                if (newFlag==-2)
                {
                    LBListsShow.ItemsSource = lists;              
                }
                else
                {
                    LBTrProducts.ItemsSource = lists;               
                }
                this.txtPage.Text = "当前是第" + currentPage + "页,共" + pageNo + "页";           
            }
            /// <summary>
            /// 发送请求,获取默认商品
            /// </summary>
            /// <param name="appKey">Key</param>
            /// <param name="appSecret">Secret</param>
            /// <param name="session">Session</param>
            /// <param name="bo">区分默认衣服、手机</param>
            private void GetProducts(string appKey, string appSecret, string session,int newFlag)
            {           
                flag = newFlag;
                string method = "taobao.items.get";
                string parameters = "title,nick,pic_url,price,type,delist_time,post_fee,express_fee,ems_fee,score,volume,location.state,location.city,num_iid,num";
                IDictionary<string, string> param = new Dictionary<string, string>();         
                Random ran = new Random();
                int Index= ran.Next(0,10000);
                param.Add("q", Index.ToString());
                param.Add("fields", parameters);
                param.Add("page_size", "108");
                Post(appKey, appSecret, method, session, param);
            }
            /// <summary>
            /// 发送请求,获取搜索商品
            /// </summary>
            /// <param name="appKey">Key</param>
            /// <param name="appSecrect">Secrect</param>
            /// <param name="session">Session</param>
            /// <param name="bo">是否为精确查询</param>
            /// <param name="request">查询的商品</param>
            private void GetProducts(string appKey, string appSecrect, string session, bool bo, string request)
            {
                string method = "taobao.items.get";
                string parameters = "title,nick,pic_url,price,type,delist_time,post_fee,express_fee,ems_fee,score,volume,location.state,location.city,num_iid,num";
                IDictionary<string, string> param = new Dictionary<string, string>();
                param.Add("fields", parameters);
                param.Add("q", request);
                param.Add("page_size", "108");
                if (bo)
                {
                    flag = 1;
                    if (cb3D.IsChecked == true)
                    {
                        param.Add("is_3D", "true");
                    }
                    if (cbCod.IsChecked == true)
                    {
                        param.Add("is_cod", "true");
                    }
                    if (cbGenuine.IsChecked == true)
                    {
                        param.Add("genuine_security", "true");
                    }
                    if (cbMall.IsChecked == true)
                    {
                        param.Add("is_mall", "true");
                    }
                    if (cbPost.IsChecked == true)
                    {
                        param.Add("post_free", "true");
                    }
                    if (cbWStatus.IsChecked == true)
                    {
                        param.Add("ww_status", "true");
                    }
                }
                else
                {
                    flag = 0;
                }
                Post(appKey, appSecret, method, session, param);
            }     
            /// <summary>
            /// 搜宝贝
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void btnSearch_Click(object sender, RoutedEventArgs e)
            {
                this.btnSearch.Background = new SolidColorBrush(Colors.Orange);
                if (LoadBLL.Load.Count != 0 && LoadBLL.Load[0] != null)
                {
                    session = LoadBLL.Load[1];
                }
                if (!string.IsNullOrEmpty(this.txtSearch.Text))
                {
                    string Search = txtSearch.Text;
                    GetProducts(appKey, appSecret, session, false, Search);
                    //获取查询商品,为排序准备
                    Products.Search = Search;
                }
                else
                {
                    MessageBox.Show("请输入你要查询的宝贝!", "温馨提示", MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 精确查询
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void btnTrSearch_Click(object sender, RoutedEventArgs e)
            {
                this.btnTrSearch.Background = new SolidColorBrush(Colors.Orange);
                if (LoadBLL.Load.Count != 0 && LoadBLL.Load[0] != null)
                {
                    session = LoadBLL.Load[1];
                }
                if (!string.IsNullOrEmpty(this.txtTrSearch.Text))
                {
                    string TrueSearch = txtTrSearch.Text;
                    GetProducts(appKey, appSecret, session, true, TrueSearch);
                }
                else
                {
                    MessageBox.Show("请选择你要查看的宝贝!", "温馨提示", MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 清空txtSearch
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void txtSearch_GotFocus(object sender, RoutedEventArgs e)
            {
                this.txtSearch.Text = string.Empty;
            }
            /// <summary>
            /// 清空txtTrSearch
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void txtTrSearch_GotFocus(object sender, RoutedEventArgs e)
            {
                this.txtTrSearch.Text = string.Empty;
            }
            /// <summary>
            /// 单个商品显示
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void LBListsShow_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                try
                {
                    int Index = LBListsShow.SelectedIndex;
                    if (Index >= 0)
                    {
                        currentIndex = (currentPage - 1) * pageSize + Index;
                        NavigationService.Navigate(new Uri("/ItemViews/SingleProduct.xaml?Index=" + currentIndex, UriKind.RelativeOrAbsolute));
                    }
                }
                catch (Exception )
                {
                    MessageBox.Show("页面跳转有误!","温馨提示",MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 单个商品显示
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void LBTrProducts_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                try
                {
                    int Index = LBTrProducts.SelectedIndex;
                    if (Index >= 0)
                    {
                        currentIndex = (currentPage - 1) * pageSize + Index;
                        NavigationService.Navigate(new Uri("/ItemViews/SingleProduct.xaml?Index=" + currentIndex, UriKind.RelativeOrAbsolute));
                    }
                }
                catch (Exception )
                {
                    MessageBox.Show("页面跳转有误!","温馨提示",MessageBoxButton.OK);
                }
            }
            #endregion

            #region ItemCats
            /// <summary>
            /// 发送请求,获取商品分类
            /// </summary>
            /// <param name="appkey">Key</param>
            /// <param name="secret">Secret</param>
            /// <param name="session">Session</param>
            private void ItemCatPost(string appkey, string secret, string session)
            {
                flag = 2;
                string method = "taobao.itemcats.get";
                string parameters = "cid,name";
                IDictionary<string, string> param = new Dictionary<string, string>();
                param.Add("fields", parameters);
                param.Add("parent_cid", "0");
                Post(appkey, secret, method, session, param);
            }
            /// <summary>
            /// 根据类目的cid获取类目下的商品
            /// </summary>
            /// <param name="appkey">Key</param>
            /// <param name="secret">Secret</param>
            /// <param name="session">Session</param>
            /// <param name="cid">商品所属类目Id</param>
            private void ItemProPost(string appkey, string secret, string session, string cid)
            {
                flag = 3;
                string method = "taobao.items.get";
                string parameters = "title,nick,pic_url,price,type,delist_time,post_fee,express_fee,ems_fee,score,volume,location.state,location.city,num_iid,num";
                IDictionary<string, string> param = new Dictionary<string, string>();
                param.Add("fields", parameters);
                param.Add("page_size", "108");
                param.Add("cid", cid);
                Post(appkey, secret, method, session, param);
            }
            /// <summary>
            /// 传入当前页,显示商品类目
            /// </summary>
            /// <param name="currentPage">当前页数</param>
            private void ShowCats(int currentPage)
            {
                List<ListBinding> lists = new List<ListBinding>();
                for (int i = (currentPage - 1) * pageSize; i < currentPage * pageSize; i++)
                {
                    ListBinding list = new ListBinding();
                    if (i <itemCats.Count)
                    {
                        list.content = itemCats[i].Name;
                        lists.Add(list);
                    }
                }
                LBItemCats.ItemsSource = lists;
                this.txtPage.Text = "当前是第" + currentPage + "页,共" + pageNo + "页";
            }
            /// <summary>
            /// 目录下的商品集合
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void LBItemCats_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                //获取当前操作对象
                int Index = LBItemCats.SelectedIndex;
                if (Index >= 0)
                {
                    currentIndex = (currentPage - 1) * 10 + Index;
                    string cid = itemCats[currentIndex].Cid;
                    ItemProPost(appKey, appSecret, session, cid);
                }
            }
            #endregion     

            #region Logistic
            /// <summary>
            /// 推荐物流
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void CBTLog_Click(object sender, RoutedEventArgs e)
            {
                isRecommand = "true";
                this.CBFLog.IsChecked = false;
                this.LPStype.IsEnabled = true;
            }
            /// <summary>
            /// 不推荐物流
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void CBFLog_Click(object sender, RoutedEventArgs e)
            {
                isRecommand = "false";
                this.CBTLog.IsChecked = false;
                this.LPStype.IsEnabled = false;
                this.LPStype.SelectedIndex = 0;
            }
            /// <summary>
            /// 获取物流公司信息Post
            /// </summary>
            /// <param name="appKey"></param>
            /// <param name="appSecret"></param>
            /// <param name="session"></param>
            private void GetLogistics(string appKey,string appSecret,string session)
            {
                flag = 4;
                currentPage = 1;
                string order_mode = LPStype.SelectedItem.ToString();
                string method = "taobao.logistics.companies.get ";
                string parameter = "id,code,name";
                IDictionary<string, string> param = new Dictionary<string, string>();
                param.Add("fields", parameter);
                if (isRecommand != null)
                {
                    param.Add("is_recommended", isRecommand);
                }
                if (!string.IsNullOrEmpty(order_mode))
                {
                    switch (order_mode)
                    {
                        case "全部": order_mode = "all"; break;
                        case "在线下单": order_mode = "online"; break;
                        case "电话联系/自己联系": order_mode = "offline"; break;
                    }
                    param.Add("order_mode", order_mode);
                }
                Post(appKey, appSecret, method, session, param);
            }
            /// <summary>
            /// 显示物流公司信息
            /// </summary>
            /// <param name="currentPage">当前页数</param>
            private void ShowLogistics(int currentPage)
            {
                List<ListBinding> lists = new List<ListBinding>();
                for (int i = (currentPage - 1) * pageSize; i < currentPage * pageSize; i++)
                {
                    ListBinding list = new ListBinding();
                    if (i < logistics.Count)
                    {
                        list.content ="物流公司标识:" +logistics[i].ID +"\n物流公司代码:"+ logistics[i].Cod + "\n物流公司名称:"+logistics[i].Name ;
                        lists.Add(list);
                    }
                }
                LBLogistic.ItemsSource = lists;
                this.txtPage.Text = "当前是第" + currentPage + "页,共" + pageNo + "页";
            }
            /// <summary>
            /// 单击查找按钮
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void btnSearchLog_Click(object sender, RoutedEventArgs e)
            {
                this.btnSearchLog.Background = new SolidColorBrush(Colors.Orange);
                GetLogistics(appKey, appSecret, session);
            }
            #endregion

            /// <summary>
            /// 根据Pivot不同变化
            /// 发送不同请求,显示不同数据
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void MyPivot_SelectionChanged(object sender, SelectionChangedEventArgs e)
            {
                products = null;
                ClearValue();
                int Index;
                try
                {
                    if (IsLoaded)
                    {
                        Index = MyPivot.SelectedIndex;
                        IsLoaded = false;
                    }
                    else
                    {
                        Index = MyPivot.SelectedIndex - 1;
                        if (Index < 0)
                        {
                            Index = 0;
                        }
                    }
                    switch (Index)
                    {   //0,默认随机28查询;1,默认随机28查询;2,类目查询;4,分页不可见
                        case 0: GetProducts(appKey, appSecret, session, -2); this.SPUpOrDown.Visibility = Visibility.Visible; break;
                        case 1: GetProducts(appKey, appSecret, session, -1); this.SPUpOrDown.Visibility = Visibility.Visible; break;
                        case 2: ItemCatPost(appKey, appSecret, session); this.SPUpOrDown.Visibility = Visibility.Visible; break;
                        case 4: this.SPUpOrDown.Visibility = Visibility.Collapsed; break;
                        case 3: GetLogistics(appKey, appSecret, session); this.SPUpOrDown.Visibility = Visibility.Visible; break;
                    }
                }
                catch
                {
                    MessageBox.Show("数据加载有误!", "温馨提示", MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 上一页
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void HLBUp_Click(object sender, RoutedEventArgs e)
            {
                try
                {
                    //根据Pivot的不同变化,显示不同的数据
                    int Index = this.MyPivot.SelectedIndex;
                    currentPage--;
                    if (currentPage > 0)
                    {
                        HLBDown.IsEnabled = true;
                        switch (Index)
                        {   //0,显示默认衣服;1,显示默认手机;2,显示商品类目
                            case 0: ShowProducts(currentPage, -2); break;
                            case 1: ShowProducts(currentPage, -1); break;
                            case 2: ShowCats(currentPage); break;
                            case 3: ShowLogistics(currentPage); break;
                            default: break;
                        }
                    }
                    else
                    {
                        HLBUp.IsEnabled = false;
                    }
                }
                catch(Exception )
                {
                    MessageBox.Show("数据显示有误!","温馨提示",MessageBoxButton.OK);
                }
            }
            /// <summary>
            /// 下一页
            /// </summary>
            /// <param name="sender"></param>
            /// <param name="e"></param>
            private void HLBDown_Click(object sender, RoutedEventArgs e)
            {
                try
                {
                    //根据Pivot的不同变化,显示不同的数据
                    int Index = this.MyPivot.SelectedIndex;
                    currentPage++;
                    if (currentPage <= pageNo)
                    {
                        HLBUp.IsEnabled = true;
                        switch (Index)
                        {   //0,显示默认衣服;1,显示默认手机;2,显示商品类目
                            case 0: ShowProducts(currentPage, -2); break;
                            case 1: ShowProducts(currentPage, -1); break;
                            case 2: ShowCats(currentPage); break;
                            case 3: ShowLogistics(currentPage); break;
                            default: break;
                        }
                    }
                    else
                    {
                        HLBDown.IsEnabled = false;
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("数据显示有误!","温馨提示",MessageBoxButton.OK);
                }
            }

            #region
            private void btnSearch_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
            {
                this.btnSearch.Background = new SolidColorBrush(Colors.Yellow);
            }

            private void btnSearchLog_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
            {
                this.btnSearchLog.Background = new SolidColorBrush(Colors.Yellow);
            }

            private void btnTrSearch_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
            {
                this.btnTrSearch.Background = new SolidColorBrush(Colors.Yellow);
            }
            #endregion   

        }

  • 相关阅读:
    欢迎大家来到氨帝萝卜的博客园
    Java利用自定义注解、反射实现简单BaseDao
    spring boot 2.0.1.RELEASE版本之消息总线 ConfigClient配置自动刷新
    spring cloud eureka server之端口8889之谜
    关于spring cloud “Finchley.RC2”版本在spring cloud config中的ArrayIndexOutOfBoundsException
    关于中间件、J2EE的一些概念
    IP地址 子网掩码 默认网关 DNS(转)
    知识点大图
    Javascript是单线程的深入分析(转)
    SQL查询--选择运算(1)
  • 原文地址:https://www.cnblogs.com/SanMaoSpace/p/2161366.html
Copyright © 2020-2023  润新知