customer.html 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. {extend name="public/layout"}
  2. {block name="body"}
  3. <style>
  4. .layui-table thead tr,
  5. .layui-table-header {
  6. background-color: #D8E6F1 !important;
  7. }
  8. .layui-form{
  9. margin-bottom: 10px;
  10. }
  11. .layui-btn-xs,.layui-btn-xs:hover {
  12. border: 1px solid #249EFB;
  13. background-color: #fff;
  14. color: #249EFB;
  15. padding: 0px 10px;
  16. }
  17. .layui-btn-danger,.layui-btn-danger:hover{
  18. color: #FF5722;
  19. background-color: #fff;
  20. border: 1px solid #FF5722;
  21. padding: 0px 10px;
  22. }
  23. </style>
  24. <body>
  25. <div class="layui-fluid">
  26. <div class="layui-row layui-col-space15">
  27. <div class="layui-col-md12">
  28. <div class="layui-card">
  29. <div class="layui-card-body">
  30. <div class="layui-form">
  31. <div class="layui-inline">
  32. <input type="text" class="layui-input" id="name" placeholder="搜索姓名">
  33. </div>
  34. <div class="layui-inline">
  35. <input type="text" class="layui-input" id="nickname" placeholder="搜索昵称">
  36. </div>
  37. <div class="layui-inline">
  38. <input type="text" class="layui-input" id="mobile" placeholder="搜索手机号">
  39. </div>
  40. <div class="layui-inline">
  41. <select id="course">
  42. <option value="">按活动场次筛选</option>
  43. {volist name="course" id="item"}
  44. <option value="{$item.cid}">{$item.start_time} / {$item.title}</option>
  45. {/volist}
  46. </select>
  47. </div>
  48. <button class="layui-btn" data-type="reload"><i class="layui-icon layui-icon-search layuiadmin-button-btn"></i></button>
  49. <div class="layui-inline" style="margin-left: 80px;">
  50. <input type="checkbox" id="show" title="只显示带手机号的用户" lay-skin="primary"
  51. lay-filter="mobile" value="0">
  52. </div>
  53. <button class="layui-btn" id="export" style="float: right;">导出</button>
  54. </div>
  55. <table class="layui-hide" id="user" lay-filter="user"></table>
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. {/block}
  62. {block name="js"}
  63. <script id="opt" type="text/html">
  64. <a class="layui-btn layui-btn-xs" lay-event="msg" title="消息记录">消息记录</a>
  65. <a class="layui-btn layui-btn-xs" lay-event="gift" title="送礼记录">送礼记录</a>
  66. <a class="layui-btn layui-btn-xs" lay-event="redbag" title="红包领取记录">红包领取记录</a>
  67. <a class="layui-btn layui-btn-xs" lay-event="visit" title="浏览记录">浏览记录</a>
  68. <a class="layui-btn layui-btn-xs remark" lay-event="remark" title="跟进" data-content="{{ d.remark }}">跟进</a>
  69. </script>
  70. <script id="sex" type="text/html">
  71. {{# if(d.sex == 1){ }}
  72. <i class="layui-icon" style="color:#4343ee">&#xe662;</i>
  73. {{# }else{ }}
  74. <i class="layui-icon" style="color:#e04e4e">&#xe661;</i>
  75. {{# } }}
  76. </script>
  77. <script id="equip" type="text/html">
  78. {{# if(d.equip == '安卓'){ }}
  79. <i class="layui-icon" style="color:#43c343">&#xe684;</i>
  80. {{# }else if(d.equip == 'Iphone') { }}
  81. <i class="layui-icon" style="color:#b0b0b0">&#xe680;</i>
  82. {{# }else if(d.equip == 'MAC'){ }}
  83. <i class="iconfont" style="color:#b0b0b0">&#xe689;</i>
  84. {{# }else{ }}
  85. <i class="layui-icon" style="color:#04e1fdcf">&#xe67f;</i>
  86. {{# } }}
  87. </script>
  88. <script id="mb" type="text/html">
  89. {{# if(d.mobile != ""){ }}
  90. <span class="mb" data-type="{{d.type}}">{{ d.mobile }}</span>
  91. {{# }else{ }}
  92. <span style="color:#c0c4cc">未采集</span>
  93. {{# } }}
  94. </script>
  95. <script>
  96. var indexurl = '{:url("broad/customer")}';
  97. var msgurl = '{:url("broad/customer_msg")}';
  98. var visiturl = '{:url("broad/customer_visit")}';
  99. var redbagurl = '{:url("broad/customer_redbag")}';
  100. var gifturl = '{:url("broad/customer_gift")}';
  101. var remarkurl = '{:url("broad/customer_remark")}';
  102. var active;
  103. layui.use(['table', 'laydate', 'layer'], function () {
  104. var laydate = layui.laydate,
  105. form = layui.form,
  106. table = layui.table,
  107. layer = layui.layer,
  108. $ = layui.jquery;
  109. active = {
  110. reload: function () {
  111. var name = $('#name');
  112. var nickname = $('#nickname');
  113. var mobile = $('#mobile');
  114. var show = $('#show');
  115. var course = $('#course');
  116. table.reload('userTable', {
  117. page: {
  118. curr: 1
  119. }
  120. , where: {
  121. name: name.val(),
  122. nickname: nickname.val(),
  123. mobile: mobile.val(),
  124. show: show.val(),
  125. courseId: course.val()
  126. }
  127. });
  128. }
  129. , msg: function () {
  130. var uid = this.data.uid;
  131. var url = msgurl + '?uid=' + uid;
  132. log(url, '消息记录');
  133. }
  134. , visit: function () {
  135. var uid = this.data.uid;
  136. var url = visiturl + '?uid=' + uid;
  137. log(url, '浏览记录');
  138. }
  139. , redbag: function () {
  140. var uid = this.data.uid;
  141. var url = redbagurl + '?uid=' + uid;
  142. log(url, '红包记录');
  143. }
  144. , gift: function () {
  145. var uid = this.data.uid;
  146. var url = gifturl + '?uid=' + uid;
  147. log(url, '送礼记录');
  148. }
  149. , remark: function () {
  150. var uid = this.data.uid;
  151. var url = remarkurl + '?uid=' + uid;
  152. log(url, '备注');
  153. }
  154. };
  155. function log(url, title) {
  156. layer.open({
  157. type: 2,
  158. shadeClose: true,
  159. closeBtn: 0,
  160. title: [title, 'color:#333333;background-color:#D8E6F1;'],
  161. area: ['80%', '80%'],
  162. resize: false,
  163. content: url
  164. });
  165. }
  166. laydate.render({
  167. elem: '#date'
  168. , range: true
  169. });
  170. //展示已知数据
  171. table.render({
  172. elem: '#user'
  173. , url: indexurl
  174. , page: true
  175. , limit: 15
  176. , limits: [15, 20, 30, 40, 50, 60, 70, 80, 90]
  177. , autoSort: true
  178. , cols: [[ //标题栏
  179. { type: 'numbers', title: '序号', fixed: 'left', width: 50 }
  180. , { field: 'nickname', title: '昵称' }
  181. , {
  182. field: 'name', title: '姓名', templet: function (d) {
  183. return d.name == '' ? '<span style="color:#c0c4cc">未采集</span>' : '<span style="color:#009688;">' + d.name + '</span>';
  184. }
  185. }
  186. , { templet: '#mb', title: '电话', minWidth: 120 }
  187. , { templet: '#sex', title: '性别', width: 60, align: 'center' }
  188. , {
  189. templet: function (d) {
  190. return d.city == '' ? '<span style="color:#c0c4cc">未知</span>' : d.province + d.city;
  191. }, title: '地域', width: 100
  192. }
  193. , { field: 'from', title: '邀请人', width: 100 }
  194. , { templet: '#equip', title: '设备', width: 60, align: 'center' }
  195. , {
  196. title: '累计访问时间', field: 'time', width: 150,
  197. templet: function (d) {
  198. var time = '';
  199. if (d.time >= 3600) {
  200. time += parseInt(d.time / 3600) + '时';
  201. }
  202. if (d.time >= 60) {
  203. time += parseInt(d.time % 3600 / 60) + '分';
  204. }
  205. time += parseInt(d.time % 3600 % 60) + '秒';
  206. return time;
  207. }
  208. }
  209. , { field: 'num', title: '访问次数', width: 90 }
  210. , { fixed: 'right', title: '操作', toolbar: '#opt', width: 350, align: 'center' }
  211. ]]
  212. , id: 'userTable'
  213. });
  214. table.on('tool(user)', function (obj) {
  215. var type = obj.event;
  216. active[type] ? active[type].call(obj) : '';
  217. })
  218. $('.layui-form>.layui-btn').on('click', function () {
  219. var type = $(this).data('type');
  220. active[type] ? active[type].call(this) : '';
  221. });
  222. table.on('sort(user)', function (obj) {
  223. table.reload('userTable', {
  224. initSort: obj
  225. , where: obj
  226. });
  227. });
  228. $('body').on('mouseover', '.mb', function () {
  229. var type = $(this).data('type');
  230. layer.tips(type, this, {
  231. tips: [1, '#3595CC'],
  232. time: 2000
  233. });
  234. });
  235. $('body').on('mouseover', '.remark', function () {
  236. var content = $(this).data('content');
  237. if (content != '') {
  238. layer.tips(content, this, {
  239. tips: [1, '#3595CC'],
  240. time: 2000
  241. });
  242. }
  243. });
  244. form.on('checkbox(mobile)', function (data) {
  245. var that = $(data.elem);
  246. if (data.elem.checked) {
  247. that.val(1);
  248. active.reload();
  249. } else {
  250. that.val(0);
  251. active.reload();
  252. }
  253. });
  254. $('#export').click(function () {
  255. var loading = layer.load(1, {shade: [0.6,'#fff']});
  256. var name = $('#name');
  257. var nickname = $('#nickname');
  258. var mobile = $('#mobile');
  259. var show = $('#show');
  260. var course = $('#course');
  261. var page = $('.layui-table-page').find('.layui-laypage-curr').find('em').eq(1).html();
  262. var limit = $('.layui-table-page').find('select').val();
  263. $.ajax({
  264. type: 'post',
  265. url: '{:url("broad/customer_export")}',
  266. data: {name: name.val(),nickname: nickname.val(),mobile: mobile.val(),show: show.val(),courseId: course.val(),page: page,limit: limit},
  267. success: function (resp) {
  268. var res = JSON.parse(resp);
  269. table.exportFile(['昵称','姓名','电话','性别','地域','邀请人','设备','累计访问时间','访问次数'], res, 'xls');
  270. layer.close(loading);
  271. }
  272. });
  273. });
  274. });
  275. </script>
  276. {/block}