edit_avatar.blade.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. @extends('layouts.app')
  2. @section('title', '修改头像')
  3. @section('content')
  4. <div class="ui centered grid container stackable">
  5. @include('pages.users._left', ['_left'=> ['active'=> 'edit_avatar']])
  6. <div class="twelve wide column">
  7. <div class="ui stacked segment">
  8. <div class="content px-3 py-3">
  9. <h1>
  10. <i class="icon image" aria-hidden="true"></i> 修改头像
  11. </h1>
  12. <div class="ui divider"></div>
  13. <form class="ui form"
  14. method="POST"
  15. action="{{ route('users.update_avatar', $user->id) }}"
  16. enctype="multipart/form-data"
  17. accept-charset="UTF-8">
  18. <input name="_method" type="hidden" value="PATCH">
  19. <input type="hidden" name="_token" value="{{ csrf_token() }}">
  20. <input type="hidden" name="image_id" value="{{ old('image_id', $user->info->image_id) }}">
  21. <div>
  22. <img id="upload-img"
  23. class="upload-img image-border ui popover"
  24. data-variation="inverted"
  25. data-content="【点击我】上传图片吧"
  26. src="{{ default_img(isset($user->info->image->path) ? $user->info->image->path : '') }}" width="320">
  27. </div>
  28. <div class="filed mt-3">
  29. <button class="ui button primary" id="upload-button" type="submit">更新头像资料</button>
  30. </div>
  31. </form>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. @endsection
  37. @section('script')
  38. <script type="text/javascript">
  39. $("#upload-img").click(function () {
  40. let self = this;
  41. new MyUploadOne({
  42. 'file_type': 'avatar',
  43. success: function (res) {
  44. let path = assert_images(res.data.path);
  45. $(self).attr('src', path);
  46. $(self).closest('form').find("input[name='image_id']").val(res.data.id);
  47. }
  48. });
  49. });
  50. </script>
  51. @endsection