set.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /** layuiAdmin.pro-v1.2.1 LPPL License By http://www.layui.com/admin/ */
  2. ;
  3. layui.define(["form", "upload"],
  4. function(t) {
  5. var i = layui.$,
  6. e = layui.layer,
  7. n = (layui.laytpl, layui.setter, layui.view, layui.admin),
  8. a = layui.form,
  9. s = layui.upload;
  10. i("body");
  11. a.render(),
  12. a.verify({
  13. nickname: function(t, i) {
  14. return new RegExp("^[a-zA-Z0-9_一-龥\\s·]+$").test(t) ? /(^\_)|(\__)|(\_+$)/.test(t) ? "用户名首尾不能出现下划线'_'": /^\d+\d+\d$/.test(t) ? "用户名不能全为数字": void 0 : "用户名不能有特殊字符"
  15. },
  16. pass: [/^[\S]{3,12}$/, "密码必须3到12位,且不能出现空格"],
  17. repass: function(t) {
  18. if (t !== i("#LAY_password").val()) return "两次密码输入不一致"
  19. }
  20. }),
  21. a.on("submit(set_website)",
  22. function(t) {
  23. return e.msg(JSON.stringify(t.field)),
  24. !1
  25. }),
  26. a.on("submit(set_system_email)",
  27. function(t) {
  28. return e.msg(JSON.stringify(t.field)),
  29. !1
  30. }),
  31. a.on("submit(setmyinfo)",
  32. function(t) {
  33. return e.msg(JSON.stringify(t.field)),
  34. !1
  35. });
  36. var r = i("#LAY_avatarSrc");
  37. s.render({
  38. url: "/api/upload/",
  39. elem: "#LAY_avatarUpload",
  40. done: function(t) {
  41. 0 == t.status ? r.val(t.url) : e.msg(t.msg, {
  42. icon: 5
  43. })
  44. }
  45. }),
  46. n.events.avartatPreview = function(t) {
  47. var i = r.val();
  48. e.photos({
  49. photos: {
  50. title: "查看头像",
  51. data: [{
  52. src: i
  53. }]
  54. },
  55. shade: .01,
  56. closeBtn: 1,
  57. anim: 5
  58. })
  59. },
  60. a.on("submit(setmypass)",
  61. function(t) {
  62. // return e.msg(JSON.stringify(t.field)),
  63. // !1
  64. var data = {
  65. "oldPassword":hex_md5(t.field.oldPassword),
  66. "password":hex_md5(t.field.password),
  67. "repassword":hex_md5(t.field.repassword)
  68. }
  69. // layui.admin.req({
  70. n.req({
  71. url:'/login/pw',
  72. type:'post',
  73. data:data,
  74. done:function (res) {
  75. // console.log(res)
  76. layer.msg(res.msg);
  77. i('#LAY_old_password').val('');
  78. i('#LAY_password').val('');
  79. i('#LAY_re_password').val('');
  80. // a.render()
  81. }
  82. })
  83. }),
  84. t("set", {})
  85. });