<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta content="telephone=no" name="format-detection">
    <meta name="wap-font-scale" content="no">
    <title>設置Paypal提現</title>
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="layer-v3.1.0/layer.css">
    <link rel="stylesheet" href="css/indexLi.css?v='201811203211'">
     <link rel="stylesheet" href="../../css/background.css" />
    <script src="js/fsize.js"></script>
    <style>
        .layui-layer-setwin .layui-layer-close2{
            display: none !important;
        }
        .layui-layer-page .layui-layer-content{
            border-radius: 0.4rem !important;
        }
        .yourclass2{
            border-radius: 0.4rem !important;
        }
        .paypal-false-btn{
        	background:  #FF57A0;
        }
        .paypal-tips{
        	color:#333;
        }
        .paypal-box .paypal-input input{
        	color:#FFF;
        }
    </style>
</head>
<body>
<div style="height: 1rem;"></div>
<div class="paypal-box">
    <div class="paypal-input"><img class="mall" src="img/mall.png" alt="">
        <input class="paypal-input-inp" type="text" placeholder="">

    </div>
    <p class="paypal-mall-tips paypal-mall-tips-Cn">請輸入正確的郵箱</p>
    <p class="paypal-mall-tips paypal-mall-tips-En">Please enter your vaild email</p>
</div>
<div class="paypal-false-btn L-Cn">完成</div>
<div class="paypal-false-btn L-En">Done</div>
<p class="paypal-tips L-Cn">沒有 PayPal 賬號,<a href="https://www.paypal.com/ "><span style="color: #FF57A0;">去註冊&gt</span></a></p>
<p class="paypal-tips L-En">No PayPal account,<a href="https://www.paypal.com/ "><span style="color: #FF57A0;">go to register&gt</span></a></p>
<a class="L-Cn" href="../help/registeredHelp.html"><p style="width: 10rem;text-align: center;font-size: 0.35rem;color: rgba(255,255,255,0.6);margin-top: 4rem;  text-decoration: underline;">paypal註冊流程</p></a>
<a class="L-En" href="../help/registeredHelp.html"><p style="width: 10rem;text-align: center;font-size: 0.35rem;color: rgba(255,255,255,0.6);margin-top: 4rem;  text-decoration: underline;">Paypal registration process</p></a>
<div class="paypal-layer">
    <div class="paypal-layer-content">
        <p><span class="lang-show"></span></p>
        <p class="paypal-check">paypal:--</p>
    </div>
    <div class="paypal-layer-btnBox">
        <div class="paypal-layer-no "><span class="lang-show"></span></div>
        <div class="paypal-layer-yes "><span class="lang-show"></span></div>
    </div>
</div>
</body>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="layer-v3.1.0/layer/layer.js"></script>
<script src="../../lib/globalizationJq.js"></script>
<script>
       //$ip = "http://ceshi.yabolive.tv/web";
    $ip = "https://webserver.yabolive.net";
        if(sessionStorage.lang==1 || sessionStorage.lang == 7){
            $("title").text("Set up Paypal withdrawal")
            $('.paypal-input-inp').attr('placeholder','Please enter your Paypal account');
            $(".wx-true-p2").css("width","9rem")
            $(".wx-true-p2").css("margin-left","auto")
            $(".wx-true-p2").css("margin-right","auto")
            $(".paypal-input input").attr("placeholder","Please enter amount")
            $(".paypal-layer-content p").eq(0).css("margin-top","0.5rem");
            $(".paypal-layer").css("height","5.6rem")
            $(".paypal-layer .paypal-layer-content").css("height","4.4rem")

            var langJSON={
                "langList":[
                    {"text":"The Paypal withdrawal account can only be set once and cannot be changed once submitted. Are you sure to set the following withdrawal account?"},
                    {"text":"Cancel"},
                    {"text":"Sure"},
                ]
            }
        }else{
            $("title").text("設置Paypal提現")
            $('.paypal-input-inp').attr('placeholder','請填寫您的Paypal郵箱');
            var langJSON={
                "langList":[
                    {"text":"Paypal提現賬號僅能設置一次,一旦提交無法更改。確定設置以下提現賬號?"},
                    {"text":"取消"},
                    {"text":"確定"},
                ]
            }
        }
        for(var i=0;i<langJSON.langList.length;i++){
            $(".lang-show").eq(i).text(langJSON.langList[i].text);
        }


        //呼唤分享
        try{
            var obj2 = {
                "cid": 9,
                "reqCode": new Date().getTime(),
                "data": {
                    msg: '是否分享或帮助',
                    shareType: 0,
                    helpType: 1
                }
            }
            var obj = JSON.stringify(obj2);
            localStorage.help='paypal'
            appCollaboration(obj)

        }
        catch(err){
            console.log(err)
        }
        $(".paypal-input-inp").on("input", function () {
//        var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
            var reg=/^([a-z0-9A-Z_]+[-|\.]?)+[a-z0-9A-Z_]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\.)+[a-zA-Z]{2,}$/;
            if(!reg.test($(".paypal-input-inp").val()))
            {
                if(sessionStorage.lang==1|| sessionStorage.lang == 7)   $(".paypal-mall-tips-En").show()
                else $(".paypal-mall-tips-Cn").show()
                $(".paypal-btn-ok").unbind("click");
                $(".paypal-false-btn").removeClass("paypal-btn-ok")

                return false;
            }else{
                $(".paypal-mall-tips").hide()
                $(".paypal-false-btn").addClass("paypal-btn-ok")
                $(".paypal-btn-ok").unbind("click");
                $(".paypal-btn-ok").on("click", function () {
                    $('.paypal-check').text('paypal: '+$(".paypal-input-inp").val())
                    if(sessionStorage.lang==1|| sessionStorage.lang == 7){
                        layer.open({
                            type: 1,
                            title: false,
                            shadeClose: false,
                            skin: 'yourclass2',
                            area : ['7.2rem','5.6rem'],
                            content:$(".paypal-layer"),
                        });
                    }else{
                        layer.open({
                            type: 1,
                            title: false,
                            shadeClose: false,
                            skin: 'yourclass2',
                            area : ['7.2rem','4.6rem'],
                            content:$(".paypal-layer"),
                        });
                    }

                })
            }
        })

        $(".paypal-layer-no").on("click", function () {
            layer.closeAll()
        })
        $(".paypal-layer-yes").on("click", function () {
            $.ajax({
                url:$ip+'/withdraw/paypalbinding.html',
                type:"post",
                data:{
                    os: "WEB",
                    cid: "web_gw",
                    lang: 2,
                    uid:  sessionStorage.bbb,
                    token:  sessionStorage.kkk,
                    cardaddr:$(".paypal-input-inp").val()
                },
                success: function (msg) {
                    var data=JSON.parse(msg);
                    console.log(data);
                    if(data.code==1){
                        if(sessionStorage.lang==1|| sessionStorage.lang == 7)layer.msg("The binding is successful, and go to paypal")
                        else layer.msg("綁定成功,即將跳轉提現")
                        setTimeout(function () {
                            window.location.href='new-cashReality.html'
                        },1500)
                    }else if(data.code=-70007){
                        if(sessionStorage.lang==1|| sessionStorage.lang == 7)layer.msg("The paypal account has been bound, please re-enter a new one")
                        else layer.msg("該郵箱已經被綁定過,請重新輸入")
                        setTimeout(function () {
                            layer.closeAll()
                        },2000)
                        $(".paypal-input-inp").val("");
                        $(".paypal-btn-ok").unbind("click");
                        $(".paypal-false-btn").removeClass("paypal-btn-ok")
                    }else{
                        layer.msg(data.msg);
                    }
                }
            })
        })
</script>
</html>