set.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view class="container">
  3. <view class="body">
  4. <!-- 个人头像区域 -->
  5. <view class="body_box">
  6. 个人头像
  7. <view class="box_right" @click="handleClickPhoto">
  8. <img mode="aspectFill" class="img" :src="imgUrl || '../../static/my/portrait.png'" />
  9. <img class="img2" src="../../static/my/right.png" />
  10. </view>
  11. </view>
  12. <!-- 账号名区域 -->
  13. <view class="body_box" @click="handleClickName">
  14. 账号名
  15. <view class="box_right">
  16. <view class="msg">{{ name }}</view>
  17. <img class="img2" src="../../static/my/right.png" />
  18. </view>
  19. </view>
  20. <!-- ID区域 -->
  21. <view class="body_box">
  22. ID
  23. <view class="box_right">
  24. <view class="msg">1925689</view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. // 头像
  35. imgUrl: '',
  36. // 账号名
  37. name: '张三'
  38. }
  39. },
  40. methods: {
  41. // 点击头像图片回调
  42. handleClickPhoto() {
  43. uni.showActionSheet({
  44. itemList: ['更换头像'],
  45. success: (res) => {
  46. if (res.tapIndex === 0) {
  47. this.changeImg()
  48. }
  49. }
  50. })
  51. },
  52. // 更换头像回调
  53. changeImg() {
  54. uni.chooseImage({
  55. count: 1,
  56. sizeType: ['compressed'],
  57. sourceType: ['album'], //从相册选择
  58. success: (res) => {
  59. // console.log(res.tempFilePaths)
  60. this.imgUrl = res.tempFilePaths[0]
  61. }
  62. })
  63. },
  64. // 点击账号名回调
  65. handleClickName() {
  66. uni.showActionSheet({
  67. itemList: ['修改账号名'],
  68. success: (res) => {
  69. if (res.tapIndex === 0) {
  70. this.changeName()
  71. }
  72. }
  73. })
  74. },
  75. // 修改账号名回调
  76. changeName() {
  77. uni.showModal({
  78. title: '请输入账号名',
  79. editable: true,
  80. success: async (res) => {
  81. if (res.confirm) {
  82. if (!res.content) {
  83. uni.showToast({
  84. title: '账号名不能为空',
  85. icon: 'none'
  86. })
  87. setTimeout(() => {
  88. this.changeName()
  89. }, 1500)
  90. } else {
  91. const result = await this.$myRequest({
  92. url: '/mhotel/ampupdateUserInfo.action',
  93. data: {
  94. userId: uni.getStorageSync('userInfo').id,
  95. userName: res.content,
  96. headPhoto: ''
  97. }
  98. })
  99. console.log(result)
  100. // this.name = res.content
  101. }
  102. }
  103. }
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .container {
  111. display: flex;
  112. flex-direction: column;
  113. min-height: 100vh;
  114. background-color: #ebeced;
  115. .body {
  116. box-sizing: border-box;
  117. margin-top: 20rpx;
  118. padding: 0 30rpx;
  119. height: calc(100vh - 20rpx);
  120. background-color: #fff;
  121. .body_box {
  122. display: flex;
  123. justify-content: space-between;
  124. align-items: center;
  125. height: 100rpx;
  126. font-size: 28rpx;
  127. border-bottom: 1rpx solid #e6e6e6;
  128. .box_right {
  129. display: flex;
  130. justify-content: flex-end;
  131. align-items: center;
  132. height: 100rpx;
  133. .img {
  134. width: 64rpx;
  135. height: 64rpx;
  136. border-radius: 50%;
  137. }
  138. .img2 {
  139. margin-left: 7rpx;
  140. width: 47rpx;
  141. height: 47rpx;
  142. }
  143. .msg {
  144. color: #808080;
  145. }
  146. }
  147. }
  148. }
  149. }
  150. </style>