// Generated by CoffeeScript 1.8.0
(function() {

  function GetQueryString(name)
  {
       var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
       var r = window.location.search.substr(1).match(reg);
       if(r!=null)return  unescape(r[2]); return null;
  }
  var productId =GetQueryString("id");
  

  	var GetQueryString = function(name){
	       var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
	       var r = window.location.search.substr(1).match(reg);
	       if(r!=null)return  unescape(r[2]); return null;
	  };
	  var portrait_uri = localStorage.getItem("y_portrait_uri")
	  if (portrait_uri != null && portrait_uri != '') {
		  $("#portrait_uri").attr("src", "/"+portrait_uri);
	  }

  $(function() {
	
    var cur_index;
    var _id=$.cookie("_id");

    var uid = GetQueryString("uid");
    var phone = "186 2191 0980";
    
    var productName = GetQueryString("productName");
    var amount = GetQueryString("amount");
    
    $("#productName").html( $("#productName").html() + productName);
    $("#amount").html ( $("#amount").html() + amount + " 万元");

    if(uid!=null&&uid!=""&&uid!="null"){
    	$.ajax({
    		url:baseUrl+'/api/user/get_user_verify.do',
    		data:{
    			uid:uid
    		},
	          success:function(data){
	        	  var user;
		    		if(data.status===200){	
		    		  user = data.data.user;
		    		  phone = user.mobile;
		    		  $(".name").html(user.name);
		    		  $(".tip").html(user.companyName);
		    		  $("#user").show();
		    		  $("#user2").hide();
		    		}else if(data.status===321){
		    			$("#user").hide();
		    			$("#user2").show();
		    		}
	          },
	          complete:function(){
	            },
    	});
    }else{
    	$("#user").hide();
		$("#user2").show();
    }
    
    $(".icon-tel").on("tap",function() {
        return location.href = "tel:" + phone;
    });
    $("#user").on("tap",function() {
        return location.href = "tel:" + phone;
    });
    $("#user2").on("tap",function() {
        return location.href = "tel:" + phone;
    });

  });

}).call(this);

