member_list.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534
  1. {extend name="base"/}
  2. {block name="resources"}
  3. <style>
  4. .ns-reason-box{display: none;width: 350px;box-sizing: border-box;padding: 20px;border: 1px solid #aaa;border-radius: 5px;background-color: #FFF;position: absolute;top: 50px;z-index: 999;color: #666;line-height: 30px;left: 0px;font-weight: normal;}
  5. .ns-balance-box {text-align: left; left: unset; right: -270px;}
  6. .ns-reason-box:before, .ns-reason-box:after{content: "";border: solid transparent;height: 0;position: absolute;width: 0;}
  7. .ns-reason-box:before{border-width: 12px;border-bottom-color: #aaa;top: -12px;left: 43px;border-top: none;}
  8. .ns-reason-growth:before{left: 56px;}
  9. .ns-reason-box:after{border-width: 10px;border-bottom-color: #FFF;top: -20px;left: 45px;}
  10. .ns-reason-growth:after{left: 58px;}
  11. .ns-reason-box p{white-space: normal;line-height: 1.5;}
  12. .layui-table-header{overflow: inherit;}
  13. .layui-table-header .layui-table-cell{overflow: inherit;}
  14. .ns-prompt .iconfont{font-size: 16px;color: rgba(0,0,0,0.7);cursor: pointer;font-weight: 500;margin-left: 3px;}
  15. .ns-prompt-block.balance {justify-content: flex-end;}
  16. </style>
  17. <link rel="stylesheet" type="text/css" href="ADMIN_CSS/member.css" />
  18. {/block}
  19. {block name="main"}
  20. <div class="layui-collapse ns-tips">
  21. <div class="layui-colla-item">
  22. <h2 class="layui-colla-title">操作提示</h2>
  23. <ul class="layui-colla-content layui-show">
  24. <li>会员由平台端进行统一管理,平台可以针对会员进行添加,编辑,锁定,调整账户等操作。</li>
  25. <li>账户类型有用户名、手机、邮箱三种类型,筛选时可以选择其中一种类型并输入对应的内容进行筛选。</li>
  26. <li>点击收起按钮可以将搜索面板隐收起,变成高级搜索按钮。</li>
  27. </ul>
  28. </div>
  29. </div>
  30. <!-- 添加会员 -->
  31. <div class="ns-single-filter-box">
  32. <button type="button" class="layui-btn ns-bg-color" onclick="window.location.href='{:addon_url("admin/member/addMember")}'">添加会员</button>
  33. </div>
  34. <div class="ns-screen layui-collapse">
  35. <div class="layui-colla-item">
  36. <h2 class="layui-colla-title">筛选</h2>
  37. <form class="layui-colla-content layui-form layui-show">
  38. <div class="layui-form-item">
  39. <div class="layui-inline">
  40. <label class="layui-form-label">账号</label>
  41. <div class="layui-input-inline">
  42. <select name="search_text_type">
  43. <option value="username">用户名</option>
  44. <option value="mobile">手机</option>
  45. <option value="email">邮箱</option>
  46. </select>
  47. </div>
  48. <div class="layui-input-inline">
  49. <input type="text" name="search_text" placeholder="用户名/手机号/邮箱" autocomplete="off" class="layui-input ">
  50. </div>
  51. </div>
  52. </div>
  53. <div class="layui-form-item">
  54. <div class="layui-inline">
  55. <label class="layui-form-label">注册时间</label>
  56. <div class="layui-input-inline">
  57. <input type="text" class="layui-input" name="reg_start_date" id="reg_start_date" placeholder="请输入开始时间" autocomplete="off" readonly>
  58. </div>
  59. <div class="layui-input-inline ns-split">-</div>
  60. <div class="layui-input-inline end-time">
  61. <input type="text" class="layui-input" name="reg_end_date" id="reg_end_date" placeholder="请输入结束时间" autocomplete="off" readonly>
  62. </div>
  63. </div>
  64. </div>
  65. <div class="layui-form-item">
  66. <div class="layui-inline">
  67. <label class="layui-form-label">会员标签</label>
  68. <div class="layui-input-inline">
  69. <select name="label_id">
  70. <option value="">请选择</option>
  71. {foreach $member_label_list as $member_label_list_k=> $member_label_list_v}
  72. <option value="{$member_label_list_v.label_id}">{$member_label_list_v.label_name}</option>
  73. {/foreach}
  74. </select>
  75. </div>
  76. </div>
  77. <div class="layui-inline">
  78. <label class="layui-form-label">状态</label>
  79. <div class="layui-input-inline">
  80. <select name="status">
  81. <option value="">请选择</option>
  82. <option value="1">正常</option>
  83. <option value="0">已锁定</option>
  84. </select>
  85. </div>
  86. </div>
  87. </div>
  88. <div class="ns-form-row">
  89. <button class="layui-btn ns-bg-color" lay-submit lay-filter="search">筛选</button>
  90. <button class="layui-btn ns-bg-color" lay-submit lay-filter="export">批量导出</button>
  91. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  92. </div>
  93. </form>
  94. </div>
  95. </div>
  96. <!-- 列表 -->
  97. <table id="member_list" lay-filter="member_list"></table>
  98. <!-- 用户信息 -->
  99. <script type="text/html" id="userdetail">
  100. <div class='ns-table-tuwen-box'>
  101. <div class='ns-img-box'>
  102. <img layer-src src="{{ns.img(d.headimg)}}" onerror="this.src = 'ADMIN_IMG/default_headimg.png' ">
  103. </div>
  104. <div class='ns-font-box'>
  105. <p class="layui-elip">{{d.nickname}}</p>
  106. </div>
  107. </div>
  108. </script>
  109. <!-- 会员标签 -->
  110. <script id="member_label" type="text/html">
  111. {{# if (d.member_label_name != null) { }}
  112. {{# var arr = d.member_label_name.split(",") }}
  113. <div id="member_label_dl">
  114. {{# for (var index in arr) { }}
  115. {{'<span>' + arr[index] + '</span>'}}
  116. {{# } }}
  117. </div>
  118. {{# } }}
  119. </script>
  120. <!-- 状态 -->
  121. <script type="text/html" id="status">
  122. {{ d.status == 1 ? '正常' : '锁定' }}
  123. </script>
  124. <!-- 工具栏操作 -->
  125. <script type="text/html" id="operation">
  126. <div class="ns-table-btn">
  127. <a class="layui-btn" lay-event="info">详情</a>
  128. <a class="layui-btn" lay-event="more">更多</a>
  129. <div class="more-operation">
  130. <a class="operation" lay-event="set_label">设置标签</a>
  131. <a class="operation" lay-event="reset_pass">重置密码</a>
  132. <a class="operation" lay-event="delete">删除</a>
  133. </div>
  134. </div>
  135. </script>
  136. {/block}
  137. {block name="script"}
  138. <script type="text/javascript">
  139. var table, form, laytpl, laydate,
  140. repeat_flag = false,
  141. currentDate = new Date(),
  142. minDate = "",
  143. layer_pass,
  144. layer_label;
  145. layui.use(['form', 'laytpl', 'laydate'], function() {
  146. form = layui.form;
  147. laytpl = layui.laytpl;
  148. laydate = layui.laydate;
  149. currentDate.setDate(currentDate.getDate() - 7);
  150. form.render();
  151. //注册开始时间
  152. laydate.render({
  153. elem: '#reg_start_date',
  154. type: 'datetime'
  155. });
  156. //注册结束时间
  157. laydate.render({
  158. elem: '#reg_end_date',
  159. type: 'datetime'
  160. });
  161. /**
  162. * 重新渲染结束时间
  163. * */
  164. function reRender() {
  165. $("#reg_end_date").remove();
  166. $(".end-time").html('<input type="text" class="layui-input" name="reg_end_date" id="reg_end_date" placeholder="请输入结束时间">');
  167. laydate.render({
  168. elem: '#reg_end_date',
  169. min: minDate
  170. });
  171. }
  172. //积分
  173. /* $("body").on("mousemove",".ns-point",function() {
  174. $("body").find(".ns-point-box").show().stop(false, true);
  175. });
  176. $("body").on("mouseout",".ns-point",function() {
  177. $("body").find(".ns-point-box").hide().stop(false, true);
  178. }); */
  179. //余额
  180. /* $("body").on("mousemove",".ns-balance",function() {
  181. $("body").find(".ns-balance-box").show().stop(false, true);
  182. });
  183. $("body").on("mouseout",".ns-balance",function() {
  184. $("body").find(".ns-balance-box").hide().stop(false, true);
  185. }); */
  186. //成长值
  187. /* $("body").on("mousemove",".ns-growth",function() {
  188. $("body").find(".ns-growth-box").show().stop(false, true);
  189. });
  190. $("body").on("mouseout",".ns-growth",function() {
  191. $("body").find(".ns-growth-box").hide().stop(false, true);
  192. }); */
  193. /**
  194. * 加载表格
  195. */
  196. table = new Table({
  197. elem: '#member_list',
  198. url: ns.url("admin/member/memberList"),
  199. cols: [
  200. [
  201. {
  202. width: "3%",
  203. type: 'checkbox',
  204. unresize: 'false'
  205. }, {
  206. field: 'userdetail',
  207. title: '账户',
  208. width: '18%',
  209. unresize: 'false',
  210. templet: '#userdetail'
  211. }, {
  212. field: 'member_level_name',
  213. title: '会员等级',
  214. width: '10%',
  215. unresize: 'false'
  216. },{
  217. field: 'member_label',
  218. title: '标签',
  219. width: '13%',
  220. unresize: 'false',
  221. templet: '#member_label'
  222. }, {
  223. field: 'reg-login',
  224. title: '成为会员时间',
  225. width: '18%',
  226. unresize: 'false',
  227. templet: function (data) {
  228. return ns.time_to_date(data.reg_time);
  229. }
  230. }, {
  231. title: '操作',
  232. width: '15%',
  233. unresize: 'false',
  234. toolbar: '#operation'
  235. }
  236. ]
  237. ],
  238. bottomToolbar: "#batchOperation"
  239. });
  240. /**
  241. * 监听工具栏操作
  242. */
  243. table.tool(function(obj) {
  244. var data = obj.data;
  245. switch (obj.event) {
  246. case 'info': //编辑
  247. location.href = ns.url("admin/member/editMember?member_id=" + data.member_id);
  248. break;
  249. case 'delete': //删除
  250. delMember(data.member_id);
  251. break;
  252. case 'reset_pass': //重置密码
  253. resetPassword(data);
  254. break;
  255. case 'set_label': //设置标签
  256. settingLabels(data.member_id);
  257. break;
  258. case 'more': //更多
  259. $('.more-operation').css('display', 'none');
  260. $(obj.tr).find('.more-operation').css('display', 'block');
  261. break;
  262. }
  263. });
  264. $(document).click(function(event) {
  265. if ($(event.target).attr('lay-event') != 'more' && $('.more-operation').not(':hidden').length) {
  266. $('.more-operation').css('display', 'none');
  267. }
  268. });
  269. /**
  270. * 批量操作
  271. */
  272. table.bottomToolbar(function(obj) {
  273. if (obj.data.length < 1) {
  274. layer.msg('请选择要操作的数据');
  275. return;
  276. }
  277. switch (obj.event) {
  278. case "del":
  279. var id_array = new Array();
  280. for (i in obj.data) id_array.push(obj.data[i].member_id);
  281. delMember(id_array.toString());
  282. break;
  283. case "setlabel":
  284. var id_array = new Array();
  285. for (i in obj.data) id_array.push(obj.data[i].member_id);
  286. settingLabels(id_array.toString());
  287. break;
  288. }
  289. });
  290. /**
  291. * 删除
  292. */
  293. function delMember(member_ids) {
  294. if (repeat_flag) return false;
  295. repeat_flag = true;
  296. layer.confirm('删除该会员,同时会删除相关账户,请谨慎操作!', function() {
  297. $.ajax({
  298. url: ns.url("admin/member/deleteMember"),
  299. data: {member_ids},
  300. dataType: 'JSON',
  301. type: 'POST',
  302. success: function(res) {
  303. layer.msg(res.message);
  304. repeat_flag = false;
  305. if (res.code == 0) {
  306. table.reload();
  307. }
  308. }
  309. });
  310. }, function () {
  311. layer.close();
  312. repeat_flag = false;
  313. });
  314. }
  315. /**
  316. * 重置密码
  317. */
  318. function resetPassword(data) {
  319. laytpl($("#pass_change").html()).render(data, function(html) {
  320. layer_pass = layer.open({
  321. title: '重置密码',
  322. skin: 'layer-tips-class',
  323. type: 1,
  324. area: ['550px'],
  325. content: html,
  326. });
  327. });
  328. }
  329. form.on('submit(repass)', function(data) {
  330. if (repeat_flag) return false;
  331. repeat_flag = true;
  332. $.ajax({
  333. type: "POST",
  334. url: ns.url("admin/member/modifyPassword"),
  335. data: data.field,
  336. dataType: 'JSON',
  337. success: function(res) {
  338. layer.msg(res.message);
  339. repeat_flag = false;
  340. if (res.code == 0) {
  341. layer.closeAll('page');
  342. }
  343. }
  344. });
  345. });
  346. /**
  347. * 设置标签
  348. */
  349. function settingLabels(data) {
  350. laytpl($("#label_change").html()).render(data, function(html) {
  351. layer_label = layer.open({
  352. title: '设置标签',
  353. skin: 'layer-tips-class',
  354. type: 1,
  355. area: ['450px'],
  356. content: html,
  357. });
  358. });
  359. form.render();
  360. }
  361. form.on('submit(setlabel)', function(obj) {
  362. if (repeat_flag) return false;
  363. repeat_flag = true;
  364. var field = obj.field;
  365. var arr_id = [];
  366. for (var prop in field) {
  367. if (prop == 'member_ids') {
  368. continue;
  369. }
  370. arr_id.push(field[prop]);
  371. }
  372. $.ajax({
  373. type: "POST",
  374. url: ns.url("admin/member/modifyLabel"),
  375. data: {
  376. 'member_ids': field.member_ids,
  377. 'label_ids': arr_id.toString()
  378. },
  379. dataType: 'JSON',
  380. success: function(res) {
  381. layer.msg(res.message);
  382. repeat_flag = false;
  383. if (res.code == 0) {
  384. table.reload();
  385. layer.closeAll('page');
  386. }
  387. }
  388. });
  389. });
  390. /**
  391. * 搜索功能
  392. */
  393. form.on('submit(search)', function(data) {
  394. table.reload({
  395. page: {
  396. curr: 1
  397. },
  398. where: data.field
  399. });
  400. return false;
  401. });
  402. /**
  403. * 导出
  404. */
  405. form.on('submit(export)', function(data) {
  406. location.href = ns.url("admin/member/exportMember",data.field);
  407. return false;
  408. });
  409. $(".search-form").click(function() {
  410. $(".layui-form-search").show();
  411. $(this).hide();
  412. });
  413. $(".form-hide-btn").click(function() {
  414. $(".layui-form-search").hide();
  415. $(".search-form").show();
  416. });
  417. /**
  418. * 表单验证
  419. */
  420. form.verify({
  421. repass: function(value) {
  422. if (value != $(".new_pass").val()) {
  423. return "输入错误,两次密码不一致!";
  424. }
  425. }
  426. });
  427. });
  428. function closePass() {
  429. layer.close(layer_pass);
  430. }
  431. function closeLabel() {
  432. layer.close(layer_label);
  433. }
  434. </script>
  435. <!-- 重置密码弹框html -->
  436. <script type="text/html" id="pass_change">
  437. <div class="layui-form" id="reset_pass" lay-filter="form">
  438. <div class="layui-form-item">
  439. <label class="layui-form-label mid"><span class="required">*</span>新密码:</label>
  440. <div class="layui-input-block">
  441. <input type="password" name="password" lay-verify="required" class="layui-input ns-len-mid new_pass" maxlength="18">
  442. </div>
  443. </div>
  444. <div class="layui-form-item">
  445. <label class="layui-form-label mid"><span class="required">*</span>确认新密码:</label>
  446. <div class="layui-input-block">
  447. <input type="password" name="password" lay-verify="repass|required" class="layui-input ns-len-mid" maxlength="18">
  448. </div>
  449. <div class="ns-word-aux mid">请再一次输入密码,两次输入密码须一致</div>
  450. </div>
  451. <div class="ns-form-row mid">
  452. <button class="layui-btn ns-bg-color" lay-submit lay-filter="repass">确定</button>
  453. <button class="layui-btn layui-btn-primary" onclick="closePass()">返回</button>
  454. </div>
  455. <input class="reset-pass-id" type="hidden" name="member_ids" value="{{d.member_id}}"/>
  456. </div>
  457. </script>
  458. <!-- 设置标签弹框html -->
  459. <script type="text/html" id="label_change">
  460. <div class="layui-form member-form" id="reset_label" lay-filter="form">
  461. <div class="layui-form-item">
  462. <label class="layui-form-label sm">标签</label>
  463. <div class="layui-input-block">
  464. {foreach $member_label_list as $member_label_list_k => $member_label_list_v}
  465. <input type="checkbox" name="label_id{$member_label_list_v.label_id}" value="{$member_label_list_v.label_id}" title="{$member_label_list_v.label_name}" lay-skin="primary">
  466. {/foreach}
  467. </div>
  468. </div>
  469. <div class="ns-form-row sm">
  470. <button class="layui-btn ns-bg-color" lay-submit lay-filter="setlabel">确定</button>
  471. <button class="layui-btn layui-btn-primary" onclick="closeLabel()">返回</button>
  472. </div>
  473. <input class="reset-label-id" type="hidden" name="member_ids" value="{{d}}" />
  474. </div>
  475. </script>
  476. <script type="text/html" id="batchOperation">
  477. <button class="layui-btn layui-btn-primary" lay-event="setlabel">设置标签</button>
  478. </script>
  479. {/block}