index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>{$user_login} - 企业信息</title>
  5. <meta name="keywords" content=""/>
  6. <meta name="description" content="">
  7. <include file="public@head"/>
  8. </head>
  9. <body class="body-white" id="top">
  10. <include file="public@nav" />
  11. <div class="container tc-main">
  12. <div class="row">
  13. <div class="col-md-3">
  14. <include file="public@usernav" />
  15. </div>
  16. <div class="col-md-9">
  17. <div class="tabs">
  18. <ul class="nav nav-tabs">
  19. <li class="active"><a href="#one" data-toggle="tab"><i class="fa fa-edit"></i> 企业信息</a></li>
  20. </ul>
  21. <div class="tab-content">
  22. <div class="tab-pane active" id="one">
  23. <br>
  24. <form class="js-ajax-form" action="{:url('user/profile/editPost')}" method="post">
  25. <div class="form-group">
  26. <label for="input-user_nickname">企业名称</label>
  27. <input type="text" class="form-control" id="input-companyname" placeholder="企业名称" name="companyname" value="{$companyname}">
  28. </div>
  29. <!-- <div class="form-group">
  30. <label for="input-sex">性别</label>
  31. <php>
  32. $sexs=array("0"=>"保密","1"=>"程序猿","2"=>"程序媛");
  33. </php>
  34. <select class="form-control" id="input-sex" name="sex">
  35. <foreach name="sexs" item="vo">
  36. <php>$sexselected=$key==$sex?"selected":"";</php>
  37. <option value="{$key}" {$sexselected}>{$vo}</option>
  38. </foreach>
  39. </select>
  40. </div>
  41. <div class="form-group">
  42. <label for="input-birthday">生日</label>
  43. <input class="form-control js-bootstrap-date" type="text" id="input-birthday" placeholder="2013-01-04" name="birthday" value="{:date('Y-m-d',$birthday)}">
  44. </div>
  45. <div class="form-group">
  46. <label for="input-user_url">个人网址</label>
  47. <input class="form-control" type="text" id="input-user_url" placeholder="http://thinkcmf.com" name="user_url" value="{$user_url}">
  48. </div>
  49. <div class="form-group">
  50. <label for="input-signature">个性签名</label>
  51. <textarea class="form-control" id="input-signature" placeholder="个性签名" name="signature">{$signature}</textarea>
  52. </div> -->
  53. <div class="form-group">
  54. <label for="input-user_nickname">联系人姓名</label>
  55. <input type="text" class="form-control" id="input-contactname" placeholder="联系人姓名" name="contactname" value="{$contactname}">
  56. </div>
  57. <div class="form-group">
  58. <label for="input-user_nickname">联系人电话</label>
  59. <input type="text" class="form-control" id="input-telno" placeholder="联系人电话" name="telno" value="{$telno}">
  60. </div>
  61. <div class="form-group">
  62. <label for="input-user_nickname" >营业执照</label>
  63. <div class="img_div">
  64. <div id="jqueryCropper" class="avatar-cropper">
  65. <img id="userAvatarImage" src="{$licensephoto}">
  66. </div>
  67. <div class="btn-group">
  68. <label class="btn btn-primary eventBtn" for="inputImage" title="打开图片">
  69. <input type="file" class="sr-only" id="inputImage" name="file" accept=".jpg,.jpeg,.png">
  70. <span class="fa fa-upload"></span> 上传
  71. </label>
  72. <button type="button" class="btn btn-primary eventBtn" role="group" data-method="reset" title="重置图片"><span class="fa fa-refresh"></span> 重置</button>
  73. <button type="button" class="btn btn-primary eventBtn btnsave" role="group" title="保存图片" id="saveavatar"></span> 保存图片</button>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="form-group">
  78. <button id="saveinfo" type="button" class="btn btn-success btn-lg btn-block btnsave1 eventBtn"><i class="fa fa-save"></i> 确认保存</button>
  79. </div>
  80. </form>
  81. </div>
  82. </div>
  83. </div>
  84. </div>
  85. </div>
  86. <include file="public@footer" />
  87. </div>
  88. <!-- /container -->
  89. <include file="public@scripts" />
  90. <style>
  91. .img_div{
  92. display: flex;
  93. flex-direction: row;
  94. align-items: flex-end;
  95. }
  96. .img_div .btn-group{
  97. padding-left: 1em;
  98. }
  99. #jqueryCropper{
  100. width: 50%;
  101. border: 1px solid #333;
  102. min-height: 200px;
  103. }
  104. #jqueryCropper img{
  105. object-fit: cover;
  106. width: 100%;
  107. }
  108. </style>
  109. <script type="text/javascript">
  110. <php>
  111. $uploadedImageName = empty($avatar) ? '' : 'temp_image.jpg';
  112. $licensephoto = empty($licensephoto) ? '' :$avatar;
  113. $userid = $user['id'];
  114. </php>
  115. var nzi = $('#userAvatarImage');
  116. var n2i = $('#inputImage');
  117. var originalImageURL = n2i.attr('src');
  118. var uploadedImageName = '{$uploadedImageName}';
  119. var uploadedImageType = 'image/jpeg';
  120. var uploadedImageURL = '';
  121. var uploadFile = '';
  122. var licensephoto='{$licensephoto}'
  123. let userid = '{$userid}'
  124. n2i.change(function () {
  125. var files = this.files;
  126. var file;
  127. if (files && files.length) {
  128. file = files[0];
  129. if (/^image\/\w+$/.test(file.type)) {
  130. uploadedImageName = file.name;
  131. uploadedImageType = file.type;
  132. if (uploadedImageURL) {
  133. URL.revokeObjectURL(uploadedImageURL);
  134. }
  135. uploadedImageURL = URL.createObjectURL(file);
  136. nzi.attr('src', uploadedImageURL);
  137. n2i.val('');
  138. uploadFile = file;
  139. } else {
  140. window.alert('Please choose an image file.');
  141. }
  142. }
  143. })
  144. $('#saveinfo').on('click',function(){
  145. let url ="{:cmf_url('portal/Companyinfo/addenterpriseapplyjoinplatform')}";
  146. var companyname = $('#input-companyname').val();
  147. var contactname = $('#input-contactname').val();
  148. var telno = $('#input-telno').val();
  149. let data= {
  150. userid:userid,
  151. licensephoto:licensephoto,
  152. companyname:companyname,
  153. contactname:contactname,
  154. telno:telno
  155. }
  156. console.log(data)
  157. $.ajax(url, {
  158. method: "POST",
  159. data: data,
  160. success: function (e) {
  161. console.log(e);
  162. console.log(e.code)
  163. if(1==e.code){
  164. noty({text: e.msg,type: 'success',layout: 'center'})
  165. }else{
  166. noty({text: e.msg,type: 'error',layout: 'center'})
  167. }
  168. },
  169. error: function (e) {
  170. console.log(e);
  171. }
  172. })
  173. })
  174. $('#saveavatar').on('click',function (){
  175. // 禁用所有控件
  176. $('.eventBtn').prop('disabled', true);
  177. $('.btnsave').html('<i class="fa fa-spinner fa-pulse fa-fw"></i> 上传中');
  178. // 判断是否有数据
  179. // let tmp_img = nzi.cropper('getCroppedCanvas',{width: 512,height: 512})
  180. if(!uploadFile) alert('请上传图片。');
  181. var formData = new FormData();
  182. formData.append('file',uploadFile);
  183. $url="https://app.tjzhxx.cn:5443/api/Cos/savephoto";
  184. $.ajax($url, {
  185. method: "POST",
  186. data: formData,
  187. processData: false,
  188. contentType: false,
  189. success: function (e) {
  190. console.log(e)
  191. let data = JSON.parse(e);
  192. console.log(data)
  193. if(1==data.status){
  194. let path = data.data.path
  195. licensephoto = path
  196. console.log(licensephoto)
  197. }else{
  198. noty({text: data.msg,type: 'error',layout: 'center'})
  199. }
  200. // delay_url = e.url
  201. // noty({text: e.msg,type: ((e.code == 0) ? 'error' : 'success'),layout: 'center'})
  202. $('.eventBtn').prop('disabled', false);
  203. $('.btnsave').html('<i class="fa fa-save"></i> 确认保存');
  204. // if(e.url != '') {
  205. // setTimeout(function(){ window.location.href = e.url }, (e.wait-1)*1000)
  206. // }
  207. console.log(e)
  208. },
  209. error: function (e) {
  210. noty({text: '网络连接失败。',type: 'error',layout: 'center'})
  211. $('.eventBtn').prop('disabled', false);
  212. $('.btnsave').html('<i class="fa fa-save"></i> 确认保存');
  213. nzi.cropper('enable')
  214. }
  215. })
  216. // 转blob上传
  217. // uploadedImageURL.toBlob(function (blob){
  218. // // 创建form
  219. // var formData = new FormData();
  220. // formData.append('file', blob, uploadedImageName);
  221. // // 禁用cropper
  222. // // nzi.cropper('disable')
  223. // // ajax 上传
  224. // Wind.use("noty", function () {
  225. // $url="https://app.tjzhxx.cn:5443/api/Cos/savephoto";
  226. // $.ajax($url, {
  227. // method: "POST",
  228. // data: formData,
  229. // processData: false,
  230. // contentType: false,
  231. // success: function (e) {
  232. // delay_url = e.url
  233. // noty({text: e.msg,type: ((e.code == 0) ? 'error' : 'success'),layout: 'center'})
  234. // $('.eventBtn').prop('disabled', false);
  235. // $('.btnsave').html('<i class="fa fa-save"></i> 确认保存');
  236. // if(e.url != '') {
  237. // setTimeout(function(){ window.location.href = e.url }, (e.wait-1)*1000)
  238. // }
  239. // console.log(e)
  240. // },
  241. // error: function (e) {
  242. // noty({text: '网络连接失败。',type: 'error',layout: 'center'})
  243. // $('.eventBtn').prop('disabled', false);
  244. // $('.btnsave').html('<i class="fa fa-save"></i> 确认保存');
  245. // nzi.cropper('enable')
  246. // }
  247. // })
  248. // })
  249. // }, "image/jpeg", 0.85);
  250. });
  251. </script>
  252. </body>
  253. </html>