index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <view class="container">
  3. <view class="back-btn" @click="backToBefore()">
  4. <u-icon name="arrow-left" color="#fff" size="20" customStyle="margin:0 auto"></u-icon>
  5. <text class="back-text">编辑信息</text>
  6. </view>
  7. <view class="avatar" @click="changeAvatar()">
  8. <image src="@/static/images/profile.jpg" mode=""></image>
  9. <view class="avatar-description">更换</view>
  10. </view>
  11. <view class="info-area">
  12. <view class="info-item">
  13. 姓名
  14. <input type="text" v-model="userName">
  15. </view>
  16. <view class="info-item" @click="showSexChoose()">
  17. 性别
  18. <view class="info-item-content">
  19. <view v-if="userSex">{{userSex}}</view>
  20. <view v-else class="remind-text">请选择性别</view>
  21. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  22. </view>
  23. </view>
  24. <view class="info-item" @click="showBirChoose()">
  25. 出生年月
  26. <view class="info-item-content">
  27. <view v-if="userBir">{{userBir}}</view>
  28. <view v-else class="remind-text">请选择出生年月</view>
  29. <u-icon name="arrow-right" color="#343437" size="16" customStyle="margin-left:10rpx"></u-icon>
  30. </view>
  31. </view>
  32. </view>
  33. <!-- 性别 -->
  34. <u-picker :show="sexShow" :columns="sexList" @confirm="sexClose" @cancel="sexClose"></u-picker>
  35. <!-- 年龄 -->
  36. <u-datetime-picker :show="birShow" @confirm="birClose" @cancel="birClose" v-model="userBirStamp"
  37. mode="date"></u-datetime-picker>
  38. </view>
  39. </template>
  40. <script setup>
  41. import {
  42. ref
  43. } from 'vue'
  44. import {
  45. onLoad
  46. } from "@dcloudio/uni-app"
  47. import {
  48. getInfo
  49. } from "@/api/login.js"
  50. import {
  51. timeFormat
  52. } from "@/utils/timeFormatter.js"
  53. function backToBefore() {
  54. uni.navigateBack({})
  55. };
  56. let userInfo = ref({})
  57. let userName = ref(null)
  58. let userSex = ref(null)
  59. let userBir = ref(null)
  60. // ====================================选择性别
  61. let sexList = ref([
  62. ["男", "女"]
  63. ])
  64. let sexShow = ref(false)
  65. function showSexChoose() {
  66. sexShow.value = true
  67. }
  68. function sexClose(e) {
  69. if (e) userSex.value = e.value[0];
  70. sexShow.value = false;
  71. }
  72. // ====================================选择年月
  73. let userBirStamp = ref(null)
  74. let birShow = ref(false)
  75. function showBirChoose() {
  76. birShow.value = true
  77. }
  78. function birClose(e) {
  79. if (e) {
  80. let time = timeFormat(e.value)
  81. userBir.value = time
  82. }
  83. birShow.value = false
  84. }
  85. function changeAvatar() {
  86. uni.showToast({
  87. title: "功能建设中...",
  88. icon: "none",
  89. duration: 2000
  90. })
  91. }
  92. onLoad(() => {
  93. getInfo().then(res => {
  94. userInfo.value = res.data.user;
  95. userName.value = userInfo.value.realName;
  96. })
  97. })
  98. </script>
  99. <style lang="scss" scoped>
  100. page {
  101. height: 100%;
  102. background-color: #EAF0FA;
  103. }
  104. .container {
  105. position: relative;
  106. width: 100%;
  107. height: 100%;
  108. background: linear-gradient(180deg, #1869F6 0%, #EAF0FA 64%, #EAF0FA 100%);
  109. .back-btn {
  110. position: absolute;
  111. top: 8%;
  112. left: 4%;
  113. display: flex;
  114. font-size: 40rpx;
  115. font-weight: 500;
  116. color: #FFF;
  117. .back-text {
  118. margin-left: 28rpx;
  119. }
  120. }
  121. .avatar {
  122. position: absolute;
  123. top: 229rpx;
  124. left: 295rpx;
  125. width: 160rpx;
  126. height: 160rpx;
  127. border-radius: 50%;
  128. background-color: #fff;
  129. overflow: hidden;
  130. image {
  131. width: 100%;
  132. height: 100%;
  133. }
  134. .avatar-description {
  135. position: absolute;
  136. bottom: 0;
  137. left: 0;
  138. width: 100%;
  139. height: 34rpx;
  140. line-height: 34rpx;
  141. font-size: 24rpx;
  142. font-weight: 400;
  143. color: #FFF;
  144. text-align: center;
  145. background: rgba(24, 105, 246, 0.46);
  146. }
  147. }
  148. .info-area {
  149. position: absolute;
  150. top: 446rpx;
  151. left: 4%;
  152. width: 92%;
  153. height: 272rpx;
  154. padding: 31rpx 28rpx;
  155. box-sizing: border-box;
  156. background-color: #fff;
  157. border-radius: 40rpx;
  158. }
  159. .info-item {
  160. display: flex;
  161. justify-content: space-between;
  162. align-items: center;
  163. height: 70rpx;
  164. color: #9E9E9E;
  165. font-size: 32rpx;
  166. input {
  167. text-align: right;
  168. font-size: 32rpx;
  169. color: #343437;
  170. }
  171. .info-item-content {
  172. display: flex;
  173. align-items: center;
  174. color: #343437;
  175. font-size: 32rpx;
  176. }
  177. .remind-text {
  178. color: #9E9E9E
  179. }
  180. }
  181. }
  182. </style>