Esempio n. 1
0
        public void next(KfkPageData data)
        {
            Loading.Hide();
            RelativeLayout relativeLayout = new RelativeLayout(this);
            View           view           = LayoutInflater.From(this).Inflate(Assets.OpenXmlResourceParser("res/layout/xamarin_pay.xml"), relativeLayout);
            CardView       cardView       = (CardView)view.FindViewWithTag("cardview");

            cardView.Radius               = 45;
            cardView.Elevation            = 1;
            cardView.PreventCornerOverlap = false;
            Spinner Goods = (Spinner)view.FindViewWithTag("goods");

            Goods.Adapter = new GoodsAdapter(this, data.data);
            Spinner     Products = (Spinner)view.FindViewWithTag("products");
            Button      button   = (Button)view.FindViewWithTag("Pay");
            AlertDialog pay      = new AlertDialog.Builder(this, 4)
                                   .SetView(relativeLayout)
                                   .Create();

            pay.Show();
            pay.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent);
            Goods.ItemSelected += (v, i) =>
            {
                Products.Adapter = new ProductAdapter(this, data.data[i.Position].products);
            };
            button.Click += delegate
            {
                List <string> item = new List <string>();
                if (data.ZfbPay)
                {
                    item.Add("支付宝支付");
                }
                if (data.WxPay)
                {
                    item.Add("微信支付");
                }
                if (data.QQPay)
                {
                    item.Add("QQ钱包支付");
                }
                AlertDialog PayType = null;
                PayType = new AlertDialog.Builder(this, 5).SetTitle("请选择支付方式")
                          .SetSingleChoiceItems(item.ToArray(), -1, (dialog, pos) =>
                {
                    //创建订单
                    Loading.Show(this);
                    int p = 0;
                    switch (item[pos.Which])
                    {
                    case "支付宝支付":
                        p = 1;
                        break;

                    case "微信支付":
                        p = 2;
                        break;

                    case "QQ钱包支付":
                        p = 3;
                        break;
                    }
                    HttpApi.Build_order(this, data.data[Goods.SelectedItemPosition].products[Products.SelectedItemPosition].product_id, p, data.buyer_token, XAppInfo.data.weburl);
                    PayType.Dismiss();
                })
                          .Show();
            };
        }