private async void AddToCartAsync() { try { if (!Tools.IsNetConnective()) { CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long); return; } RestSharpService _restSharpService = new RestSharpService(); string memberId = GlobalVariables.LoggedUser.id.ToString(); string productId = Product.productId.ToString(); string num = ProductNum.ToString(); string attributeValue = Product.itemAttributeValues[Index].attributeValue; SimpleRD simpleRD = await _restSharpService.AddToCart(memberId, productId, num, attributeValue); if (simpleRD.message == "success") { CrossToastPopUp.Current.ShowToastSuccess("已添加到购物车!", ToastLength.Short); } else { CrossToastPopUp.Current.ShowToastError("添加到购物车失败!", ToastLength.Long); } } catch (Exception) { throw; } }