set.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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: (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. this.name = res.content
  92. }
  93. }
  94. }
  95. })
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .container {
  102. display: flex;
  103. flex-direction: column;
  104. min-height: 100vh;
  105. background-color: #ebeced;
  106. .body {
  107. box-sizing: border-box;
  108. margin-top: 20rpx;
  109. padding: 0 30rpx;
  110. height: calc(100vh - 20rpx);
  111. background-color: #fff;
  112. .body_box {
  113. display: flex;
  114. justify-content: space-between;
  115. align-items: center;
  116. height: 100rpx;
  117. font-size: 28rpx;
  118. border-bottom: 1rpx solid #e6e6e6;
  119. .box_right {
  120. display: flex;
  121. justify-content: flex-end;
  122. align-items: center;
  123. height: 100rpx;
  124. .img {
  125. width: 64rpx;
  126. height: 64rpx;
  127. border-radius: 50%;
  128. }
  129. .img2 {
  130. margin-left: 7rpx;
  131. width: 47rpx;
  132. height: 47rpx;
  133. }
  134. .msg {
  135. color: #808080;
  136. }
  137. }
  138. }
  139. }
  140. }
  141. </style>