update-setting.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="mx3 pb100">
  3. <view>
  4. <view class="d-flex a-center py2">
  5. <view class="p-relative">
  6. <image src="/static/images/avatar.svg" style="width: 36rpx;height: 36rpx;" mode=""></image>
  7. </view>
  8. <text class="ml-2 f-size-28 f-weight-6">头像</text>
  9. </view>
  10. <view class="d-flex j-between">
  11. <text class="f-size-28 text-color-9" style="width: 400rpx;">请上传清晰规范的头像</text>
  12. <view class="flex1 text-center p-relative border-radius" style="margin-top: -80rpx;width: 200rpx;height: 200rpx;overflow: hidden;" @click="handleUpload">
  13. <image
  14. :src="avatar"
  15. class="border-radius bg-color-light"
  16. @error="myDefaultAvatar"
  17. style="width: 200rpx;height: 200rpx;overflow: hidden;"
  18. mode=""></image>
  19. <!-- <view class="p-absolute bg-color-dark "
  20. style="width: 200rpx;height: 200rpx; left: 0;">
  21. <image src="/sub/static/images/avatar.svg" style="width: 36rpx;height: 36rpx;" mode=""></image>
  22. </view> -->
  23. </view>
  24. </view>
  25. </view>
  26. <!-- 姓名 -->
  27. <view class="mb-2">
  28. <view class="d-flex a-center py2">
  29. <image src="/static/images/name.svg" style="width: 36rpx;height: 36rpx;" mode=""></image>
  30. <text class="ml-2 f-size-28 f-weight-6">姓名</text>
  31. </view>
  32. <view class="d-flex j-between a-center border1" >
  33. <u-input v-model="model.realName" placeholder="请输入姓名" style="flex: 1;" />
  34. </view>
  35. </view>
  36. <!-- 职业类别 -->
  37. <view class="mb-2">
  38. <view class="d-flex a-center py2">
  39. <image src="/static/images/type.svg" style="width: 36rpx;height: 36rpx;" mode=""></image>
  40. <text class="ml-2 f-size-28 f-weight-6">部门</text>
  41. </view>
  42. <view class="d-flex j-between a-center border1">
  43. <u-input v-model="model.deptName" placeholder="请选择部门" disabled @click="industryTypeShow = true" style="flex: 1;" />
  44. <image src="/static/images/select_b.svg" class="w36" mode=""></image>
  45. </view>
  46. </view>
  47. <u-select
  48. v-model="industryTypeShow"
  49. value-name="id"
  50. label-name="title"
  51. child-name="children"
  52. :list="deptList"
  53. mode="mutil-column-auto"
  54. @confirm="industryTypeConfirm"></u-select>
  55. <button
  56. class="main-color-bg text-color-white logout"
  57. @tap="saveInfo">保存</button>
  58. </view>
  59. </template>
  60. <script>
  61. import { getUserInfo } from '@/api'
  62. export default {
  63. data() {
  64. return {
  65. userName: '',
  66. industryTypeShow: false,
  67. userInfo: {},
  68. avatar: null,
  69. model: {
  70. avatar: null,
  71. realName: null,
  72. deptId: null,
  73. deptName: null
  74. },
  75. deptList: {}
  76. }
  77. },
  78. onLoad() {
  79. this.userInfo = this.$BaseTool.UserUtil.getUserInfo();
  80. console.log(333, this.userInfo)
  81. if (this.userInfo.avatar) {
  82. this.avatar = this.$BaseTool.UserUtil.getFileUrl(this.userInfo.avatar);
  83. this.model.avatar = this.userInfo.avatar
  84. }
  85. this.model.realName = this.userInfo.realName
  86. this.model.deptId = this.userInfo.deptId
  87. this.model.deptName = this.userInfo.deptName
  88. // this.$Http.getUserPersonalByUserId(this.userInfo.userId).then(res=>{
  89. // this.model = res.data
  90. // this.avatar = this.model.avatar
  91. // this.model.industryTypeLabel =this.industryTypeMap[this.model.industryType]
  92. // this.model.workYearLabel =this.workYearMap[this.model.workYear]
  93. // this.model.educationLabel =this.educationMap[this.model.education]
  94. // this.model.freeTimeLabel =this.freeTimeMap[this.model.freeTime]
  95. // })
  96. },
  97. created() {
  98. this.$Http.getDeptTree().then(res => {
  99. this.deptList = res.data
  100. console.log(3333, this.deptList)
  101. })
  102. },
  103. methods: {
  104. saveInfo() {
  105. this.model.editType = 1
  106. if (!this.model.realName) {
  107. this.$Message.toast('请输入姓名')
  108. return
  109. }
  110. if (!this.model.deptId) {
  111. this.$Message.toast('请输入部门')
  112. return
  113. }
  114. this.model.deptIds = [this.model.deptId]
  115. this.$Http.updateInfo(this.model).then(res => {
  116. uni.showToast({ icon: 'none', title: '修改成功' })
  117. getUserInfo().then(response => {
  118. uni.setStorage({
  119. key: 'userInfo',
  120. data: response.data,
  121. success: function () {
  122. uni.redirectTo({ url: '/pages/setting/setting?update=true' })
  123. }
  124. });
  125. });
  126. })
  127. },
  128. myDefaultAvatar() {
  129. this.avatar = '/static/images/user_pic.png'
  130. },
  131. // 图片
  132. handleUpload() {
  133. const that = this
  134. this.$Http.uploadImageOpen({ count: 1, type: 1 }).then(res => {
  135. if (res.length > 0) {
  136. that.model.avatar = res[0].url
  137. this.avatar = this.$BaseTool.UserUtil.getFileUrl(that.model.avatar);
  138. }
  139. }, err => {
  140. this.$Message.toast(err.message)
  141. })
  142. },
  143. industryTypeConfirm(e) {
  144. this.model.deptId = e[e.length - 1].value
  145. this.model.deptName = e[e.length - 1].label
  146. }
  147. }
  148. }
  149. </script>
  150. <style>
  151. page {
  152. background-color: #FFFFFF;
  153. }
  154. .border1{
  155. border-bottom: 1px solid #e4e5e4;
  156. }
  157. .w36{
  158. width: 26rpx;height: 26rpx;
  159. }
  160. .button-save {
  161. z-index: 5;
  162. position: fixed;
  163. }
  164. </style>