dailiboy 2018-06-23 13:37 采纳率: 14.3%
浏览 1089
已结题

微信支付动态设置支付金额 ASP.NET

.aspx文件

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <meta name="viewport" content="width=640px, maximum-scale=1.0, user-scalable=no"/>
    <link href="/images/payStyle.css" type="text/css" rel="Stylesheet" />
    <script type="text/javascript">
        $(function () {
            $(window).bind('resize load', function() {
                $("body").css("zoom", $(window).width() / 640);
                $("body").css("display", "block");
                $("body").css("zoom", $(window).width() / 640);
                $("input").attr("placeholder", "请填写");
            });
        })
    </script>
<script type="text/javascript">
    //调用微信JS api 支付
    function jsApiCall()
    {
        WeixinJSBridge.invoke(
        'getBrandWCPayRequest',
        <%#wxJsApiParam%>,//josn串
                    function (res)
                    {
                        if (res.err_msg == "get_brand_wcpay_request:ok")
                        {
                            var OrderId=$("#OrderId").val();
                            var orderProductName=$("#orderProductName").val();
                            var orderMoneySum=$("#orderMoneySum").val();

                            window.location.href="http://11.com/fk.aspx;//支付成功后的跳转页面

                        }else
                        {
                            WeixinJSBridge.call('closeWindow');
                        }

                    }
                    );
    }

    function callpay()
    {
        if (typeof WeixinJSBridge == "undefined")
        {
            if (document.addEventListener)
            {
                document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
            }
            else if (document.attachEvent)
            {
                document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
            }
        }
        else
        {
            jsApiCall();
        }
    }

           </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="bodydiv">
        <div id="payhead"></div>
        <div id="middlebody">
            <table class="tablestyle">
                <tr class="tablestyletr">
                    <td colspan="2" class="ttdstyle">企业名称</td>
                </tr>
                <tr class="tablestyletr">
                    <td colspan="2" class="tdstyle"><asp:TextBox runat="server" ID="companyNameText" BorderWidth="0px" Width="100%" Font-Size="25px"></asp:TextBox></td>
                </tr>
                <tr class="backcolor">
                    <td colspan="2" class="backcolor"></td>
                </tr>
                <tr class="tablestyletr">
                    <td class="ttdstyle">企业税号</td>
                    <td class="tdstyle"><asp:TextBox runat="server" ID="noText" BorderWidth="0px" Width="100%"></asp:TextBox></td>
                </tr>
                <tr class="backcolor">
                    <td colspan="2" class="backcolor"></td>
                </tr>
                <tr class="tablestyletr">
                    <td class="ttdstyle">所属区县</td>
                    <td class="tdstyle">
                        <asp:DropDownList ID="DropDownList1" runat="server">
                            <asp:ListItem>1</asp:ListItem>
                            <asp:ListItem>2</asp:ListItem>
                            <asp:ListItem>3</asp:ListItem>
                            <asp:ListItem>4</asp:ListItem>
                            <asp:ListItem>5</asp:ListItem>
                            <asp:ListItem>8</asp:ListItem>
                            <asp:ListItem>6</asp:ListItem>
                            </asp:DropDownList></td>
                </tr>
                <tr class="backcolor">
                    <td colspan="2" class="backcolor"></td>
                </tr>
                <tr class="tablestyletr">
                    <td class="ttdstyle">座机电话</td>
                    <td class="tdstyle"><asp:TextBox runat="server" ID="phoneText" BorderWidth="0px" Width="100%"></asp:TextBox></td>
                </tr>
                <tr class="backcolor">
                    <td colspan="2" class="backcolor"></td>
                </tr>
                <tr class="tablestyletr">
                    <td class="ttdstyle">联系人</td>
                    <td class="tdstyle"><asp:TextBox runat="server" ID="menText" BorderWidth="0px" Width="100%"></asp:TextBox></td>
                </tr>
                <tr class="backcolor">
                    <td colspan="2" class="backcolor"></td>
                </tr>
                <tr class="tablestyletr">
                    <td class="ttdstyle">手机号码</td>
                    <td class="tdstyle"><asp:TextBox runat="server" ID="menphoneText" BorderWidth="0px" Width="100%"></asp:TextBox></td>
                               </tr>
            </table>
        </div>
        <div id="middlehander"></div>
        <div id="jediv">
            <table class="tablestyle">
                <tr class="tablestyletr">
                    <td class="ttdstyle">续费金额</td>
                    <td class="tdstyle"><asp:TextBox runat="server" ID="jeText" BorderWidth="0px" Width="100%"></asp:TextBox></td>
                </tr>
            </table>
        </div>
        <div id="footdiv">

            <div style="width:100%; text-align:center;">
                <asp:ImageButton runat="server" ID="submitBtn" ImageUrl="~/images/submitbtn.jpg" OnClick="submitBtn_Click" />

            </div>
        </div>
    </div>
    </form>
</body>
</html>

.cs文件


    public partial class pay : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                JsApiPay jsApiPay = new JsApiPay(this);
                try
                {
                    string total_fee = Money;// Request["total_fee"];
                    orderMoneySum = total_fee;
                    string ParkName = "服务费";// Request["ParkName"];
                    orderProductName = ParkName + "停车费用";
                    OrderId = "145448545";// Request["OrderId"];
                    //if (string.IsNullOrWhiteSpace(total_fee) || total_fee == "0")
                    if (total_fee == "0")
                    {
                        throw new WxPayException("<span style='color:#FF0000;font-size:20px'>" + "费用为零,请求参数错误" + "</span>");
                    }

                    jsApiPay.total_fee = int.Parse((Convert.ToDouble(total_fee) * 100).ToString());
                    Money = (Convert.ToDouble(jsApiPay.total_fee) / 100).ToString();
                    jsApiPay.orderid = OrderId;
                    //JSAPI支付预处理
                    try
                    {
                        Common common = new Common(Context);
                        jsApiPay.openid = common.GetOpenId();
                        if (Common.OpenId == "Openid")
                        {
                            throw new WxPayException("OpenId为空无法下单!");
                        }
                        jsApiPay.access_token = Common.access_token;

                        WxPayData unifiedOrderResult = jsApiPay.GetUnifiedOrderResult(ParkName);//ParkName不能是空,这是一个大坑
                        wxJsApiParam = jsApiPay.GetJsApiParameters();//获取H5调起JS API参数 
                    }
                    catch (Exception ex)
                    {
                        Response.Write("<span style='color:#FF0000;font-size:20px'>" + "下单失败,请返回重试:" + ex.InnerException.Message + "</span>");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<span style='color:#FF0000;font-size:20px'>" + "页面加载出错,请重试:" + ex.Message + "</span>");
                }
                this.DataBind();
            }
        }

        public string wxJsApiParam { get; set; } //H5调起JS API参数
        public string Money = "1";
        public string OrderId { get; set; }
        public string orderMoneySum { get; set; }//商品金额
        public string orderProductName { get; set; }//商品名称

        protected void submitBtn_Click(object sender, ImageClickEventArgs e)
        {
            Session["companyVar"] = this.companyNameText.Text.ToString();//企业名称
            Session["noVar"] = noText.Text.ToString();//统一社会信用代码
            Session["menVar"] = menText.Text.ToString();//联系人
            Session["menphoneVar"] = menphoneText.Text.ToString();//联系人手机号
            Session["phoneVar"] = this.phoneText.Text.ToString();//联系电话
            Session["address"] = this.DropDownList1.SelectedValue.ToString();
            Session["dateVar"] = DateTime.Now.ToString();//缴费日期
            Session["moneyVar"] = this.jeText.Text.ToString();//缴费金额
            Money = Convert.ToDouble(this.jeText.Text.ToString()).ToString();
            ClientScript.RegisterStartupScript(this.GetType(), "myscript", "<script>callpay();</script>");
        }
    }

**我在.cs文件里面Money设置为1。但是在填写金额为2后,提交后。跳转到支付,金额仍然是1.。。请问如何设置。。。

**

  • 写回答

4条回答 默认 最新

  • devmiao 2018-06-23 15:49
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog