video.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,layer = layui.layer //弹层
  5. ,table = layui.table //表格
  6. ,element = layui.element //元素操作
  7. ,form = layui.form
  8. ,upload = layui.upload;
  9. var tableIds = 'videolist'; //表格ID
  10. var type_id = $('input[name="type"]').val();
  11. //第一个实例
  12. table.render({
  13. elem: '#'+tableIds
  14. ,url: '/push/choiceform' //数据接口
  15. ,where:{token:csrfToken}
  16. ,method:'post'
  17. ,page: true //开启分页
  18. ,text:'数据加载中'
  19. ,id:'tablerReload'
  20. ,cols: [[ //表头
  21. {type:'numbers',title:'序号',width:50},
  22. {field: 'title', title: '精选标题', align:'center'},
  23. {field: 'name', title: '归属楼盘', align:'center'},
  24. {field: 'img', title: '封面图',width:200, align:'center',templet:function(d){
  25. return '<img class="layui_magnify" src="'+d.img+'"/>'
  26. }}
  27. , {field: 'url', title: '地址',width:200, align:'center',templet:function(d){
  28. return '<a href="'+d.url+'" target="_blank">'+d.url+'</a>';
  29. }}
  30. ,{field: 'create_at', title: '添加时间',width:150, align:'center'}
  31. ,{field: 'is_show', title: '审核',align:'center',width:100, templet:function (d) {
  32. if(d.is_show == 2){
  33. return '<input type="checkbox" value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  34. } else {
  35. return '<input type="checkbox" checked value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  36. }
  37. }}
  38. ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
  39. ]]
  40. });
  41. // 列表点击放大图片
  42. $('.layui-table-main').on('click','.layui_magnify', function(){
  43. var _src = $(this).attr('src');
  44. layui.layer.open({
  45. type: 1,
  46. title: false, //是否显示标题
  47. area: ['95%', '55%'],
  48. shade: 0.6, //透明度
  49. closeBtn: 1, //按钮 1有,0无
  50. shadeClose: true,
  51. content: '<img style="width:100%;height:100%" src="'+_src+'">',
  52. });
  53. });
  54. //监听指定开关
  55. form.on('switch(switchTest)', function(data){
  56. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  57. $.post('/push/choicedelshow',{id:data.value,type:'show'},function (data) {
  58. layer.msg(data.msg);
  59. table.reload('tablerReload');
  60. })
  61. },function (aa) {
  62. table.reload('tablerReload'); //重新加载
  63. })
  64. });
  65. //列表操作
  66. table.on('tool('+tableIds+')', function(obj){
  67. var layEvent = obj.event,
  68. data = obj.data;
  69. if(layEvent === 'edit'){
  70. var index = layer.open({
  71. type: 2,
  72. title: '修改本周精选',
  73. area:['800px','500px'],
  74. content: '/push/choiceedit?id='+data.id+'&house_name='+data.name,
  75. end:function () {
  76. table.reload('tablerReload'); //重新加载
  77. }
  78. });
  79. } else if(layEvent === 'del') {
  80. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  81. $.post('/push/choicedelshow',{id:data.id,type:'del'},function (data) {
  82. layer.msg(data.msg);
  83. table.reload('tablerReload');
  84. })
  85. })
  86. }
  87. });
  88. //添加图片上传
  89. upload.render({
  90. elem: '#test1'
  91. ,url: '/house/createimg'
  92. ,data:{token:csrfToken}
  93. ,field:'img'
  94. ,size:1000 //限制上传图片的大小,单位为KB
  95. ,exts: 'png|jpg|jpeg' //只允许上传压缩文件
  96. ,auto:false
  97. ,bindAction:'#addcity'
  98. ,choose: function(obj){
  99. obj.preview(function(index, file, result){
  100. $('#breviary_img').attr('src', result); //图片链接(base64)
  101. });
  102. }
  103. });
  104. // 图片放大浏览
  105. $('.layui_magnify').click(function(){
  106. var _src = $(this).attr('src');
  107. layui.layer.open({
  108. type: 1,
  109. title: false, //是否显示标题
  110. area: ['60%', '80%'],
  111. shade: 0.6, //透明度
  112. closeBtn: 1, //按钮 1有,0无
  113. shadeClose: true,
  114. content: '<img style="width:100%;height:100%" src="'+_src+'">',
  115. });
  116. })
  117. // 新增
  118. var $ = layui.$, active = {
  119. addData: function(){ //获取选中数据
  120. var index = layui.layer.open({
  121. type: 2,
  122. title: '添加推荐视频',
  123. closeBtn: 1, //不显示关闭按钮
  124. area: ['800px','500px'],
  125. content: '/pushone/videoadd' //iframe的url,no代表不显示滚动条
  126. ,success:function (layero, index) {
  127. },
  128. end:function () {
  129. table.reload('tablerReload');
  130. }
  131. });
  132. },
  133. reload:function(){//搜索
  134. var form = pfgs_serialize($('form'));
  135. var name = '';
  136. var house_name = '';
  137. if(form.input_house == 'name'){
  138. name = form.input_house_text;
  139. } else if(form.input_house == 'house_name'){
  140. house_name = form.input_house_text;
  141. }
  142. table.reload('tablerReload',{
  143. where:{
  144. title:name,
  145. house_name:house_name,
  146. city:form.input_city,
  147. type_name:form.type_name
  148. }
  149. })
  150. },
  151. };
  152. $('.demoTable .layui-btn').on('click', function(){
  153. var type = $(this).data('type');
  154. active[type] ? active[type].call(this) : '';
  155. });
  156. $('.The_house').focus(function(){
  157. // $('form').append('<input type="hidden" name="aa" value="aaa">');
  158. indexOpen = parent.layui.layer.open({
  159. type: 2,
  160. title: '选择需要添加的推荐视频',
  161. area: ['','100%'],
  162. content: '/publicuse/video?type=1',
  163. success:function (layero, index) {
  164. },
  165. end:function(){
  166. }
  167. });
  168. parent.layui.layer.full(indexOpen);
  169. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  170. $(window).on("resize",function(){
  171. parent.layui.layer.full(indexOpen);
  172. })
  173. })
  174. //添加页面提交数据
  175. form.on('submit(add_choice)', function(data){
  176. var formData = new FormData($('form')[0]);
  177. if(formData.getAll('img')[0].size == 0){
  178. layer.msg('请选择图片');
  179. return false;
  180. }
  181. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  182. $.ajax({
  183. cache : false,
  184. type : "post",
  185. url : "/push/choiceaddform",
  186. data : formData, // 你的formid
  187. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  188. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  189. error : function(request) {
  190. layer.close(index);
  191. layer.msg("请联系管理员");
  192. },
  193. success : function(data) {
  194. if(data.data != null){
  195. layer.msg(ReturnInfo(data.data),{icon:5});
  196. return ;
  197. }
  198. layer.msg(data.msg);
  199. }
  200. });
  201. return false;
  202. });
  203. form.on('submit(edit_choice)', function(data){
  204. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  205. var formData = new FormData($('form')[0]);
  206. $.ajax({
  207. type : "post",
  208. url : "/push/choiceeditform",
  209. data : formData,
  210. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  211. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  212. error : function(request) {
  213. layer.close(index);
  214. layer.msg("请联系管理员");
  215. },
  216. success : function(data) {
  217. if(data.data != null){
  218. layer.msg(ReturnInfo(data.data),{icon:5});
  219. return ;
  220. }
  221. layer.msg(data.msg);
  222. parent.layer.close(oindex); //再执行关闭
  223. }
  224. });
  225. return false;
  226. });
  227. })