edit.html 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {include file="public/header" /}
  2. <body class="gray-bg">
  3. <div class="layui-fluid layui-col-md12">
  4. <div class="layui-card">
  5. <div class="layui-card-body layui-form">
  6. <div class="layui-row layui-col-space10 layui-form-item ">
  7. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  8. <label class="layui-form-label">编辑公司信息</label>
  9. <div class="layui-input-block">
  10. <textarea name="text" required lay-verify="required" placeholder="请输入" class="layui-textarea">{$data.text}</textarea>
  11. </div>
  12. </div>
  13. <div class="layui-form-item layui-col-md-offset1 layui-col-md8">
  14. <div class="layui-input-block">
  15. <button class="layui-btn" lay-submit="" lay-filter="component-form-element">保存
  16. </button>
  17. <button class="layui-btn layui-btn-primary" onclick="wk.layer_close('close')">关闭</button>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </div>
  23. </div>
  24. {include file="public/footer" /}
  25. <script type="text/javascript" src="__JS__/plugins/cropper/Crop.js"></script>
  26. <script>
  27. //裁剪后的处理
  28. $("#sureCut").on("click",function () {
  29. if ($("#tailoringImg").attr("src") == null ){
  30. layer.msg('请先选择头像',{anim:6})
  31. }else{
  32. var cas = $('#tailoringImg').cropper('getCroppedCanvas');//获取被裁剪后的canvas
  33. var base64url = cas.toDataURL('image/png'); //转换为base64地址形式
  34. $("#img_data").attr('src',base64url).show();
  35. $('#data_photo').val(base64url);
  36. //关闭裁剪框
  37. layer.closeAll();
  38. }
  39. });
  40. </script>
  41. <script>
  42. layui.use(['form'], function() {
  43. var form = layui.form;
  44. form.verify({
  45. username:function(value,item){
  46. if(!/^[\S]{2,10}$/.test(value)){
  47. return '名称必须2到10字符,且不能出现空格';
  48. }
  49. var checkResult = "";
  50. $.ajax({
  51. url:"{:url('User/checkName')}",
  52. type:'post',
  53. data:"username="+value,
  54. async: false,//必须同步
  55. success:function(res){
  56. if(res.code == 100){
  57. checkResult = "该名称已存在";
  58. }
  59. }
  60. })
  61. return checkResult;
  62. },
  63. pass: [/^[\S]{6,16}$/,'密码必须6到16位,且不能出现空格'],
  64. // headCrop:[/^[\S]$/,'头像不能为空'],
  65. // headCrop:function(value,item){
  66. // if(value == ""){
  67. // return '头像不能为空';
  68. // }
  69. // },
  70. realname:[/^[\S]{2,10}$/,'真实姓名必须2到10字符,且不能出现空格']
  71. });
  72. form.on('submit(component-form-element)', function (data) {
  73. $('.layui-btn').addClass('layui-disabled').attr('disabled','disabled');
  74. $.ajax({
  75. url:"{:url('edit')}",
  76. type:'post',
  77. dataType:'json',
  78. data:data.field,
  79. success:function(res){
  80. if (res.code == 200) {
  81. wk.success(res.msg,'wk.layer_close()');
  82. } else {
  83. wk.error(res.msg,'$(".layui-btn").removeClass(\'layui-disabled\').removeAttr(\'disabled\')');
  84. }
  85. }
  86. })
  87. });
  88. });
  89. </script>
  90. <script>
  91. layui.use('layedit', function(){
  92. var layedit = layui.layedit;
  93. layedit.build('demo'); //建立编辑器
  94. });
  95. </script>
  96. </body>
  97. </html>