<!doctype html>
<html class="no-js">
<head>

<include file="Common/head" />
<style type="text/css">
    a.am-text-secondary:visited{color:#3bb4f2;}
    a.am-text-danger:visited{color:#dd514c;}
    .am-btn-default {background-color: #fff;}
    th {text-align:center;}
    tr td{text-align:center;}
    select{padding: 4px;border: 1px solid #ccc;}
    .am-popup-bd {background:#fff;}
    .am-popup-bd img {max-width: 100%}
    .am-u-sm-2 {border-top: 1px solid #ddd;margin-top: 10px;}
    .am-u-sm-10 {border-left: 1px solid #ddd;margin-top: 10px;}
</style>
</head>
<body>

<include file="Common/header" />

<div class="am-cf admin-main">

    <!-- sidebar start -->
    <include file="Common/sidebar" nav="shop"/>
    <!-- sidebar end -->
    
    <!-- content start -->
    <div class="admin-content">
        <div class="admin-content-body">
            <div class="am-cf am-padding am-padding-bottom-0">
                <div class="am-fl am-cf">
                    <strong class="am-text-primary am-text-lg">商品管理</strong> / <small>商品列表</small>
                </div>
            </div>
            <hr style="margin-top:0px;">
                
            <div class="am-g">
                <div class="am-u-sm-12 am-u-md-12">
                    <form action="" method="get">
                    <div class="am-form-group">
                        
                        <span class="onm">
                            <input type="text" name="name" value="{$name}" placeholder="商品名称" style="width: 230px">
                        </span>
                        <span class="cate">
                            <select name="cate" id="">
                                <option value="0" <?php if($cate==0){echo "selected";}?>>所有分类</option>
                                <?php foreach($categories as $k => $v){ ?>
                                <option value="<?php echo $v['id']?>" <?php if($cate==$v['id']){echo "selected";}?> ><?php echo $v['name']?></option>
                                <?php } ?>
                            </select> 
                        </span>
                        <button class="am-btn am-btn-default" type="submit" onclick="javascript:this.form.action='{:U('shopList')}';">搜索</button>
                        <a href="{:U('shopList')}" class="am-btn am-btn-default">重置</a>
                        <!-- <input class="am-btn am-btn-default" type="submit" onclick="javascript:this.form.action='';" value="导出excel"> -->
                    </div>
                    </form>
                    
                </div>
            </div>   

            <div class="am-g">
                <form class="am-form-inline" action="" method="get">
                    <div class="am-u-sm-12 am-u-md-6">
                        <div class="am-btn-toolbar">
                            <div class="am-btn-group am-btn-group-xs">
                                <a class="am-btn am-btn-secondary" href="{:U('shop_add')}">添加商品</a>
                            </div>
                        </div>
                    </div>
                    <div class="am-u-sm-12 am-u-md-3">&nbsp;</div>
                </form>
            </div>
            <div class="am-g">
                <div class="am-u-sm-12">
                    <table class="am-table am-table-hover table-main am-text-nowrap">
                        <thead>
                            <tr>
                                <th>ID</th>
                                <th>排序</th>
                                <th>商品名称</th>
                                <th>图片</th>
                                <th>所属分类</th>
                                <th>商品价格</th>
                                <th>上架</th>
                                <th>热销</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            <volist name="list" id="vo">
                                <tr>
                                    <td>{$vo.id}</td>
                                    <td>{$vo.sort}</td>
                                    <td style="width:350px;">{$vo.goods_name}</td>
                                    <td>
                                        <img src="__ROOT__/Uploads/{$vo.thumb}" style="width:50px;height:50px" />
                                    </td>
                                    <td style="width:150px;"><if condition="$vo[cate_name]">{$vo.cate_name}<else/><span style="color:#f00;font-weight:bold">原分类已删除</span></if></td>
                                    <td>{$vo['goods_price']}</td>
                                    <td>
                                        <if condition="$vo[is_sale] eq 2">
                                            是
                                        <elseif condition="$vo[is_sale] eq 1"/>
                                            <span style="font-weight:bold;color:#F00">否</span>
                                        </if>
                                    </td>
                                    <td>
                                        <if condition="$vo[is_hot] eq 2">
                                            <span style="font-weight:bold;color:#F00">是</span>
                                        <elseif condition="$vo[is_hot] eq 1"/>
                                            否
                                        </if>
                                    </td>
                                    <td>
                                        <div class="am-dropdown" data-am-dropdown>
                                            <button class="am-btn am-btn-default am-btn-xs am-dropdown-toggle" data-am-dropdown-toggle>
                                                <span class="am-icon-cog"></span>
                                                <span class="am-icon-caret-down"></span>
                                            </button>
                                            <ul class="am-dropdown-content">
                                                <li><a href="{:U('shop_add',array('id' => $vo['id'],'p'=>I('p')))}">编辑</a></li>
                                                <li>
                                                    <a class="del_link" data-name="{$vo.name}" data-url="{:U('shopDel', array('id' => $vo[id],'p'=>I('p')))}" href="javascript:;">
                                                        删除
                                                    </a>
                                                </li>
                                            </ul>
                                        </div>
                                    </td>
                                </tr>
                            </volist>
                        </tbody>
                    </table>
                    {$page}
                </div>
            </div>
        </div>
    </div>
    <!-- content end -->
</div>
<script type="text/javascript">
    $(function(){
        // 删除
        $(".del_link").on("click",function(){
            var name=$(this).attr("data-name");
            var the_link=$(this).attr("data-url");
            var bool = confirm("确认删除记录吗？");
            if (bool) {
                location.href = the_link;
            };
        });
    });
</script>
<include file="Common/footer" />

</body>
</html>