<include file="public:header" />
<!--商品列表-->
<div class="subnav">
	<div class="content_menu ib_a blue line_x">
	<a class="add fb " href="javascript:tqk_collect()" style="background:#ec971f;"><em style="background:#ec971f;">推券客数据采集</em></a>
	
	说明：采集推券客数据请点击左侧按钮，下面分类列表为采集淘宝网站数据 (采集非常耗费资源，如果采集时网站打开慢，属于正常现象) <br />
	
	
	</div>

</div>
<div class="pad_lr_10" >

    <div class="J_tablelist table_list" >
    <table width="100%" cellspacing="0">
        <thead>
            <tr>
                <th><span data-tdtype="order_by" data-field="id">ID</span></th>
                <th align="left"><span data-tdtype="order_by" data-field="name">淘宝商品分类</span></th>
				<th width="70"><span data-tdtype="order_by" data-field="page">采集页数</span></th>
				<th width="100"><span data-tdtype="order_by" data-field="last_page">上次采集页数</span></th>
				<th width="40"><span data-tdtype="order_by" data-field="status">状态</span></th>
                <th width="120"><span data-tdtype="order_by" data-field="last_time">最近时间</span></th>
                <th width="200">{:L('operations_manage')}</th>
            </tr>
        </thead>
    	<tbody>
            <volist name="list" id="val" >
            <tr>
                <td align="center">{$val.id}</td>
                <td align="left">{$val.name}</td>
				<td align="center" class="red">{$val.page}</td> 
				<td align="center" class="red">{$val.last_page}</td> 
				<td align="center"><img data-tdtype="toggle" data-id="{$val.id}" data-field="status" data-value="{$val.status}" src="__STATIC__/images/admin/toggle_<if condition="$val.status eq 0">disabled<else/>enabled</if>.gif" /></td>
                <td align="center">{$val.last_time|frienddate}</td>
                <td align="center"><a href="javascript:collect({$val.id},{$val.last_page});">继续上次采集</a> |<a href="javascript:collect({$val.id},1);">开始采集</a> </td>
            </tr>
            </volist>
    	</tbody>
    </table>
    </div>

</div>
<include file="public:footer" />
<script>
    var collect_url = "{:U('robots/collect')}";
    var id = 0;
	var p = 1;
	function collect(id,p){
        $.getJSON(collect_url, {id:id,p:p}, function(result){
            if(result.status == 1){
				$.dialog({id:'cmt_yhxia', title:result.msg, content:result.data, padding:'', lock:true});
                p++;
				setTimeout("collect_page("+ id +","+ p+")",1000);
            }else{
              if($.dialog.get('cmt_yhxia')){
                $.dialog.get('cmt_yhxia').close();
                $.yhxia.tip({content:result.msg});
               }else{
               	 $.yhxia.tip({content:result.msg});
               }
            }
        });
    }
	function collect_page(id,p){
        $.getJSON(collect_url, {id:id,p:p}, function(result){
            if(result.status == 1){
                $.dialog.get('cmt_yhxia').content(result.data);
                 p++;
				setTimeout("collect_page("+ id +","+ p+")",1000);
            }else{
                if($.dialog.get('cmt_yhxia')){
                $.dialog.get('cmt_yhxia').close();
                $.yhxia.tip({content:result.msg});
               }else{
               	 $.yhxia.tip({content:result.msg});
               }
            }
        });
    }
	
    function tqk_collect(p){
        $.getJSON("{:U('tuiquanke')}", {page:p?p:1}, function(result){
            if(result.status == 1){
            	if($.dialog.get('cmt_yhxia')){
                	$.dialog.get('cmt_yhxia').content(result.data);
            	}else{
            		$.dialog({id:'cmt_yhxia', title:'提示', content:result.data, padding:'', lock:true});
            	}
                p = result.msg;
                setTimeout("tqk_collect("+ p +")",1500);
            }else{
               if($.dialog.get('cmt_yhxia')){
                $.dialog.get('cmt_yhxia').close();
                $.yhxia.tip({content:result.msg});
               }else{
               	 $.yhxia.tip({content:result.msg});
               }
            }
        });
    }
</script>
</body>
</html>