lists.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. {layout name="layout1" /}
  2. <!-- 样式 -->
  3. <style>
  4. .layui-table-cell {
  5. height: auto;
  6. }
  7. </style>
  8. <!-- 操作提示 -->
  9. <div class="layui-fluid">
  10. <div class="layui-card" style="margin-top: 15px;">
  11. <div class="layui-card-body">
  12. <div class="layui-collapse like-layui-collapse" lay-accordion="" style="border:1px dashed #c4c4c4">
  13. <div class="layui-colla-item">
  14. <h2 class="layui-colla-title like-layui-colla-title" style="background-color: #fff">操作提示</h2>
  15. <div class="layui-colla-content layui-show">
  16. <p>*商家可以对会员的商品评价进行回复,不能隐藏和删除评价;</p>
  17. <p>*商品评价会在商城的商品详情中进行显示;</p>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="layui-card-body">
  23. <div class="layui-tab layui-tab-card" lay-filter="tabContainer">
  24. <ul class="layui-tab-title">
  25. <li data-type="1" class="layui-this">已回复评价</li>
  26. <li data-type="0">待回复评价</li>
  27. </ul>
  28. <div class="layui-tab-content">
  29. <!-- 搜索 -->
  30. <div class="layui-form">
  31. <div class="layui-form-item">
  32. <div class="layui-inline">
  33. <label class="layui-form-label">评价信息:</label>
  34. <div class="layui-input-inline">
  35. <select name="search_type">
  36. <option value="name">商品名称</option>
  37. <option value="sn">会员编号</option>
  38. <option value="nickname">会员昵称</option>
  39. </select>
  40. </div>
  41. <div class="layui-input-inline">
  42. <input type="text" name="search_word" class="layui-input" />
  43. </div>
  44. <label class="layui-form-label">评价等级:</label>
  45. <div class="layui-input-inline">
  46. <select name="goods_comment">
  47. <option value="">全部</option>
  48. <option value="1">好评</option>
  49. <option value="2">中评</option>
  50. <option value="3">差评</option>
  51. </select>
  52. </div>
  53. </div>
  54. <div class="layui-inline">
  55. <label class="layui-form-label">显示状态:</label>
  56. <div class="layui-input-inline">
  57. <select name="status">
  58. <option value="">全部</option>
  59. <option value="1">显示</option>
  60. <option value="2">隐藏</option>
  61. </select>
  62. </div>
  63. </div>
  64. <div class="layui-inline">
  65. <label class="layui-form-label">日期范围:</label>
  66. <div class="layui-input-inline" style="width: 390px">
  67. <input type="text" class="layui-input" name="start_end" id="start_end">
  68. </div>
  69. </div>
  70. <div class="layui-inline" style="margin-left: 20px;">
  71. <button class="layui-btn layui-btn-normal" lay-submit lay-filter="search">查询</button>
  72. <button class="layui-btn layui-btn-primary" lay-submit lay-filter="clear-search">重置</button>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <!-- 数据表格 -->
  79. <table id="comment-lists" lay-filter="comment-lists"></table>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. <script type="text/html" id="user-info">
  85. <img src="{{d.avatar}}" style="height:80px;width: 80px;margin-right: 10px;" class="image-show">
  86. <div class="layui-input-inline" style="text-align:left;width: 240px">
  87. <p>会员编号:{{d.sn}}</p>
  88. <p style="width: 180px;text-overflow:ellipsis;overflow: hidden">昵称:{{d.nickname}}</p>
  89. <p>会员等级:{{d.levelName}}</p>
  90. </div>
  91. </script>
  92. <script type="text/html" id="goods-info">
  93. <img src="{{d.item_image}}" style="height:80px;width: 80px;margin-right: 10px;" class="image-show">
  94. <div class="layui-input-inline" style="text-align:left;width: 240px">
  95. <p>{{d.goods_name}}</p>
  96. <p style="width: 180px;text-overflow:ellipsis;overflow: hidden">{{d.spec_value_str}}</p>
  97. </div>
  98. </script>
  99. <script type="text/html" id="image-lists">
  100. {{# layui.each(d.comment_image, function(index, item){ }}
  101. <img src="{{item}}" style="height:80px;width: 80px;margin-right: 10px;" class="image-show">
  102. {{# }); }}
  103. </script>
  104. <script type="text/html" id="operate">
  105. {{# if( d.type == 1 ){ }}
  106. <button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="changeReply">修改回复</button>
  107. {{# } }}
  108. {{# if( d.type == 0 ){ }}
  109. <button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="reply">商家回复</button>
  110. {{# } }}
  111. </script>
  112. <script>
  113. layui.config({
  114. version: "{$front_version}",
  115. base: '/static/lib/'
  116. }).use(['layer', 'table', 'form', 'element', 'laydate'], function () {
  117. var $ = layui.jquery;
  118. var layer = layui.layer;
  119. var form = layui.form;
  120. var laydate = layui.laydate;
  121. var table = layui.table;
  122. var element = layui.element;
  123. // 日期范围选择器
  124. laydate.render({
  125. elem: '#start_end',
  126. type: 'datetime',
  127. range: '~'
  128. });
  129. // 监听选项卡切换
  130. element.on('tab(tabContainer)', function(data) {
  131. // 获取类型
  132. var type = $(this).attr('data-type');
  133. // 重置搜索
  134. $('input[name=search_word]').val('');
  135. $('input[name=start_end]').val('');
  136. $('select[name=search_type]').val('name');
  137. $('select[name=goods_comment]').val('');
  138. $('select[name=status]').val('');
  139. form.render('select');
  140. // 重新加载数据表格
  141. getList(type);
  142. });
  143. // 监听查询
  144. form.on('submit(search)', function(data){
  145. var field = data.field;
  146. // 执行重载
  147. table.reload('comment-lists', {
  148. where: field,
  149. page: {curr: 1}
  150. });
  151. });
  152. // 重置查询
  153. form.on('submit(clear-search)', function(data){
  154. // 重置搜索
  155. $('input[name=search_word]').val('');
  156. $('input[name=start_end]').val('');
  157. $('select[name=search_type]').val('name');
  158. $('select[name=goods_comment]').val('');
  159. $('select[name=status]').val('');
  160. form.render('select');
  161. // 重新加载数据表格
  162. table.reload('comment-lists', {
  163. where: {},
  164. page: {curr: 1}
  165. });
  166. });
  167. // 首次进入
  168. getList(1); // 1 已回复列表
  169. function getList(type) {
  170. table.render({
  171. id: 'comment-lists'
  172. ,elem: '#comment-lists'
  173. ,url: "{:url('goods.comment/lists')}?type=" + type
  174. , parseData: function(res) { // res 原始返回数据
  175. return {
  176. 'code' : res.code // 0 代表正常返回
  177. , 'msg' : res.msg // 提示消息
  178. , 'count' : res.data.count // 数据长度
  179. , 'data' : res.data.lists // 数据列表
  180. }
  181. }
  182. , response: { // 重新设定返回的数据格式
  183. statusCode: 1, // 成功的状态码,默认0
  184. }
  185. , page: true // 开启分页
  186. , limit: 10
  187. , limits: [10, 20, 30, 40, 50]
  188. , text: {
  189. none: '暂无数据'
  190. }
  191. , cols: [[ // 设置表头,二维数组,方法渲染必填
  192. { title: '会员信息', width: 250, align: 'center', templet: '#user-info' },
  193. { title: '商品信息', width: 250, align: 'center', templet: '#goods-info' },
  194. { field: 'goods_comment_desc', title: '评分等级', width: 100,align: 'center' },
  195. { field: 'comment', title: '买家评价', width: 200, align: 'center' },
  196. { title: '评论图片', width: 250, align: 'center',templet: '#image-lists' },
  197. { field: 'reply', title: '商家回复', width: 200, align: 'center' },
  198. { field: 'status_desc', title: '显示状态', width: 100, align: 'center' },
  199. { field: 'create_time', title: '评价时间', width: 180, align: 'center' },
  200. { fixed: 'right' ,title: '操作',width: 160, align: 'center', toolbar: '#operate' }
  201. ]], done: function () {
  202. setTimeout(function () {
  203. $(".layui-table-main tr").each(function (index, val) {
  204. $($(".layui-table-fixed-l .layui-table-body tbody tr")[index]).height($(val).height());
  205. $($(".layui-table-fixed-r .layui-table-body tbody tr")[index]).height($(val).height());
  206. });
  207. }, 200);
  208. }
  209. });
  210. }
  211. table.on('tool(comment-lists)', function(obj) {
  212. if(obj.event == 'reply') { // 商家回复
  213. layer.prompt({
  214. formType: 2,
  215. value: '',
  216. title: '商家回复',
  217. area: ['500px', '180px'] //自定义文本域宽高
  218. }, function(value, index, elem){
  219. if($.trim(value) == '') {return false;}
  220. like.ajax({
  221. url: '{:url("goods.comment/reply")}',
  222. data: {'id': obj.data.id, 'reply': value},
  223. type: "post",
  224. success: function (res) {
  225. if(res.code == 1) {
  226. layer.msg(res.msg);
  227. }
  228. table.reload('comment-lists', {
  229. where: {},
  230. page: {curr: 1}
  231. });
  232. }
  233. });
  234. layer.close(index);
  235. });
  236. }
  237. if(obj.event == 'changeReply') { // 修改回复
  238. layer.prompt({
  239. formType: 2,
  240. value: obj.data.reply,
  241. title: '修改回复',
  242. area: ['500px', '180px'] //自定义文本域宽高
  243. }, function(value, index, elem){
  244. if($.trim(value) == '') {return false;}
  245. like.ajax({
  246. url: '{:url("goods.comment/reply")}',
  247. data: {'id': obj.data.id, 'reply': value},
  248. type: "post",
  249. success: function (res) {
  250. if(res.code == 1) {
  251. layer.msg(res.msg);
  252. }
  253. table.reload('comment-lists', {
  254. where: {},
  255. page: {curr: 1}
  256. });
  257. }
  258. });
  259. layer.close(index);
  260. });
  261. }
  262. });
  263. });
  264. </script>