public SendDynamicDialog(DynamicItemDisplayModel dynamicItem)
 {
     this.InitializeComponent();
     emoteVM       = new EmoteVM();
     atVM          = new AtVM();
     topicVM       = new TopicVM();
     sendDynamicVM = new SendDynamicVM(dynamicItem);
 }
예제 #2
0
 public void OpenDetail(DynamicItemDisplayModel data)
 {
     MessageCenter.OpenNewWindow(this, new NavigationInfo()
     {
         icon       = Symbol.Document,
         page       = typeof(DynamicDetailPage),
         title      = "动态详情",
         parameters = data.DynamicID
     });
 }
예제 #3
0
        private DynamicItemDisplayModel ConvertToDisplayRepost(DynamicCardModel item)
        {
            var card = JObject.Parse(item.card);
            var data = new DynamicItemDisplayModel()
            {
                Datetime    = Utils.TimestampToDatetime(item.desc.timestamp).ToString(),
                DynamicID   = item.desc.dynamic_id,
                Mid         = item.desc.uid,
                Time        = Utils.HandelTimestamp(item.desc.timestamp.ToString()),
                UserCommand = UserCommand
            };
            var content = "";

            //内容
            if (card.ContainsKey("item") && card["item"]["content"] != null)
            {
                content = card["item"]["content"]?.ToString();
            }
            data.ContentStr = content;

            if (item.desc.user_profile != null)
            {
                data.UserName = item.desc.user_profile.info.uname;
                data.Photo    = item.desc.user_profile.info.face;
                if (item.desc.user_profile.vip != null)
                {
                    data.IsYearVip = item.desc.user_profile.vip.vipType == 2;
                }
                switch (item.desc.user_profile.card?.official_verify?.type ?? 3)
                {
                case 0:
                    data.Verify = AppHelper.VERIFY_PERSONAL_IMAGE;
                    break;

                case 1:
                    data.Verify = AppHelper.VERIFY_OGANIZATION_IMAGE;
                    break;

                default:
                    data.Verify = AppHelper.TRANSPARENT_IMAGE;
                    break;
                }
                if (!string.IsNullOrEmpty(item.desc.user_profile.pendant?.image))
                {
                    data.Pendant = item.desc.user_profile.pendant.image;
                }
            }
            return(data);
        }
예제 #4
0
        public async void OpenSendDynamicDialog(DynamicItemDisplayModel data)
        {
            if (!SettingHelper.Account.Logined && !await Utils.ShowLoginDialog())
            {
                Utils.ShowMessageToast("请先登录后再操作");
                return;
            }

            SendDynamicDialog sendDynamicDialog = new SendDynamicDialog();

            if (data != null)
            {
                sendDynamicDialog = new SendDynamicDialog(data);
            }
            await sendDynamicDialog.ShowAsync();
        }
예제 #5
0
        public async void DoLike(DynamicItemDisplayModel item)
        {
            if (!SettingHelper.Account.Logined && !await Utils.ShowLoginDialog())
            {
                Utils.ShowMessageToast("请先登录后再操作");
                return;
            }

            try
            {
                var results = await dynamicAPI.Like(item.DynamicID, item.Liked? 2 : 1).Request();

                if (results.status)
                {
                    var data = await results.GetJson <ApiDataModel <object> >();

                    if (data.success)
                    {
                        if (item.Liked)
                        {
                            item.Liked      = false;
                            item.LikeCount -= 1;
                        }
                        else
                        {
                            item.Liked      = true;
                            item.LikeCount += 1;
                        }
                    }
                    else
                    {
                        Utils.ShowMessageToast(data.message);
                    }
                }
                else
                {
                    Utils.ShowMessageToast(results.message);
                }
            }
            catch (Exception ex)
            {
                var handel = HandelError <object>(ex);
                Utils.ShowMessageToast(handel.message);
            }
        }
예제 #6
0
        public async void Delete(DynamicItemDisplayModel item)
        {
            if (!SettingHelper.Account.Logined && !await Utils.ShowLoginDialog())
            {
                Utils.ShowMessageToast("请先登录后再操作");
                return;
            }
            MessageDialog messageDialog = new MessageDialog("确定要删除动态吗?", "删除动态");

            messageDialog.Commands.Add(new UICommand("确定", cmd => { }, commandId: 0));
            messageDialog.Commands.Add(new UICommand("取消", cmd => { }, commandId: 1));
            var result = await messageDialog.ShowAsync();

            if (result.Id.ToInt32() == 1)
            {
                return;
            }
            try
            {
                var results = await dynamicAPI.Delete(item.DynamicID).Request();

                if (results.status)
                {
                    var data = await results.GetJson <ApiDataModel <object> >();

                    if (data.success)
                    {
                        Items.Remove(item);
                    }
                    else
                    {
                        Utils.ShowMessageToast(data.message);
                    }
                }
                else
                {
                    Utils.ShowMessageToast(results.message);
                }
            }
            catch (Exception ex)
            {
                var handel = HandelError <object>(ex);
                Utils.ShowMessageToast(handel.message);
            }
        }
예제 #7
0
        private DynamicItemDisplayModel ConvertToDisplay(DynamicCardModel item)
        {
            try
            {
                var card        = JObject.Parse(item.card);
                var extend_json = JObject.Parse(item.extend_json);
                var data        = new DynamicItemDisplayModel()
                {
                    CommentCount      = item.desc.comment,
                    Datetime          = Utils.TimestampToDatetime(item.desc.timestamp).ToString(),
                    DynamicID         = item.desc.dynamic_id,
                    LikeCount         = item.desc.like,
                    Mid               = item.desc.uid,
                    ShareCount        = item.desc.repost,
                    Time              = Utils.HandelTimestamp(item.desc.timestamp.ToString()),
                    IntType           = item.desc.type,
                    ReplyID           = item.desc.rid_str,
                    ReplyType         = item.desc.r_type,
                    Type              = DynamicParse.ParseType(item.desc.type),
                    UserCommand       = UserCommand,
                    LaunchUrlCommand  = LaunchUrlCommand,
                    WebCommand        = WebCommand,
                    TagCommand        = TagCommand,
                    LotteryCommand    = LotteryCommand,
                    VoteCommand       = VoteCommand,
                    IsSelf            = item.desc.uid == SettingHelper.Account.UserID,
                    ImageCommand      = ImageCommand,
                    CommentCommand    = CommentCommand,
                    LikeCommand       = LikeCommand,
                    DeleteCommand     = DeleteCommand,
                    RepostCommand     = RepostCommand,
                    DetailCommand     = DetailCommand,
                    WatchLaterCommand = watchLaterVM.AddCommand,
                    Liked             = item.desc.is_liked == 1
                };
                if (data.Type == DynamicDisplayType.Other)
                {
                    return(new DynamicItemDisplayModel()
                    {
                        Type = DynamicDisplayType.Other,
                        IntType = 999,
                        DynamicID = item.desc.dynamic_id,
                        ContentStr = $"未适配的类型{data.IntType}:\r\n" + JsonConvert.SerializeObject(item)
                    });
                }
                data.OneRowInfo = DynamicParse.ParseOneRowInfo(data.Type, card);
                if (data.Type == DynamicDisplayType.ShortVideo)
                {
                    data.ShortVideoInfo = DynamicParse.ParseShortVideoInfo(card);
                }
                if (data.Type == DynamicDisplayType.Photo)
                {
                    List <DyanmicItemDisplayImageInfo> imgs = new List <DyanmicItemDisplayImageInfo>();
                    List <string> allImageUrl = new List <string>();
                    int           i           = 0;
                    foreach (var img in card["item"]["pictures"])
                    {
                        allImageUrl.Add(img["img_src"].ToString());
                        imgs.Add(new DyanmicItemDisplayImageInfo()
                        {
                            ImageUrl     = img["img_src"].ToString(),
                            Height       = img["img_height"].ToInt32(),
                            Width        = img["img_width"].ToInt32(),
                            Index        = i,
                            ImageCommand = ImageCommand
                        });
                        i++;
                    }

                    //偷懒方法,点击图片时可以获取全部图片信息,好孩子不要学
                    imgs.ForEach((x) => x.AllImages = allImageUrl);

                    data.ImagesInfo = imgs;
                }

                if (data.Type == DynamicDisplayType.Repost)
                {
                    if (card.ContainsKey("origin_user"))
                    {
                        var originUser    = JsonConvert.DeserializeObject <DynamicCardDescUserProfileModel>(card["origin_user"].ToString());
                        var originDisplay = ConvertToDisplay(new DynamicCardModel()
                        {
                            extend_json = card["origin_extend_json"].ToString(),
                            card        = card["origin"].ToString(),
                            display     = item.display?.origin,
                            desc        = new DynamicCardDescModel()
                            {
                                user_profile = originUser,
                                uid          = originUser.info.uid,
                                dynamic_id   = item.desc.orig_dy_id,
                                type         = item.desc.orig_type
                            }
                        });
                        originDisplay.IsRepost = true;
                        data.OriginInfo        = new List <DynamicItemDisplayModel>()
                        {
                            originDisplay
                        };
                    }
                    else
                    {
                        data.OriginInfo = new List <DynamicItemDisplayModel>()
                        {
                            new DynamicItemDisplayModel()
                            {
                                IsRepost = true,
                                IntType  = 1024,
                                Type     = DynamicDisplayType.Miss
                            }
                        };
                    }
                }
                if (item.desc.comment == 0 && card.ContainsKey("stat"))
                {
                    data.CommentCount = card["stat"]["reply"].ToInt32();
                }
                //Season数据会出现desc.comment为0的情况
                if (item.desc.comment == 0 && card.ContainsKey("reply_count"))
                {
                    data.CommentCount = card["reply_count"].ToInt32();
                }
                //专栏数据会出现desc.comment为0的情况
                if (item.desc.comment == 0 && card.ContainsKey("stats"))
                {
                    data.CommentCount = card["stats"]["reply"].ToInt32();
                }
                var content = "";
                //内容
                if (card.ContainsKey("item") && card["item"]["content"] != null)
                {
                    content = card["item"]["content"]?.ToString();
                    extend_json["at_control"] = card["item"]["ctrl"];
                }
                else if (card.ContainsKey("item") && card["item"]["description"] != null)
                {
                    content = card["item"]["description"]?.ToString();
                    extend_json["at_control"] = card["item"]["at_control"];
                }
                else if (card.ContainsKey("dynamic"))
                {
                    content = card["dynamic"]?.ToString();
                }
                else if (card.ContainsKey("vest") && card["vest"]["content"] != null)
                {
                    content = card["vest"]["content"]?.ToString();
                }

                if (!string.IsNullOrEmpty(content))
                {
                    data.ContentStr = content;
                    data.Content    = DynamicParse.StringToRichText(item.desc.dynamic_id, content, item.display?.emoji_info?.emoji_details, extend_json);
                }
                else
                {
                    data.ShowContent = false;
                }


                if (item.desc.user_profile != null)
                {
                    data.UserName = item.desc.user_profile.info.uname;
                    data.Photo    = item.desc.user_profile.info.face;
                    if (item.desc.user_profile.vip != null)
                    {
                        data.IsYearVip = item.desc.user_profile.vip.vipType == 2;
                    }
                    switch (item.desc.user_profile.card?.official_verify?.type ?? 3)
                    {
                    case 0:
                        data.Verify = AppHelper.VERIFY_PERSONAL_IMAGE;
                        break;

                    case 1:
                        data.Verify = AppHelper.VERIFY_OGANIZATION_IMAGE;
                        break;

                    default:
                        data.Verify = AppHelper.TRANSPARENT_IMAGE;
                        break;
                    }
                    if (!string.IsNullOrEmpty(item.desc.user_profile.pendant?.image))
                    {
                        data.Pendant = item.desc.user_profile.pendant.image;
                    }
                    //装扮
                    data.DecorateName  = item.desc.user_profile.decorate_card?.name;
                    data.DecorateText  = item.desc.user_profile.decorate_card?.fan?.num_desc;
                    data.DecorateColor = item.desc.user_profile.decorate_card?.fan?.color;
                    data.DecorateImage = item.desc.user_profile.decorate_card?.big_card_url;
                }


                if (card.ContainsKey("apiSeasonInfo"))
                {
                    data.UserName = card["apiSeasonInfo"]["title"].ToString();
                    data.Photo    = card["apiSeasonInfo"]["cover"].ToString();
                    data.TagName  = card["apiSeasonInfo"]["type_name"].ToString();
                    data.ShowTag  = true;
                    data.Time     = data.Time + "更新了";
                }
                if (card.ContainsKey("season"))
                {
                    data.UserName = card["season"]["title"].ToString();
                    data.Photo    = card["season"]["cover"].ToString();
                    data.TagName  = card["season"]["type_name"].ToString();
                    data.ShowTag  = true;
                    data.Time     = data.Time + "更新了";
                }
                return(data);
            }
            catch (Exception)
            {
                return(new DynamicItemDisplayModel()
                {
                    Type = DynamicDisplayType.Other,
                    IntType = 999,
                    DynamicID = item.desc.dynamic_id,
                    ContentStr = "动态加载失败:\r\n" + JsonConvert.SerializeObject(item)
                });
            }
        }
예제 #8
0
 public void OpenComment(DynamicItemDisplayModel data)
 {
     OpenCommentEvent?.Invoke(this, data);
 }
예제 #9
0
 public SendDynamicVM(DynamicItemDisplayModel repostInfo)
 {
     dynamicAPI = new Api.User.DynamicAPI();
     RepostInfo = repostInfo;
     IsRepost   = true;
 }