<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin.Yun.KeTangJieAPI" Codebehind="KS.YunKeTangJieApi.aspx.cs" %>
<%@ Import Namespace="Kesion.Publics" %>
<%@ Import Namespace="Kesion.Cache" %>
<%@ Import Namespace="Kesion.BLL" %>
<%@ Import Namespace="System.Data" %>
<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" runat="server">
   <div class="clear blank20"></div>

    <asp:Panel ID="PanelList" runat="server">
     <%if (KeTangJieWxid<=0)
         { %>
    <div class="content-area mt20"> 
    	<div class="myTitle">科汛微门户接口
            <span class="fr greenFont"></span>
    	</div>
        <ul class="yun-Interface clearfix">
        	<li>
            	<div class="yinterface-inner">
                	<div class="yinterface-imgBox">
                    	<img src="/Admin/images/yun_bg_ktjinter.png" />
                    </div>
                    <div class="yinterface-introBox">
                    	<h3 class="yinterface-tit">科汛微门户互动课堂</h3>
                        <div class="yinterface-intro">
                        	科汛微门户互动课堂提供一对一、小班、大班的师生互动平台，帮助学生爱上学习，使学习不受时间以及空间上的限制提高学习效率、用最少的时间获得最有价值的知识，学生可以和老师进行连麦对话，还可以举手问问题、在线做题等，最大还原传统教学场景，增加学生学习乐趣。
                        </div>
                        <a href="https://store.kesion.com/home/virtual" target="_blank" class="mt20 greenFont moreBox">→了解更多</a>
                    </div>
                </div>
            </li>
            <li>
            	<div class="yinterface-inner">
                	<div class="yinterface-imgBox">
                    	<img src="/Admin/images/yun_bg_ktjwechat.png" />
                    </div>
                    <div class="yinterface-introBox">
                    	<h3 class="yinterface-tit">科汛微门户</h3>
                        <div class="yinterface-intro">
                        	科汛微门户依托微信的大流量，更加方便的进行网校宣传与传播，解决网校微信变现难题，微门户提供微信内直播功能，学生随时随地能学习，老师随时随地能直播，同时提供后台管理及营销工具，更好的进行网校宣传及网校的管理。
                        </div>
                        <a href="https://store.kesion.com" target="_blank" class="mt20 greenFont moreBox">→了解更多</a>
                    </div>
                </div>
            </li>
            <li>
            	<div class="yinterface-inner">
                	<div class="yinterface-imgBox">
                    	<img src="/Admin/images/yun_bg_ktjvideo.png" />
                    </div>
                    <div class="yinterface-introBox">
                    	<h3 class="yinterface-tit">科汛微门户点播</h3>
                        <div class="yinterface-intro">
                        	 科汛微门户点播已打通PC端、APP端、微信端等，开通后可将科汛网校内点播课程数据迁移到科汛微门户，同时利用科汛微门户的各端接口，让学生可从多个入口进行学习，借助科汛微门户的营销工具还可对网校现有点播课程进行更好的推广宣传。
                        </div>
                        <a href="https://store.kesion.com" target="_blank" class="mt20 greenFont moreBox">→了解更多</a>
                    </div>
                </div>
            </li>
        </ul>
        <%if (IsVerify == false)
            { %>
        <div class="y-tips  redFont">
            <strong>温馨提示：</strong><br />
            1、科汛微门户是科汛公司旗下的一款面向广大教育从业者提供的SaaS服务平台,主要提供实时互动课堂及教育微门户产品；<br />
            2、科汛微门户产品可以很好的和KesionEDU在线教育产品软件结合使用，为提供更好的服务在开通科汛微门户服务前您需要先开通科汛云市场。<a href="KS.YunAccountApi.aspx" class="button button_on">点此开通</a></div>
        <%}
            else
            {

                if (KeTangJieWxid == -1&& !string.IsNullOrEmpty(KetangjieUserName))
                {
                    Response.Write(@"<div class=""y-tips  redFont"" style=""font-size:26px"">您的科汛微门户账号[" + KetangjieUserName +"] 正在审核，请耐心等待审核结果！</div>");
                }
                else
                {
                %>

        <script>
            function DoKetangJieReg() {
                var PassWord = $("#PassWord").val();
                var mobile = $("#Mobile").val();
                var mobileCode = $("#MobileCode").val();
                if (mobile == '') {
                     KesionJS.Alert('请输入手机号码！', "$('#Mobile').focus()");
	                 return false;
                }
                if (mobileCode == '') {
                     KesionJS.Alert('请输入手机短信验证码！', "$('#MobileCode').focus()");
	                 return false;
                }
                if (PassWord == '') {
                     KesionJS.Alert('请输入登录密码！', "$('#PassWord').focus()");
	                 return false;
                }
                if (PassWord.length<6) {
                     KesionJS.Alert('登录密码长度不能少于6位！', "$('#PassWord').focus()");
	                 return false;
                }
                 $.ajax({
                    type: "get",
                     url: "KS.YunKetangJieApi.aspx",
                     data: "action=openketangjie&mobileCode="+mobileCode+"&password=" + PassWord + "&mobile=" + mobile, 
                     success: function (data) {
                         if (data == 'true') {
                              KesionJS.Alert('恭喜，绑定成功！', "location.reload();");
                             
                         } else {
                             KesionJS.Alert(data);
                         }
                     }
                });
               
            }
            function DoKetangJieBind() {
                var PassWord = $("#B_PassWord").val();
                var mobile = $("#B_Mobile").val();
                var mobileCode = $("#B_MobileCode").val();
                if (mobile == '') {
                     KesionJS.Alert('请输入登录手机号码！', "$('#B_Mobile').focus()");
	                 return false;
                }
                if (mobileCode == '') {
                     KesionJS.Alert('请输入手机短信验证码！', "$('#B_MobileCode').focus()");
	                 return false;
                }
                if (PassWord == '') {
                     KesionJS.Alert('请输入登录密码！', "$('#B_PassWord').focus()");
	                 return false;
                }
                if (PassWord.length<6) {
                     KesionJS.Alert('登录密码长度不能少于6位！', "$('#B_PassWord').focus()");
	                 return false;
                }
                 $.ajax({
                    type: "get",
                     url: "KS.YunKetangJieApi.aspx",
                     data: "action=bindketangjie&mobileCode="+mobileCode+"&password=" + PassWord + "&mobile=" + mobile, 
                     success: function (data) {
                         if (data == 'true') {
                              KesionJS.Alert('恭喜，绑定成功！', "location.reload();");
                             
                         } else {
                             KesionJS.Alert(data);
                         }
                     }
                });
            }

            function ismobile(s)
            {
                var p = /^(013|014|015|017|018|13|14|15|17|18|19)\d{9}$/;
               if(s.match(p) != null){
              return true;
              }
              return false;
            }
            var OutTimes =60;
            var tOutTimes=OutTimes;
            function leavePage(btn) {
                if (tOutTimes == 0) {
		             tOutTimes=OutTimes;
		             $("#"+btn+"SendMobileBtn").attr("disabled",false);
                     $("#" + btn + "SendMobileBtn").val("免费获取手机验证码")
		             }
		             else{
		             tOutTimes -= 1;
		             $("#"+btn+"SendMobileBtn").val("已发，"+tOutTimes+"秒后可重发!")
		             setTimeout("leavePage('"+btn+"')", 1000);}
            }
            function getMobileCode(btn){
                var mobile = $("#"+btn+"Mobile").val();
	            var fieldName=""+btn+"Mobile";
	            if (mobile==''){
	              $.dialog.alert('请选输入手机号码！',function(){ $("#"+fieldName).focus();});
	               return false;
	            }
	            if (ismobile(mobile)==false){
	              $.dialog.alert('手机号码格式不正确，请重新输入！',function(){ $("#"+fieldName).focus();});
	              return false;
                }
                $("#" + btn + "SendMobileBtn").attr("disabled", true);
                $.ajax({
                    type: "get",
                    url: "KS.YunAccountApi.aspx", 
                    data: "action=sendsmscode&model=ketangjie&mobile="+mobile, 
                    success: function (data) {
                         if (data == 'true') {
			                    leavePage(btn);
		                     }else{
			                     $.dialog.alert(data,function(){$("#"+btn+"SendMobileBtn").attr("disabled",false); });
		                     }
                    }
                });
	            return false;
            }
            function ShowKetangJieBox(v) {
                if (v == 0) {
                    $('#KetangJieRegBox').show();
                    $('#KetangJieBindBox').hide();
                    $("#kbtn0").attr("class", "button button_on");
                    $("#kbtn1").attr("class", "button");
                } else {
                    $('#KetangJieRegBox').hide();
                     $('#KetangJieBindBox').show();
                     $("#kbtn1").attr("class", "button button_on");
                     $("#kbtn0").attr("class", "button");
                }
            }
        </script>
        <div style="text-align:center;margin:50px;">
            <input type="button" title="点击开通科汛微门户服务" id="kbtn0" class="button button_on" onclick="ShowKetangJieBox(0)" value="没有科汛微门户账号，我要开通科汛微门户服务" />
            <input type="button" title="点击绑定科汛微门户服务" id="kbtn1" class="button" onclick="ShowKetangJieBox(1)" value="已有科汛微门户账号，我要绑定" />

        </div>

         <!--注册科汛微门户账号-->
         <table id="KetangJieRegBox" class="yun-bindBox yun-bindBox3">
            <tr>
                <td class="yun-bindTit" width="120" align="right">手机号：</td>
                <td>
                    <input name="Mobile" id="Mobile" type="text" style="width:300px" value="<%=dr["mobile"].ToString() %>" readonly> <span class="tips">开通成功，该手机号同时为<a href="https://store.kesion.com" target="_blank">store.kesion.com</a>的登录账号。</span>
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="120" align="right">验证码：</td>
                <td class="V-Code">
                    <input name="MobileCode" id="MobileCode" type="text" style="width:150px;" maxlength="6">
                    <input type="button" value="获取手机验证码" class="button button_on" id="SendMobileBtn" onclick="getMobileCode('');"/>
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="120" align="right">设置密码：</td>
                <td>
                    <input name="PassWord" id="PassWord" type="password" style="width:300px" maxlength="20">
                    <span class="tips">
                    开通成功，该密码同时为<a href="https://store.kesion.com" target="_blank">"store.kesion.com"</a>的登录密码。
                    </span>
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="120" align="right"> </td>
                <td class="yun-btndBox">
                    <input type="button" title="点击确定提交" class="button button_on" onclick="return(DoKetangJieReg())" value="确定提交" />
                </td>
            </tr>
         </table>


         <!--科汛微门户绑定账号-->
         <table id="KetangJieBindBox" class="yun-bindBox yun-bindBox3" style="display:none;">
            <tr>
                <td class="yun-bindTit" width="120" align="right">手机号：</td>
                <td>
                    <input name="Mobile" id="B_Mobile" type="text" style="width:300px" value="<%=dr["mobile"].ToString() %>"> <span class="tips">科汛微门户(<a href="https://store.kesion.com" target="_blank">store.kesion.com</a>)的登录手机号。</span>
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="120" align="right">验证码：</td>
                <td class="V-Code">
                    <input name="MobileCode" id="B_MobileCode" type="text" style="width:150px;" maxlength="6">
                    <input type="button" value="获取手机验证码" class="button button_on" id="B_SendMobileBtn" onclick="getMobileCode('B_');"/>
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="120" align="right">登录密码：</td>
                <td>
                    <input name="PassWord" id="B_PassWord" type="password" style="width:300px" maxlength="20">
                    <span class="tips">
                    科汛微门户(<a href="https://store.kesion.com" target="_blank">store.kesion.com</a>)的登录密码。
                    </span>
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="120" align="right"> </td>
                <td class="yun-btndBox">
                    <input type="button" title="点击确定提交" class="button button_on" onclick="return(DoKetangJieBind())" value="确定绑定" />
                </td>
            </tr>
         </table>



        <%}
            } %>
    </div>
    <%}
    else
    { %>
    <!--科汛微门户接口-->
      
    <div class="content-area mt20"> 
    	<div class="myTitle"><span class="fr"> <input type="button" title="点击取消绑定" class="button button_on" onclick="return(DoKetangJieUnBind())" value="取消绑定" /></span>
            科汛微门户接口</div>
        <table class="CTable" cellspacing="0" border="0" style="color:Black;width:100%;border-collapse:collapse;">
        	<tr class="CTitle">
                <th scope="col" style="width:200px">科汛微门户模块</th>
                <th scope="col" style="text-align:left;">模块信息</th>
                <th scope="col" style="width:160px;text-align:center;">管理操作</th>
            </tr>
            <tr onmouseover="this.className='CtrMouseOver'" onmouseout="this.className='CtrMouseOut'" class="CtrMouseOut">
            	<td class="Ctd" align="center">
                	互动课堂
                </td>
                <td class="Ctd" align="left">
                	你当前剩余 <font class="redFont"><%=livemoney %></font> 枚直播币
                </td>
                <td class="Ctd" align="center">
                	<a href="javascript:;" onclick="ShowRecharge()" class="greenFont">充值</a>&nbsp;&nbsp;
                    <a href="?action=livemoney" class="greenFont">使用明细</a>
                </td>
            </tr>
            <tr onmouseover="this.className='CtrMouseOver'" onmouseout="this.className='CtrMouseOut'" class="CtrMouseOut">
            	<td class="Ctd" align="center">
                	微门户
                </td>
                <td class="Ctd" align="left">
                	基于微信的大流量，手机即可管理网校，提供丰富的营销工具，更好的进行网校的宣传和推广
                </td>
                <td class="Ctd" align="center">
                	<span class="Access greenFont">
                    	访问微门户
                        <span class="yun-code">
                        	<img src="<%=wxcode%>" />
                            <em>微信扫一扫访问</em>
                            <input type="hidden" id="url2" value="<%=storeUrl %>" /><%=storeUrl %>
                            <a href="javascript:;" onclick="copyUrl()" class="button">复制链接</a>
                        </span>
                    </span>&nbsp;&nbsp;
                    <a href="KS.YunKetangJieApi.aspx?action=manage" target="_blank" class="greenFont" title="进入科汛微门户管理后台">管理</a>
                </td>
            </tr>
            <tr onmouseover="this.className='CtrMouseOver'" onmouseout="this.className='CtrMouseOut'" class="CtrMouseOut"  style="display:none">
            	<td class="Ctd" align="center">
                	点播课程
                </td>
                <td class="Ctd" align="left">
                	开通后可将网校内点播课程数据迁移至科汛微门户，利用科汛微门户进行推广，同时学生可以进行多端学习
                </td>
                <td class="Ctd" align="center">
                	<a href="" class="greenFont">开通模块</a>
                </td>
            </tr>
        </table>


    <!--充值弹窗-->
    <div class="Recharge" style="display:none;">
    	<table class="yun-bindBox">
        	<tr>
                <td class="yun-bindTit" width="200" align="right">购买直播币：</td>
                <td class="yun-Choice">
                   <span class="button button_on" onclick="Choice(this,800)">800枚</span> 
                   <span class="button" onclick="Choice(this,1000)">1000枚</span> 
                   <span class="button" onclick="Choice(this,3000)">3000枚</span> 
                   <span class="button" onclick="Choice(this,5000)">5000枚</span> 
                   <span class="button" onclick="Choice(this,0)">自定义</span> 
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="200" align="right">直播币单价：</td>
                <td>
                   ￥<span class="redFont">1</span> 元/枚
                </td>
            </tr>
            <tr id="showDiyNum" style="display:none">
                <td class="yun-bindTit" width="200" align="right">购买数量：</td>
                <td class="yun-space">
                   <input type="text" name="DiyNum" id="DiyNum" class="text" style="width:60px;text-align:center" value="800" onblur="DiyOut()" onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')"  />枚
                </td>
            </tr>
            <tr>
                <td class="yun-bindTit" width="200" align="right">所需费用：</td>
                <td>
                   <span class="redFont" id="totalMoney">1000</span> 元
                </td>
            </tr>

            <tr>
                <td class="yun-bindTit" width="200" align="right"> </td>
                <td>
                   <a class="button button_on" onclick="CZ()">立即支付</a>
                </td>
            </tr>
        </table>
    </div>
    <div class="showToPay" style="display:none"></div>

            </div>

    <%} %>
    <script>
        $(function () {
           Total();
        })
        function ShowRecharge() {
           $(".Recharge").toggle();
        }
        function Choice(obj, num) {
            $(obj).addClass('button_on').siblings('.button').removeClass('button_on')

            if (num == 0) {
                $("#showDiyNum").show();
                num = 500;

            } else {
                $("#showDiyNum").hide();
            }
            $("#DiyNum").val(num);
            Total();
        }
        function Total() {
             var totalMoney =parseInt($("#DiyNum").val());
            $("#totalMoney").html(totalMoney);
        }
        function DiyOut() {
            var num = parseInt($("#DiyNum").val());
            if (num < 500) {
                $.dialog.alert('购买数量必须大于等于500！', function () { $("#DiyNum").focus(); });
                return;
            }
          Total();
        }
        function CZ() {
            var num = $("#DiyNum").val();
            if (num < 500) {
                $.dialog.alert('购买数量必须大于等于500！', function () { $("#DiyNum").focus(); });
                return;
            }
         // num = 1;
            $.ajax({
                     type: "get",
                     url: "KS.YunKetangJieApi.aspx",
                     data: "action=buylive&num=" + num, 
                     success: function (data) {
                         if (data.indexOf("success") != -1) {
                             var str = "<div class='message'>";
                             str += "本次充值：<span class='redFont'>" + num + "</span>元<br/> 请用微信扫以下二维码支付：<br/>";
                             str += "<img src='" + data.split('success:')[1] + "'/>";
                             str+="</div>"
                             str += "<div>温馨提示：在线支付成功后，请刷新本页面查看是否充值成功！"
                             str +="<br/><br/><input type='button' class='button button_on' onclick='ChangePay()' value='取回返回'/>"
                             str += "</div>"
                             $(".showToPay").html(str).show();
                             $(".Recharge").hide();
                             
                         } else {
                             KesionJS.Alert(data);
                         }
                     }
                });
        }
        function ChangePay() {
            $(".Recharge").show();
            $(".showToPay").hide();
        }
        function copyUrl(){
			 var Url2=document.getElementById("url2");
			 Url2.select(); // 选择对象
			 document.execCommand("Copy"); // 执行浏览器复制命令
            $.dialog.alert('复制成功！', function () {  });
        }
        function DoKetangJieUnBind() {
            if (confirm("取消绑定后， 将不能再使用科汛微门户提供的服务（如一对一，小班课等），确认取消科汛微门户绑定吗？")) {
                $.ajax({
                    type: "get",
                    url: "KS.YunKetangJieApi.aspx",
                    data: "action=unbindketangjie",
                    success: function (data) {
                        if (data == 'true') {
                            KesionJS.Alert('恭喜，取消绑定成功！', "location.reload();");
                        } else {
                            KesionJS.Alert(data);
                        }
                    }
                });
            }
        }
    </script>

  </asp:Panel>


    <!--直播币使用明细-->
  <asp:Panel ID="PanelLiveMoney" runat="server" Visible="false">
                  


       <div class="content-area"> 
     <div class="tabs_header">
        <a href="KS.YunKeTangJieApi.aspx" class="fr button mr20">返回</a>
        <ul class="tabs">
         <li<%=KSCMS.S("From")==""?" class='active'":"" %>><a href="KS.YunKeTangJieApi.aspx?action=livemoney"><span>直播币购买记录</span></a></li>
         <li<%=KSCMS.S("From")!=""?" class='active'":"" %>><a href="KS.YunKeTangJieApi.aspx?action=livemoney&from=consumer"><span>直播币消费记录</span></a></li>
        </ul>
        
    </div>

  
        <%if (string.IsNullOrEmpty(KSCMS.S("from")))
            { %>
        <table class="CTable" cellspacing="0" border="0" style="color:Black;width:100%;border-collapse:collapse;">
        	<tr class="CTitle">
                <th scope="col" style="width:200px">购买时间</th>
                <th scope="col" style="width:200px">订单号</th>
                <th scope="col">购买数量</th>
                <th scope="col">单价</th>
                <th scope="col" style="width:160px;text-align:center;">实际支付</th>
            </tr>
           <asp:Repeater ID="LiveMoneyBuyList" runat="server">
                <HeaderTemplate>
                </HeaderTemplate>
                <ItemTemplate>
            <tr onmouseover="this.className='CtrMouseOver'" onmouseout="this.className='CtrMouseOut'" class="CtrMouseOut">
            	<td class="Ctd" align="center">
                	<%# Kesion.Publics.Utils.unixTimeStampToDateTime(Utils.StrToLong(Eval("adddate"))) %>
                </td>
            	<td class="Ctd" align="center">
                	<%# Eval("ordersn") %>
                </td>
                <td class="Ctd" align="center">
                	 <font><%# Utils.StrToFloat(Eval("numb")) %>枚</font> 
                </td>
                <td class="Ctd" align="center">
                	 <font class="tips"><%# Eval("market_price") %></font> 
                </td>
                <td class="Ctd" align="center">
                	 <font class="redFont"><%# Utils.StrToDecimal(Eval("price"))>0?Kesion.APPCode.Public.ReturnShopPrice(Eval("price")):"赠送" %></font> 
                </td>
            </tr>
           </ItemTemplate>
                <FooterTemplate>
                    <tr onmouseover="this.className='CtrMouseOver'" onmouseout="this.className='CtrMouseOut'" class="CtrMouseOut"<%# LiveMoneyBuyList.Items.Count>0?" style='display:none'":"" %>>
            	        <td class="empty" align="center" colspan="6">
                	        没有任何充值记录!
                        </td>
                    </tr>
                </FooterTemplate>
            </asp:Repeater>
        </table>
           <%}
    else
    { %>
           <table class="CTable" cellspacing="0" border="0" style="color:Black;width:100%;border-collapse:collapse;">
        	<tr class="CTitle">
                <th scope="col" style="width:200px">消费时间</th>
                <th scope="col" style="width:200px">课程</th>
                <th scope="col">总时长</th>
                <th scope="col">花费(直播币)</th>
                <th scope="col" style="width:160px;text-align:center;">开始时间</th>
                <th scope="col" style="width:160px;text-align:center;">结束时间</th>
            </tr>
           <asp:Repeater ID="LiveMoneyConsumerList" runat="server">
                <HeaderTemplate>
                </HeaderTemplate>
                <ItemTemplate>
            <tr onmouseover="this.className='CtrMouseOver'" onmouseout="this.className='CtrMouseOut'" class="CtrMouseOut">
            	<td class="Ctd" align="center">
                	<%# Kesion.Publics.Utils.unixTimeStampToDateTime(Utils.StrToLong(Eval("settlement"))) %>
                </td>
            	<td class="Ctd" align="center">
                	<%# Eval("title") %>
                </td>
                <td class="Ctd" align="center">
                	 <font><%# Utils.StrToInt(Eval("time"))/60 %>分钟</font> 
                </td>
                <td class="Ctd" align="center">
                	 <font class="readFont"><%# Eval("cost") %>枚</font> 
                </td>
                <td class="Ctd" align="center">
                	<%# Kesion.Publics.Utils.unixTimeStampToDateTime(Utils.StrToLong(Eval("starttime"))) %>
                </td>
                <td class="Ctd" align="center">
                	<%# Kesion.Publics.Utils.unixTimeStampToDateTime(Utils.StrToLong(Eval("endtime"))) %>
                </td>
            </tr>
           </ItemTemplate>
                <FooterTemplate>
                     <tr onmouseover="this.className='CtrMouseOver'" onmouseout="this.className='CtrMouseOut'" class="CtrMouseOut"<%# LiveMoneyConsumerList.Items.Count>0?" style='display:none'":"" %>>
            	        <td class="empty" align="center" colspan="6">
                	        没有任何使用记录!
                        </td>
                    </tr>
                </FooterTemplate>
            </asp:Repeater>
        </table>

           <%} %>

        <asp:Label ID="LabPage" runat="server"></asp:Label>


    </div>
  </asp:Panel>

</asp:Content>

