2021-04-14 15:02:33 +08:00
|
|
|
|
|
|
|
|
|
|
using Assets.Scenes.Ride.Scripts.Model;
|
2021-03-30 17:15:16 +08:00
|
|
|
|
using Assets.Scripts.Apis.Models;
|
2021-03-22 16:05:40 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2021-06-07 17:05:49 +08:00
|
|
|
|
using System.Globalization;
|
2021-03-22 16:05:40 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Assets.Scripts.Apis
|
|
|
|
|
|
{
|
|
|
|
|
|
public class MapApi :ApiBase
|
|
|
|
|
|
{
|
|
|
|
|
|
public string GetMapToken(string name)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Get($"Map/GetMapToken?name={name}");
|
|
|
|
|
|
}
|
2021-12-24 18:33:58 +08:00
|
|
|
|
public string GetTipsList()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Get($"Map/GetTipList");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-22 16:05:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取路线数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="url"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public MapDataModel GetData(int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Newtonsoft.Json.JsonConvert.DeserializeObject<MapDataModel>(Get("Map/GetData?routeId="+id));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从服务端获取记录信息
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public List<MapRecordRanking> GetRecordFileFromServer(List<string> id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Post<JsonResult<List<MapRecordRanking>>>("Map/GetCyclingRecordsById", id).data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-14 18:10:58 +08:00
|
|
|
|
|
2021-03-22 16:05:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 通过Id获取路书
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="id"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public JsonResult<MapRoute> GetById(int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Get<JsonResult<MapRoute>>($"Map/GetMapRouteById?id={id}");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-27 09:39:07 +08:00
|
|
|
|
|
2021-03-22 16:05:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
///
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="pageIndex"></param>
|
|
|
|
|
|
/// <param name="pageSize"></param>
|
|
|
|
|
|
/// <param name="name">名称,地址,编号</param>
|
|
|
|
|
|
/// <param name="distance">距离,格式0-10</param>
|
|
|
|
|
|
/// <param name="is3D"></param>
|
|
|
|
|
|
/// <param name="sort">hot, distance</param>
|
|
|
|
|
|
/// <param name="sortDire">asc</param>
|
|
|
|
|
|
/// <returns></returns>
|
2021-12-14 18:10:58 +08:00
|
|
|
|
public Task<JsonResult<List<MapRoute>>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "", bool isFav = false,bool isMine = false,bool isRecent = false)
|
2021-03-22 16:05:40 +08:00
|
|
|
|
{
|
2021-08-17 18:43:41 +08:00
|
|
|
|
string lngLat = "";
|
2021-08-19 13:23:22 +08:00
|
|
|
|
if (sort.Equals("Near"))
|
2021-08-17 18:43:41 +08:00
|
|
|
|
{
|
|
|
|
|
|
lngLat = $"{App.longitude},{App.latitude}";
|
|
|
|
|
|
}
|
2021-12-14 18:10:58 +08:00
|
|
|
|
var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }&isFav={isFav}&lngLat={lngLat}&isMine={isMine}&isRecent={isRecent}";
|
2021-03-22 16:05:40 +08:00
|
|
|
|
|
2021-04-21 16:16:14 +08:00
|
|
|
|
return GetAsync<JsonResult<List<MapRoute>>>(url);
|
2021-03-22 16:05:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-28 11:25:09 +08:00
|
|
|
|
public async Task<JsonResult<object>> CancelAreaFav(int areaId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await PostAsync<JsonResult<object>>("/MapRouteArea/CancelCollectArea", new { areaId });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<object>> AddAreaFav(int areaId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await PostAsync<JsonResult<object>>("/MapRouteArea/CollectArea",new { areaId});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-22 16:05:40 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 从服务端获取Key
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public Dictionary<string, string> GetServiceKeyFromServer()
|
|
|
|
|
|
{
|
|
|
|
|
|
return Get<JsonResult<Dictionary<string, string>>>($"Map/GetServiceKey").data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-30 17:15:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取在线用户的数据
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="ids"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public JsonResult<List<OnlineUser>> GetOnlineUserInfo(IEnumerable<int> ids)
|
|
|
|
|
|
{
|
|
|
|
|
|
//var result = PostAsync<JsonResult<List<OnlineUser>>>("Map/GetUserInfoByIds", ids).ConfigureAwait(false).GetAwaiter().GetResult();
|
|
|
|
|
|
var result = Newtonsoft.Json.JsonConvert.DeserializeObject<JsonResult<List<OnlineUser>>>(Post("Map/GetUserInfoByIds", ids));
|
|
|
|
|
|
if (result.result)
|
|
|
|
|
|
{
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-14 15:02:33 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<List<NearRouteModel>>> GetNearRouteAsync(float lat, float lng, float zoom, string bounds)
|
|
|
|
|
|
{
|
2021-06-07 17:05:49 +08:00
|
|
|
|
var res = await GetAsync<JsonResult<List<NearRouteModel>>>($"/Map/GetNearRoute?lat={ lat.ToString(CultureInfo.InvariantCulture) }&lng={ lng.ToString(CultureInfo.InvariantCulture) }&zoom={zoom.ToString(CultureInfo.InvariantCulture)}&bounds={ bounds }");
|
2021-04-14 15:02:33 +08:00
|
|
|
|
|
|
|
|
|
|
//var result = System.Text.Encoding.UTF8.GetString(res);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task<string> GetDetailsAsync(int[] ids)
|
|
|
|
|
|
{
|
|
|
|
|
|
var res = await GetAsync("/Map/GetDetails?ids=" + string.Join(",", ids));
|
|
|
|
|
|
|
|
|
|
|
|
return Encoding.UTF8.GetString(res);
|
|
|
|
|
|
}
|
2021-04-16 17:49:11 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 添加收藏
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public async Task<JsonResult<object>> AddFav(string routeId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await PostAsync<JsonResult<object>>("/MemberFavoriteMap/Add",new { routeId });
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 取消收藏
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
public async Task<JsonResult<object>> CancelFav(string routeId)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await PostAsync<JsonResult<object>>("/MemberFavoriteMap/Cancel", new { routeId });
|
|
|
|
|
|
}
|
2021-04-28 15:21:06 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<object>> DeleteRecord(string id)
|
|
|
|
|
|
{
|
|
|
|
|
|
return await PostAsync<JsonResult<object>>("/MapRecord/Delete", new { id });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-15 10:13:01 +08:00
|
|
|
|
public JsonResult<MapRouteRankingList> GetRouteRanking(int id,string type, int pageIndex,int pageSize,string name)
|
|
|
|
|
|
{
|
2021-05-11 18:21:32 +08:00
|
|
|
|
var url = $"Map/v1/GetRouteRanking?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&id={ id }&type={ type }&filterSelf={ false }";
|
|
|
|
|
|
|
|
|
|
|
|
return Get<JsonResult<MapRouteRankingList>>(url);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public JsonResult<MapRouteRankingList> GetShadowList(int id, string name, int pageIndex, int pageSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
var url = $"Map/GetShadowList?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&id={ id }";
|
2021-04-15 10:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
return Get<JsonResult<MapRouteRankingList>>(url);
|
|
|
|
|
|
}
|
2021-04-27 19:47:02 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<object>> GetEarthData(double lat, double lon)
|
|
|
|
|
|
{
|
2021-06-07 17:05:49 +08:00
|
|
|
|
var result = await GetAsync<JsonResult<object>>($"Map/GetEarthData?lat={ lat.ToString(CultureInfo.InvariantCulture) }&lon={ lon.ToString(CultureInfo.InvariantCulture) }");
|
2021-04-27 19:47:02 +08:00
|
|
|
|
|
2021-07-06 18:24:15 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取Loading页面路书封面图
|
2021-07-16 18:37:02 +08:00
|
|
|
|
public async Task<JsonResult<string>> GetMapLoadingCoverageUrl(int routeId,int type=0)
|
2021-07-06 18:24:15 +08:00
|
|
|
|
{
|
2021-07-16 18:37:02 +08:00
|
|
|
|
var url = $"Map/GetLoadingCoverage?id={ routeId }&type={ type }";
|
|
|
|
|
|
var result = await GetAsync<JsonResult<string>>(url);
|
2021-07-06 18:24:15 +08:00
|
|
|
|
|
2021-04-27 19:47:02 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2021-12-14 18:10:58 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<List<MapRouteArea>>> GetMapRouteAreaList(int pageIndex, int pageSize)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await GetAsync<JsonResult<List<MapRouteArea>>>($"MapRouteArea/GetList?pageSize={pageSize}&pageIndex={pageIndex}");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-27 18:29:23 +08:00
|
|
|
|
public async Task<JsonResult<MapRouteAreaRouteList>> GetMapRouteAreaDetailList(int id, int pageIndex, int pageSize)
|
2021-12-14 18:10:58 +08:00
|
|
|
|
{
|
2021-12-27 18:29:23 +08:00
|
|
|
|
var result = await GetAsync<JsonResult<MapRouteAreaRouteList>>($"MapRouteArea/GetRouteList?areaId={id}&pageSize={pageSize}&pageIndex={pageIndex}");
|
2021-12-14 18:10:58 +08:00
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2021-12-15 11:08:18 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<MapRouteAreaDetail>> GetMapRouteAreaDetail(int id)
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await GetAsync<JsonResult<MapRouteAreaDetail>>($"MapRouteArea/GetDetail?areaId={id}");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2021-12-15 18:18:12 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<List<MapMaxRanking>>> GetMaxRanking()
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await GetAsync<JsonResult<List<MapMaxRanking>>>($"Map/GetMaxRanking");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
|
|
|
|
|
|
public async Task<JsonResult<List<MapRouteAreaItem>>> GetRecommendAreaList()
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await GetAsync<JsonResult<List<MapRouteAreaItem>>>($"MapRouteArea/GetRecommendAreaList");
|
|
|
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-22 16:05:40 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|