一般来说,在开发直播带货系统时必定少不了的就是礼物系统的开发,毕竟刷礼物可以说是直播过程中一道“亮丽的风景线”,当然这也是大多数主播实现变现收益的主要方式。今天就来分享下如何实现直播带货系统中礼物后台部分的开发。
新建礼物数据表 字段根据自己需求设计。在后台实现增删改查功能 如下是礼物列表实现方法
/**
礼物
*/
var $type=array(“0”=>”普通礼物”,”1”=>”豪华礼物”);
var $mark=array(“0”=>”普通”,”1”=>”热门”,”2”=>”守护”,”3”=>”vip”);
function index(){}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
设计后端增删改查模板页 如下是礼物列表后台页面模板/* $gift_sort=M("gift_sort")->getField("id,sortname");
$gift_sort[0]="默认分类";
$this->assign('gift_sort', $gift_sort); */
$gift_model=M("gift");
$count=$gift_model->count();
$page = $this->page($count, 20);
$lists = $gift_model
//->where()
->order("orderno, addtime desc")
->limit($page->firstRow . ',' . $page->listRows)
->select();
$this->assign('lists', $lists);
$this->assign('type', $this->type);
$this->assign('mark', $this->mark);
$this->assign("page", $page->show('Admin'));
$this->display();
<admintpl file="header" />
</head>
<body>
<div class="wrap">
<ul class="nav nav-tabs">
<li class="active"><a >礼物列表</a></li>
<li><a href="{:U('Gift/add')}">礼物添加</a></li>
</ul>
<form method="post" class="js-ajax-form" action="{:U('Gift/listorders')}">
<div class="table-actions">
<button class="btn btn-primary btn-small js-ajax-submit" type="submit">{:L(‘SORT’)}</button>
</div>
<table class="table table-hover table-bordered"> <thead> <tr> <th>排序</th> <th align="center">ID</th> <th>类型</th> <!-- <th>分类</th> --> <th>标识</th> <th>名称</th> <th>所需点数</th> <!-- <th>礼物小图 (25 X 25)</th> --> <th>图片</th> <th>动画</th> <th>动画时长</th> <th>发布时间</th> <th align="center">{:L('ACTIONS')}</th> </tr> </thead> <tbody> <foreach name="lists" item="vo"> <tr> <td><input name="listorders[{$vo['id']}]" type="text" size="3" value="{$vo['orderno']}" class="input input-order"></td> <td align="center">{$vo.id}</td> <td>{$type[$vo['type']]}</td> <!-- <td>{$gift_sort[$vo['sid']]}</td> --> <td>{$mark[$vo['mark']]}</td> <td>{$vo['giftname']}</td> <td>{$vo['needcoin']}</td> <!-- <td><img width="25" height="25" src="{$vo['gifticon_mini']}" /></td> --> <td><img width="25" height="25" src="{$vo['gifticon']}" /></td> <td><if condition="$vo['swf']"><img width="100" height="100" src="{$vo['swf']}" /></if></td> <td>{$vo['swftime']}</td> <td>{$vo.addtime|date="Y-m-d H:i:s",###}</td> <td align="center"> <a href="{:U('Gift/edit',array('id'=>$vo['id']))}" >编辑</a> | <a href="{:U('Gift/del',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn" data-msg="您确定要删除吗?">删除</a> </td> </tr> </foreach> </tbody> </table> <div class="pagination">{$page}</div> <div class="table-actions"> <button class="btn btn-primary btn-small js-ajax-submit" type="submit">{:L('SORT')}</button> </div> </form></div><script src="__PUBLIC__/js/common.js"></script>
</body>
</html>