zoukankan      html  css  js  c++  java
  • js 面向对象 jquery 全局变量 封装

    var G_amount, G_orderid, G_mob, G_payUrl, G_mobilePhone, G_registerFlag, G_FromUserName, G_channel, G_goBackUrl, G_Subscribe, G_type, G_domain;
    var setPay = {
        payUrl: null,
        mob: null,
        orderid: null,
        orderTime: null,
        pay: null,
        type: null,
        Action: null,
        NextUrl: "",
        Plain: "",
        Signature: "",
        mobile: "",//签约手机号
        sign:''
    }
    
    function initCon(ret) {
        setPay.payUrl = ret.payUrl;
        setPay.mob = ret.mob;
        setPay.orderid = ret.orderid;
        setPay.pay = ret.pay;
        setPay.type = ret.type;
        setPay.Mobile = ret.Mobile;
        setPay.sign = ret.sign;
        var orderDate = ret.orderTime;
        setPay.orderTime = orderDate.substr(0, 4) + "-" + orderDate.substr(4, 2) + "-" + orderDate.substr(6, 2) + " " + orderDate.substr(8, 2) + ":" + orderDate.substr(10, 2) + ":" + orderDate.substr(12, 2);
        $("#mobText").html(setPay.mob);
        $("#orderidText").html(setPay.orderid);
        $(".pay").html(ret.pay.toFixed(2) + "元");
        $("#ordTime").html(setPay.orderTime);
    
    }
    //支付函数
    function gotoPay() {
        var u = navigator.userAgent, app = navigator.appVersion;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
        var isiOS = !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        /**参数**/
        var param = '{"Amount":"' + setPay.pay + '","PdtNum":"1","PdtType":"0001","SerialNo":"14000099819126444","MerId":"JD64030001"," Action ":"payInfo","NextUrl":"' + setPay.NextUrl + '","phoneNum":"' + setPay.mob + '","Plain":"' + setPay.Plain + '","Signature":"' + setPay.Signature + '","Mobile":"'+ setPay.Mobile + '"}';
        //alert(param);
        if (isAndroid) {// 安卓端加载页面时调用
            window.CSIIPAY.sendPayment(param);
            $('.btnPay').show().next('.btnPay1').hide();
        } else if (isiOS) {//IOS端加载页面时调用
            window.location.href = "objc://?" + param;
            $('.btnPay').show().next('.btnPay1').hide();
        } else {
            alert("目前仅支持Android和IOS等系统的手机");
        }
    }
    
    $(function () {
        $(".button").click(function () {
            $.getJSON(setPay.payUrl + '?orderid=' + setPay.orderid + '&amount=' + setPay.pay + '&mob=' + setPay.mob + '&type=' + setPay.type + '&mobile=' + setPay.Mobile + "&sign="+setPay.sign+"&random=" + Math.random(), function (ret) {
                if (ret.rstCode = '0000') {
                    setPay.Action = ret.data.Action;
                    setPay.NextUrl = ret.data.NextUrl;
                    setPay.Plain = ret.data.Plain;
                    setPay.Signature = ret.data.Signature;
                    setPay.Mobile = ret.data.Mobile;
                    $('.btnPay').hide().next('.btnPay1').show();
                    gotoPay();
                }
            })
        })
    
        $("#back").click(function () {
            window.history.go(-1);
        });
    })
  • 相关阅读:
    读写excel的组件
    一个关于C#语言中的Property的低级BUG,花了我二十分钟
    使用wwAppConfiguration类库来轻松读写应用程序配置信息
    为因地震死难的同胞默哀
    页面执行时生成静态文件的方法
    【转载】sp_spaceused2,看库里全部表占用的物理空间
    在微软中文技术论坛 CSDN cnblogs 三个微软社区中提问
    在内网服务器中获得真正的客户端ip的方法
    深拷贝的通用方法
    你知道在word中如何将段落标记替换成其他字符吗?
  • 原文地址:https://www.cnblogs.com/shaoing/p/9950710.html
Copyright © 2011-2022 走看看