<style type="text/css">
	.dhmgl_box {
    width: 100%;
    padding: 0px 30px;
    overflow: hidden;
    min-width: 960px;}
</style>	
	<div class="col-md-10" role="main">
        <nav class="breadcrumb"></i> 积分商城模块<span class="c-gray en">&gt;</span>商品管理</nav>
		<div class="title-box">
            <p class="t-p"  style="font-size: 28px; color: #7d7d7d;vertical-align: middle; padding-top: 15px; padding-bottom: 15px;">商品管理</p>
        </div>

        <div class="dhmgl_box">             
            <div class="form_head" style="margin-top: 15px;">
                <span class="form_tle">商品列表</span>
                <div class="form_btn">
                    <a href="<?php echo site_url('score/goods/add/2')?>">
                        <button class="form_btn_A">新增虚拟商品</button>
                    </a>  

                    <a href="<?php echo site_url('score/goods/add/1')?>">  
                        <button class="form_btn_A">新增实物商品</button>
                    </a>    
                </div>
             
            </div>     
		
		
    		<div class="m_table_box" style="width:auto;margin-left:0px;margin-top: 25px;min-width:1100px!important;">
                <table class="spgl_table_list">
                    <thead>
                        <tr>
                        	<th class="s-thead">商品名称</th>
                            <th class="s-thead">种类</th>
                            <th class="s-thead">类型</th>
                            <th class="s-thead">库存</th>
                            <th class="s-thead">方式</th>
                            <th class="s-thead">状态</th>
                            <th class="s-thead">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    	<?php foreach ($listInfo as $v):?>
                         <tr>
                         	<td><?php echo $v['name'];?></td>
    	                    <td><?php echo $v['cate'];?></td>
    	                    <td><?php echo $v['type'];?></td>
    	                    <td><?php echo $v['num']>0?$v['num']:0;?></td>
    	                    <td><?php echo $v['get_type'];?></td>
    	                    <td>
                                <?php 
                                    if($v['num']!=0)
                                    {
                                        echo $v['c_status']==0?$v['status']:($v['c_recommend']==1?$v['recommend']:'正常');
                                    }
                                    else{
                                        echo "库存不足";
                                    }
                                ?>
                            </td>
    	                    <td class="td-center spgl_table_btn">
                                <input type="hidden" name="gid" value="<?php echo $v['id'];?>">
                                <?php 
                                    if($v['num'] !=0)
                                    {
                                        if($v['c_status'] !=0){
                                ?>
                                            <button type="button" class="operate  level spgl_btn_off" value="0" name="status">
                                                <span>下架</span>
                                            </button>
                                <?php
                                        }
                                        else{
                                ?>
                                           <button type="button" class="operate  level spgl_btn_sj" value="1" name="status">
                                                <span>上架</span>
                                            </button>  
                                <?php                                                  
                                        }
                                        if($v['c_recommend'] !=0){
                                ?>
                                            <button type="button" class="operate level spgl_btn_off" value="0" name="recommend">
                                                <span>取消推荐</span>
                                            </button>
                                <?php
                                        }
                                        else{
                                ?>
                                           <button type="button" class="operate  level spgl_btn_tj" value="1" name="recommend">
                                                <span>推荐</span>
                                            </button> 
                                <?php                                       
                                        }

                                    }
                                ?>
                                <a href="<?php echo site_url('score/goods/edit/'.$v['id']);?>">
                                <button type="button" class="level spgl_btn_bj">
                                    <span>编辑</span>
                                </button></a>
    	                    	<a href="<?php echo site_url('score/exchange/index/'.$v['id']);?>"><button type="button" class="level spgl_btn_dhgl">
    								<span>兑换管理</span>
    		                    </button></a>
    	                    </td>                
                        </tr> 
                        <?php endforeach;?>              
                    </tbody>
                </table>
            </div>
            <?php echo $pageinfo;?>
        </div>
	</div>
	<script type="text/javascript" src="<?php echo asset_url('js/paging.js');?>"></script>
    <script>
    jQuery(document).ready(function($) {
        $(".operate").on('click',function(event) {
            var gid = $(this).parent('td').children('input').val();
            var status = $(this).val();
            var mod = $(this).attr('name');//操作方法
            $.ajax({
                url: '<?php echo site_url("score/goods/operate");?>',
                type: 'POST',
                dataType: 'json',
                data: {mod: mod,gid:gid,status:status},
                success:function(data)
                {
                    if(data.code ==1)
                    {
                        location.href='';
                    }
                    else
                    {
                        alert(data.msg);
                    }                   
                }
            }); 
        });      
    });
    </script>



