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

                RestSharpService _restSharpService = new RestSharpService();

                string memberId = GlobalVariables.LoggedUser.id.ToString();

                AddressRD addressRD = await _restSharpService.GetAddressListById(memberId);

                if (addressRD.result.Count != 0)
                {
                    AddressList = new ObservableCollection <AddressInfo>(addressRD.result);
                    Visible     = false;
                }
                else
                {
                    Visible = true;
                    CrossToastPopUp.Current.ShowToastError("无收货地址列表,请添加。", ToastLength.Long);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// 获取收货地址列表
        /// </summary>
        /// <param name="memberId"></param>
        /// <returns></returns>
        public async Task <AddressRD> GetAddressListById(string memberId)
        {
            string url  = "/member/addressList";
            string json = "{\"userId\":" + memberId + "}";

            AddressRD addressRD = await RestSharpHelper <AddressRD> .PostAsync(url, json);

            return(addressRD);
        }
Example #3
0
        /// <summary>
        /// 获取收货地址列表
        /// </summary>
        /// <param name="memberId"></param>
        /// <returns></returns>
        public async Task <AddressRD> GetAddressListById(string memberId)
        {
            string url = rootUrl3 + "/member/addressList";

            string httpContent = "{\"userId\":" + memberId + "}";

            string responseBody = await PostAsync(url, httpContent);

            AddressRD addressRD = JsonConvert.DeserializeObject <AddressRD>(responseBody);   //反序列化

            return(addressRD);
        }
        /// <summary>
        /// 获取收货地址列表
        /// </summary>
        /// <param name="memberId"></param>
        /// <returns></returns>
        public static async Task <AddressRD> GetAddressListById(string memberId)
        {
            try
            {
                string url  = "/member/addressList";
                string json = "{\"userId\":" + memberId + "}";

                AddressRD addressRD = await RestSharpHelper <AddressRD> .PostAsync(url, json);

                return(addressRD);
            }
            catch (ApplicationException ex)
            {
                throw ex;
            }
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        private async void InitAddress()
        {
            try
            {
                if (!Tools.IsNetConnective())
                {
                    CrossToastPopUp.Current.ShowToastError("无网络连接,请检查网络。", ToastLength.Long);
                    return;
                }

                //RestSharpService _restSharpService = new RestSharpService();

                string memberId = GlobalVariables.LoggedUser.id.ToString();

                AddressRD addressRD = await RestSharpService.GetAddressListById(memberId);

                if (addressRD.result.Count != 0)
                {
                    foreach (var item in addressRD.result)
                    {
                        if (item.isDefault)
                        {
                            AddressId  = item.addressId;
                            UserName   = item.userName;
                            Tel        = item.tel;
                            IsDefault  = item.isDefault;
                            StreetName = item.streetName;
                            break;
                        }
                    }

                    if (AddressId == 0)
                    {
                        UserName = "******";
                    }
                }
                else
                {
                    CrossToastPopUp.Current.ShowToastError("无收货地址列表,请添加。", ToastLength.Long);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Example #6
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);
            }
        }