special_live.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. {extend name="public/container"}
  2. {block name='head_top'}
  3. <style>
  4. .go-live{width: 100%;background-color: #eeeeee;display: none;}
  5. .go-live .live-box{padding: 10px 0 10px 30px;background-color: #ffffff;border-radius: 5px;margin-top: 30px;}
  6. .go-live .live-box .live-text{font-size: 15px;color: #0092DC;margin: 5px;padding: 10px 0;}
  7. .go-live .live-box .live-title{text-align: center;}
  8. .go-live .live-box .live-text p{color:#333333;padding:10px;display: inline-block;width: 80%;background-color: #eeeeee;border-radius: 10px;}
  9. .go-live .live-box .live-text label{width: 8%;}
  10. .layui-table-cell img{max-width: 100%;height: 50px;cursor: pointer;}
  11. </style>
  12. {/block}
  13. {block name="content"}
  14. <div class="layui-fluid">
  15. <div class="layui-row layui-col-space15">
  16. <div class="layui-col-md12">
  17. <div class="layui-card">
  18. <div class="layui-card-body">
  19. <div class="layui-row layui-col-space15" id="app">
  20. <div class="layui-col-md12">
  21. <div class="layui-tab layui-tab-brief" lay-filter="tab">
  22. <ul class="layui-tab-title">
  23. <li lay-id="list" {eq name='type' value='1'}class="layui-this" {/eq} >
  24. <a href="{eq name='type' value='1'}javascript:;{else}{:Url('special_live',['special_type'=>4,'type'=>1])}{/eq}">直播列表</a>
  25. </li>
  26. <li lay-id="list" {eq name='type' value='2'}class="layui-this" {/eq}>
  27. <a href="{eq name='type' value='2'}javascript:;{else}{:Url('index',['special_type'=>4,'type'=>2])}{/eq}">直播间管理</a>
  28. </li>
  29. </ul>
  30. </div>
  31. </div>
  32. <div class="layui-col-md12">
  33. <form class="layui-form layui-form-pane" action="">
  34. <div class="layui-form-item">
  35. <div class="layui-inline">
  36. <label class="layui-form-label">直播搜索</label>
  37. <div class="layui-input-inline">
  38. <input type="text" name="store_name" class="layui-input" placeholder="直播标题、简介、编号">
  39. </div>
  40. </div>
  41. <div class="layui-inline">
  42. <label class="layui-form-label">专题分类</label>
  43. <div class="layui-input-inline">
  44. <select name="subject_id" lay-search="">
  45. <option value="0">全部</option>
  46. {volist name='subject_list' id='vc'}
  47. <option {if $vc.grade_id==0}disabled{/if} value="{$vc.id}">{$vc.html}{$vc.name}</option>
  48. {/volist}
  49. </select>
  50. </div>
  51. </div>
  52. <div class="layui-inline">
  53. <label class="layui-form-label">状态</label>
  54. <div class="layui-input-inline">
  55. <select name="is_show">
  56. <option value="">全部</option>
  57. <option value="1">上架</option>
  58. <option value="0">下架</option>
  59. </select>
  60. </div>
  61. </div>
  62. <div class="layui-inline">
  63. <label class="layui-form-label">审核状态</label>
  64. <div class="layui-input-inline">
  65. <select name="status">
  66. <option value="">全部</option>
  67. <option value="1">通过</option>
  68. <option value="0">未审核</option>
  69. <option value="-1">未通过</option>
  70. </select>
  71. </div>
  72. </div>
  73. <div class="layui-inline">
  74. <label class="layui-form-label">时间范围</label>
  75. <div class="layui-input-inline" style="width: 260px;">
  76. <input type="text" name="datetime" class="layui-input" id="datetime" placeholder="时间范围">
  77. </div>
  78. </div>
  79. <div class="layui-inline">
  80. <div class="layui-input-inline">
  81. <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" lay-submit="search" lay-filter="search">
  82. <i class="layui-icon">&#xe615;</i>搜索
  83. </button>
  84. </div>
  85. </div>
  86. </div>
  87. </form>
  88. </div>
  89. <!--产品列表-->
  90. <div class="layui-col-md12">
  91. <div class="layui-btn-group">
  92. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="action.open_add('{:Url('special.special_type/add',['special_type' =>$special_type])}','添加{$special_title}')">
  93. <i class="layui-icon">&#xe608;</i>添加{$special_title}
  94. </button>
  95. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" onclick="window.location.reload()">
  96. <i class="layui-icon">&#xe669;</i>刷新
  97. </button>
  98. </div>
  99. <table class="layui-hide" id="List" lay-filter="List"></table>
  100. <script type="text/html" id="is_pink">
  101. {{# if(d.is_pink){ }}
  102. <span class="layui-badge layui-bg-blue">开启</span>
  103. {{# }else{ }}
  104. <span class="layui-badge">关闭</span>
  105. {{# } }}
  106. </script>
  107. <script type="text/html" id="status">
  108. {{# if(d.status==1){ }}
  109. <span class="layui-badge layui-bg-blue">通过</span>
  110. {{# }else if(d.status==0){ }}
  111. <span class="layui-badge layui-bg-blue">未审核</span>
  112. {{# }else{ }}
  113. <span class="layui-badge">未通过</span>
  114. <span class="layui-badge layui-bg-blue" lay-event='fail'>查看原因</span>
  115. {{# } }}
  116. </script>
  117. <script type="text/html" id="is_show">
  118. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_show' lay-text='上架|下架' {{ d.is_show == 1 ? 'checked' : '' }}>
  119. </script>
  120. <script type="text/html" id="is_mer_visible">
  121. <input type='checkbox' name='id' lay-skin='switch' value="{{d.id}}" lay-filter='is_mer_visible' lay-text='是|否' {{ d.is_mer_visible == 1 ? 'checked' : '' }}>
  122. </script>
  123. <script type="text/html" id="image">
  124. <img lay-event='open_image' src="{{d.image}}">
  125. </script>
  126. <script type="text/html" id="act">
  127. <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" onclick="dropdown(this)">
  128. <i class="layui-icon">&#xe625;</i>操作
  129. </button>
  130. <ul class="layui-nav-child layui-anim layui-anim-upbit">
  131. <li>
  132. <a href="javascript:void(0)" onclick="action.open_add('{:Url('special.special_type/add')}?id={{d.id}}&special_type={$special_type}','编辑直播')" >
  133. <i class="iconfont icon-bianji"></i> 编辑直播
  134. </a>
  135. </li>
  136. <li>
  137. <a href="javascript:void(0)" lay-event='go_live'>
  138. <i class="iconfont icon-quzhibo"></i> 去直播
  139. </a>
  140. </li>
  141. <li>
  142. <a href="javascript:void(0)" onclick="$eb.createModalFrame('{{d.title}}-拼团管理','{:Url('special.special_type/pink')}?special_id={{d.id}}',{h:500})">
  143. <i class="iconfont icon-pintuanshezhi"></i> 拼团设置
  144. </a>
  145. </li>
  146. <li>
  147. <a href="{:Url('ump.store_combination/combina_list')}?cid={{d.id}}&special_type={$special_type}" >
  148. <i class="iconfont icon-chakanpintuan"></i> 查看拼团
  149. </a>
  150. </li>
  151. <li>
  152. <a href="javascript:void(0)" onclick="$eb.createModalFrame('{{d.title}}-直播回放','{:Url('download_list')}?special_id={{d.id}}',{w:1200})">
  153. <i class="iconfont icon-huifang"></i> 直播回放
  154. </a>
  155. </li>
  156. <li>
  157. <a lay-event='delect' href="javascript:void(0)">
  158. <i class="iconfont icon-shanchu"></i> 删除直播
  159. </a>
  160. </li>
  161. </ul>
  162. </script>
  163. </div>
  164. </div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. <div class="go-live">
  171. <div class="live-box">
  172. <div class="live-title">
  173. <h2>直播推流地址</h2>
  174. </div>
  175. <div class="live-text">
  176. <label>服务器</label>
  177. <p id="live-href"></p>
  178. <button type="button" class="layui-btn layui-btn-normal copy" data-id="live-href">复制</button>
  179. </div>
  180. <div class="live-text">
  181. <label>串流密钥</label>
  182. <p id="live-code"></p>
  183. <button type="button" class="layui-btn layui-btn-normal copy" data-id="live-code">复制</button>
  184. </div>
  185. </div>
  186. </div>
  187. <script src="{__ADMIN_PATH}js/layuiList.js"></script>
  188. {/block}
  189. {block name="script"}
  190. <script>
  191. var $ = layui.jquery;
  192. var layer = layui.layer;
  193. //实例化form
  194. layList.form.render();
  195. layList.date({elem: '#datetime', type: 'datetime', range: '~'});
  196. //加载列表
  197. layList.tableList({o:'List', done:function () {}},"{:Url('special_list',['special_type'=>$special_type])}",function (){
  198. return [
  199. {field: 'id', title: '编号', width:'6%',align: 'center'},
  200. {field: 'title', title: '直播标题',align: 'left'},
  201. {field: 'subject_name', title: '分类',align: 'center',width:'8%'},
  202. {field: 'image', title: '封面',templet:'#image',align: 'center',width:'7%'},
  203. {field: 'stream_name', title: '直播间ID',align: 'center',width:'6%'},
  204. {field: 'money', title: '价格',align: 'center',width:'6%'},
  205. {field: 'member_money', title: '会员价',align: 'center',width:'6%'},
  206. {field: 'pink_money', title: '拼团价',align: 'center',width:'6%'},
  207. {field: 'is_pink', title: '拼团状态',templet:'#is_pink',align: 'center',width:'6%'},
  208. {field: 'sort', title: '排序',sort: true,event:'sort',edit:'sort',align: 'center',width:'5%'},
  209. {field: 'status', title: '审核',templet:'#status',align: 'center',width:'7%'},
  210. {field: 'is_show', title: '状态',templet:'#is_show',align: 'center',width:'7%'},
  211. {field: 'is_mer_visible', title: '仅会员可见',templet:'#is_mer_visible',align: 'center',width:'7%'},
  212. {field: 'right', title: '操作',align:'center',toolbar:'#act',width:'7%'},
  213. ];
  214. });
  215. //下拉框
  216. $(document).click(function (e) {
  217. $('.layui-nav-child').hide();
  218. })
  219. function dropdown(that){
  220. var oEvent = arguments.callee.caller.arguments[0] || event;
  221. oEvent.stopPropagation();
  222. var offset = $(that).offset();
  223. var top=offset.top-$(window).scrollTop();
  224. var index = $(that).parents('tr').data('index');
  225. $('.layui-nav-child').each(function (key) {
  226. if (key != index) {
  227. $(this).hide();
  228. }
  229. })
  230. if($(document).height() < top+$(that).next('ul').height()){
  231. $(that).next('ul').css({
  232. 'padding': 10,
  233. 'top': - ($(that).parent('td').height() / 2 + $(that).height() + $(that).next('ul').height()/2),
  234. 'min-width': 'inherit',
  235. 'position': 'absolute'
  236. }).toggle();
  237. }else{
  238. $(that).next('ul').css({
  239. 'padding': 10,
  240. 'top':$(that).parent('td').height() / 2 + $(that).height(),
  241. 'min-width': 'inherit',
  242. 'position': 'absolute'
  243. }).toggle();
  244. }
  245. }
  246. //自定义方法
  247. var action= {
  248. set_value: function (field, id, value, model_type) {
  249. layList.baseGet(layList.Url({
  250. c: 'special.special_type' ,
  251. a: 'set_value',
  252. q: {field: field, id: id, value: value, model_type:model_type}
  253. }), function (res) {
  254. layList.msg(res.msg);
  255. });
  256. },
  257. //打开新添加页面
  258. open_add: function (url,title) {
  259. layer.open({
  260. type: 2 //Page层类型
  261. ,area: ['100%', '100%']
  262. ,title: title
  263. ,shade: 0.6 //遮罩透明度
  264. ,maxmin: true //允许全屏最小化
  265. ,anim: 1 //0-6的动画形式,-1不开启
  266. ,content: url
  267. ,end:function() {
  268. location.reload();
  269. }
  270. });
  271. },
  272. //直播间转移
  273. move_live_admin: function(data){
  274. layer.open({
  275. type: 1
  276. ,scrollbar: true
  277. ,area: ['500px', '70%']
  278. ,content: $('.move_live_admin')
  279. ,btn: '转让'
  280. ,btnAlign: 'c' //按钮居中
  281. ,shade: 0 //不显示遮罩
  282. ,yes: function(){
  283. var admin_id = $("#admin_id").val();
  284. if (!admin_id) {
  285. layer.msg("请选择转让账号", {
  286. icon: 2,
  287. time: 2000
  288. });
  289. return false;
  290. }
  291. layList.baseGet(layList.U({a:'move_live_admin',q:{special_id:data.id, admin_id:admin_id}}),function(res){
  292. if (res.code == 200) {
  293. layer.closeAll();
  294. layer.msg("转让成功", {
  295. icon: 1,
  296. time: 2000
  297. });
  298. }else{
  299. layer.closeAll();
  300. layer.msg("转让失败", {
  301. icon: 2,
  302. time: 2000
  303. });
  304. }
  305. }, function (res) {
  306. layer.msg(res.msg, {
  307. icon: 2,
  308. time: 2000
  309. });
  310. })
  311. }
  312. ,cancel:function () {
  313. $('.live_remind').hide();
  314. }
  315. });
  316. }
  317. }
  318. $('.copy').each(function () {
  319. $(this).on('click',function () {
  320. copy($(this).data('id'),function () {
  321. layList.msg('复制成功');
  322. });
  323. });
  324. })
  325. function copy (id, attr,errorFn)
  326. {
  327. var target = null,successFn=null;
  328. if(typeof attr=='function'){
  329. successFn=attr;
  330. attr='';
  331. }
  332. if (attr && typeof attr=='string') {
  333. target = document.createElement('div');
  334. target.id = 'tempTarget';
  335. target.style.opacity = '0';
  336. if (id) {
  337. var curNode = document.querySelector('#' + id);
  338. target.innerText = curNode[attr];
  339. } else {
  340. target.innerText = attr;
  341. }
  342. document.body.appendChild(target);
  343. } else {
  344. target = document.querySelector('#' + id);
  345. }
  346. try {
  347. var range = document.createRange();
  348. range.selectNode(target);
  349. window.getSelection().removeAllRanges();
  350. window.getSelection().addRange(range);
  351. document.execCommand('copy');
  352. window.getSelection().removeAllRanges();
  353. successFn && successFn();
  354. } catch (e) {
  355. errorFn && errorFn();
  356. }
  357. if (attr) {
  358. target.parentElement.removeChild(target);
  359. }
  360. }
  361. //查询
  362. layList.search('search',function(where){
  363. var arr_time = [];
  364. var start_time = '';
  365. var end_time = '';
  366. if (where.datetime) {
  367. arr_time = where.datetime.split('~');
  368. start_time = arr_time[0].trim();
  369. end_time = arr_time[1].trim();
  370. }
  371. layList.reload({
  372. subject_id: where.subject_id,
  373. is_show: where.is_show,
  374. status: where.status,
  375. start_time: start_time,
  376. end_time: end_time,
  377. store_name: where.store_name
  378. },true);
  379. });
  380. layList.switch('is_show',function (odj,value) {
  381. var is_show_value = 0
  382. if(odj.elem.checked==true){
  383. var is_show_value = 1
  384. }
  385. action.set_value('is_show',value,is_show_value,'special');
  386. });
  387. layList.switch('is_mer_visible',function (odj,value) {
  388. var is_show_value = 0
  389. if(odj.elem.checked==true){
  390. var is_show_value = 1
  391. }
  392. action.set_value('is_mer_visible',value,is_show_value,'special');
  393. });
  394. //快速编辑
  395. layList.edit(function (obj) {
  396. var id=obj.data.id,value=obj.value;
  397. switch (obj.field) {
  398. case 'title':
  399. action.set_value('title',id,value,'special');
  400. break;
  401. case 'sort':
  402. if (value.trim()) {
  403. if (isNaN(value.trim())) {
  404. layList.msg('请输入正确的数字');
  405. } else {
  406. if (value.trim() < 0) {
  407. layList.msg('排序不能小于0');
  408. } else if (value.trim() > 9999) {
  409. layList.msg('排序不能大于9999');
  410. } else if (parseInt(value.trim()) != value.trim()) {
  411. layList.msg('排序不能为小数');
  412. } else {
  413. action.set_value('sort', id, value.trim(), 'special');
  414. }
  415. }
  416. } else {
  417. layList.msg('排序不能为空');
  418. }
  419. break;
  420. case 'fake_sales':
  421. if(value < 0) return layList.msg('虚拟不能小于0');
  422. action.set_value('fake_sales',id,value,'special');
  423. break;
  424. case 'online_num':
  425. layList.baseGet(layList.Url({
  426. c: 'live.aliyun_live' ,
  427. a: 'set_value',
  428. q: {stream_name: obj.data.stream_name,field:'online_num',value: value}
  429. }), function (res) {
  430. layList.msg(res.msg);
  431. });
  432. break;
  433. }
  434. });
  435. //监听并执行排序
  436. layList.sort(['id','sort'],true);
  437. //点击事件绑定
  438. layList.tool(function (event,data,obj) {
  439. switch (event) {
  440. case 'delect':
  441. var url=layList.U({a:'delete',q:{id:data.id}});
  442. $eb.$swal('delete',function(){
  443. $eb.axios.get(url).then(function(res){
  444. if(res.status == 200 && res.data.code == 200) {
  445. $eb.$swal('success','删除成功!');
  446. obj.del();
  447. }else
  448. return Promise.reject(res.data.msg || '删除失败')
  449. }).catch(function(err){
  450. $eb.$swal('error',err);
  451. });
  452. });
  453. break;
  454. case 'recommend':
  455. var url=layList.U({a:'recommend',q:{id:data.id}});
  456. $eb.$swal('delete',function(){
  457. $eb.axios.get(url).then(function(res){
  458. if(res.status == 200 && res.data.code == 200) {
  459. $eb.$swal('success',res.data.msg);
  460. obj.update({is_publish:1});
  461. }else
  462. return Promise.reject(res.data.msg || '删除失败')
  463. }).catch(function(err){
  464. $eb.$swal('error',err);
  465. });
  466. },{title:"确认要把该直播专题推荐到首页弹窗吗?",text:'确认后无法修改',confirm:'确认'});
  467. break;
  468. case 'open_image':
  469. $eb.openImage(data.image);
  470. break;
  471. case 'go_live':
  472. layList.baseGet(layList.U({a:'is_audit',q:{id:data.id}}),function(res){
  473. if(res.data.status==1){
  474. layList.baseGet(layList.U({a:'go_live',q:{id:data.id}}),function(res){
  475. $('#live-href').text(res.data.href);
  476. $('#live-code').text(res.data.code);
  477. layList.layer.open({
  478. type: 1,
  479. area: ['800px', 'auto'], //宽高
  480. content:$('.go-live'),
  481. title:false,
  482. cancel:function () {
  483. $('.go-live').hide();
  484. }
  485. });
  486. },function (res) {
  487. layList.msg(res.msg);
  488. });
  489. }else if(res.data.status==0){
  490. layList.msg('请等待总平台审核');
  491. }else if(res.data.status==-1){
  492. layList.msg('审核未通过');
  493. }else{
  494. $eb.createModalFrame(data.title+'--直播审核',layList.U({a:'audit',q:{id:data.id}}),{w:800,h:600});
  495. }
  496. });
  497. break;
  498. case 'move_live_admin':
  499. action.move_live_admin(data);
  500. break;
  501. case 'fail':
  502. layer.open({
  503. type: 1,
  504. skin: 'layui-layer-rim', //加上边框
  505. area: ['420px', '240px'], //宽高
  506. title: '审核未通过原因',
  507. content: data.fail_message
  508. });
  509. break;
  510. }
  511. })
  512. </script>
  513. {/block}