"use strict";document.querySelector("body").addEventListener("touchmove",function(e) {
    e.preventDefault()}

);var rule=function() {
    var e=document.querySelector(".rule-wrap"),t=document.querySelector(".check-rule"),n=document.querySelector(".close-rule");return {
        init: function() {
            t.onclick=function() {
                e.style.display="block"
            }

                ,n.onclick=function() {
                e.style.display="none"}
        }
    }
}

();rule.init();var vote=function() {
    function e() {
        !function() {
            var e= {
                }

            ;location.search.substring(1).split("&").filter(function(t) {
                var n=t.split("=")[0],o=t.split("=")[1];e[n]=o}

            ),c=e}

        (),function(e,t) {
            return new Promise(function(n,o) {
                var a=new XMLHttpRequest;a.onreadystatechange=function() {
                    4==a.readyState&&200==a.status&&n(JSON.parse(a.responseText))}

                    ,a.open("POST",e,!0),a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a.send("uflag="+t+"&open_id="+localStorage.openId)}

            )}

        (host+"/vote.php/Index/userInfo",c.uflag).then(function(e) {
            var aaaaaaa=e.data.info.vote>0?("第"+e.data.info.sort+"名"):"";
                s.style.display="none",t.src=e.data.info.avatar_pic,n[0].innerHTML+=e.data.info.uname,n[1].innerHTML+=e.data.info.no,n[2].innerHTML+=e.data.info.address,i.innerHTML="<span>"+e.data.info.vote+"</span>票  "+aaaaaaa,e.data.info.voteable||o.classList.add("disabled"),o.onclick=function(e) {
                    s.style.display="block",o.classList.add("cannotclick"),function(e,t) {
                        return new Promise(function(n,o) {
                            var a=new XMLHttpRequest;a.onreadystatechange=function() {
                                4==a.readyState&&200==a.status&&n(JSON.parse(a.responseText))}

                                ,a.open("POST",e,!0),a.setRequestHeader("Content-type","application/x-www-form-urlencoded"),a.send("uflag="+t+"&open_id="+localStorage.openId)}

                        )}

                    (host+"/vote.php/Index/voteTo",c.uflag).then(function(e) {
                        1==e.status?(i.firstElementChild.innerHTML=+i.firstElementChild.innerHTML+1,a.classList.add("vote"),o.classList.add("disabled")): -1==e.status?(localStorage.removeItem("openId"),location.reload()):(r.firstElementChild.innerHTML=e.info,r.classList.add("show"),setTimeout(function() {
                                r.classList.remove("show")
                            }

                            ,1e3)),o.classList.remove("cannotclick"),s.style.display="none"}

                    )}
            }

        )}

    var t=document.querySelector(".thum").querySelector("img"),n=document.querySelector(".info").querySelectorAll("p"),o=document.querySelector(".to-vote"),a=document.querySelector(".and-one"),r=document.querySelector(".tip"),i=document.querySelector(".vote-info"),s=document.querySelector(".loading"),c=null;return {
        init: e
    }
}

();vote.init();