添加nuget和网络请求api
This commit is contained in:
parent
f8bcfd977f
commit
f557e2f5df
2
.gitignore
vendored
2
.gitignore
vendored
@ -69,3 +69,5 @@ crashlytics-build.properties
|
||||
# Temporary auto-generated Android Assets
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa.meta
|
||||
/[Aa]ssets/[Ss]treamingAssets/aa/*
|
||||
Assets/Packages
|
||||
Assets/Packages.meta
|
||||
|
||||
15
Assets/NuGet.config
Normal file
15
Assets/NuGet.config
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<clear/>
|
||||
<add key="NuGet" value="http://www.nuget.org/api/v2/" />
|
||||
</packageSources>
|
||||
<disabledPackageSources />
|
||||
<activePackageSource>
|
||||
<add key="All" value="(Aggregate source)" />
|
||||
</activePackageSource>
|
||||
<config>
|
||||
<add key="repositoryPath" value="./Packages" />
|
||||
<add key="DefaultPushSource" value="http://www.nuget.org/api/v2/" />
|
||||
</config>
|
||||
</configuration>
|
||||
32
Assets/NuGet.config.meta
Normal file
32
Assets/NuGet.config.meta
Normal file
@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36beb3506906c8048ad370241fcd0b87
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/NuGet.meta
Normal file
9
Assets/NuGet.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 217cb7caed5f7fb49b339428b1d80974
|
||||
folderAsset: yes
|
||||
timeCreated: 1510280316
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/NuGet/Editor.meta
Normal file
9
Assets/NuGet/Editor.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3fad56c531ac5a4db190a745f589a8e
|
||||
folderAsset: yes
|
||||
timeCreated: 1510280304
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/NuGet/Editor/NugetForUnity.dll
Normal file
BIN
Assets/NuGet/Editor/NugetForUnity.dll
Normal file
Binary file not shown.
33
Assets/NuGet/Editor/NugetForUnity.dll.meta
Normal file
33
Assets/NuGet/Editor/NugetForUnity.dll.meta
Normal file
@ -0,0 +1,33 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dc1be91775c4bb469f6b74cef450eaa
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/NuGet/LICENSE
Normal file
21
Assets/NuGet/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Patrick McCarthy
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
8
Assets/NuGet/LICENSE.meta
Normal file
8
Assets/NuGet/LICENSE.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d9014b99ad06af428514a5902d29ff3
|
||||
timeCreated: 1573248500
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/NuGet/README.pdf
Normal file
BIN
Assets/NuGet/README.pdf
Normal file
Binary file not shown.
8
Assets/NuGet/README.pdf.meta
Normal file
8
Assets/NuGet/README.pdf.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83c5d2001771f15429a88d67e81366d6
|
||||
timeCreated: 1517876157
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
9
Assets/NuGet/Resources.meta
Normal file
9
Assets/NuGet/Resources.meta
Normal file
@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1738075a39a390447b7a620ca6962142
|
||||
folderAsset: yes
|
||||
timeCreated: 1510280362
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/NuGet/Resources/defaultIcon.png
Normal file
BIN
Assets/NuGet/Resources/defaultIcon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
88
Assets/NuGet/Resources/defaultIcon.png.meta
Normal file
88
Assets/NuGet/Resources/defaultIcon.png.meta
Normal file
@ -0,0 +1,88 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eec19781926cd2248b7c9abfde8db555
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
externalObjects: {}
|
||||
serializedVersion: 9
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -100
|
||||
wrapU: 1
|
||||
wrapV: 1
|
||||
wrapW: 1
|
||||
nPOTScale: 0
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 1
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 8
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 2
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID: 215e43cda847e6d44af8b40376eeed8a
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
spritePackingTag:
|
||||
pSDRemoveMatte: 0
|
||||
pSDShowRemoveMatteOption: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,298 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!29 &1
|
||||
OcclusionCullingSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_OcclusionBakeSettings:
|
||||
smallestOccluder: 5
|
||||
smallestHole: 0.25
|
||||
backfaceThreshold: 100
|
||||
m_SceneGUID: 00000000000000000000000000000000
|
||||
m_OcclusionCullingData: {fileID: 0}
|
||||
--- !u!104 &2
|
||||
RenderSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 9
|
||||
m_Fog: 0
|
||||
m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1}
|
||||
m_FogMode: 3
|
||||
m_FogDensity: 0.01
|
||||
m_LinearFogStart: 0
|
||||
m_LinearFogEnd: 300
|
||||
m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1}
|
||||
m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1}
|
||||
m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1}
|
||||
m_AmbientIntensity: 1
|
||||
m_AmbientMode: 0
|
||||
m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1}
|
||||
m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_HaloStrength: 0.5
|
||||
m_FlareStrength: 1
|
||||
m_FlareFadeSpeed: 3
|
||||
m_HaloTexture: {fileID: 0}
|
||||
m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_DefaultReflectionMode: 0
|
||||
m_DefaultReflectionResolution: 128
|
||||
m_ReflectionBounces: 1
|
||||
m_ReflectionIntensity: 1
|
||||
m_CustomReflection: {fileID: 0}
|
||||
m_Sun: {fileID: 705507994}
|
||||
m_IndirectSpecularColor: {r: 0.44657826, g: 0.49641263, b: 0.57481676, a: 1}
|
||||
m_UseRadianceAmbientProbe: 0
|
||||
--- !u!157 &3
|
||||
LightmapSettings:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 11
|
||||
m_GIWorkflowMode: 1
|
||||
m_GISettings:
|
||||
serializedVersion: 2
|
||||
m_BounceScale: 1
|
||||
m_IndirectOutputScale: 1
|
||||
m_AlbedoBoost: 1
|
||||
m_EnvironmentLightingMode: 0
|
||||
m_EnableBakedLightmaps: 1
|
||||
m_EnableRealtimeLightmaps: 0
|
||||
m_LightmapEditorSettings:
|
||||
serializedVersion: 12
|
||||
m_Resolution: 2
|
||||
m_BakeResolution: 40
|
||||
m_AtlasSize: 1024
|
||||
m_AO: 0
|
||||
m_AOMaxDistance: 1
|
||||
m_CompAOExponent: 1
|
||||
m_CompAOExponentDirect: 0
|
||||
m_ExtractAmbientOcclusion: 0
|
||||
m_Padding: 2
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_LightmapsBakeMode: 1
|
||||
m_TextureCompression: 1
|
||||
m_FinalGather: 0
|
||||
m_FinalGatherFiltering: 1
|
||||
m_FinalGatherRayCount: 256
|
||||
m_ReflectionCompression: 2
|
||||
m_MixedBakeMode: 2
|
||||
m_BakeBackend: 1
|
||||
m_PVRSampling: 1
|
||||
m_PVRDirectSampleCount: 32
|
||||
m_PVRSampleCount: 500
|
||||
m_PVRBounces: 2
|
||||
m_PVREnvironmentSampleCount: 500
|
||||
m_PVREnvironmentReferencePointCount: 2048
|
||||
m_PVRFilteringMode: 2
|
||||
m_PVRDenoiserTypeDirect: 0
|
||||
m_PVRDenoiserTypeIndirect: 0
|
||||
m_PVRDenoiserTypeAO: 0
|
||||
m_PVRFilterTypeDirect: 0
|
||||
m_PVRFilterTypeIndirect: 0
|
||||
m_PVRFilterTypeAO: 0
|
||||
m_PVREnvironmentMIS: 0
|
||||
m_PVRCulling: 1
|
||||
m_PVRFilteringGaussRadiusDirect: 1
|
||||
m_PVRFilteringGaussRadiusIndirect: 5
|
||||
m_PVRFilteringGaussRadiusAO: 2
|
||||
m_PVRFilteringAtrousPositionSigmaDirect: 0.5
|
||||
m_PVRFilteringAtrousPositionSigmaIndirect: 2
|
||||
m_PVRFilteringAtrousPositionSigmaAO: 1
|
||||
m_ExportTrainingData: 0
|
||||
m_TrainingDataDestination: TrainingData
|
||||
m_LightProbeSampleCountMultiplier: 4
|
||||
m_LightingDataAsset: {fileID: 0}
|
||||
m_UseShadowmask: 1
|
||||
--- !u!196 &4
|
||||
NavMeshSettings:
|
||||
serializedVersion: 2
|
||||
m_ObjectHideFlags: 0
|
||||
m_BuildSettings:
|
||||
serializedVersion: 2
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 2
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
manualCellSize: 0
|
||||
cellSize: 0.16666667
|
||||
manualTileSize: 0
|
||||
tileSize: 256
|
||||
accuratePlacement: 0
|
||||
debug:
|
||||
m_Flags: 0
|
||||
m_NavMeshData: {fileID: 0}
|
||||
--- !u!1 &705507993
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 705507995}
|
||||
- component: {fileID: 705507994}
|
||||
m_Layer: 0
|
||||
m_Name: Directional Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!108 &705507994
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 705507993}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 1
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1}
|
||||
m_Intensity: 1
|
||||
m_Range: 10
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 1
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 1
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 1, y: 1}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!4 &705507995
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 705507993}
|
||||
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
|
||||
m_LocalPosition: {x: 0, y: 3, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
|
||||
--- !u!1 &963194225
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 963194228}
|
||||
- component: {fileID: 963194227}
|
||||
- component: {fileID: 963194226}
|
||||
m_Layer: 0
|
||||
m_Name: Main Camera
|
||||
m_TagString: MainCamera
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!81 &963194226
|
||||
AudioListener:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 963194225}
|
||||
m_Enabled: 1
|
||||
--- !u!20 &963194227
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 963194225}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 1
|
||||
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_FocalLength: 50
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 0
|
||||
orthographic size: 5
|
||||
m_Depth: -1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingPath: -1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 1
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 1
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!4 &963194228
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 963194225}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: -10}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -1,5 +1,6 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fc0d4010bbf28b4594072e72b8655ab
|
||||
guid: c3657715ecf71dd4ca94ba58d3468e81
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
516
Assets/Scripts/Apis/ApiBase.cs
Normal file
516
Assets/Scripts/Apis/ApiBase.cs
Normal file
@ -0,0 +1,516 @@
|
||||
using Assets.Scripts;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public abstract class ApiBase
|
||||
{
|
||||
private static CookieContainer _cookieCollection = new CookieContainer();
|
||||
public static CookieCollection cookies
|
||||
{
|
||||
get
|
||||
{
|
||||
return _cookieCollection.GetCookies(new Uri(ConfigHelper.Host));
|
||||
}
|
||||
//set
|
||||
//{
|
||||
// _cookieCollection = value;
|
||||
//}
|
||||
}
|
||||
//protected static EasyHttp.Http.HttpClient http;
|
||||
private static System.Net.Http.HttpClient httpClient;
|
||||
private static HttpClientHandler httpClientHandler;
|
||||
static ApiBase()
|
||||
{
|
||||
//http = new EasyHttp.Http.HttpClient();
|
||||
//http.Request.PersistCookies = true;
|
||||
|
||||
httpClientHandler = new HttpClientHandler();
|
||||
httpClientHandler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
|
||||
httpClientHandler.CookieContainer = _cookieCollection;
|
||||
httpClientHandler.UseCookies = true;
|
||||
|
||||
httpClient = new System.Net.Http.HttpClient(httpClientHandler);
|
||||
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
httpClient.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Unity", ConfigHelper.AppVersion));
|
||||
}
|
||||
|
||||
protected async Task<bool> GetAsFileSync(string url, string fileName)
|
||||
{
|
||||
//var result = await Task.Factory.StartNew(() =>
|
||||
//{
|
||||
// var res = http.GetAsFile(ConfigHelper.Host + url, fileName);
|
||||
// return res;
|
||||
//});
|
||||
//return result;
|
||||
|
||||
|
||||
//using (var httpResponseMessage = await httpClient.SendAsync(CreateRequest(url, System.Net.Http.HttpMethod.Get), HttpCompletionOption.ResponseContentRead))
|
||||
//{
|
||||
byte[] data1 = await GetAsync(url);
|
||||
|
||||
if (data1 != null)
|
||||
{
|
||||
using (var stream = new FileStream(fileName, FileMode.Create))
|
||||
{
|
||||
stream.Write(data1, 0, data1.Length);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// return httpResponseMessage.IsSuccessStatusCode;
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected async Task<byte[]> GetAsync(string url)
|
||||
{
|
||||
AddLanguage();
|
||||
var httpResponseMessage = await httpClient.GetAsync(ConfigHelper.Host + url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
|
||||
if (!httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] data1 = await httpResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
return data1;
|
||||
}
|
||||
|
||||
protected async Task<byte[]> GetUrlAsync(string url)
|
||||
{
|
||||
var httpResponseMessage = await httpClient.GetAsync(url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
|
||||
if (!httpResponseMessage.IsSuccessStatusCode)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
byte[] data1 = await httpResponseMessage.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
|
||||
return data1;
|
||||
}
|
||||
//private HttpResponse Get(string url, object query = null)
|
||||
//{
|
||||
// return http.Get(ConfigHelper.Host + url, query);
|
||||
//}
|
||||
|
||||
protected async Task<T> GetAsync<T>(string url)
|
||||
{
|
||||
//var result = await Task.Factory.StartNew(() =>
|
||||
//{
|
||||
// return Get(url, query);
|
||||
//});
|
||||
|
||||
//return result;
|
||||
AddLanguage();
|
||||
var response = await httpClient.GetAsync(ConfigHelper.Host + url, HttpCompletionOption.ResponseContentRead).ConfigureAwait(false);
|
||||
return await ParseJsonAsync<T>(response);
|
||||
}
|
||||
|
||||
private async Task<T> ParseJsonAsync<T>(HttpResponseMessage response)
|
||||
{
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
Console.WriteLine(result);
|
||||
return JsonConvert.DeserializeObject<T>(result);
|
||||
}
|
||||
|
||||
//protected T Post<T>(string url, object data)
|
||||
//{
|
||||
// //var stream = new StreamContent()
|
||||
// var stringContent = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
|
||||
// AddLanguage();
|
||||
// var response = httpClient.PostAsync(ConfigHelper.Host + url, stringContent).GetAwaiter()
|
||||
// .GetResult();
|
||||
// if (response.IsSuccessStatusCode == false)
|
||||
// {
|
||||
// //return default(T);
|
||||
|
||||
// throw new Exception($"服务器端返回:{ response.StatusCode }\r\n{ response.RequestMessage }");
|
||||
// }
|
||||
// var info = ParseJsonAsync<T>(response).GetAwaiter().GetResult();
|
||||
// return info;
|
||||
//}
|
||||
|
||||
//protected HttpResponse Post(string url, object data, IList<FileInfo> files)
|
||||
//{
|
||||
// var formData = data.ToDictionary();
|
||||
// IList<FileData> files1 = new List<FileData>();
|
||||
// foreach (var item in files)
|
||||
// {
|
||||
// var fileData = new FileData();
|
||||
// fileData.FieldName = item.Name;
|
||||
// fileData.Filename = item.FullName;
|
||||
|
||||
// files1.Add(fileData);
|
||||
// }
|
||||
// return http.Post(ConfigHelper.Host + url, formData, files1);
|
||||
//}
|
||||
|
||||
//protected async Task<HttpResponse> PostAsync(string url, object data, IList<FileInfo> files)
|
||||
//{
|
||||
// var result = await Task.Factory.StartNew(() =>
|
||||
// {
|
||||
// return Post(url, data, files);
|
||||
// });
|
||||
// return result;
|
||||
//}
|
||||
|
||||
protected string Upload(string url, object data, IList<string> files)
|
||||
{
|
||||
var files1 = new Dictionary<string, Stream>();
|
||||
foreach (var file in files)
|
||||
{
|
||||
//writer.Write( // file header
|
||||
// $"\r\n--{boundary}\r\nContent-Disposition: " +
|
||||
// $"form-data; name=\"{ Path.GetFileName(file) }\"; filename=\"{Path.GetFileName(file)}\"\r\n" +
|
||||
// "Content-Type: application/octet-stream\r\n\r\n");
|
||||
|
||||
//writer.Flush();
|
||||
var fileStream = File.OpenRead(file);
|
||||
//fileStream.CopyTo(requestStream);
|
||||
|
||||
files1.Add(Path.GetFileName(file), fileStream);
|
||||
}
|
||||
|
||||
return Upload(url, data, files1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// formdata
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="files"></param>
|
||||
/// <returns></returns>
|
||||
protected string Upload(string url, object data, Dictionary<string, Stream> files)
|
||||
{
|
||||
//var requestContent = new MultipartFormDataContent();
|
||||
//foreach (var item in files)
|
||||
//{
|
||||
// // here you can specify boundary if you need---^
|
||||
// //var file = new System.IO.FileInfo(item);
|
||||
// var bytes = System.IO.File.ReadAllBytes(item);
|
||||
// var imageContent = new ByteArrayContent(bytes);
|
||||
// imageContent.Headers.ContentType =
|
||||
// MediaTypeHeaderValue.Parse(GetMimeType(System.IO.Path.GetExtension(item)));
|
||||
|
||||
// requestContent.Add(imageContent, Path.GetFileName(item), Path.GetFileName(item));
|
||||
//}
|
||||
|
||||
//var dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(JsonConvert.SerializeObject(data));
|
||||
//foreach (var item in dict)
|
||||
//{
|
||||
// if (item.Value == null) continue;
|
||||
// requestContent.Add(new StringContent(item.Value.ToString()), item.Key);
|
||||
//}
|
||||
|
||||
//using (var res = await httpClient.PostAsync(ConfigHelper.Host + url, requestContent).ConfigureAwait(false))
|
||||
//{
|
||||
// var rrr = await res.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
// return rrr;
|
||||
//}
|
||||
var request = (HttpWebRequest)WebRequest.Create(ConfigHelper.Host + url);
|
||||
request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
|
||||
request.Headers.Add("Language", "Zh-cn");
|
||||
request.CookieContainer = new CookieContainer();
|
||||
foreach (Cookie item in cookies)
|
||||
{
|
||||
request.CookieContainer.Add(item);
|
||||
}
|
||||
|
||||
var postData = new StringBuilder();
|
||||
var values = JsonConvert.DeserializeObject<Dictionary<string, string>>(JsonConvert.SerializeObject(data));
|
||||
foreach (var item in values)
|
||||
{
|
||||
postData.Append(WebUtility.UrlEncode($"{ item.Key }={ item.Value }&"));
|
||||
}
|
||||
|
||||
var boundary = $"{Guid.NewGuid():N}";
|
||||
request.ContentType = $"multipart/form-data; {nameof(boundary)}={boundary}";
|
||||
request.Method = "POST";
|
||||
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
|
||||
|
||||
//byte[] bytes;
|
||||
//using (var stream = new MemoryStream())
|
||||
//using (var writer = new StreamWriter(stream))
|
||||
//{
|
||||
// foreach (var ddd in values)
|
||||
// {
|
||||
// writer.Write( // put all POST data into request
|
||||
// $"\r\n--{boundary}\r\nContent-Disposition: " +
|
||||
// $"form-data; name=\"{ ddd.Key }\"\r\n\r\n{ ddd.Value }");
|
||||
// }
|
||||
// foreach (var file in files)
|
||||
// {
|
||||
// writer.Write( // file header
|
||||
// $"\r\n--{boundary}\r\nContent-Disposition: " +
|
||||
// $"form-data; name=\"{ Path.GetFileName(file) }\"; filename=\"{Path.GetFileName(file)}\"\r\n" +
|
||||
// "Content-Type: application/octet-stream\r\n\r\n");
|
||||
|
||||
// writer.Flush();
|
||||
// using (var fileStream = File.OpenRead(file))
|
||||
// fileStream.CopyTo(stream);
|
||||
// }
|
||||
// writer.Write($"\r\n--{boundary}--\r\n");
|
||||
|
||||
// bytes = stream.ToArray();
|
||||
//}
|
||||
//using (Stream postStream = request.GetRequestStream())
|
||||
//{
|
||||
// using (var zipStream = new GZipStream(postStream, CompressionMode.Compress))
|
||||
// {
|
||||
// zipStream.Write(bytes, 0, bytes.Length);
|
||||
// }
|
||||
//}
|
||||
|
||||
using (var requestStream = request.GetRequestStream())
|
||||
using (var writer = new StreamWriter(requestStream))
|
||||
{
|
||||
foreach (var ddd in values)
|
||||
{
|
||||
writer.Write( // put all POST data into request
|
||||
$"\r\n--{boundary}\r\nContent-Disposition: " +
|
||||
$"form-data; name=\"{ ddd.Key }\"\r\n\r\n{ ddd.Value }");
|
||||
}
|
||||
foreach (var file in files)
|
||||
{
|
||||
//writer.Write( // file header
|
||||
// $"\r\n--{boundary}\r\nContent-Disposition: " +
|
||||
// $"form-data; name=\"{ Path.GetFileName(file) }\"; filename=\"{Path.GetFileName(file)}\"\r\n" +
|
||||
// "Content-Type: application/octet-stream\r\n\r\n");
|
||||
|
||||
//writer.Flush();
|
||||
//using (var fileStream = File.OpenRead(file))
|
||||
// fileStream.CopyTo(requestStream);
|
||||
|
||||
|
||||
writer.Write( // file header
|
||||
$"\r\n--{boundary}\r\nContent-Disposition: " +
|
||||
$"form-data; name=\"{ file.Key }\"; filename=\"{ file.Key }\"\r\n" +
|
||||
"Content-Type: application/octet-stream\r\n\r\n");
|
||||
|
||||
writer.Flush();
|
||||
//using (var fileStream = File.OpenRead(file))
|
||||
file.Value.CopyTo(requestStream);
|
||||
}
|
||||
writer.Write($"\r\n--{boundary}--\r\n");
|
||||
}
|
||||
|
||||
using (var response = (HttpWebResponse)request.GetResponse())
|
||||
using (var responseStream = response.GetResponseStream())
|
||||
{
|
||||
if (responseStream == null)
|
||||
return string.Empty;
|
||||
using (var reader = new StreamReader(responseStream))
|
||||
return reader.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private string GetMimeType(string extension)
|
||||
{
|
||||
if (extension.Contains(".txt"))
|
||||
{
|
||||
return "text/plain";
|
||||
}
|
||||
if (extension.Contains(".png"))
|
||||
{
|
||||
return "image/png";
|
||||
}
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
//protected async Task<string> PostUrlAsync(string url, string data)
|
||||
//{
|
||||
// StringContent stringContent;
|
||||
// if (data != null)
|
||||
// {
|
||||
// stringContent = new StringContent(data, Encoding.UTF8, "application/json");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// stringContent = new StringContent("", Encoding.UTF8);
|
||||
// }
|
||||
// var response = await httpClient.PostAsync(url, stringContent).ConfigureAwait(false);
|
||||
// var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
// return result;
|
||||
//}
|
||||
|
||||
protected async Task<string> PostAsync(string url, object data)
|
||||
{
|
||||
StringContent stringContent;
|
||||
if (data != null)
|
||||
{
|
||||
stringContent = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json");
|
||||
}
|
||||
else
|
||||
{
|
||||
stringContent = new StringContent("", Encoding.UTF8);
|
||||
}
|
||||
AddLanguage();
|
||||
var response = await httpClient.PostAsync(ConfigHelper.Host + url, stringContent).ConfigureAwait(false);
|
||||
var result = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
protected async Task<T> PostAsync<T>(string url, object data)
|
||||
{
|
||||
//var result = await Task.Factory.StartNew(() =>
|
||||
//{
|
||||
// return Post(url, data);
|
||||
//});
|
||||
//new EasyHttp.Http.HttpResponse().Cookies
|
||||
//return result;
|
||||
|
||||
|
||||
StringContent stringContent;
|
||||
if (data != null)
|
||||
{
|
||||
var str = JsonConvert.SerializeObject(data);
|
||||
stringContent = new StringContent(str, Encoding.UTF8, "application/json");
|
||||
}
|
||||
else
|
||||
{
|
||||
stringContent = new StringContent("", Encoding.UTF8);
|
||||
}
|
||||
AddLanguage();
|
||||
var response = await httpClient.PostAsync(ConfigHelper.Host + url, stringContent).ConfigureAwait(false);
|
||||
//var cookies = response.Headers.GetValues("Set-Cookie");
|
||||
//if (cookies.Any())
|
||||
//{
|
||||
// foreach (var cookie in cookies)
|
||||
// {
|
||||
// ApiBase.cookies.Add(cookie)
|
||||
// }
|
||||
|
||||
//}
|
||||
var info = await ParseJsonAsync<T>(response);
|
||||
return info;
|
||||
}
|
||||
|
||||
//private static HttpRequestMessage CreateRequest(string url, System.Net.Http.HttpMethod method)
|
||||
//{
|
||||
// HttpRequestMessage httpRequestMessage1 = new HttpRequestMessage();
|
||||
// httpRequestMessage1.Method = method;
|
||||
// Uri uri = new Uri(ConfigHelper.Host + url);
|
||||
// httpRequestMessage1.RequestUri = uri;
|
||||
// HttpRequestMessage httpRequestMessage2 = httpRequestMessage1;
|
||||
// //if (requiresAuthentication)
|
||||
// // httpRequestMessage2.Headers.Authorization = this._authorization;
|
||||
// return httpRequestMessage2;
|
||||
//}
|
||||
|
||||
private void AddLanguage()
|
||||
{
|
||||
httpClient.DefaultRequestHeaders.Remove("Language");
|
||||
//httpClient.DefaultRequestHeaders.Add("Language", PubCommData.Lauguage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 因为cef调用c#代码,异步请求在win7上会有问题,所以写了同步的方法
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <returns></returns>
|
||||
public string Get(string url)
|
||||
{
|
||||
var url1 = url;
|
||||
if (url1.IndexOf("http") == -1)
|
||||
{
|
||||
url1 = ConfigHelper.Host + url1;
|
||||
}
|
||||
//AddLanguage();
|
||||
var request = (HttpWebRequest)WebRequest.Create(url1);
|
||||
request.Method = "GET";
|
||||
//foreach (var item in httpClient.DefaultRequestHeaders)
|
||||
//{
|
||||
// request.Headers.Add(item.Key, item.Value.First());
|
||||
//}
|
||||
request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
|
||||
request.Accept = "application/json";
|
||||
request.Headers.Add("Language", "Zh-cn");
|
||||
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
|
||||
request.CookieContainer = new CookieContainer();
|
||||
foreach (Cookie item in cookies)
|
||||
{
|
||||
request.CookieContainer.Add(item);
|
||||
}
|
||||
|
||||
var res = request.GetResponse();
|
||||
using (var stream = new StreamReader(res.GetResponseStream()))
|
||||
{
|
||||
return stream.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public T Get<T>(string url)
|
||||
{
|
||||
var res = Get(url);
|
||||
|
||||
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(res);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 因为cef调用c#代码,异步请求在win7上会有问题,所以写了同步的方法
|
||||
/// </summary>
|
||||
/// <param name="url"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public string Post(string url, object data)
|
||||
{
|
||||
var request = (HttpWebRequest)WebRequest.Create(ConfigHelper.Host + url);
|
||||
request.Method = "POST";
|
||||
request.UserAgent = httpClient.DefaultRequestHeaders.UserAgent.ToString();
|
||||
request.Accept = "application/json";
|
||||
request.Headers.Add("Language", "Zh-cn");
|
||||
request.CookieContainer = new CookieContainer();
|
||||
foreach (Cookie item in cookies)
|
||||
{
|
||||
request.CookieContainer.Add(item);
|
||||
}
|
||||
|
||||
request.ContentType = "application/json";
|
||||
if (data != null)
|
||||
{
|
||||
using (var streamWriter = new StreamWriter(request.GetRequestStream()))
|
||||
{
|
||||
streamWriter.Write(Newtonsoft.Json.JsonConvert.SerializeObject(data));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
request.ContentLength = 0;
|
||||
}
|
||||
var res = request.GetResponse();
|
||||
using (var stream = new StreamReader(res.GetResponseStream()))
|
||||
{
|
||||
return stream.ReadToEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public T Post<T>(string url, object data)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(Post(url, data));
|
||||
}
|
||||
|
||||
protected byte[] GetBytes(string url)
|
||||
{
|
||||
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
|
||||
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
|
||||
using (Stream netStream = response.GetResponseStream())
|
||||
{
|
||||
var data = ((MemoryStream)netStream).ToArray();
|
||||
return data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Scripts/Apis/ApiBase.cs.meta
Normal file
11
Assets/Scripts/Apis/ApiBase.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 852043d14fe11e044bd628892492efce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Scripts/Apis/JsonResult.cs
Normal file
22
Assets/Scripts/Apis/JsonResult.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class JsonResult
|
||||
{
|
||||
public bool result { get; set; }
|
||||
//public dynamic data { get; set; }
|
||||
public string errMsg { get; set; }
|
||||
}
|
||||
|
||||
public class JsonResult<T> : JsonResult
|
||||
{
|
||||
//public bool result { get; set; }
|
||||
public T data { get; set; }
|
||||
//public string errMsg { get; set; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/JsonResult.cs.meta
Normal file
11
Assets/Scripts/Apis/JsonResult.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d782ebdf1197264fbb7df630c9ec289
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
Assets/Scripts/Apis/MapApi.cs
Normal file
74
Assets/Scripts/Apis/MapApi.cs
Normal file
@ -0,0 +1,74 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
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}");
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过Id获取路书
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public JsonResult<MapRoute> GetById(int id)
|
||||
{
|
||||
return Get<JsonResult<MapRoute>>($"Map/GetMapRouteById?id={id}");
|
||||
}
|
||||
|
||||
/// <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>
|
||||
public JsonResult<List<MapRoute>> GetList(int pageIndex, int pageSize, string name, string distance="", string hands="", bool is3D=false, string sort="", string sortDire = "")
|
||||
{
|
||||
var url = $"Map/GetRoute?pageIndex={ pageIndex }&pageSize={ pageSize }&name={ name }&distance={ distance }&hands={ hands }&is3D={ is3D }&sort={ sort }&sortDire={ sortDire }";
|
||||
|
||||
return Get<JsonResult<List<MapRoute>>>(url);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从服务端获取Key
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> GetServiceKeyFromServer()
|
||||
{
|
||||
return Get<JsonResult<Dictionary<string, string>>>($"Map/GetServiceKey").data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/MapApi.cs.meta
Normal file
11
Assets/Scripts/Apis/MapApi.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efd73e0e9fe10314e8fbfa123aa6d210
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/Apis/MapInterruptRecordApi.cs
Normal file
25
Assets/Scripts/Apis/MapInterruptRecordApi.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class MapInterruptRecordApi:ApiBase
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 上传骑行记录到服务端
|
||||
/// </summary>
|
||||
/// <param name="interruptRecord"></param>
|
||||
public JsonResult<AddMapRecordResultModel> Add(MapInterruptRecord interruptRecord, List<string> fileNames)
|
||||
{
|
||||
var result = Upload("MapRecord/AddMapInterruptRecord", interruptRecord, fileNames);
|
||||
var jsonResult = JsonConvert.DeserializeObject<JsonResult<AddMapRecordResultModel>>(result);
|
||||
return jsonResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/MapInterruptRecordApi.cs.meta
Normal file
11
Assets/Scripts/Apis/MapInterruptRecordApi.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a19da168ad334a54abc24f4eb95751e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/Apis/Models.meta
Normal file
8
Assets/Scripts/Apis/Models.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 92062add3e1975c46bbf4d70543955a7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
13
Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs
Normal file
13
Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class AddMapRecordResultModel
|
||||
{
|
||||
public int RankingId { get; set; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/AddMapRecordResultModel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e10150ebcdd04eb4588cc8cd22385286
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
147
Assets/Scripts/Apis/Models/MapDataModel.cs
Normal file
147
Assets/Scripts/Apis/Models/MapDataModel.cs
Normal file
@ -0,0 +1,147 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class MapDataModel
|
||||
{
|
||||
public string Type { get; set; }
|
||||
|
||||
public double TotalDistance { get; set; }
|
||||
|
||||
//private double? _TotalClimb;
|
||||
///// <summary>
|
||||
///// 累计爬升
|
||||
///// </summary>
|
||||
//public double TotalClimb
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if(_TotalClimb == null)
|
||||
// {
|
||||
// var total = 0D;
|
||||
// for (int i = 0; i < List.Count; i++)
|
||||
// {
|
||||
// if(i < List.Count - 1)
|
||||
// {
|
||||
// var item = List[i];
|
||||
// var next = List[i + 1];
|
||||
// var value = next.Elevation - item.Elevation;
|
||||
// if(value > 0)
|
||||
// {
|
||||
// total += value;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// _TotalClimb = total;
|
||||
// }
|
||||
|
||||
// return _TotalClimb.GetValueOrDefault(0);
|
||||
// }
|
||||
//}
|
||||
|
||||
//public double AverageGrade
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// }
|
||||
//}
|
||||
|
||||
private List<Item> _List;
|
||||
public List<Item> List
|
||||
{
|
||||
get
|
||||
{
|
||||
return _List;
|
||||
}
|
||||
set
|
||||
{
|
||||
_List = value;
|
||||
if (_List == null) return;
|
||||
this.CalcDistance();
|
||||
this.CalcGrade();
|
||||
}
|
||||
}
|
||||
|
||||
private void CalcDistance()
|
||||
{
|
||||
//TODO:需要加上turfHelper
|
||||
//for (int i = 0; i < _List.Count - 1; i++)
|
||||
//{
|
||||
// var value = TurfHelper.GetDistances(new double[] { _List[i].Point[1], _List[i].Point[0] }, new double[] { _List[i + 1].Point[1], _List[i + 1].Point[0] });
|
||||
// _List[i].Distance = value;
|
||||
//}
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算坡度数据
|
||||
/// </summary>
|
||||
private void CalcGrade()
|
||||
{
|
||||
for (int i = 0; i < this._List.Count - 1; i++)
|
||||
{
|
||||
var a = _List[i + 1].Elevation - _List[i].Elevation;
|
||||
if (a == 0)
|
||||
{
|
||||
//grade.Add(0);
|
||||
_List[i].Grade = 0;
|
||||
continue;
|
||||
}
|
||||
//勾股定理
|
||||
var c = _List[i].Distance;//如果车停了下来,c为0
|
||||
//如果当前点到下一个点的距离是0,并且不是第一条记录,则坡度用上一个点的坡度
|
||||
if (c == 0 && i > 0)
|
||||
{
|
||||
_List[i].Grade = _List[i - 1].Grade;
|
||||
continue;
|
||||
}
|
||||
|
||||
var b = Math.Sqrt(c * c - a * a);
|
||||
if (double.IsNaN(b))
|
||||
{
|
||||
_List[i].Grade = 0;
|
||||
}
|
||||
else if (b == 0)//如果b等于,这就是垂直的墙壁
|
||||
{
|
||||
_List[i].Grade = _List[i - 1].Grade;
|
||||
}
|
||||
else
|
||||
{
|
||||
_List[i].Grade = Math.Round(a / b * 100, 4);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public MapDataModel()
|
||||
{
|
||||
//List = new List<Item>();
|
||||
}
|
||||
|
||||
public class Item
|
||||
{
|
||||
/// <summary>
|
||||
/// 坐标(lat,lon)
|
||||
/// </summary>
|
||||
public double[] Point { get; set; }
|
||||
/// <summary>
|
||||
/// 距离(单位米)
|
||||
/// </summary>
|
||||
public double Distance { get; set; }
|
||||
/// <summary>
|
||||
/// 海拔
|
||||
/// </summary>
|
||||
public double Elevation { get; set; }
|
||||
|
||||
public double Grade { get; set; }
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
//return base.ToString();
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/MapDataModel.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/MapDataModel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6894ce41336dd9f488f53bbe4ded61f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
109
Assets/Scripts/Apis/Models/MapInterruptRecord.cs
Normal file
109
Assets/Scripts/Apis/Models/MapInterruptRecord.cs
Normal file
@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class MapInterruptRecord
|
||||
{
|
||||
public string Id { get; set; }
|
||||
|
||||
public int RouteId { get; set; }
|
||||
|
||||
public string RouteUrl { get; set; }
|
||||
|
||||
public double EndDistance { get; set; }
|
||||
|
||||
public string RouteImage { get; set; }
|
||||
|
||||
public string RecordFileName { get; set; }
|
||||
|
||||
public string RouteName { get; set; }
|
||||
|
||||
public DateTime CreateTime { get; set; }
|
||||
|
||||
public bool IsCompleted { get; set; }
|
||||
|
||||
public string ElevationUrl { get; set; }
|
||||
|
||||
public double TotalDistance { get; set; }
|
||||
|
||||
public int UserId { get; set; }
|
||||
|
||||
public int? Ftp { get; set; }
|
||||
|
||||
public double? IF { get; set; }
|
||||
|
||||
public double? Kj { get; set; }
|
||||
|
||||
public double? Tss { get; set; }
|
||||
|
||||
public double? NormalizedPower { get; set; }
|
||||
|
||||
public double? AveragePower { get; set; }
|
||||
|
||||
public double? MaxPower { get; set; }
|
||||
|
||||
public int Ticks { get; set; }
|
||||
|
||||
public string TrainingTime { get; set; }
|
||||
/// <summary>
|
||||
/// 功率体重比
|
||||
/// </summary>
|
||||
public double? WeightKg { get; set; }
|
||||
/// <summary>
|
||||
/// 车重
|
||||
/// </summary>
|
||||
public double BicycleWeight { get; set; }
|
||||
|
||||
public double Weight { get; set; }
|
||||
|
||||
public double? AverageCadence { get; set; }
|
||||
|
||||
public double? MaxCadence { get; set; }
|
||||
|
||||
public double? AverageHeartRate { get; set; }
|
||||
|
||||
public double? MaxHeartRate { get; set; }
|
||||
/// <summary>
|
||||
/// 用户实际骑的距离和总线路长度的比
|
||||
/// </summary>
|
||||
public double? Progress { get; set; }
|
||||
|
||||
public string SpeedRange { get; set; }
|
||||
|
||||
public string ContinueMark { get; set; }
|
||||
|
||||
public int? ContinueIndex { get; set; }
|
||||
|
||||
public bool IsDelete { get; set; }
|
||||
|
||||
public int MapCompetitionId { get; set; }
|
||||
|
||||
public string ManufacturerName { get; set; }
|
||||
|
||||
public string DeviceNumber { get; set; }
|
||||
|
||||
public bool IsRanking { get; set; }
|
||||
|
||||
public double CurrentRouteStartDistance { get; set; }
|
||||
|
||||
public int? ManufacturerId { get; set; }
|
||||
|
||||
public int? AntModelId { get; set; }
|
||||
|
||||
public DateTime StartTime { get; set; }
|
||||
/// <summary>
|
||||
/// 骑行模式
|
||||
/// </summary>
|
||||
public string Mode { get; set; }
|
||||
/// <summary>
|
||||
/// 骑行模式的参数
|
||||
/// </summary>
|
||||
public string Param { get; set; }
|
||||
|
||||
public int GlobalCyclingId { get; set; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/MapInterruptRecord.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/MapInterruptRecord.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 35f4d405c5be4b74a913ae454acaae42
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/Scripts/Apis/Models/MapRecordRanking.cs
Normal file
27
Assets/Scripts/Apis/Models/MapRecordRanking.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class MapRecordRanking
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
|
||||
public string RecordFileName { get; set; }
|
||||
|
||||
public int RouteId { get; set; }
|
||||
|
||||
public int Ticks { get; set; }
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string[] record { get; set; }
|
||||
|
||||
public string WxHeadImg { get; set; }
|
||||
|
||||
public string NickName { get; set; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/MapRecordRanking.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/MapRecordRanking.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43f7b75b9a3b54845bfcfe10bc670621
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
104
Assets/Scripts/Apis/Models/MapRoute.cs
Normal file
104
Assets/Scripts/Apis/Models/MapRoute.cs
Normal file
@ -0,0 +1,104 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class MapRoute
|
||||
{
|
||||
public int Id { get; set; }
|
||||
/// <summary>
|
||||
/// 路线名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// 路线描述
|
||||
/// </summary>
|
||||
public string Dec { get; set; }
|
||||
/// <summary>
|
||||
/// 文件路径
|
||||
/// </summary>
|
||||
public string DirPath { get; set; }
|
||||
/// <summary>
|
||||
/// 路线区域
|
||||
/// </summary>
|
||||
public int Area { get; set; }
|
||||
/// <summary>
|
||||
/// 区域名称
|
||||
/// </summary>
|
||||
public string AreaName { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
/// </summary>
|
||||
public int UserId { get; set; }
|
||||
/// <summary>
|
||||
/// 是否删除:0未删除,1删除
|
||||
/// </summary>
|
||||
public bool? IsUsable { get; set; }
|
||||
/// <summary>
|
||||
/// 是否官方路书
|
||||
/// </summary>
|
||||
public bool? IsOfficial { get; set; }
|
||||
/// <summary>
|
||||
/// 路书的hash值,判断是否重复,得到byte[] hashcode必须传入
|
||||
/// </summary>
|
||||
public string Hash { get; set; }
|
||||
/// <summary>
|
||||
/// 路线长度
|
||||
/// </summary>
|
||||
public double Distance { get; set; }
|
||||
/// <summary>
|
||||
/// 最大高程落差
|
||||
/// </summary>
|
||||
public double EleDifference { get; set; }
|
||||
/// <summary>
|
||||
/// 落差长度
|
||||
/// </summary>
|
||||
public int GapLength { get; set; }
|
||||
/// <summary>
|
||||
/// 累计爬升
|
||||
/// </summary>
|
||||
public double? TotalClimb { get; set; }
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime UpdateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 状态(0未发布,1已发布)
|
||||
/// </summary>
|
||||
public int State { get; set; }
|
||||
/// <summary>
|
||||
/// 封面文件地址
|
||||
/// </summary>
|
||||
public string CoverImage { get; set; }
|
||||
/// <summary>
|
||||
/// 海拔数据
|
||||
/// </summary>
|
||||
public string ElevationPath { get; set; }
|
||||
/// <summary>
|
||||
/// 做为附近的人计算参数,不做数据存储
|
||||
/// </summary>
|
||||
public double? Near { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人姓名
|
||||
/// </summary>
|
||||
public string NickName { get; set; }
|
||||
|
||||
|
||||
public double[] Point { get; set; }
|
||||
|
||||
public string Address { get; set; }
|
||||
|
||||
public double AverageGrade { get; set; }
|
||||
|
||||
public bool IsFavorite { get; set; }
|
||||
|
||||
public bool Enable3D { get; set; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/MapRoute.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/MapRoute.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be111aadd2f1b034a9eece75ae35b955
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Scripts/Apis/Models/SummaryResultModel.cs
Normal file
50
Assets/Scripts/Apis/Models/SummaryResultModel.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class SummaryResultModel
|
||||
{
|
||||
public string NickName { get; set; }
|
||||
public int Id { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string WxHeadImg { get; set; }
|
||||
public int Ftp { get; set; }
|
||||
|
||||
public int Sex { get; set; }
|
||||
|
||||
public string CountryCode { get; set; }
|
||||
public string CountryImg { get; set; }
|
||||
|
||||
public double TotalKj { get; set; }
|
||||
public double MaxPower { get; set; }
|
||||
public double MaxHeartRate { get; set; }
|
||||
public double Weight { get; set; }
|
||||
public double BicycleWeight { get; set; }
|
||||
public int WheelDiameter { get; set; }
|
||||
/// <summary>
|
||||
/// 骑行次数
|
||||
/// </summary>
|
||||
public double Count { get; set; }
|
||||
public double TotalDistance { get; set; }
|
||||
public double TotalTicks { get; set; }
|
||||
public string TotalClimb { get; set; }
|
||||
public string Kcal { get; set; }
|
||||
public double TwentyMinutesMaxAP { get; set; }
|
||||
/// <summary>
|
||||
/// 单次最高海拔提升
|
||||
/// </summary>
|
||||
public string SingleElevationIncrease { get; set; }
|
||||
public double OneMinuteMaxAP { get; set; }
|
||||
public double SingleMaxCyclingTime { get; set; }
|
||||
public string MaxKcal { get; set; }
|
||||
public double FiveMinutesMaxAp { get; set; }
|
||||
public string SingleTripDistance { get; set; }
|
||||
public double CompleteRoute { get; set; }
|
||||
|
||||
public string Tips { get; set; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/SummaryResultModel.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/SummaryResultModel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5365c1dd3a8ce72429bf173971fa6597
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
Assets/Scripts/Apis/Models/UserResultModel.cs
Normal file
60
Assets/Scripts/Apis/Models/UserResultModel.cs
Normal file
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis.Models
|
||||
{
|
||||
public class UserResultModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Nickname { get; set; }
|
||||
/// <summary>
|
||||
/// 用户的性别,值为1时是男性,值为2时是女性,值为0时是未知
|
||||
/// </summary>
|
||||
public int Sex { get; set; }
|
||||
public int Unit { get; set; }
|
||||
public double Weight { get; set; }
|
||||
public int FTP { get; set; }
|
||||
public int WheelDiameter { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Pass { get; set; }
|
||||
public string OtherPlatforms { get; set; }
|
||||
public string Country { get; set; }
|
||||
public string Province { get; set; }
|
||||
public string City { get; set; }
|
||||
public string Area { get; set; }
|
||||
public string WxHeadImg { get; set; }
|
||||
public DateTime LastLoginTime { get; set; }
|
||||
/// <summary>
|
||||
/// 自动暂停
|
||||
/// </summary>
|
||||
public bool AutoPause { get; set; }
|
||||
/// <summary>
|
||||
/// 最大心率
|
||||
/// </summary>
|
||||
public int MaxHeartRate { get; set; }
|
||||
|
||||
public bool CanEditRoom { get; set; }
|
||||
/// <summary>
|
||||
/// 自行车重
|
||||
/// </summary>
|
||||
public double BicycleWeight { get; set; }
|
||||
|
||||
public string Contact { get; set; }
|
||||
|
||||
public string ContactPhone { get; set; }
|
||||
|
||||
public string ContactAddress { get; set; }
|
||||
/// <summary>
|
||||
/// 阻力灵敏度
|
||||
/// </summary>
|
||||
public int Sensitivity { get; set; }
|
||||
/// <summary>
|
||||
/// 已连接到Strava
|
||||
/// </summary>
|
||||
public bool ConnectedToStrava { get; set; }
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/Models/UserResultModel.cs.meta
Normal file
11
Assets/Scripts/Apis/Models/UserResultModel.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b02776a537d93a042bb09a7c0f7b4815
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
97
Assets/Scripts/Apis/UserApi.cs
Normal file
97
Assets/Scripts/Apis/UserApi.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts.Apis
|
||||
{
|
||||
public class UserApi : ApiBase
|
||||
{
|
||||
public async Task<JsonResult<UserResultModel>> Login(string phone, string pwd, string countryCode)
|
||||
{
|
||||
var param = new
|
||||
{
|
||||
Phone = phone,
|
||||
Pwd = pwd,
|
||||
countryCode
|
||||
};
|
||||
|
||||
JsonResult<UserResultModel> ret = null;
|
||||
try
|
||||
{
|
||||
ret = await PostAsync<JsonResult<UserResultModel>>("NoAuth/v1/Login", param);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new JsonResult<UserResultModel> { result = false, errMsg = ex.Message };
|
||||
}
|
||||
//ApiBase.cookies = response.Cookies;
|
||||
//var ret = response.DynamicBody;
|
||||
if (ret.result)
|
||||
{
|
||||
//var str = Newtonsoft.Json.JsonConvert.SerializeObject(ret.data);
|
||||
var user = new UserResultModel();
|
||||
user.Id = ret.data.Id;
|
||||
user.Nickname = ret.data.Nickname;
|
||||
user.Phone = ((string)ret.data.Phone).Trim();
|
||||
user.Country = ret.data.Country;
|
||||
user.Province = ret.data.Province;
|
||||
user.City = ret.data.City;
|
||||
user.Area = ret.data.Area;
|
||||
user.Pass = ret.data.Pass;
|
||||
user.Sex = ret.data.Sex;
|
||||
user.Unit = ret.data.Unit;
|
||||
user.Weight = ret.data.Weight;
|
||||
user.FTP = ret.data.FTP;
|
||||
user.WheelDiameter = ret.data.WheelDiameter;
|
||||
user.Email = user.Email ?? "";
|
||||
user.Pass = user.Pass ?? "";
|
||||
user.OtherPlatforms = user.OtherPlatforms ?? "";
|
||||
user.WxHeadImg = ret.data.WxHeadImg ?? "";
|
||||
//user.LoginTime = ret.data.LoginTime;
|
||||
user.LastLoginTime = ret.data.LastLoginTime;
|
||||
user.AutoPause = ret.data.AutoPause;
|
||||
user.MaxHeartRate = ret.data.MaxHeartRate;
|
||||
user.CanEditRoom = ret.data.CanEditRoom;
|
||||
user.BicycleWeight = ret.data.BicycleWeight;
|
||||
user.Contact = ret.data.Contact;
|
||||
user.ContactPhone = ret.data.ContactPhone;
|
||||
user.ContactAddress = ret.data.ContactAddress;
|
||||
user.Sensitivity = ret.data.Sensitivity;
|
||||
if (ret.data.ConnectedToStrava != null)
|
||||
{
|
||||
user.ConnectedToStrava = ret.data.ConnectedToStrava;
|
||||
}
|
||||
//todo: check local database, insert new user
|
||||
|
||||
//PubCommData.CurrentUser = user;
|
||||
|
||||
return new JsonResult<UserResultModel>() { result = true, data = user };
|
||||
}
|
||||
else
|
||||
{
|
||||
return new JsonResult<UserResultModel>() { result = false, data = null, errMsg = ret.errMsg };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取个人中心的统计信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public JsonResult<SummaryResultModel> GetSummary()
|
||||
{
|
||||
var result = Get<JsonResult<SummaryResultModel>>("User/GetSummary");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public DateTime GetNow()
|
||||
{
|
||||
var result = Get("NoAuth/GetNow");
|
||||
|
||||
return DateTime.Parse(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Apis/UserApi.cs.meta
Normal file
11
Assets/Scripts/Apis/UserApi.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5125f13b6b78d534bada8457fa9c2413
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
15
Assets/Scripts/ConfigHelper.cs
Normal file
15
Assets/Scripts/ConfigHelper.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public class ConfigHelper
|
||||
{
|
||||
public static string Host = "http://192.168.0.97:5082/";
|
||||
|
||||
public static string AppVersion = "1.0.0";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ConfigHelper.cs.meta
Normal file
11
Assets/Scripts/ConfigHelper.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 021b5a61b832e5543b09fc9b06da54a6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
4
Assets/packages.config
Normal file
4
Assets/packages.config
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="12.0.3" />
|
||||
</packages>
|
||||
32
Assets/packages.config.meta
Normal file
32
Assets/packages.config.meta
Normal file
@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0564d4e30aa722a499a256f4aa9eab96
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user