my.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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" @click="edit">编辑资料</button>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. person: {},
  47. enable: true,
  48. name: ''
  49. }
  50. },
  51. onLoad() {
  52. this.getSelfInfo()
  53. },
  54. methods: {
  55. // 查看个人信息
  56. getSelfInfo() {
  57. this.http.request({
  58. url: '/sp-admin/app/AppUser/getSelfInfo',
  59. success: res => {
  60. this.person = res.data.data
  61. }
  62. });
  63. },
  64. edit(){
  65. uni.showModal({
  66. title: '请输入用户名',
  67. editable: true,
  68. placeholderText: '请输入新的用户名',
  69. success: res => {
  70. if(res.confirm){
  71. this.name = res.content
  72. this.updateUser()
  73. // uni.navigateBack({delta: 1})
  74. }
  75. }
  76. })
  77. },
  78. // 修改个人信息
  79. updateUser(){
  80. let userId = this.getUser().id
  81. let param = {
  82. id: userId,
  83. name: this.name
  84. }
  85. this.http.request({
  86. url: '/sp-admin/app/AppUser/update',
  87. data: param,
  88. method: 'POST',
  89. success: res => {
  90. uni.showModal({
  91. content: '修改成功',
  92. showCancel: false
  93. }),
  94. this.getSelfInfo()
  95. }
  96. });
  97. }
  98. }
  99. }
  100. </script>
  101. <style lang="scss">
  102. page {
  103. background-color: $pg;
  104. }
  105. .con{
  106. background-color: #fff;
  107. margin: 20px;
  108. padding: 10px;
  109. border-radius: 10px;
  110. border: 1px #fff solid;
  111. }
  112. .item{
  113. height: 50px;
  114. display: flex;
  115. align-items: center;
  116. border-bottom: 1px #dcdcdc solid;
  117. .l{
  118. flex: 4;
  119. }
  120. .r{
  121. flex: 10;
  122. }
  123. }
  124. .btn{
  125. width: 80%;
  126. }
  127. </style>