comment.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. layui.use([ 'laypage', 'layer', 'table', 'element','form'], function(){
  2. var laypage = layui.laypage //分页
  3. ,$ = layui.jquery
  4. ,layer = layui.layer //弹层
  5. ,table = layui.table //表格
  6. ,form = layui.form
  7. // ,xingji1 = layui.xingji,xingji2 = layui.xingji;
  8. // rate.render({
  9. // elem: '#test1'
  10. // ,setText: function(value){
  11. // var arrs = {
  12. // '1': '极差'
  13. // ,'2': '差'
  14. // ,'3': '中等'
  15. // ,'4': '好'
  16. // };
  17. // this.span.text(arrs[value] || ( value + "星"));
  18. // }
  19. // });
  20. // ,xingji1 = layui.xingji,xingji2 = layui.xingji;
  21. //
  22. // // 每个星星高度,宽度
  23. // //xingji1.canshu.gaodu = 100';
  24. // //xingji1.canshu.kuandu = 100';
  25. // //表单名称
  26. // xingji1.canshu.namezhi = 'diduan';
  27. //
  28. // // 每个星星之间间距
  29. // xingji1.canshu.jianju = 5;
  30. // //星星样式
  31. // xingji1.canshu.weixuan = '/img/weixing.png';
  32. // xingji1.canshu.quanxuan = '/img/quanxing.png';
  33. // xingji1.canshu.banxuan = '/img/banxing.png';
  34. // //星星个数
  35. // xingji1.canshu.geshu = 5;
  36. // //星星存放容器
  37. // xingji1.chuangjian('.xingxing1');
  38. // //动态设置星星评分
  39. // // xingji1.shezhifenshu('.xingxing1',5);
  40. // //动态获取星星评分
  41. // // if(xingji1.huoqufenshu('.xingxing1')){
  42. // // $('input[name="diduan"]').val(xingji1.huoqufenshu('.xingxing1'));
  43. // // }
  44. var tableId = 'citylist';
  45. var dataObj = {};
  46. //第一个实例
  47. table.render({
  48. elem: '#'+tableId
  49. ,url: '/routinecomment/homeform' //数据接口
  50. ,where:{token:csrfToken}
  51. ,method:'post'
  52. ,page: true //开启分页
  53. ,text:'数据加载中'
  54. ,id:'tablerReload'
  55. ,limit:20
  56. ,cols: [[ //表头
  57. // {field: 'id', title: 'ID', width:80, sort: true,align:'center'}
  58. {field: 'name', title: '楼盘名称',align:'center'}
  59. ,{field: 'total', title: '点评数量',align:'center'}
  60. ,{field: 'yes', title: '已读',align:'center',sort: true}
  61. ,{field: 'no', title: '未读',align:'center',sort: true}
  62. // ,{field: 'read', title: '阅读状态',width:100,align:'center',sort: true,templet:function (e) {
  63. // var str = '';
  64. // if(e.read == '已读'){
  65. // str = '<span >'+e.read+' </span>';
  66. // }else if(e.read == '未读'){
  67. // str = '<span style="color: red">'+e.read+' </span>';
  68. // }
  69. // return str;
  70. // }}
  71. // ,{field: 'is_show', title: '审核',width:80, align:'center', templet:"#Toexamine",templet:function(d){
  72. // if(d.is_show == 2){
  73. // return '<input type="checkbox" value="'+d.id+'" name="'+d.is_show+'" show="" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  74. // } else {
  75. // return '<input type="checkbox" checked value="'+d.id+'" name="'+d.is_show+'" show="" lay-skin="switch" lay-filter="switchTest" lay-text="|">'
  76. // }
  77. // }}
  78. ,{field: 'create_at', title: '添加时间', width:200,align:'center'}
  79. ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#operate'}
  80. ]]
  81. });
  82. //监听指定开关
  83. form.on('switch(switchTest)', function(data){
  84. var show;
  85. switch (data.elem.name){
  86. case '1':
  87. show = 2;
  88. break;
  89. case '2':
  90. show = 1;
  91. break;
  92. }
  93. layer.confirm('确定要修改此操作吗?',{btn: ['确定', '取消']},function () {
  94. $.post('/routinecomment/delandshow',{id:data.value,is_show:show},function (data) {
  95. layer.msg(data.msg);
  96. table.reload('tablerReload');
  97. })
  98. },function (aa) {
  99. table.reload('tablerReload'); //重新加载
  100. })
  101. });
  102. //table.reload('tablerReload'); //重新加载
  103. //列表操作
  104. table.on('tool('+tableId+')', function(obj){
  105. var layEvent = obj.event,
  106. data = obj.data;
  107. if(layEvent === 'chakan'){
  108. var index = layer.open({
  109. type: 2,
  110. title: '<span style="color:red;">【'+data.name+'】</span>楼盘点评',
  111. area: ['', '100%'],
  112. content: '/routinecomment/morecomment?hid='+data.hid,
  113. end:function(){
  114. table.reload('tablerReload');
  115. }
  116. });
  117. layer.full(index);
  118. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  119. $(window).on("resize",function(){
  120. layer.full(index);
  121. })
  122. }
  123. });
  124. $('.The_house').click(function(){
  125. // $('form').append('<input type="hidden" name="aa" value="aaa">');
  126. indexOpen = parent.layui.layer.open({
  127. type: 2,
  128. title: '选择需要添加的楼盘',
  129. area: ['60%','100%'],
  130. content: '/publicuse/housename',
  131. success:function (layero, index) {
  132. },
  133. end:function(){
  134. }
  135. });
  136. // parent.layui.layer.full(indexOpen);
  137. // //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  138. // $(window).on("resize",function(){
  139. // parent.layui.layer.full(indexOpen);
  140. // })
  141. })
  142. // 满意程度
  143. /*
  144. * prevAll() 当前位置之前
  145. * nextAll() 当前位置之后
  146. * 以上两个都不包括当前位置
  147. */
  148. $('.w_up_degree_con dl dd').on('click',function(){
  149. var that = $(this);
  150. var txt = that.parent().attr('data-title');
  151. var subscript = that.index();
  152. that.addClass('in').prevAll('dd').addClass('in');
  153. that.nextAll().removeClass('in');
  154. FnSatisfaction(txt,(subscript + 1));
  155. console.log(subscript)
  156. })
  157. // 满意程度存储值
  158. function FnSatisfaction(label,index){
  159. switch(label)
  160. {
  161. case "地段":
  162. dataObj.diduan = index;
  163. $('#diduan').val(index);
  164. break;
  165. case "交通":
  166. dataObj.jiaotong = index;
  167. $('#jiaotong').val(index);
  168. break;
  169. case "配套":
  170. dataObj.peitao = index;
  171. $('#peitao').val(index);
  172. break;
  173. case "环境":
  174. dataObj.huanjing = index;
  175. $('#huanjing').val(index);
  176. break;
  177. case "性价比":
  178. dataObj.xingjiabi = index;
  179. $('#xingjiabi').val(index);
  180. break;
  181. }
  182. }
  183. var $ = layui.$, active = {
  184. addData: function(){ //获取选中数据
  185. var index = layui.layer.open({
  186. type: 2,
  187. title: '新增点评',
  188. maxmin: true,
  189. area: ['', '100%'],
  190. content: '/routinecomment/create',
  191. });
  192. layui.layer.full(index);
  193. //改变窗口大小时,重置弹窗的宽高,防止超出可视区域(如F12调出debug的操作)
  194. $(window).on("resize",function(){
  195. layui.layer.full(index);
  196. })
  197. },
  198. reload:function () {
  199. var formdara = pfgs_serialize($('form'));
  200. table.reload('tablerReload',{
  201. where:{
  202. content_status:formdara.content_status,
  203. house_text:formdara.house_text,
  204. }
  205. })
  206. }
  207. };
  208. $('.demoTable .layui-btn').on('click', function(){
  209. var type = $(this).data('type');
  210. active[type] ? active[type].call(this) : '';
  211. });
  212. //添加
  213. form.on('submit(tijiao)', function(data){
  214. var index = layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8}); //数据提交提示
  215. var formData = new FormData($('form')[0]);
  216. $.ajax({
  217. type : "post",
  218. url : '/routinecomment/createform',
  219. data : formData, // 你的formid
  220. contentType: false, //jax 中 contentType 设置为 false 是为了避免 JQuery 对其操作,从而失去分界符,而使服务器不能正常解析文件
  221. processData: false, //当设置为true的时候,jquery ajax 提交的时候不会序列化 data,而是直接使用data
  222. error : function(request) {
  223. layer.close(index); //关闭数据提交信息
  224. layer.alert("网络超时");
  225. },
  226. success : function(data) {
  227. if(data.data != null){
  228. layer.msg(ReturnInfo(data.data),{icon:5});
  229. return ;
  230. }
  231. layer.msg(data.msg);
  232. parent.layui.table.reload('tablerReload');
  233. }
  234. });
  235. return false;
  236. });
  237. });