This commit is contained in:
Caiyanpeng committed 2022-03-09 09:11:53 +08:00
1 parent c3514df331
commit e3f5280d94
14 files changed
+191 -20

No files matched your search

@@ -38,5 +38,10 @@ namespace Assets.Scripts.Apis
{
return Get<JsonResult<AntManufacturer>>($"MapRecord/GetAntManufacturerById?id={id}");
}
public async Task<JsonResult<byte[]>> GetRecordSnapShot(int id)
{
return await GetAsync<JsonResult<byte[]>>($"Share/GetRecordSnapShot?id={id}");
}
}
}
+10 -1
View File
@@ -164,7 +164,16 @@ public class WeChatController
public void ShareImageToWX(int scene, byte[] image)
{
#if UNITY_ANDROID
mainActivityClass.CallStatic("ShareImageToWX", scene, image);
mainActivityClass.CallStatic("ShareImageToWX", scene, image,null);
#elif UNITY_IOS
ShareImgToWX(scene,image,image.Length);
#endif
}
public void ShareImageToWX(int scene, byte[] image,byte[] thumb)
{
#if UNITY_ANDROID
mainActivityClass.CallStatic("ShareImageToWX", scene, image, thumb);
#elif UNITY_IOS
ShareImgToWX(scene,image,image.Length);
#endif
@@ -9,6 +9,10 @@ using DG.Tweening;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using Facebook.Unity;
using System.Web;
using UnityEngine.Networking;
using System.Collections;
using System.Threading.Tasks;
namespace Assets.Scenes.Ride.Scripts
{
@@ -104,11 +108,13 @@ namespace Assets.Scenes.Ride.Scripts
photoURL: new Uri(cyclingController.mapRoute.CoverImage));
}
private void shareToWx(BaseEventData b)
{
private async void shareToWx(BaseEventData b)
{
UIManager.Instance.StartCoroutine(ShowLoading());
var res = await ConfigHelper.mapInterruptRecordApi.GetRecordSnapShot(cyclingController.RankingId);
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}", cyclingController.mapRoute.Name, "By " + App.CurrentUser.Nickname,null);
App.weChatController.ShareImageToWX(0, res.data, Resources.Load<Sprite>("Images/pf").texture.EncodeToJPG());
}
else
{
@@ -116,11 +122,18 @@ namespace Assets.Scenes.Ride.Scripts
}
}
private void shareToWxGp(BaseEventData b)
private IEnumerator ShowLoading()
{
Utils.showToast(null, "首次分享图片会消耗一些时间,请耐心等待", type: 1);
yield return null;
}
private async void shareToWxGp(BaseEventData b)
{
UIManager.Instance.StartCoroutine(ShowLoading());
var res = await ConfigHelper.mapInterruptRecordApi.GetRecordSnapShot(cyclingController.RankingId);
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}", cyclingController.mapRoute.Name, "By " + App.CurrentUser.Nickname,null);
App.weChatController.ShareImageToWX(1, res.data,Resources.Load<Sprite>("Images/pf").texture.EncodeToJPG());
}
else
{
+2 -1
View File
@@ -140,7 +140,8 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
SetActive4Button(false);
var isRecent = App.CurrentRouteType == "Recent Routes" && myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null && !isModal;
var isRecent = myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null && !isModal;
//var isRecent = App.CurrentRouteType == "Recent Routes" && myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null && !isModal;
transform.Find("BtnContinue").gameObject.SetActive(isRecent);
transform.Find("BtnReride").gameObject.SetActive(isRecent);
transform.Find("MapHBImg").gameObject.SetActive(!isRecent);
+13
View File
@@ -840,5 +840,18 @@ namespace Assets.Scripts
return time.ToString("yyyy-MM-dd");
}
}
public static IEnumerator ShareImageToWx(int scene, byte[] image)
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareImageToWX(scene, image);
}
else
{
Utils.showToast(null, "未安装微信");
}
yield return null;
}
}
}