using BBWY.Client.APIServices;
using BBWY.Client.Models.APIModel.Response.PackTask;
using BBWY.Client.Models;
using BBWY.Client.Views.PackTask;
using BBWY.Common.Models;
using BBWY.Controls;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Linq;
using System.Windows.Controls;
using System.ComponentModel;
using HandyControl.Controls;
using System.Windows;
using System.Collections;
using NPOI.SS.Formula.Functions;
using GalaSoft.MvvmLight.Messaging;
using BBWY.Client.Models.APIModel;
using BBWY.Client.Models.PackTask;
using BBWY.Client.Views.SealBox;
using BBWY.Client.Views.FallWare;
using BBWY.Client.Models.FallWare;

namespace BBWY.Client.ViewModels.PackTask
{

    public partial class WareHouseListViewModel : BaseVM, IDenpendency//注入服务
    {

        #region 属性绑定

        private string searchWayBillNo;
        public string SearchWayBillNo
        {
            get => searchWayBillNo; set
            {
                Set(ref searchWayBillNo, value);
            }
        }
        private string searchExpressName;
        public string SearchExpressName
        {
            get => searchExpressName; set
            {
                Set(ref searchExpressName, value);
            }
        }

        public string fallWareWaitConfigureCount;
        public string FallWareWaitConfigureCount { get => fallWareWaitConfigureCount; set { Set(ref fallWareWaitConfigureCount, value); } }

        public string fallWareConfiguredCount;
        public string FallWareConfiguredCount { get => fallWareConfiguredCount; set { Set(ref fallWareConfiguredCount, value); } }



        private ObservableCollection<WaitFallWareModel> waitFallWareList;
        /// <summary>
        /// 待落仓列表
        /// </summary>
        public ObservableCollection<WaitFallWareModel> WaitFallWareList { get => waitFallWareList; set { Set(ref waitFallWareList, value); } }




        private ObservableCollection<SealBoxModel> waitSealBoxModels;
        /// <summary>
        /// 分箱列表
        /// </summary>
        public ObservableCollection<SealBoxModel> WaitSealBoxModels { get => waitSealBoxModels; set { Set(ref waitSealBoxModels, value); } }

        private ObservableCollection<PackTaskModel> packTaskList;
        /// <summary>
        /// 打包任务列表
        /// </summary>
        public ObservableCollection<PackTaskModel> PackTaskList { get => packTaskList; set { Set(ref packTaskList, value); } }

        /// <summary>
        /// 查询时间段
        /// </summary>
        private DateTime startTime;
        public DateTime StartTime { get => startTime; set { Set(ref startTime, value); } }

        private DateTime endTime;
        public DateTime EndTime { get => endTime; set { Set(ref endTime, value); } }

        private string searchShopName;
        public string SearchShopName
        {
            get => searchShopName; set
            {
                Set(ref searchShopName, value);
            }
        }

        /// <summary>
        /// 查询任务id
        /// </summary>
        private string searchTaskId;
        public string SearchTaskId
        {
            get => searchTaskId; set
            {
                Set(ref searchTaskId, value);
            }
        }

        /// <summary>
        /// 查询Sku
        /// </summary>
        private string searchSkuId;
        public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } }

        public TaskState? taskState;
        /// <summary>
        /// 任务状态
        /// </summary>
        public TaskState? TaskState
        {
            get => taskState; private set
            {
                Set(ref taskState, value);
            }
        }

        private int pageIndex = 1;
        private int pageSize = 10;
        private int orderCount;//总数量

        private Visibility tipVisitity;
        /// <summary>
        /// 
        /// </summary>
        public Visibility TipVisitity { get => tipVisitity; set { Set(ref tipVisitity, value); } }

        /// <summary>
        /// 未到货数量
        /// </summary>
        public string NoArrivedCount { get => noArrivedCount; set { Set(ref noArrivedCount, value); } }
        private string noArrivedCount;
        private string someArrivedCount;
        /// <summary>
        /// 部分到货数量
        /// </summary>
        public string SomeArrivedCount { get => someArrivedCount; set { Set(ref someArrivedCount, value); } }
        private string worryCount;
        /// <summary>
        /// 加急数
        /// </summary>
        public string WorryCount { get => worryCount; set { Set(ref worryCount, value); } }


        private string arrivedCount;
        /// <summary>
        /// 已到货数量
        /// </summary>
        public string ArrivedCount { get => arrivedCount; set { Set(ref arrivedCount, value); } }




        private string waitPackCount;
        /// <summary>
        /// 待打包任务数
        /// </summary>
        public string WaitPackCount { get => waitPackCount; set { Set(ref waitPackCount, value); } }
        private string waitSealBoxCount;
        /// <summary>
        /// 带封箱任务数
        /// </summary>
        public string WaitSealBoxCount { get => waitSealBoxCount; set { Set(ref waitSealBoxCount, value); } }



        private string waitFallWareCount;
        /// <summary>
        /// 待落仓任务数
        /// </summary>
        public string WaitFallWareCount { get => waitFallWareCount; set { Set(ref waitFallWareCount, value); } }

        private string waitOutbound;
        /// <summary>
        /// 待出库任务数
        /// </summary>
        public string WaitOutbound { get => waitOutbound; set { Set(ref waitOutbound, value); } }


        private string waitCompleted;
        /// <summary>
        /// 待完成任务数
        /// </summary>
        public string WaitCompleted { get => waitCompleted; set { Set(ref waitCompleted, value); } }



        public int PageIndex { get => pageIndex; set { Set(ref pageIndex, value); } }

        public int PageSize { get => pageSize; set { Set(ref pageSize, value); } }

        public int OrderCount { get => orderCount; set { Set(ref orderCount, value); } }

        private bool isLoading;
        public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }


        private int? IsWorry { get; set; }
        public int? taskStatus { get; set; }


        public string searchDepartment;
        public string SearchDepartment
        {
            get => searchDepartment; set
            {
                Set(ref searchDepartment, value);

            }
        }
        private SealBoxConfigureType sealBoxConfigureType;
        /// <summary>
        /// 封箱配置状态
        /// </summary>
        public SealBoxConfigureType SealBoxConfigureType { get => sealBoxConfigureType; set { Set(ref sealBoxConfigureType, value); } }

        #endregion

        private readonly PackTaskService packTaskService;
        private readonly SealBoxService sealBoxService;
        public GlobalContext globalContext;
        public WareHouseListViewModel(PackTaskService packTaskService, GlobalContext globalContext, SealBoxService sealBoxService)
        {
            this.globalContext = globalContext;
            this.sealBoxService = sealBoxService;
            this.packTaskService = packTaskService;


            //Messenger.Default.Send(globalContext, "AcceptGlobalContext");
            PackTaskList = new ObservableCollection<PackTaskModel>();//初始化数据

            SetTaskStateCommand = new RelayCommand<TaskState?>(SetTaskState);

            SearchTaskCommand = new RelayCommand(() =>
            {
                PageIndex = 1;
                Task.Factory.StartNew(() => SearchTaskList());  //手动点击查询订单
            });
            TaskPageIndexChangedCommand = new RelayCommand<PageArgs>(p =>
            {
                LoadIndex(p.PageIndex);
            });

            OpenSkuDetailCommand = new RelayCommand<object>(OpenSkuDetail);

            StartTime = DateTime.Now.Date;
            EndTime = DateTime.Now.Date;
            IsLoading = false;
            SetTaskStatusCommand = new RelayCommand<object>(SetTaskStatus);

            //加载数据
            SetTaskState(null);

            UpdateTaskStateCommand = new RelayCommand<object>(UpdateTaskState);

            CompeteSealBoxCommand = new RelayCommand<object>(CompeteSealBox);

            SetSealBoxCommand = new RelayCommand<object>(SetSealBox);
            CompeteFallWareCommand = new RelayCommand<object>(CompeteFallWare);
            SealBoxConfigureType = SealBoxConfigureType.已配置;
            PositionState = PositionState.已配置待落仓;
           SetSealBoxConfigureTypeCommand = new RelayCommand<SealBoxConfigureType>(s =>
            {
                PageIndex = 1;
                SealBoxConfigureType = s;
                PositionState = s == SealBoxConfigureType.已配置 ? PositionState.已配置待落仓 : PositionState.待落仓;
                Task.Factory.StartNew(() => SearchTaskList());
            });

     

            LookBoxConfigureCommand = new RelayCommand<object>(LookBoxConfigure);

            PrintBoxConfigureCommand = new RelayCommand<object>(PrintBoxConfigure);
        }


        /// <summary>
        /// todo: 打印数据
        /// </summary>
        /// <param name="obj"></param>
        private void PrintBoxConfigure(object obj)
        {
            var fallware = obj as WaitFallWareModel;

            JDWareBoxModel model = new JDWareBoxModel
            {
                ShopName = globalContext.User.Shop.ShopName,
                WareName = fallware.WareName,
                SealBoxId = fallware.SealBoxId,
                ProductCount = fallware.ProductCount,
                BoxCount = fallware.SealBoxCount,
                PrewOrder = fallware.BoxConfigureData.PrewOrder,
                ProductTitle = fallware.BoxConfigureData.ProductTitle,
                PurchaseOrder = fallware.BoxConfigureData.PurchaseOrder,
                WaybillNo = fallware.BoxConfigureData.WaybillNo
            };
            if (fallware.WareType == WareType.京仓)
            {
              //加载模板数据
            }
            if (fallware.WareType == WareType.云仓)
            {
              
            }
           //打印
        }

        private void LookBoxConfigure(object obj)
        {
            var fallware = obj as WaitFallWareModel;
            JDWareBoxModel model = new JDWareBoxModel
            {
                ShopName = globalContext.User.Shop.ShopName,
                WareName = fallware.WareName,
                SealBoxId = fallware.SealBoxId,
                ProductCount = fallware.ProductCount,
                BoxCount = fallware.SealBoxCount,
                PrewOrder = fallware.BoxConfigureData.PrewOrder,
                ProductTitle = fallware.BoxConfigureData.ProductTitle,
                PurchaseOrder = fallware.BoxConfigureData.PurchaseOrder,
                WaybillNo = fallware.BoxConfigureData.WaybillNo
            };
            if (fallware.WareType == WareType.京仓)
            {
                //SetJDWareBoxWindow window = new SetJDWareBoxWindow(model, sealBoxService, fallware.WareType, ReflashTask,false);
                //window.Show();
                var w = new SetJDWareBoxWindow2(model, sealBoxService, fallware.WareType, ReflashTask, false);
                w.ShowDialog();
            }
            if (fallware.WareType == WareType.云仓)
            {
                SetCloudWareBoxWindow window = new SetCloudWareBoxWindow(model, sealBoxService, fallware.WareType, ReflashTask, false);
                window.Show();
            }
        }

        public PositionState PositionState { get; set; }

        /// <summary>
        /// 完成落仓(todo:)
        /// </summary>
        /// <param name="obj"></param>
        private void CompeteFallWare(object obj)
        {

            if (System.Windows.MessageBox.Show("是否完成落仓?", "提示",
                                MessageBoxButton.YesNo,
                                MessageBoxImage.Warning) != MessageBoxResult.Yes)
                return;

            var model = obj as WaitFallWareModel;
            var res = sealBoxService.WareCompeteFallWare(model.SealBoxId);
            if (res != null&&res.Success)
            {
                ReflashTask();return;
            }
            if (res==null)
            {
                System.Windows.MessageBox.Show("网络异常");
                return;
            }
            System.Windows.MessageBox.Show(res.Msg);
        }

        private void SetSealBox(object obj)
        {

            var model = (SealBoxModel)obj;
            if (model.SealBoxSkus.Any(s => s.TaskState == Models.TaskState.待质检 || s.TaskState == Models.TaskState.待打包))
            {
                System.Windows.MessageBox.Show("无法封箱,存在未封箱的任务");
                return;
            }

            SetSealBoxWindow setSealBoxWindow = new SetSealBoxWindow(model);
            setSealBoxWindow.SendBoxCount = boxCount =>
            {
                model.SealBoxCount = boxCount;
            };
            setSealBoxWindow.ShowDialog();
        }


        #region 事件绑定 

        public ICommand LookBoxConfigureCommand { get; set; }
        /// <summary>
        /// 待配置 /已配置
        /// </summary>
        public ICommand SetSealBoxConfigureTypeCommand { get; set; }
        public ICommand CompeteFallWareCommand { get; set; }
        public ICommand CompeteSealBoxCommand { get; set; }

        public ICommand SetTaskStatusCommand { get; set; }
        /// <summary>
        /// 打开图片链接
        /// </summary>
        public ICommand OpenSkuDetailCommand { get; set; }


        /// <summary>
        /// 筛选数据 
        /// </summary>
        public ICommand SetTaskStateCommand { get; set; }

        /// <summary>
        /// 修改任务状态
        /// </summary>
        public ICommand UpdateTaskStateCommand { get; set; }
        /// <summary>
        /// 搜索数据
        /// </summary>
        public ICommand SearchTaskCommand { get; set; }

        /// <summary>
        /// 创建任务
        /// </summary>
        public ICommand CreateTaskCommand { get; set; }

        /// <summary>
        /// 页面改变事件
        /// </summary>
        public ICommand TaskPageIndexChangedCommand { get; set; }

        /// <summary>
        /// 设置分箱数量
        /// </summary>
        public ICommand SetSealBoxCommand { get; set; }
        

        /// <summary>
        /// 打印封箱数据
        /// </summary>
        public ICommand PrintBoxConfigureCommand { get; set; }



    /// <summary>
    /// 完成封箱
    /// </summary>
    /// <param name="obj"></param>
    private void CompeteSealBox(object obj)
        {
            var model = (SealBoxModel)obj;

            if (model.SealBoxCount == null || model.SealBoxCount.Value <= 0)
            {
                System.Windows.MessageBox.Show("请先设置封箱数量");
                return;
            }
            var res = sealBoxService.WareCompeteSealBox(model.SealBoxId, model.SealBoxCount);
            if (res == null)
            {
                System.Windows.MessageBox.Show("网络异常", "");
                return;
            }



            if (!res.Success || !res.Data)
            {
                System.Windows.MessageBox.Show(res.Msg);
                return;
            }
            SearchTaskList();

        }

        private void UpdateTaskState(object obj)
        {
            var model = (PackTaskModel)obj;
            long taskId = model.TaskId;
            var packTaskState = model.TaskState;

            ApiResponse<object> res = null;


            switch (packTaskState)
            {
                case Models.TaskState.未到货:
                case Models.TaskState.部分到货:

                    if (System.Windows.MessageBox.Show("是否确认收货?", "提示",
                                  MessageBoxButton.YesNo,
                                  MessageBoxImage.Warning) != MessageBoxResult.Yes)
                        return;

                    res = packTaskService.SetPackTaskState(taskId, Models.TaskState.待质检);
                    break;
                case Models.TaskState.待质检:
                    break;
                case Models.TaskState.待打包:

                    var packModel = PackTaskList.SingleOrDefault(p => p.TaskId == taskId);
                    if (packModel == null || packModel.FeesItemResponse == null || packModel.FeesItemResponse.DiscountAllFees == 0)
                    {
                        System.Windows.MessageBox.Show("请先设置打包费用!");
                        return;
                    }
                    if (System.Windows.MessageBox.Show("是否完成打包?", "提示",
                                 MessageBoxButton.YesNo,
                                 MessageBoxImage.Warning) != MessageBoxResult.Yes)
                        return;
                    res = packTaskService.SetPackTaskState(taskId, Models.TaskState.待封箱);
                    break;
                case Models.TaskState.待封箱:
                    break;
                case Models.TaskState.待出库:


                    break;
                case Models.TaskState.已完成:
                    break;
                case Models.TaskState.已取消:
                    break;
                default:
                    break;
            }
            if (res != null && res.Success)
            {
                SearchTaskList();
            }


        }
        public void SetTaskStatus(object obj)
        {
            var objList = (object[])obj;

            long taskId = (long)objList[0];

            string orderId = (string)objList[1];
            ///修改完成
            var model = packTaskService.UpdateTaskStatus(taskId, 1, orderId);
            if (model != null && model.Success)
                SearchTaskList();

        }
        public void SetTaskState(TaskState? taskState)
        {
            PageIndex = 1;
            TaskState = taskState;
            SearchTaskList();

        }



        /// <summary>
        /// 搜索任务列表
        /// </summary>
        public void SearchTaskList()
        {
            long? taskId = null;
            try
            {
                if (SearchTaskId != null && !string.IsNullOrEmpty(SearchTaskId.Trim()))
                    taskId = Convert.ToInt64(SearchTaskId);
            }
            catch
            {
                taskId = null;

            }
            IsLoading = true;
            if (TaskState == Models.TaskState.待落仓)
                Task.Factory.StartNew(() =>
                {
                   

                    WaitFallWareList = new ObservableCollection<WaitFallWareModel>();
                    var datas = sealBoxService.SearchWareFallWareConfigureList(PositionState, SearchShopName, taskId, SearchSkuId, PageIndex, PageSize);
                    if (datas != null && datas.Data != null && datas.Success)
                    {
                        var dataModel = datas.Data;
                        OrderCount = dataModel.TotalCount;
                        foreach (var item in dataModel.WaitFallWareList)
                        {
                            App.Current.Dispatcher.Invoke(new Action(() =>
                            {
                                WaitFallWareList.Add(new WaitFallWareModel
                                {
                                    AcceptUserNames = string.Join("|", item.AcceptUserNames),
                                    DepartmentName = item.DepartmentName,
                                    SealBoxSkus = item.SealBoxSkus,
                                    ShopId = item.ShopId,
                                    ShopName = item.ShopName,
                                    WareId = item.WareId,
                                    WareName = item.WareName,
                                    SealBoxCount = item.SealBoxCount,
                                    SealBoxId = item.SealBoxId,
                                     BoxConfigureData = item.BoxConfigureData,
                                      ProductCount = item.ProductCount,
                                       WareType = item.WareType,

                                });
                            }));

                        }
                    }
                    else
                    {
                        //App.Current.Dispatcher.BeginInvoke(new Action(() =>
                        //{
                        //    new TipsWindow("查不到数据").Show();
                        //}));
                    }
                    IsLoadCount();
                    IsLoadFallWareCount();
                     IsLoading = false;

                });
            else if (TaskState == Models.TaskState.待封箱)
                Task.Factory.StartNew(() =>
                {


                    var randNum = new Random().Next(81, 90);
                    WaitSealBoxModels = new ObservableCollection<SealBoxModel>();

                    var datas = sealBoxService.GetWareSealBoxList(SearchShopName, taskId, SearchSkuId, PageIndex, PageSize);
                    if (datas != null && datas.Data != null && datas.Success)
                    {
                        var dataModel = datas.Data;
                        OrderCount = dataModel.TotalCount;
                        foreach (var item in dataModel.WaitSealBoxModels)
                        {

                            App.Current.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                WaitSealBoxModels.Add(new SealBoxModel
                                {
                                    AcceptUserName = string.Join("|", item.AcceptUserNames),
                                    DepartmentName = item.DepartmentName,
                                    SealBoxSkus = item.SealBoxSkus.Select(s =>
                                    {

                                        s.Logo = s.Logo.Replace("80x80", $"{randNum}x{randNum}");
                                        return s;
                                    }).ToList(),
                                    ShopId = item.ShopId,
                                    ShopName = item.ShopName,
                                    WareId = item.WareId,
                                    WareName = item.WareName,
                                    SealBoxId = item.SealBoxId,
                                });
                            }));

                        }
                    }
                    else
                    {
                        //App.Current.Dispatcher.BeginInvoke(new Action(() =>
                        //{
                        //    new TipsWindow("查不到数据").Show();
                        //}));
                    }
                    IsLoadCount();
                    IsLoading = false;

                });
            else
                Task.Factory.StartNew(() =>
                {
                    PackTaskList = new ObservableCollection<PackTaskModel>();//初始化数据

                    var datas = packTaskService.GetWareHouseList(SearchWayBillNo, SearchExpressName, IsWorry, SearchDepartment, SearchSkuId, SearchTaskId, StartTime, EndTime, (this.TaskState), SearchShopName,
                        PageIndex, PageSize);
                    if (datas != null && datas.Data != null && datas.Success)
                    {
                        var dataModel = datas.Data;
                        OrderCount = dataModel.TotalCount;
                        foreach (var item in dataModel.Items)
                        {
                            var data = new PackTaskModel()
                            {
                                AcceptName = item.UserName,
                                Availability = (Availability)item.Availability,
                                BasicPack = (BasicPack)item.BasicPack,
                                DepartmentName = item.DepartmentName,
                                CertificatePosition = (CertificatePosition)item.CertificatePosition,

                                GoodsNumber = item.GoodsNumber,
                                Increment1 = item.Increment1,
                                ItemList = new List<SkuMessage>() { new SkuMessage
                            {    BrandName = item.BrandName,
                                 GoodsNo = item.ProductItemNum, Logo= item.Logo,
                                 ShopName = item.ShopName, SkuName = item.SkuName,
                                 Id = item.SkuId

                            } },
                                MarkMessage = item.MarkMessage,
                                PackType = (PackType)item.PackType,
                                TaskState = item.TaskState,
                                PositionType = item.PositionType,
                                SkuCount = item.SkuCount,
                                SkuTitle = item.SkuGoodsTitle,
                                TaskId = item.TaskId,
                                EndTime = item.CreateTime,
                                OrderId = item.OrderId,
                                SkuId = item.SkuId,
                                SkuName = item.SkuName,
                                FloorDragNumber = item.FloorDragNumber,


                            };
                            if (item.BarCodeDTO != null && item.BarCodeDTO.Id > 0)
                            {

                                data.BarCodeModel = item.BarCodeDTO;

                            }
                            if (item.Cers != null)
                            {
                                data.CertificateModel = item.Cers;

                            }

                            data.ReflashTask = ReflashTask;

                            if (item.FeesItemResponse != null)
                            {
                                data.FeesItemResponse = item.FeesItemResponse;
                                data.FeesMoney = item.FeesItemResponse.SingleFees;

                                data.FeesItemResponse.DiscountAllFees = item.FeesItemResponse.AllFees *
                                item.FeesItemResponse.disCount;
                                data.IsShowFees = data.FeesMoney > 0 ? true : false;

                            }
                            else
                            {
                                data.IsShowFees = false;
                            }

                            if (item.PackUserName != null && item.PackUserName.Count() > 0)
                            {
                                data.PackUser = string.Join("\r\n", item.PackUserName);
                            }

                            App.Current.Dispatcher.BeginInvoke(new Action(() =>
                            {
                                PackTaskList.Add(data);
                            }));

                        }
                    }
                    else
                    {
                    }
                    IsLoadCount();
                    IsLoading = false;
                });
        }
        private void IsLoadFallWareCount()
        {
            var res = sealBoxService.GetFallWareConfigureCounts(null);
            if (res != null && res.Success && res.Data != null)
            {
                FallWareWaitConfigureCount = res.Data.FallWareWaitConfigureCount.ToString();
                FallWareConfiguredCount = res.Data.FallWareConfiguredCount.ToString();
            }
        }
        private void IsLoadCount()
        {
            var packTaskResult = packTaskService.GetTaskAllCount();
            if (packTaskResult != null && packTaskResult.Success && packTaskResult.Data != null)
            {
                App.Current.Dispatcher.Invoke(new Action(() =>
                {
                    ArrivedCount = packTaskResult.Data.ArrivedCount.ToString();
                    NoArrivedCount = packTaskResult.Data.NoArrivedCount.ToString();
                    SomeArrivedCount = packTaskResult.Data.SomeArrivedCount.ToString();
                    WorryCount = packTaskResult.Data.WorryCount.ToString();
                    WaitOutbound = packTaskResult.Data.WaitOutbound?.ToString();
                    WaitPackCount = packTaskResult.Data.WaitPackCount?.ToString();
                    WaitSealBoxCount = packTaskResult.Data.WaitSealBox?.ToString();
                    WaitFallWareCount = packTaskResult.Data.WaitFallWareCount?.ToString();
                    WaitCompleted = packTaskResult.Data.WaitCompleted?.ToString();
                }));
            }
        }
        private void LoadIndex(int pageIndex)
        {
            PageIndex = pageIndex;//
            SearchTaskList();
        }
        public void ReflashTask()//刷新界面
        {
            SearchTaskList();
        }


        private void OpenSkuDetail(object param)
        {
            var paramList = (object[])param;
            var skuId = paramList.Last().ToString();
            var url = $"https://item.jd.com/{skuId}.html";
            try
            {
                System.Diagnostics.Process.Start("explorer.exe", url);
            }
            catch (Exception ex)
            {
                Clipboard.SetText(url);
                System.Windows.MessageBox.Show($"{ex.Message}\r\n调用浏览器失败,网页链接已复制到剪切板,请手动打开浏览器访问", "提示");
            }
        }


        #endregion

    }
}