profile.lbi 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. {include file="{$_lang.moban}/library/member_paths.lbi"}
  2. <style>
  3. .head_img_container{
  4. width: 120px;
  5. max-height: 120px;
  6. text-align: center;
  7. border: 1px solid #e4e4e4;
  8. }
  9. .head_img_desc ol li{
  10. line-height: 30px;
  11. color:#656565;
  12. }
  13. label{
  14. text-align: center;
  15. }
  16. </style>
  17. <div class="works-container">
  18. <div class="container container_works" style="margin-top: 0;">
  19. <div class="row row_margin_bottom " style="margin-top: 0px;">
  20. <div class="col-md-10 advanced-setting-block" style="padding-top:10px;padding-bottom:10px;">
  21. <form class="form-horizontal" id="profile_form" action="/member/profile">
  22. <input type="hidden" name="act" value="edit">
  23. <div class="form-group">
  24. <label class="col-md-2 col-md-offset-1" style="line-height: 108px;text-align: center;">头像</label>
  25. <div class="col-md-2 col-sm-4">
  26. <div class="head_img_container">
  27. <img src="{$profile.avatar}" id="head_img">
  28. </div>
  29. </div>
  30. <div class="col-md-4 head_img_desc">
  31. <ol>
  32. <li>建议图片大小为120*120 px</li>
  33. <li>图片比例为1:1,大小不超过200KB</li>
  34. <li>允许上传JPG,PNG格式的图片</li>
  35. </ol>
  36. <input id="head_img_btn" type="file" />
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label class="col-sm-2 col-md-offset-1">手机号</label>
  41. <div class="col-md-6 col-sm-10">
  42. <input type="text" class="form-control" value="{$profile.phone}" disabled>
  43. </div>
  44. </div>
  45. <div class="form-group">
  46. <label for="nickname" class="col-sm-2 col-md-offset-1">昵称</label>
  47. <div class="col-md-6 col-sm-10">
  48. <input type="text" class="form-control" name="nickname" value="{$profile.nickname}" maxlength="32">
  49. </div>
  50. </div>
  51. <!-- <div class="form-group">
  52. <label for="province" class="col-sm-2">地址</label>
  53. <div class="col-sm-3">
  54. <select class="form-control" id="province">
  55. <option>北京</option>
  56. <option>上海</option>
  57. </select>
  58. </div>
  59. <div class="col-sm-3">
  60. <input type="text" class="form-control" id="exampleInputAddress2" placeholder="市/县">
  61. </div>
  62. </div> -->
  63. <div class="form-group">
  64. <div class="col-sm-offset-3 col-md-3">
  65. <button type="button" id="sub_btn" class="btn btn-primary btn-block" onclick="ajaxFormSubmit('profile_form')">保存</button>
  66. </div>
  67. </div>
  68. </form>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <!-- <div style="display: none;" data-keyboard="false" data-backdrop="static" id="imgCutterModal" class="modal fade" aria-hidden="true">
  74. </div> -->
  75. <div class="modal fade" id="imgCutterModal" data-backdrop="static">
  76. <div class="modal-dialog modal-lg">
  77. <div class="modal-content">
  78. <div style="width:100%;height:100%;position:relative">
  79. <div class="img-cutter" id="imgCutter">
  80. <div class="canvas" ><img id="cutterImg" src=""></div>
  81. <div class="actions">
  82. <h5>拖拽来剪切图片</h5>
  83. <button type="button" class="btn btn-primary img-cutter-submit">确认</button>
  84. <button type="button" data-dismiss="modal" class="btn btn-primary">取消</button>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <link rel="stylesheet" href="/static/css/fileinput.min.css">
  92. <link rel="stylesheet" href="/static/css/zui.imgcutter.css">
  93. <script src="/static/js/fileinput-v4.34.js"></script>
  94. <script src="/static/js/fileinput_locale_zh.js"></script>
  95. <script src="/static/js/zui.imgcutter.js"></script>
  96. <script>
  97. {literal}
  98. var cutterParam ={};
  99. $(function(){
  100. $("#head_img_btn").fileinput({
  101. language: 'zh',
  102. showUpload: false, // hide upload button
  103. showRemove: false, // hide remove button
  104. showCancel: false,
  105. showPreview: false,
  106. showCaption: false,
  107. browseClass: "btn btn-primary",
  108. browseLabel: "上传头像",
  109. browseIcon: "<i class=\"icon-file-image\"></i>",
  110. allowedFileExtensions: ["jpg","png"],
  111. //uploadUrl: "http://upload.qiniu.com/",
  112. uploadUrl: "/member/profile",
  113. uploadAsync: false,
  114. textEncoding: "UTF-8",
  115. uploadExtraData: function(){
  116. cutterParam.act="update_head_img";
  117. return cutterParam;
  118. }
  119. }).on('fileloaded', function(event, file, previewId, index, reader) {
  120. //重置token,以便再次获取
  121. tokenObj = {};
  122. //校验文件长宽
  123. var objUrl = window.URL || window.webkitURL;
  124. var url = objUrl.createObjectURL(file);
  125. var img = new Image();
  126. img.src = url;
  127. img.onload = function(){
  128. if(img.naturalWidth < 100 || img.naturalHeight < 100 ){
  129. alert_notice("图片尺寸小于100*100像素");
  130. $("#head_img_btn").fileinput("clear");
  131. return;
  132. }
  133. if(file.size > 300*1024){
  134. alert_notice("图片大小不应超过300KB");
  135. $("#errorMsgDiv").show();
  136. $("#head_img_btn").fileinput("clear");
  137. return ;
  138. }
  139. $("#errorMsgDiv").hide();
  140. $("#cutterImg").attr("src",url);
  141. $("#imgCutter").find(".cliper").find("img").attr("src",url);
  142. var $imgCutterInfo = $('.img-cutter-info');
  143. $("#imgCutter").imgCutter({
  144. coverColor:'#000',
  145. coverOpacity : 0.5,
  146. defaultWidth :200,
  147. defaultHeight :200,
  148. fixedRatio:true,
  149. minWidth : 120,
  150. minHeight : 120,
  151. fixedRatio:true,
  152. before:function(e){
  153. cutterParam.width = Math.floor(e.width); //裁剪后的宽度
  154. cutterParam.height = Math.floor(e.height);//裁剪后的高度
  155. cutterParam.left = Math.floor(e.left);//裁剪位置距离左侧的距离
  156. cutterParam.top = Math.floor(e.top); //裁剪位置距离上边的距离
  157. $("#imgCutterModal").modal("hide");
  158. //调用上传按钮
  159. $("#head_img_btn").fileinput("upload");
  160. },
  161. });
  162. $("#imgCutterModal").modal("show");
  163. }
  164. }).on('filebatchuploadsuccess', function (event, data) {
  165. var response = data.response;
  166. if(response.status == '1'){
  167. alert_notice("头像上传成功","success");
  168. $("#head_img").attr("src",response.imgsrc);
  169. }
  170. }).on('filebatchuploaderror', function (event, data, previewId, index) {
  171. console.log("upload fail response:"+JSON.stringify(data));
  172. });
  173. })
  174. {/literal}
  175. </script>