Example #1
0
        private async void TwoTapped_TappedAsync(long id)
        {
            try
            {
                string action = await Application.Current.MainPage.DisplayActionSheet("选择操作", "取消", null, "删除", "修改");

                if (action == "删除")
                {
                    if (!Tools.IsNetConnective())
                    {
                        CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long);
                        return;
                    }

                    CartItemInfo temp = new CartItemInfo();
                    foreach (var item in ItemList)
                    {
                        if (item.productId == id)
                        {
                            temp = item;
                            //ItemList.Remove(item);
                        }
                    }

                    //Frame frame = sender as Frame;
                    //int index = ItemStack.Children.IndexOf(frame);

                    StupidRD stupidRD = await _restSharpService.DeleteItemInCart(temp);

                    if (stupidRD.success)
                    {
                        CrossToastPopUp.Current.ShowToastSuccess("删除成功!", ToastLength.Short);
                        InitCart();
                    }
                    else
                    {
                        CrossToastPopUp.Current.ShowToastError("删除失败!", ToastLength.Short);
                    }
                }
            }
            catch (System.Exception)
            {
                throw;
            }
        }