video.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. var indexOpen;
  2. layui.use([ 'laypage', 'layer', 'table', 'element','form','upload'], function(){
  3. var laypage = layui.laypage //分页
  4. ,$ = layui.jquery
  5. ,layer = layui.layer //弹层
  6. ,table = layui.table //表格
  7. ,element = layui.element //元素操作
  8. ,form = layui.form
  9. ,upload = layui.upload;
  10. var tableIds = 'videolist'; //表格ID
  11. //第一个实例
  12. table.render({
  13. elem: '#'+tableIds
  14. ,url: '/routinevideo/homeform' //数据接口
  15. ,where:{token:csrfToken}
  16. ,method:'post'
  17. ,page: true //开启分页
  18. ,text:'数据加载中'
  19. ,limit:20
  20. ,id:'tablerReload'
  21. ,cols: [[ //表头
  22. // {field: 'id', title: 'ID', width:80, sort: true, fixed: 'left',align:'center'},
  23. {type:'numbers'},
  24. {field: 'type_name', title: '分类名称', align:'center'},
  25. {field: 'title', title: '视频标题', align:'center'},
  26. {field: 'house_name', title: '楼盘名称', align:'center'},
  27. {field: 'city_name', title: '所属区域', align:'center'},
  28. {field: 'source', title: '来源', align:'center'}
  29. ,{field: 'create_at', title: '添加时间',width:130, align:'center'}
  30. ,{field: 'state', title: '审核',width:100, templet:function (d) {
  31. if(d.state == 2){
  32. return '<input type="checkbox" value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  33. } else {
  34. return '<input type="checkbox" checked value="'+d.id+'" name="open" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  35. }
  36. }}
  37. ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
  38. ]]
  39. });
  40. table.reload('tablerReload'); //重新加载
  41. //监听指定开关
  42. form.on('switch(switchTest)', function(data){
  43. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  44. $.post('/routinevideo/videostate',{id:data.value},function (data) {
  45. if(data.data != null){
  46. layer.msg(ReturnInfo(data.data),{icon:5});
  47. return ;
  48. }
  49. layer.msg(data.msg);
  50. table.reload('tablerReload');
  51. })
  52. },function (aa) {
  53. table.reload('tablerReload'); //重新加载
  54. })
  55. });
  56. //列表操作
  57. table.on('tool('+tableIds+')', function(obj){
  58. var layEvent = obj.event,
  59. data = obj.data;
  60. if(layEvent === 'edit'){
  61. var index = layer.open({
  62. type: 2,
  63. title: '修改视频',
  64. area:['','100%'],
  65. content: '/routinevideo/videoedit?id='+data.id+'&house_name='+data.house_name,
  66. end:function () {
  67. table.reload('tablerReload'); //重新加载
  68. }
  69. });
  70. layui.layer.full(index);
  71. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  72. $(window).on("resize",function(){
  73. layui.layer.full(index);
  74. })
  75. } else if(layEvent === 'del') {
  76. layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
  77. $.post('/routinevideo/videodel',{'id':data.id},function (data) {
  78. if(data.data != null){
  79. layer.msg(ReturnInfo(data.data),{icon:5});
  80. return ;
  81. }
  82. layer.msg(data.msg);
  83. table.reload('tablerReload');
  84. })
  85. })
  86. }
  87. });
  88. $('.layui_magnify').click(function(){
  89. var _src = $(this).attr('src');
  90. layui.layer.open({
  91. type: 1,
  92. title: false, //是否显示标题
  93. area: ['60%', '80%'],
  94. shade: 0.6, //透明度
  95. closeBtn: 1, //按钮 1有,0无
  96. shadeClose: true,
  97. content: '<img style="width:100%;height:100%" src="'+_src+'">',
  98. });
  99. })
  100. //添加图片上传
  101. upload.render({
  102. elem: '#test1'
  103. ,url: '/house/createimg'
  104. ,data:{token:csrfToken}
  105. ,field:'img'
  106. ,size:1000 //限制上传图片的大小,单位为KB
  107. ,exts:'png|jpg|jpeg' //只允许上传压缩文件
  108. ,auto:false
  109. ,bindAction:'#addcity'
  110. ,choose: function(obj){
  111. obj.preview(function(index, file, result){
  112. $('#breviary_img').attr('src', result); //图片链接(base64)
  113. });
  114. }
  115. });
  116. var $ = layui.$, active = {
  117. addData: function(){ //获取选中数据
  118. var index = layui.layer.open({
  119. type: 2,
  120. title: '添加视频',
  121. area: ['','100%'],
  122. content: '/routinevideo/videoadd' //iframe的url,no代表不显示滚动条
  123. ,success:function (layero, index) {
  124. // indexOpen = layer.getChildFrame('body', index) ;
  125. // console.log(indexOpen);
  126. },
  127. end:function () {
  128. table.reload('tablerReload');
  129. }
  130. });
  131. layui.layer.full(index);
  132. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  133. $(window).on("resize",function(){
  134. layui.layer.full(index);
  135. })
  136. },
  137. reload:function(){
  138. var form = pfgs_serialize($('form'));
  139. var name = '';
  140. var house_name = '';
  141. if(form.input_house == 'name'){
  142. name = form.input_house_text;
  143. } else if(form.input_house == 'house_name'){
  144. house_name = form.input_house_text;
  145. }
  146. table.reload('tablerReload',{
  147. where:{
  148. title:name,
  149. house_name:house_name,
  150. city:form.input_city,
  151. type_name:form.type_name
  152. }
  153. })
  154. },
  155. house_reload:function(){
  156. var form = pfgs_serialize($('form'));
  157. console.log(form);
  158. table.reload('houseReload',{
  159. where:{
  160. name:11111
  161. }
  162. })
  163. }
  164. };
  165. $('.demoTable .layui-btn').on('click', function(){
  166. var type = $(this).data('type');
  167. active[type] ? active[type].call(this) : '';
  168. });
  169. //修改
  170. form.on('submit(edit_video_type_name)', function(data){
  171. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  172. var formData = new FormData($('form')[0]);
  173. $.ajax({
  174. cache : false,
  175. type : "post",
  176. url : "/routinevideo/videoeditform",
  177. data : formData,
  178. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  179. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  180. error : function(request) {
  181. layer.close(index);
  182. layer.msg("请联系管理员");
  183. },
  184. success : function(data) {
  185. if(data.data != null){
  186. layer.msg(ReturnInfo(data.data),{icon:5});
  187. return ;
  188. }
  189. layer.msg(data.msg);
  190. }
  191. });
  192. return false;
  193. });
  194. //添加
  195. form.on('submit(add_video_type_name)', function(data){
  196. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  197. var formData = new FormData($('form')[0]);
  198. $.ajax({
  199. cache : false,
  200. type : "post",
  201. url : "/routinevideo/videoaddform",
  202. data : formData, // 你的formid
  203. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  204. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  205. error : function(request) {
  206. layer.close(index);
  207. layer.msg("请联系管理员");
  208. },
  209. success : function(data) {
  210. if(data.data != null){
  211. layer.msg(ReturnInfo(data.data),{icon:5});
  212. return ;
  213. }
  214. layer.msg(data.msg);
  215. }
  216. });
  217. return false;
  218. });
  219. $('.The_house').focus(function(){
  220. indexOpen = parent.layui.layer.open({
  221. type: 2,
  222. title: '选择需要添加的楼盘',
  223. area: ['','100%'],
  224. content: '/publicuse/housename',
  225. success:function (layero, index) {
  226. },
  227. end:function(){
  228. }
  229. });
  230. parent.layui.layer.full(indexOpen);
  231. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  232. $(window).on("resize",function(){
  233. parent.layui.layer.full(indexOpen);
  234. })
  235. })
  236. // var indexO = table.render({
  237. // elem: '#houselist'
  238. // ,url: '/routinevideo/allhouseform' //数据接口
  239. // ,where:{token:csrfToken}
  240. // ,method:'post'
  241. // ,page: true //开启分页
  242. // ,text:'数据加载中'
  243. // ,id:'houseReload'
  244. // ,cols: [[ //表头
  245. // {title:'选择',event:'check',width:60,align:'center',templet:"#checkBox",templet:function(d){
  246. // return '<div class="layui-inline"><input type="radio" name="sex" ></div>'
  247. // }},
  248. // {type:'numbers',title:'序号'},
  249. // {field: 'name', title: '楼盘名称', align:'center'},
  250. // ]]
  251. // });
  252. //选择所属楼盘添加
  253. // var _data;
  254. // table.on('tool(houselist)', function(obj){
  255. // var layEvent = obj.event,
  256. // data = obj.data;
  257. // if(layEvent === 'check'){
  258. // _data = data;
  259. // }
  260. // });
  261. // // 提交按钮
  262. // $('.xuanzhouse').click(function () {
  263. // var a = parent.layer.getChildFrame('body', indexOpen);
  264. // var _length = a.find('input#hiddenBox[type="hidden"]');
  265. // if(_length.length > 0){
  266. // _length.remove();
  267. // }
  268. // if(typeof _data == 'object'){
  269. // a.find('#house_name').val(_data.name)
  270. // a.find('form').append('<input type="hidden" id="hiddenBox" name="hid" value="'+_data.id+'" />');
  271. // TableClose();
  272. // }
  273. // })
  274. //判断是否需要编辑,需要才加载
  275. var verdict = $('#editor_content').html();
  276. if(typeof verdict == "string"){
  277. var ue = UE.getEditor('editor'); //编辑器
  278. }
  279. });