add.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <fieldset class="layui-elem-field layui-field-title">
  5. <legend>{$title}</legend>
  6. </fieldset>
  7. <form class="layui-form layui-form-pane" lay-filter="form">
  8. <div class="layui-form-item">
  9. <label class="layui-form-label">所属等级</label>
  10. <div class="layui-input-inline">
  11. <select name="level_id" lay-verify="required">
  12. <option value="">请选择等级</option>
  13. {volist name="userLevel" id="vo"}
  14. <option value="{$vo.id}" {if !empty($info) && $info.level_id==$vo.id} selected {/if} >{$vo.level_name}</option>
  15. {/volist}
  16. </select>
  17. </div>
  18. </div>
  19. <div class="layui-form-item">
  20. <label class="layui-form-label">昵称</label>
  21. <div class="layui-input-inline">
  22. <input type="text" name="username" lay-verify="required" placeholder="{:lang('pleaseEnter')}昵称" class="layui-input">
  23. </div>
  24. <div class="layui-form-mid layui-word-aux">
  25. 在4到25个字符之间。
  26. </div>
  27. </div>
  28. <div class="layui-form-item">
  29. <label class="layui-form-label">手机</label>
  30. <div class="layui-input-inline">
  31. <input type="text" name="mobile" placeholder="{:lang('pleaseEnter')}手机" lay-verify="phone" class="layui-input">
  32. </div>
  33. <div class="layui-form-mid layui-word-aux">
  34. 必须是正确的手机号
  35. </div>
  36. </div>
  37. <div class="layui-form-item">
  38. <label class="layui-form-label">{:lang('email')}</label>
  39. <div class="layui-input-inline">
  40. <input type="text" name="email" placeholder="{:lang('pleaseEnter')}{:lang('email')}" lay-verify="email" class="layui-input">
  41. </div>
  42. </div>
  43. <div class="layui-form-item">
  44. <label class="layui-form-label">头像</label>
  45. <input type="hidden" name="avatar" id="avatar">
  46. <div class="layui-input-inline">
  47. <div class="layui-upload">
  48. <button type="button" class="layui-btn layui-btn-primary" id="addBtn"><i class="icon icon-upload3"></i>点击上传</button>
  49. <div class="layui-upload-list">
  50. <img class="layui-upload-img" id="addPic">
  51. <p id="notice"></p>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. <div class="layui-form-item">
  57. <label class="layui-form-label">{:lang('email')}</label>
  58. <div class="layui-input-inline">
  59. <input type="text" name="link_email" lay-verify="email" placeholder="{:lang('pleaseEnter')}邮箱" class="layui-input">
  60. </div>
  61. </div>
  62. <div class="layui-form-item">
  63. <label class="layui-form-label">{:lang('sex')}</label>
  64. <div class="layui-input-block">
  65. <input type="radio" name="sex" lay-filter="sex" checked value="1" title="男">
  66. <input type="radio" name="sex" lay-filter="sex" value="2" title="女">
  67. <input type="radio" name="sex" lay-filter="sex" value="0" title="保密">
  68. </div>
  69. </div>
  70. <div class="layui-form-item">
  71. <div class="layui-input-inline">
  72. <input type="hidden" name="id" >
  73. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
  74. <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
  75. </div>
  76. </div>
  77. </form>
  78. </div>
  79. </div>
  80. {include file="common/footer"/}
  81. <script>
  82. layui.use(['form', 'layer','upload','laydate'], function () {
  83. var form = layui.form, laydate=layui.laydate,layer = layui.layer,$= layui.jquery,upload = layui.upload;
  84. var info = '';
  85. //日期范围
  86. laydate.render({
  87. elem: '#date'
  88. ,range: true
  89. });
  90. info = {:json_encode($info)};
  91. form.val("form", info);
  92. if(info){
  93. $('#addPic').attr('src',info.avatar);
  94. }
  95. form.render();
  96. form.on('submit(submit)', function (data) {
  97. loading =layer.load(1, {shade: [0.1,'#fff']});
  98. $.post("", data.field, function (res) {
  99. layer.close(loading);
  100. if (res.code > 0) {
  101. layer.msg(res.msg, {time: 1800, icon: 1}, function () {
  102. location.href = res.url;
  103. });
  104. } else {
  105. layer.msg(res.msg, {time: 1800, icon: 2});
  106. }
  107. });
  108. });
  109. //普通图片上传
  110. var uploadInt = upload.render({
  111. elem: '#addBtn'
  112. ,url: '{:url("uploads/uploads")}'
  113. ,before: function(obj){
  114. //预读本地文件示例,不支持ie8
  115. obj.preview(function(index, file, result){
  116. $('#addPic').attr('src', result); //图片链接(base64)
  117. });
  118. },
  119. done: function(res){
  120. if(res.code>0){
  121. $('#avatar').val(res.url);
  122. }else{
  123. //如果上传失败
  124. return layer.msg('上传失败');
  125. }
  126. }
  127. ,error: function(){
  128. //演示失败状态,并实现重传
  129. var notice = $('#notice');
  130. notice.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
  131. notice.find('.demo-reload').on('click', function(){
  132. uploadInt.upload();
  133. });
  134. }
  135. });
  136. });
  137. </script>