今天完成了商品分类管理、商品管理、用户管理、订单列表功能
一、商品分类管理
商品分类主要功能是新建商品一级分类列表,有添加、编辑、删除功能,还有二级分类列表。添加编辑,更具传入的id值确定,然后将id传给add方法,然后查到数据,展示给前台,然后保存;删除根据传入的id来删除;二级列表通过url方法,将传入的id值get到二级分类列表方法,然后查询该id下的所有记录。
//分类一级
public function cat_index() {
$list = $this->db->table('shop_cat')->where(array('cat_fid'=>0))->order('sort DESC')->lists();
$this->assign('list', $list);
return $this->fetch();
}
//添加编辑商品分类
public function cat_add() {
$id = (int)input('get.id');
$fid = (int)input('get.fid');
//查询出id的商品分类记录
$data = $this->db->table('shop_cat')->where(array('cat_id'=>$id))->item();
$this->assign('data', $data);
$this->assign('fid', $fid);
return $this->fetch();
}
//保存商品分类
public function cat_save() {
//将传过来的数据整理在一起
$id = (int)input('post.cat_id');
$data['cat_name'] = trim(input('post.cat_name'));
$data['sort'] = (int)input('post.sort');
$data['status'] = (int)input('post.status');
//判断 如果id存在那么就是修改执行更新操作
if ($id) {
$res = $this->db->table('shop_cat')->where(array('cat_id'=>$id))->update($data);
} else {
//如果id不存在 那么就是新增需要把level fid 和data插入
$data['cat_fid'] = (int)input('post.fid');
$res = $this->db->table('shop_cat')->insert($data);
}
if ($res) {
exit(json_encode(array('code'=>0, 'msg'=>'保存成功')));
} else {
exit(json_encode(array('code'=>1, 'msg'=>'保存失败')));
}
}
//删除分类
public function cat_del() {
$id = (int)input('post.id');
//16 执行删除操作
$res = $this->db->table('shop_cat')->where(array('cat_id'=>$id))->delete();
if (!$res) {
exit(json_encode(array('code'=>1, 'msg'=>'删除失败')));
}
exit(json_encode(array('code'=>0, 'msg'=>'删除成功')));
}
//二级分类列表
public function cat_two_index() {
$fid = (int)input('get.fid');
//查找出一级分类记录
$item = $this->db->table('shop_cat')->where(array('cat_id'=>$fid))->item();
$list = $this->db->table('shop_cat')->where(array('cat_fid'=>$fid))->lists();
$this->assign('list', $list);
$this->assign('item', $item);
$this->assign('fid', $fid);
return $this->fetch();
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<style type="text/css">
.header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
.header div{border-bottom: solid 2px #009688;margin-top: 8px;}
.header button{float: right;margin-top: -5px;}
</style>
</head>
<body style="padding: 10px;">
<div class="header">
<span>商品一级分类</span>
<button class="layui-btn layui-btn-sm" onclick="add()">添加</button>
<div></div>
</div>
<table class="layui-table">
<thead>
<tr>
<th>排序</th>
<th>ID</th>
<th>分类名</th>
<th>状态</th>
<th>二级列表</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!-- 循环出所有广告分类 -->
{volist name="list" id="vo"}
<tr>
<td>{$vo.sort}</td>
<td>{$vo.cat_id}</td>
<td>{$vo.cat_name}</td>
<td>{if condition="$vo.status == 1"}<span style="color: green;">开启</span>{else/}<span style="color: red;">关闭</span>{/if}</td>
<td>
<button class="layui-btn layui-btn-xs" onclick="url({$vo.cat_id})">进入二级分类列表</button>
</td>
<td>
<button class="layui-btn layui-btn-xs" onclick="add({$vo.cat_id})">编辑</button>
<button class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$vo.cat_id})">删除</button>
</td>
</tr>
{/volist}
</tbody>
</table>
<script type="text/javascript">
layui.use(['layer'],function(){
layer = layui.layer;
$ = layui.jquery;
});
// 添加编辑
function add(id) {
layer.open({
type: 2,
title: id>0 ? '编辑分类' : '添加分类',
shade: 0.3,
area: ['480px', '420px'],
content: '/index.php/admins/Shop/cat_add?id='+id
});
}
//分类下的广告列表
function url(id) {
window.location.href = "/index.php/admins/Shop/cat_two_index?fid="+id;
}
// 删除
function del(id) {
layer.confirm('确定要删除吗?', {
icon: 3,
btn: ['确定', '取消']
}, function () {
$.post('/index.php/admins/Shop/cat_del', {'id':id}, function (res) {
if (res.code > 0) {
layer.alert(res.msg, {icon:2});
} else {
layer.msg(res.msg);
setTimeout(function () {
window.location.reload();
}, 1000)
}
}, 'json');
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
</head>
<body style="padding: 10px;">
<form class="layui-form">
<!-- hidden 是把input框隐藏,它的作用是把一些隐藏信息传值到接口中 -->
<input type="hidden" name="cat_id" value="{$data.cat_id}">
<input type="hidden" name="fid" value="{$fid}">
<div class="layui-form-item">
<label class="layui-form-label">名称</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="cat_name" value="{$data.cat_name}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="sort" value="{$data.sort}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline">
<input type="checkbox" name="status" lay-skin="primary" title="开启" value="1" {$data.status==1 || !$data ?'checked':''}>
</div>
</div>
</form>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" onclick="save()">保存</button>
</div>
</div>
<script type="text/javascript">
layui.use(['layer','form'],function(){
form = layui.form;
layer = layui.layer;
$ = layui.jquery;
});
// 保存管理员
function save(){
// 用js 获取省名称 首字母
var cat_name = $.trim($('input[name="cat_name"]').val());
if(cat_name==''){
layer.alert('请输入名称',{icon:2});
return;
}
// 请求保存接口,把数据传值到接口中。
$.post('/index.php/admins/Shop/cat_save',$('form').serialize(),function(res){
if(res.code>0){
layer.alert(res.msg,{icon:2});
}else{
layer.msg(res.msg);
setTimeout(function(){parent.window.location.reload();},1000);
}
},'json');
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<style type="text/css">
.header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
.header div{border-bottom: solid 2px #009688;margin-top: 8px;}
.header button{float: right;margin-top: -5px;}
</style>
</head>
<body style="padding: 10px;">
<div class="header">
<span style="background-color:#999;"><a href="/index.php/admins/Shop/cat_index" style="color:#fff;">商品分类一级列表</a></span>
<span>{$item.cat_name}的二级列表</span>
<button class="layui-btn layui-btn-sm" onclick="add()">添加</button>
<div></div>
</div>
<table class="layui-table">
<thead>
<tr>
<th>排序</th>
<th>ID</th>
<th>分类名</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!-- 循环出二级分类 -->
{volist name="list" id="vo"}
<tr>
<td>{$vo.sort}</td>
<td>{$vo.cat_id}</td>
<td>{$vo.cat_name}</td>
<td>{if condition="$vo.status == 1"}<span style="color: green;">开启</span>{else/}<span style="color: red;">关闭</span>{/if}</td>
<td>
<button class="layui-btn layui-btn-xs" onclick="add({$vo.cat_id})">编辑</button>
<button class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$vo.cat_id})">删除</button>
</td>
</tr>
{/volist}
</tbody>
</table>
<script type="text/javascript">
layui.use(['layer'],function(){
layer = layui.layer;
$ = layui.jquery;
});
var fid = '{$fid}';
// 添加编辑
function add(id) {
layer.open({
type: 2,
title: id>0 ? '编辑分类' : '添加分类',
shade: 0.3,
area: ['480px', '420px'],
content: '/index.php/admins/Shop/cat_add?id='+id+'&fid='+fid
});
}
// 删除
function del(id) {
layer.confirm('确定要删除吗?', {
icon: 3,
btn: ['确定', '取消']
}, function () {
$.post('/index.php/admins/Shop/cat_del', {'id':id}, function (res) {
if (res.code > 0) {
layer.alert(res.msg, {icon:2});
} else {
layer.msg(res.msg);
setTimeout(function () {
window.location.reload();
}, 1000)
}
}, 'json');
});
}
</script>
</body>
</html>
二、商品管理
道理和之前的一样,查询所有商品在前端展示出来,可以添加编辑删除,重点在添加编辑功能,有图片上传功能和一二级分类选择(下一节在完善)。
//商品列表
public function shop_index() {
//查询出商品列表中的所有商品
$list = $this->db->table('shop_goods')->order('sort DESC,id DESC')->lists();
//查找出该商品的分类,将分类名赋给list
if ($list) {
foreach ($list as &$v) {
$cat = $this->db->table('shop_cat')->where(array('cat_id'=>$v['cat_id']))->item();
$v['cat_name'] = $cat['cat_name'];
}
}
$this->assign('list', $list);
return $this->fetch();
}
//添加编辑商品
public function shop_add() {
$id = (int)input('get.id');
//查找出id对应下的单条商品记录
$data = $this->db->table('shop_goods')->where(array('id'=>$id))->item();
$this->assign('data', $data);
// 查询出所有的一级分类
$cat = $this->db->table('shop_cat')->where(array('status'=>1, 'cat_fid'=>0))->lists();
$this->assign('cat', $cat);
return $this->fetch();
}
//保存商品信息
public function shop_save(){
$id = (int)input('post.id');
$data['cat_id'] = (int)input('post.cat_id'); // 分类ID
$data['title'] = trim(input('post.title')); // 标题
$data['price'] = trim(input('post.price')); // 价格
$data['o_price'] = trim(input('post.o_price')); // 原价
$data['img'] = input('post.img'); // 图片
$data['info'] = trim(input('post.info')); // 商品介绍
$data['sort'] = (int)input('post.sort'); // 排序
$data['status'] = (int)input('post.status'); // 状态
if($id){
$add = $this->db->table('shop_goods')->where(array('id'=>$id))->update($data);
}else{
$add = $this->db->table('shop_goods')->insert($data);
}
if($add > 0){
exit(json_encode(array('code'=>0,'msg'=>'数据保存成功')));
}else{
exit(json_encode(array('code'=>1,'msg'=>'数据保存失败')));
}
}
# 商品删除
public function shop_del(){
$id = (int)input('post.id');
$del = $this->db->table('shop_goods')->where(array('id'=>$id))->delete();
if($del){
exit(json_encode(array('code'=>0,'msg'=>'删除成功')));
}else{
exit(json_encode(array('code'=>1,'msg'=>'删除失败')));
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<style type="text/css">
.header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
.header div{border-bottom: solid 2px #009688;margin-top: 8px;}
.header button{float: right;margin-top: -5px;}
</style>
</head>
<body style="padding: 10px;">
<div class="header">
<span>商品列表</span>
<button class="layui-btn layui-btn-sm" onclick="add()">添加</button>
<div></div>
</div>
<table class="layui-table">
<thead>
<tr>
<th>排序</th>
<th>ID</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.sort}</td>
<td>{$vo.id}</td>
<td>{$vo.cat_id}</td>
<td>{$vo.title}</td>
<td>{$vo.price}</td>
<td>{$vo.o_price}</td>
<td><img src="{$vo.img}" alt=""></td>
<td>{if condition="$vo.status == 1"}<span style="color: green;">开启</span>{else/}<span style="color: red;">关闭</span>{/if}</td>
<td>
<button class="layui-btn layui-btn-xs" onclick="add({$vo.id})">编辑</button>
<button class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$vo.id})">删除</button>
</td>
</tr>
{/volist}
</tbody>
</table>
<script type="text/javascript">
layui.use(['layer'],function(){
layer = layui.layer;
$ = layui.jquery;
});
// 添加编辑
function add(id) {
layer.open({
type: 2,
title: id>0 ? '编辑分类' : '添加分类',
shade: 0.3,
area: ['1080px', '600px'],
content: '/index.php/admins/Shop/shop_add?id='+id
});
}
// 删除
function del(id) {
layer.confirm('确定要删除吗?', {
icon: 3,
btn: ['确定', '取消']
}, function () {
$.post('/index.php/admins/Shop/shop_del', {'id':id}, function (res) {
if (res.code > 0) {
layer.alert(res.msg, {icon:2});
} else {
layer.msg(res.msg);
setTimeout(function () {
window.location.reload();
}, 1000)
}
}, 'json');
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
</head>
<body style="padding: 10px;">
<form class="layui-form">
<!-- hidden 是把input框隐藏,它的作用是把一些隐藏信息传值到接口中 -->
<input type="hidden" name="id" value="{$data.id}">
<div class="layui-form-item">
<label class="layui-form-label">标题</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="title" value="{$data.title}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">一级分类</label>
<div class="layui-input-inline">
<select name="cat_fid" id="cat_id">
<option value="0">请选择</option>
{volist name="cat" id="cat_vo"}
<option value="{$cat_vo['cat_id']}">{$cat_vo.cat_name}</option>
{/volist}
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">二级分类</label>
<div class="layui-input-inline">
<select name="cat_id">
<option value=0>请选择</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">原价</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="price" value="{$data.price}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">现价</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="o_price" value="{$data.o_price}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图片上传</label>
<div class="layui-upload">
<button type="button" class="layui-btn" id="test1">上传图片</button>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">图片预览</label>
<div class="layui-upload-list">
<img class="layui-upload-img" id="demo1" style="width: 200px;" src="{$data.img}">
<p id="demoText"></p>
<input type="hidden" name="img" value="">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">排序</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="sort" value="{$data.sort}">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">状态</label>
<div class="layui-input-inline">
<input type="checkbox" name="status" lay-skin="primary" title="开启" value="1" {$data.status==1 || !$data ?'checked':''}>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">商品介绍</label>
<div class="layui-input-inline" id="editor" style="width: 80%;">
</div>
</div>
</form>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" onclick="save()">保存</button>
</div>
</div>
<script type="text/javascript" src="/static/wangEditor/release/wangEditor.js"></script>
<script type="text/javascript">
var E = window.wangEditor;
var editor = new E('#editor');
// 或者 var editor = new E( document.getElementById('editor') )
editor.create();
editor.txt.html('<?php echo htmlspecialchars_decode($data['info']); ?>');
layui.use(['layer','form', 'upload'],function(){
form = layui.form;
layer = layui.layer;
$ = layui.jquery;
upload = layui.upload;
var uploadInst = upload.render({
elem: '#test1'
,url: '/index.php/admins/Home/up_img'
,before: function(obj){
//预读本地文件示例,不支持ie8
obj.preview(function(index, file, result){
$('#demo1').attr('src', result); //图片链接(base64)
});
}
,done: function(res){
//如果上传失败
if(res.code > 0){
return layer.msg('上传失败');
}else{
$('#demo1').attr('src', res.data); //图片链接(base64)
$('input[name="img"]').val(res.data); //图片链接(base64)
}
//上传成功
}
,error: function(){
//演示失败状态,并实现重传
var demoText = $('#demoText');
demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
demoText.find('.demo-reload').on('click', function(){
uploadInst.upload();
});
}
});
});
// 保存管理员
function save(){
// 用js 获取省名称 首字母
var title = $.trim($('input[name="title"]').val());
if(title==''){
layer.alert('请输入标题',{icon:2});
return;
}
var data = new Object();
data.id = $('input[name="id"]').val();
data.title = $('input[name="title"]').val();
data.price = $('input[name="pirce"]').val();
data.o_price = $('input[name="o_price"]').val();
data.img = $('input[name="img"]').val();
data.info = editor.txt.html();
data.sort = $('input[name="sort"]').val();
data.status = $('input[name="status"]').val();
// 请求保存接口,把数据传值到接口中。
$.post('/index.php/admins/Shop/shop_save',data,function(res){
if(res.code>0){
layer.alert(res.msg,{icon:2});
}else{
layer.msg(res.msg);
setTimeout(function(){parent.window.location.reload();},1000);
}
},'json');
}
</script>
</body>
</html>
三、用户管理
这里只需要查询到所有的用户 然后展示出来就可以
//用户列表
public function index() {
//查找所有用户按照uid降序
$list = $this->db->table('shop_user')->order('uid DESC')->lists();
$this->assign('list', $list);
$address = $this->db->table('shop_city')->where(array('status'=>1))->cates('id');
$this->assign('address', $address);
return $this->fetch();
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<style type="text/css">
.header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
.header div{border-bottom: solid 2px #009688;margin-top: 8px;}
.header button{float: right;margin-top: -5px;}
</style>
</head>
<body style="padding: 10px;">
<div class="header">
<span>用户列表</span>
<div></div>
</div>
<table class="layui-table">
<thead>
<tr>
<th>ID</th>
<th>昵称</th>
<th>电话</th>
<th>性别</th>
<th>省市区</th>
<th>状态</th>
</tr>
</thead>
<tbody>
<!-- 循环出所有用户 -->
{volist name="list" id="vo"}
<tr>
<td>{$vo.uid}</td>
<td>{$vo.nickname}</td>
<td>{$vo.phone}</td>
<td>
{if condition="$vo.sex == 1"}<span style="color: green;">男</span>
{elseif condition="$vo.sex == 2" /}<span style="color: red;">女</span>
{else/}未知
{/if}
</td>
<td>{$address[$vo.province]['name']}{$address[$vo.city]['name']}{$address[$vo.area]['name']}</td>
<td>{if condition="$vo.status == 1"}<span style="color: green;">开启</span>{else/}<span style="color: red;">关闭</span>{/if}</td>
</tr>
{/volist}
</tbody>
</table>
</body>
</html>
四、订单管理
查询出所有总订单列表展示出来,可以查看子订单,可以发货。这里主要是数据库的数据需要转化成相应的文字,产看子订单就是根据order_id在子订单表理查询出来,发货是弹出新页面,选择快递、单号,然后发送给保存方法,同时还有order_id,发货时间、发货状态,然后修改数据库数据
//订单列表
public function order() {
//按照添加时间降序查询出所有订单信息
$list = $this->db->table('shop_order')->order('add_time DESC')->lists();
$this->assign('list', $list);
return $this->fetch();
}
//子订单页面
public function order_two() {
$id = (int)input('get.id');
$list = $this->db->table('shop_order_son')->where(array('order_id'=>$id))->lists();
$this->assign('list', $list);
$user = $this->db->table('shop_order')->where(array('order_id'=>$id))->item();
$uid = $user['uid'];
$people = $this->db->table('shop_user')->where(array('uid'=>$uid))->item();
$nickname = $people['nickname'];
$this->assign('nickname', $nickname);
return $this->fetch();
}
//发货
public function send_goods() {
$order_id = (int)input('get.id');
$this->assign('order_id', $order_id);
return $this->fetch();
}
//发货保存
public function order_save() {
$id = (int)input('post.id');
$data['express'] = trim(input('post.express'));
$data['express_id'] = trim(input('post.express_id'));
$data['deliver_time'] = time();
$data['status'] = 3;
//修改
$add = $this->db->table('shop_order')->where(array('order_id'=>$id))->update($data);
if($add > 0){
exit(json_encode(array('code'=>0,'msg'=>'发货成功')));
}else{
exit(json_encode(array('code'=>1,'msg'=>'发货失败')));
}
}
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<style type="text/css">
.header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
.header div{border-bottom: solid 2px #009688;margin-top: 8px;}
.header button{float: right;margin-top: -5px;}
</style>
</head>
<body style="padding: 10px;">
<div class="header">
<span>订单列表</span>
<div></div>
</div>
<table class="layui-table">
<thead>
<tr>
<th>ID</th>
<th>第三方ID</th>
<th>支付方式</th>
<th>总价</th>
<th>支付价格</th>
<th>用户id</th>
<th>地址</th>
<th>手机</th>
<th>快递</th>
<th>时间</th>
<th>状态</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!-- 循环出所有用户 -->
{volist name="list" id="vo"}
<tr>
<td>{$vo.order_id}</td>
<td>{$vo.orders_id}</td>
<td>
{if condition="$vo.pay_mode == 1"}支付宝{/if}
{if condition="$vo.pay_mode == 2"}微信{/if}
{if condition="$vo.pay_mode == 3"}PayPal{/if}
{if condition="$vo.pay_mode == 4"}线下支付{/if}
</td>
<td>{$vo.price}</td>
<td>{$vo.pay_price}</td>
<td>{$vo.uid}</td>
<td>{$vo.address}</td>
<td>{$vo.phone}</td>
<td>
{if condition="$vo.express == 1"}顺丰:{$vo.express_id}{/if}
{if condition="$vo.express == 2"}韵达:{$vo.express_id}{/if}
{if condition="$vo.express == 3"}中通:{$vo.express_id}{/if}
</td>
<td>
支付时间:{$vo.pay_time|date="Y-m-d H:i:s"}<br/>
发货时间:{$vo.deliver_time|date="Y-m-d H:i:s"}<br/>
收货时间:{$vo.receiv_time|date="Y-m-d H:i:s"}<br/>
</td>
<td>
{if condition="$vo.status == 1"}<span style="color: red;">未支付</span>{/if}
{if condition="$vo.status == 2"}<span style="color: red;">已支付 未发货</span>{/if}
{if condition="$vo.status == 3"}<span style="color: red;">已发货 未收货</span>{/if}
{if condition="$vo.status == 4"}<span style="color: red;">已收货 未评论</span>{/if}
{if condition="$vo.status == 5"}<span style="color: red;">已退货</span>{/if}
{if condition="$vo.status == 10"}<span style="color: red;">已关闭</span>{/if}
</td>
<td>
<button class="layui-btn layui-btn-xs" onclick="add({$vo.order_id})">子订单</button>
<button class="layui-btn layui-btn-danger layui-btn-xs" onclick="del({$vo.order_id})">发货</button>
</td>
{/volist}
</tbody>
</table>
<script type="text/javascript">
layui.use(['layer'],function(){
layer = layui.layer;
$ = layui.jquery;
});
//跳转到子订单
function add(id) {
window.location.href = '/index.php/admins/User/order_two?id='+id;
}
//弹出发货页面
function del(id) {
layer.open({
type: 2,
title: '发货',
shade: 0.3,
area: ['1080px', '600px'],
content: '/index.php/admins/User/send_goods?id=' + id
});
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
<style type="text/css">
.header span{background: #009688;margin-left: 30px;padding: 10px;color:#ffffff;}
.header div{border-bottom: solid 2px #009688;margin-top: 8px;}
.header button{float: right;margin-top: -5px;}
</style>
</head>
<body style="padding: 10px;">
<div class="header">
<span style="background-color:#999;"><a href="/index.php/admins/User/order" style="color:#fff;">总订单</a></span>
<span>{$nickname}的子订单</span>
<div></div>
</div>
<table class="layui-table">
<thead>
<tr>
<th>ID</th>
<th>总订单ID</th>
<th>商品ID</th>
<th>价格</th>
<th>数量</th>
</tr>
</thead>
<tbody>
<!-- 循环出所有用户 -->
{volist name="list" id="vo"}
<tr>
<td>{$vo.id}</td>
<td>{$vo.order_id}</td>
<td>{$vo.goods_id}</td>
<td>{$vo.price}</td>
<td>{$vo.number}</td>
{/volist}
</tbody>
</table>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
<script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
</head>
<body style="padding: 10px;">
<form class="layui-form">
<input type="hidden" name="id" value="{$order_id}">
<div class="layui-form-item">
<label class="layui-form-label">快递</label>
<div class="layui-input-inline">
<select name="express">
<option value="1">顺丰</option>
<option value="2">韵达</option>
<option value="3">中通</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">快递单号</label>
<div class="layui-input-inline">
<input type="text" class="layui-input" name="express_id">
</div>
</div>
</form>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" onclick="save()">保存</button>
</div>
</div>
<script type="text/javascript">
layui.use(['layer','form'],function(){
form = layui.form;
layer = layui.layer;
$ = layui.jquery;
});
// 保存管理员
function save(){
var express_id = $.trim($('input[name="express_id"]').val());
if(express_id==''){
layer.alert('请输入快递单号',{icon:2});
return;
}
// 请求保存接口,把数据传值到接口中。
$.post('/index.php/admins/User/order_save',$('form').serialize(),function(res){
if(res.code>0){
layer.alert(res.msg,{icon:2});
}else{
layer.msg(res.msg);
setTimeout(function(){parent.window.location.reload();},1000);
}
},'json');
}
</script>
</body>
</html>