<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <meta name="author" content="" />
  <meta name="viewport" content="width=device-width,height=device-height, user-scalable=no,initial-scale=1, minimum-scale=1, maximum-scale=1,target-densitydpi=device-dpi ">
  <meta name="robots" content="" />
  <title>发现</title>
  <script type="text/javascript" src="${ctx }/scripts/jquery/jquery-1.9.1.min.js"></script>
  <script type="text/javascript" src="${ctx }/scripts/lib/template-native.js"></script>
  <script type="text/javascript" src="${ctx }/scripts/visitor/controlOptionMenu.js?v=4.0"></script>
  <script type="text/javascript" src="https://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
  <script type="text/javascript" src="<c:url value='/plugin/layer_mobile/layer.js?v=4.5'/>"></script>
  <script type="text/javascript" src="${ctx }/plugin/swiper/swiper_js/swiper-3.4.1.min.js"></script>
  <link rel="stylesheet" type="text/css" href="${ctx }/plugin/swiper/swiper_css/swiper-3.4.1.min.css" />
  <link rel="stylesheet" type="text/css" href="${ctx }/styles/userset/address_index.css?ver=2.0" />
  <script type="text/javascript" src="${ctx }/scripts/servicehome/ordAddress.js?v=9.2111111122222"></script>

  <script type="text/javascript" src="${ctx }/plugin/flex/index.min.js"></script>
  <link rel="stylesheet" href="${ctx }/styles/common/reset.css?ver=5.2" type="text/css">
  <link rel="stylesheet" type="text/css" href="${ctx }/styles/servicehome/tradeArea.css?v=4.99" />
  
  
  <script type="text/javascript" src="${ctx}/plugin/vconsole/vconsole.min.js"></script> 
</head>
<style>
	  .wx-wp{
	-webkit-overflow-scrolling: touch; overflow-y: scroll; 
	bottom: 54px;
	}  
	#iframe_content{
		position: absolute;
    	bottom: 0;
	}
</style>

<body>
  <input type="hidden" id="contextPath" value="${ctx }" />
  
  <div class="wx-wp" >
  	<iframe id="iframe_content"  src=""  width='100%' height='100%'></iframe> 
    <!-- <div class="area-wp">
      <div class="headerArea">
        <span class="swiper-icon"></span>
        <span class="add-icon"></span>
      </div>
      <div class="banner">
        <div class="swiper-container">
          <div class="swiper-wrapper">
          </div>
          <div class="swiper-pagination"></div>
        </div>
      </div>
      <div class="recommed-list">
      </div>
      <div class="title">超值爆品
        <i></i>
      </div>
      <div class="hotGoods">
        <div class="hot-box">
        </div>
      </div>
    </div> -->
   

  </div>
   <div class="nav-wp">
      <a href="javascript:void(0)" class="nav-btn home">
        <span class="icon"></span>
        <div class="name">首页</div>
      </a>
      <a href="javascript:void(0)" class="nav-btn service ">
        <span class="icon"></span>
        <div class="name">服务</div>
      </a>
      <a href="javascript:void(0)" class="nav-btn trade_area active ">
        <span class="icon"></span>
        <div class="name">发现</div>
      </a>
      <a href="javascript:void(0)" class="nav-btn mine" onclick="getUserInfo('${organId}')">
        <span class="icon"></span>
        <div class="name">我的</div>
      </a>
    </div>
  <script type="text/javascript">
    // 跳转我的
    function getUserInfo(orgId) {
      var organizationId = getQueryStr(location.href, 'organId');
      var openid = getQueryStr(location.href, 'openId');
      // var developId = $("#developId").val();
      var developId = getQueryStr(location.href, 'developId');
      var userId = getQueryStr(location.href, 'userId');
      var register = getQueryStr(location.href, 'register');
      var userStatus = getQueryStr(location.href, 'userStatus');
      $.ajax({
        url: $("#contextPath").val() + "/wechat/appUser/getUserInfo",
        type: "POST",
        dataType: "json",
        data: {
          openId: openid,
          organizationId: organizationId
        },
        success: function (data) {
          if (data.code == "200") {
            var dataObj = data.data;
            if (dataObj.isLogin == 2) {
              window.location.href = $("#contextPath").val() + "/wechat/appUser/newmine?openId=" + openid +
                "&developId=" + developId + "&userStatus=" + userStatus + "&userId=" + userId +
                "&register=" + register + "&organizationId=" + organizationId;
            } else {
              // if (dataObj.accountType == 1) {
                window.location.href = $("#contextPath").val() + "/wechat/appUser/newmine?openId=" + openid +
                  "&developId=" + developId + "&userStatus=" + userStatus + "&userId=" + userId + "&register=" +
                  register + "&organizationId=" + organizationId;
              // } 
              // else {
              //   location.href = $("#contextPath").val() + "/wechat/appUser/virAccount?openId=" + openId +
              //     "&developId=" + developId + "&userStatus=" + userStatus + "&userId=" + userId + "&register=" +
              //     register + "&organizationId=" + organizationId;
              // }
            }
          } else {
            alert(data.msg)
          }
        },
        error: function (data) {
          //alert("系统繁忙,菜单加载失败..");
        }
      });
    }

    //获取数据
    function getDataList(url, type) {
      var organizationId = getQueryStr(location.href, 'organId');
      var swiper = "",
        service = "",
        goods = "";
      $.ajax({
        url: $("#contextPath").val() + url,
        data:{
          orgId: organizationId
        },
        type: "POST",
        // dataType: "json",
        success: function (res) {
          if (res.code == "200") {
            var data = res.data;
            if (type == 1) {
              swiperList = data;
              //banner列表
              $.each(swiperList, function (index, value) {
                var trs = "";
                trs += " <div class='swiper-slide'><a href='" + value.urlAddress + "'><img src='" + value.coverUrl +
                  "'/></a></div>";
                swiper += trs;
              })
              $(".swiper-wrapper").append(swiper);
              var mySwiper = new Swiper('.swiper-container', {
                direction: 'horizontal',
                loop: true,
                autoplay: 3000,
                slidesPerView: "auto",
                centeredSlides: true,
                spaceBetween: 15,
                // 如果需要分页器
                pagination: '.swiper-pagination',
              });
            } else if (type == 2) {
              serviceList = data;
              console.log(serviceList, 111);
              //服务列表
              $.each(serviceList, function (index, value) {
                var trs = "";
                trs += " <div class='recommed-item'><a href='" + value.jumpAddress +
                  "'><img class='img' alt='' src='" + value.serviceIcon +
                  "'/><div class='name'>" + value.serviceName + "</div></a></div>";
                service += trs;
              })
              $(".recommed-list").append(service);
            } else if (type == 3) {
              hotGoods = data;
              //HOT列表
              $.each(hotGoods, function (index, item) {
                var trs = "";
                trs += "  <a href='" + item.goodsUrl + "' class='hot'><div class='img-border'><img src='" +
                  item.goodsPic +
                  "'></div> <p><span>" + item.goodsName + "</span></p><div class='price'><span>￥" + item.goodsPrice +
                  "</span><i></i></div></a>";
                goods += trs;
              })
              $(".hot-box").append(goods);
            }
          } else {
            alert(res.msg)
          }
        },
        error: function (res) {
          //alert("系统繁忙,菜单加载失败..");
        }
      });
    };
    // 查询URL参数
    function getQueryStr(_url, _param) {
      var rs = new RegExp("(^|)" + _param + "=([^\&]*)(\&|$)", "g").exec(_url),
        tmp;
      if (tmp = rs) {
        return tmp[2];
      }
      return "";
    };
    
    function setIframeContent(id){
    	var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    	 var findUrl = sessionStorage.getItem('findUrl');
    	 $('#iframe_content').attr('src',findUrl);
    	 //$('#iframe_content').attr('src','http://superdesk.avic-s.com/super_service/wechat/index/homePageView?oldUrl=%2Fwechat%2Findex%2FhomePageView&redirectUrl=%2Fwechat%2Findex%2FhomePageView&code=0718nqgF13WsA80GOKhF1xQagF18nqgK&openId=o31ne0WAkV-kpyCyIQ-EiJaTeEgE&userMobile=13732960941&developId=gh_5e42b7c7c069&state=10&Client=C004&userId=19119&orgId=615');
    	 //http://www.baidu.com
    };
    $(function () {
      var name = sessionStorage.getItem("name");
      $(".trade_area .name").html(name);
      //
     
      var swiperList = [],
        serviceList = [],
        hotGoods = [];
      var url1 = "/wechat/notice/discoverBannerList"; //banner列表
      var url2 = "/wechat/index/discoverServiceList"; //服务列表
      var url3 = "/wechat/index/goodsList"; //HOT列表
      var findUrl = sessionStorage.getItem('findUrl');
     /*  setTimeout(function(){debugger
    	  "document.frames['"+iframe_content+"'].location.href='"+findUrl+"';"
      },0) */
      //$('#iframe_content').attr('src',findUrl);
     // $(".wx-wp").load(findUrl);
     setIframeContent("iframe_content");
      //alert(findUrl);
     // alert(6);
      //console.log('findUrl',findUrl)
      getDataList(url1, 1);
      getDataList(url2, 2);
      getDataList(url3, 3);

      //var vConsole = new VConsole();
      var _url = location.href;
      var openId = getQueryStr(_url, 'openId');
      var developId = getQueryStr(_url, 'developId');
      var userStatus = getQueryStr(_url, 'userStatus');
      var userId = getQueryStr(_url, 'userId');
      var register = getQueryStr(_url, 'register');
      var organId = getQueryStr(_url, 'organId');
      var contextPath = $("#contextPath").val();
      if(organId == 663){
			$(".headerArea .swiper-icon").addClass("fude-icon")
      }else if(organId == 691) {
        $(".headerArea .swiper-icon").addClass("suoke-icon")
      }else{
        $(".headerArea .swiper-icon").removeClass("fude-icon")
        $(".headerArea .swiper-icon").removeClass("suoke-icon")
      }
      //跳转服务
      $(".nav-btn.service").on("click", function () {
        window.location.href = $("#contextPath").val() + "/wechat/index/serviceListPage?openId=" + openId +
          "&developId=" + developId + "&userStatus=" + userStatus + "&userId=" + $("#userId").val() +
          "&register=" + register + "&organId=" + organId;
      });
      //跳转首页
      $(".nav-btn.home").on("click", function () {
        window.location.href = $("#contextPath").val() + "/wechat/index/homePageView?openId=" + openId +
          "&developId=" + developId + "&organizationId=" + organId;
      });
      //var vConsole = new VConsole();
      // //判断是否显示商圈/发现
      // var isEnabled = sessionStorage.getItem("isEnabled");
      // var name = sessionStorage.getItem("name");
      // if (isEnabled == "true") {
      //   $(".trade_area").show();
      //   $(".trade_area .name").html(name);
      // }
    })
  </script>
</body>

</html>