Пример #1
0
        /// <summary>
        /// 获取地址列表
        /// </summary>
        public async void InitAddressList()
        {
            try
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long);
                    return;
                }

                string memberId = GlobalVariables.LoggedUser.id.ToString();
                string url      = "/member/addressList";
                string json     = "{\"userId\":" + memberId + "}";

                string result = await RestSharpHelper <string> .PostAsyncWithoutDeserialization(url, json);

                if (!string.IsNullOrWhiteSpace(result))
                {
                    AddressRD addressRD = JsonConvert.DeserializeObject <AddressRD>(result);

                    if (addressRD.result.Count != 0)
                    {
                        AddressList = new ObservableCollection <AddressInfo>(addressRD.result);
                        Visible     = false;
                    }
                    else
                    {
                        Visible = true;
                        CrossToastPopUp.Current.ShowToastError("无收货地址列表,请添加。", ToastLength.Long);
                    }
                }
                else
                {
                    CrossToastPopUp.Current.ShowToastError("Error", ToastLength.Long);
                    return;
                }
            }
            catch (Exception ex)
            {
                CrossToastPopUp.Current.ShowToastError(ex.Message, ToastLength.Long);
            }
        }