my.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view>
  3. <view class="con">
  4. <view class="item">
  5. <view class="l">用户名:</view>
  6. <input class="r" v-model="person.name" :disabled="enable" />
  7. </view>
  8. <view class="item">
  9. <view class="l">性别:</view>
  10. <input class="r" v-model="person.genderName" :disabled="enable" />
  11. </view>
  12. <view class="item">
  13. <view class="l">年龄:</view>
  14. <input class="r" v-model="person.age" :disabled="enable" />
  15. </view>
  16. <view class="item">
  17. <view class="l">手机号:</view>
  18. <input class="r" v-model="person.phone" :disabled="enable" />
  19. </view>
  20. <view class="item">
  21. <view class="l">互助组:</view>
  22. <input class="r" v-model="person.groupName" :disabled="enable" />
  23. </view>
  24. <view class="item">
  25. <view class="l">角色:</view>
  26. <input class="r" v-model="person.roleName" :disabled="enable" />
  27. </view>
  28. <view class="item">
  29. <view class="l">贸易区域:</view>
  30. <input class="r" v-model="person.tradeAreaName" :disabled="enable" />
  31. </view>
  32. <view class="item" style="border: none;">
  33. <view class="l">地址:</view>
  34. <input class="r" v-model="person.address" :disabled="enable" />
  35. </view>
  36. </view>
  37. <view>
  38. <button class="btn" v-if="btnTitle=='编辑资料'" @click="edit">{{btnTitle}}</button>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. person: {},
  47. enable: true,
  48. btnTitle: '编辑资料',
  49. name: ''
  50. }
  51. },
  52. onLoad() {
  53. this.getSelfInfo()
  54. },
  55. methods: {
  56. // 查看个人信息
  57. getSelfInfo() {
  58. this.http.request({
  59. url: '/sp-admin/app/AppUser/getSelfInfo',
  60. success: res => {
  61. this.person = res.data.data
  62. }
  63. });
  64. },
  65. edit(){
  66. this.enable = false
  67. this.btnTitle = '确认修改'
  68. uni.showModal({
  69. title: '请输入用户名',
  70. editable: true,
  71. placeholderText: '请输入用户名',
  72. success: res => {
  73. if(res.confirm){
  74. this.name = res.content
  75. this.updateUser()
  76. }
  77. }
  78. })
  79. },
  80. // 修改个人信息
  81. updateUser(){
  82. let userId = this.getUser().id
  83. let param = {
  84. id: userId,
  85. name: this.name
  86. }
  87. this.http.request({
  88. url: '/sp-admin/app/AppUser/update',
  89. data: param,
  90. method: 'POST',
  91. success: res => {
  92. uni.showModal({
  93. content: '修改成功',
  94. showCancel: false
  95. }),
  96. this.getSelfInfo()
  97. }
  98. });
  99. }
  100. }
  101. }
  102. </script>
  103. <style lang="scss">
  104. page {
  105. background-color: $pg;
  106. }
  107. .con{
  108. background-color: #fff;
  109. margin: 20px;
  110. padding: 10px;
  111. border-radius: 10px;
  112. border: 1px #fff solid;
  113. }
  114. .item{
  115. height: 50px;
  116. display: flex;
  117. align-items: center;
  118. border-bottom: 1px #dcdcdc solid;
  119. .l{
  120. flex: 4;
  121. }
  122. .r{
  123. flex: 10;
  124. }
  125. }
  126. .btn{
  127. width: 80%;
  128. }
  129. </style>