personalData.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="wrap">
  3. <view class="info-wrap">
  4. <uni-list>
  5. <view class="uni-list-item-custom" @click="handle('avatar')">
  6. <view class="headline">头像</view>
  7. <image class="slot-image" :src="avatar" mode="widthFix" @error="avatar=defaultAvatar"></image>
  8. </view>
  9. <uni-list-item title="姓名" :rightText="name" clickable @click="handle('name')" showArrow></uni-list-item>
  10. <uni-list-item title="职称" :rightText="doctorTitle" clickable @click="handle('doctorTitle')" showArrow></uni-list-item>
  11. <uni-list-item title="所属医院" :rightText="hospital" clickable @click="handle('hospital')" showArrow></uni-list-item>
  12. <uni-list-item title="邮箱" :rightText="email" clickable @click="handle('email')" showArrow></uni-list-item>
  13. <uni-list-item title="手机号码" :rightText="phone" @click="handle('phone')"></uni-list-item>
  14. <!-- <uni-list-item title="生日" :rightText="birthday" clickable @click="handle('birthday')"></uni-list-item> -->
  15. </uni-list>
  16. </view>
  17. <uni-popup ref="popup" type="dialog" style="top">
  18. <view class="uni-popup-dialog-wrap">
  19. <uni-popup-dialog mode="input"
  20. class="uni-popup-dialog"
  21. v-model="updateValue"
  22. :duration="2000"
  23. :before-close="true"
  24. placeholder="请输入修改信息"
  25. @close="close"
  26. @confirm="confirm">
  27. </uni-popup-dialog>
  28. </view>
  29. </uni-popup>
  30. </view>
  31. </template>
  32. <script>
  33. import {isEmpty} from '@/libs';
  34. import {getDetailByIdApi,updateDoctor} from '@/api/doctor';
  35. export default {
  36. data() {
  37. return {
  38. defaultAvatar:"/static/components/avatar.png",
  39. avatar:"",
  40. name:"",
  41. doctorTitle:"",
  42. hospital:"",
  43. phone:"",
  44. email:"",
  45. birthday:"",
  46. updateValue:"",
  47. form:{}
  48. }
  49. },
  50. onShow() {
  51. this.init();
  52. },
  53. methods: {
  54. init(){
  55. this.getDetailById();
  56. },
  57. getDetailById(){
  58. let user=uni.getStorageSync('accountInfo');
  59. if(user){user=JSON.parse(user)}
  60. let userId=user.userId;
  61. getDetailByIdApi(userId).then((res)=>{
  62. let {email,birthday,doctorTitle,name,avatar,phone,hospital}=res.data;
  63. this.avatar=avatar||this.defaultAvatar;
  64. this.name=name;
  65. this.doctorTitle=doctorTitle;
  66. this.birthday=birthday;
  67. this.phone=phone;
  68. this.hospital=hospital;
  69. this.email=email;
  70. this.form=res.data;
  71. })
  72. },
  73. handle(type){
  74. if(type==='avatar'){
  75. this.updateAvatar();
  76. }else{
  77. this.updateValue=isEmpty(this.form[type])?'':this.form[type];
  78. this.type=type;
  79. this.open();
  80. }
  81. },
  82. updateAvatar(){
  83. uni.chooseImage({
  84. complete() {
  85. }
  86. })
  87. },
  88. open() {
  89. this.$refs.popup.open();
  90. },
  91. close() {
  92. this.$refs.popup.close()
  93. },
  94. confirm(value) {
  95. if(isEmpty(value)){
  96. uni.showToast({
  97. icon:"none",
  98. title:'请填写修改内容'
  99. })
  100. return;
  101. }
  102. let params={...this.form};
  103. params[this.type]=value;
  104. updateDoctor(params).then((res)=>{
  105. uni.showToast({
  106. icon:"none",
  107. title:'修改成功!',
  108. complete: () => {
  109. this.getDetailById();
  110. this.close();
  111. }
  112. })
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .wrap{
  120. .info-wrap{
  121. // margin-top: 20upx;
  122. background-color: #f8f8f8;
  123. .slot-image{
  124. display: block;
  125. width: 90upx;
  126. height: 90upx;
  127. border-radius: 50%;
  128. }
  129. .uni-list-item-custom{
  130. display: flex;
  131. justify-content: space-between;
  132. align-items: center;
  133. padding: 12rpx 15px;
  134. padding-left: 15px;
  135. border-bottom: 1px solid #e7e7e7;
  136. .headline{
  137. font-size: 14px;
  138. color: #3b4144;
  139. overflow: hidden;
  140. }
  141. }
  142. }
  143. .uni-popup-dialog-wrap{
  144. margin-top: -180upx;
  145. }
  146. }
  147. </style>