/// <summary> /// 获得经纬度 /// </summary> /// <returns></returns> public ActionResult GetLocal() { JsonSMsg msg = new JsonSMsg(); string lo = Request["LO"]; string ln = Request["LN"]; string code = Request["CODE"]; List <BCJ_CITY> citys = new List <BCJ_CITY>(); //如果城市编码是空表示顾客自己定位刚进入页面需要加载城市等信息 if (string.IsNullOrEmpty(code)) { TenAPI model = Utility.GetLocal(lo, ln); string citymodel = model.result.formatted_address; logger.Info(citymodel + "====" + lo + "===" + ln); //citys.AddRange(_book.GetCity()); citys.AddRange(_book.GetAvalibleCity()); BCJ_CITY one = citys.Where(a => citymodel.Contains(a.CITY_NAME)).ToList().FirstOrDefault(); code = one == null ? "110100" : one.CITY_CODE; } //加载门店列表 List <BCJ_STORES_EX> stores = _bcjStore.GetStoresByCityCode(code); //如果不是定位则计算距离城市中心点的位置 foreach (BCJ_STORES_EX storeM in stores) { Poin beigin = new Poin(double.Parse(ln), double.Parse(lo)); Poin end = new Poin(double.Parse(storeM.LONGITUDE), double.Parse(storeM.LATITUDE)); storeM.Distance = Utility.GetDistance(beigin, end).ToString(); storeM.NAME = storeM.NAME.Trim(); } msg.Data = new { CIRY_CODE = code, CIRYS = citys, STORES = stores.OrderBy(a => a.Distance) }; return(Json(msg)); }
/// <summary> /// 获取城市信息 /// </summary> /// <returns></returns> public ActionResult GetCity() { JsonSMsg msg = new JsonSMsg(); string lo = Request["LO"]; string ln = Request["LN"]; string city_code = Request["city_code"]; List <BCJ_CITY> citys = new List <BCJ_CITY>(); BCJ_CITY one = null; if (string.IsNullOrEmpty(city_code)) { citys = _book.GetCity(); if (citys.Count() <= 0) { msg.Status = 0; return(Json(msg)); } TenAPI model = Utility.GetLocal(lo, ln); string cityname = model.result.formatted_address; JavaScriptSerializer js = new JavaScriptSerializer(); logger.Info(js.Serialize(model) + lo + "====" + ln); one = citys.Where(a => cityname.Contains(a.CITY_NAME)).ToList().FirstOrDefault(); city_code = one == null ? "110100" : one.CITY_CODE; } //加载门店列表 List <BCJ_STORES_EX> stores = _store.GetStoresByCityCode(city_code); msg.Data = new { CITYS = citys, STORES = stores }; msg.Status = 1; msg.Message = one == null ? "110100" : one.CITY_CODE; return(Json(msg)); }