group_photo.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view>
  3. <view class="main">
  4. <avatar
  5. selWidth="600upx"
  6. selHeight="600upx"
  7. @upload="upload"
  8. :avatarSrc="show_path"
  9. avatarStyle="width: 600upx; height: 600upx; border-radius: 15upx;">
  10. </avatar>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. import avatar from "../../components/yq-avatar/yq-avatar.vue";
  16. import _hook from '../../common/_hook';
  17. import _get from '../../common/_get';
  18. import _data from '../../common/_data';
  19. export default {
  20. components: {
  21. avatar,
  22. },
  23. data() {
  24. return {
  25. show_path: '',
  26. list_id: 0,
  27. }
  28. },
  29. onShow(){
  30. let _this = this;
  31. _hook.routeSonHook();
  32. /** 更新头像上传状态 */
  33. _this.$httpSend({
  34. path: '/im/message/getGroupPhoto',
  35. data: {list_id: _this.list_id },
  36. success(data) {
  37. _this.show_path = _data.staticPhoto() + data;
  38. }
  39. });
  40. },
  41. computed: {
  42. },
  43. methods: {
  44. upload(e){
  45. this.show_path = e.path;
  46. this.send();
  47. },
  48. send(){
  49. let _this = this;
  50. uni.showLoading();
  51. _this.$httpSendFile({
  52. local_url: _this.show_path,
  53. data: { list_id: _this.list_id },
  54. type: 4,
  55. success(data){
  56. /** 更新头像上传状态 */
  57. _this.$httpSend({
  58. path: '/im/message/upGroupPhoto',
  59. data: { list_id: _this.list_id },
  60. success(data) {
  61. /** 更换群头像时,更新会话列表 */
  62. _get.getChatList();
  63. uni.hideLoading();
  64. uni.showToast({
  65. title: '更换成功',
  66. duration: 1000,
  67. });
  68. }
  69. });
  70. },
  71. });
  72. }
  73. },
  74. onLoad(option) {
  75. let _this = this;
  76. _this.list_id = option.list_id;
  77. },
  78. watch: {
  79. },
  80. }
  81. </script>
  82. <style>
  83. .main {
  84. text-align: center;
  85. padding-top: 70upx;
  86. }
  87. </style>