mine111.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <!-- 设置 -->
  2. <template>
  3. <view class="page">
  4. <!-- 表单 -->
  5. <view class="form">
  6. <u-form label-position="left" :model="form" ref="form" label-width="180rpx">
  7. <u-form-item label="头像">
  8. <view class="value" @click="uploadAvatar">
  9. <u-avatar style="height: 72rpx;" size="72" src="../../../static/user/1.png"></u-avatar>
  10. <u-icon :color="arrowColor" style="margin-left: 20rpx;" size="28" name="arrow-right"></u-icon>
  11. </view>
  12. </u-form-item>
  13. <u-form-item label="昵称">
  14. <view class="value" @click="openUsernameModal">
  15. <text>{{ username || '无' }}</text>
  16. <u-icon :color="arrowColor" style="margin-left: 20rpx;" size="28" name="arrow-right"></u-icon>
  17. </view>
  18. </u-form-item>
  19. <u-form-item label="性别">
  20. <view class="value" @click="openSexPicker">
  21. <text v-if="sex == '1'">男</text>
  22. <text v-if="sex == '0'">女</text>
  23. <text v-if="sex == ''">保密</text>
  24. <u-icon :color="arrowColor" style="margin-left: 20rpx;" size="28" name="arrow-right"></u-icon>
  25. </view>
  26. </u-form-item>
  27. <u-form-item label="个性签名">
  28. <view class="value" @click="openSignatureModal">
  29. <text>{{ signature || '无' }}</text>
  30. <u-icon :color="arrowColor" style="margin-left: 20rpx;" size="28" name="arrow-right"></u-icon>
  31. </view>
  32. </u-form-item>
  33. <u-form-item label="生日">
  34. <view class="value" @click="openDatePicker">
  35. <text>{{ date || '1990-01-02' }}</text>
  36. <u-icon :color="arrowColor" style="margin-left: 20rpx;" size="28" name="arrow-right"></u-icon>
  37. </view>
  38. </u-form-item>
  39. <u-form-item label="地区">
  40. <view class="value" @click="openRegionPicker">
  41. <text>{{ '请选择所在地区' }}</text>
  42. <u-icon :color="arrowColor" style="margin-left: 20rpx;" size="28" name="arrow-right"></u-icon>
  43. </view>
  44. </u-form-item>
  45. <u-form-item label="设置密码">
  46. <view class="value" @click="openPasswordModal">
  47. <text></text>
  48. <u-icon :color="arrowColor" style="margin-left: 20rpx;" size="28" name="arrow-right"></u-icon>
  49. </view>
  50. </u-form-item>
  51. </u-form>
  52. </view>
  53. <!-- 按钮 -->
  54. <view class="btn">
  55. <u-button type="primary" shape="circle" @click="logout"><text>退出登录</text></u-button>
  56. </view>
  57. <!-- picker -->
  58. <u-picker mode="region" v-model="showRegion" :area-code="regionCode" :confirm-color="themeColor"></u-picker>
  59. <u-picker mode="time" v-model="showDate" :default-time="date" :confirm-color="themeColor"></u-picker>
  60. <u-picker mode="selector" v-model="showSex" :default-selector="sex" :confirm-color="themeColor" :range="range" range-key="label"></u-picker>
  61. <!-- modal -->
  62. <u-modal v-model="showUsername" title="修改昵称" show-cancel-button :confirm-color="themeColor">
  63. <view class="slot-content">
  64. <u-field label-width="60" focus placeholder="请输入昵称" clearable :border-bottom="false" v-model="username" label="昵称" required></u-field>
  65. </view>
  66. </u-modal>
  67. <u-modal v-model="showSignature" title="修改个性签名" show-cancel-button :confirm-color="themeColor">
  68. <view class="slot-content">
  69. <u-field
  70. label-width="120"
  71. focus
  72. placeholder="请输入个性签名"
  73. clearable
  74. :border-bottom="false"
  75. v-model="signature"
  76. label="个性签名"
  77. required
  78. auto-height
  79. type="textarea"
  80. ></u-field>
  81. </view>
  82. </u-modal>
  83. <u-modal v-model="showPassword" title="修改密码" show-cancel-button :confirm-color="themeColor">
  84. <view class="slot-content">
  85. <u-field label-width="120" focus placeholder="请输入密码" clearable v-model="password" label="密码" required auto-height></u-field>
  86. <u-field label-width="120" placeholder="请再次输入密码" clearable :border-bottom="false" v-model="passwordAgain" label="确认密码" required auto-height></u-field>
  87. </view>
  88. </u-modal>
  89. </view>
  90. </template>
  91. <script>
  92. export default {
  93. data() {
  94. return {
  95. arrowColor: this.$appTheme.appThemeTextGrayColor,
  96. themeColor: this.$appTheme.appThemeColor,
  97. // picker
  98. showRegion: false,
  99. showDate: false,
  100. showSex: false,
  101. range: [{ label: '男', value: '1' }, { label: '女', value: '0' }, { label: '保密', value: '' }],
  102. // modal
  103. showUsername: false,
  104. showSignature: false,
  105. showPassword: false,
  106. // 默认回显
  107. regionCode: '',
  108. date: '',
  109. sex: '',
  110. username: '',
  111. signature: '',
  112. // 表单
  113. form: {},
  114. // 上传地址
  115. uploadUrl: ''
  116. };
  117. },
  118. onLoad(options) {},
  119. methods: {
  120. // 上传头像
  121. uploadAvatar() {
  122. uni.chooseImage({
  123. count: 1,
  124. sizeType: ['original', 'compressed'],
  125. sourceType: ['album', 'camera'],
  126. success(res) {
  127. console.log(JSON.stringify(res.tempFilePaths));
  128. }
  129. });
  130. },
  131. // 修改昵称
  132. openUsernameModal() {
  133. this.showUsername = true;
  134. },
  135. // 选择性别
  136. openSexPicker() {
  137. this.showSex = true;
  138. },
  139. // 修改个性签名
  140. openSignatureModal() {
  141. this.showSignature = true;
  142. },
  143. // 选择日期
  144. openDatePicker() {
  145. this.showDate = true;
  146. },
  147. // 选择地区
  148. openRegionPicker() {
  149. this.showRegion = true;
  150. },
  151. // 设置密码
  152. openPasswordModal() {
  153. this.showPassword = true;
  154. },
  155. // 退出登录
  156. logout() {
  157. uni.showModal({
  158. title: '提示',
  159. content: '是否退出当前账号?',
  160. confirmColor: this.themeColor,
  161. success(res) {
  162. if (res.confirm) {
  163. uni.removeStorageSync('IS_LOGIN');
  164. uni.navigateBack({
  165. delta: 1
  166. });
  167. }
  168. }
  169. });
  170. }
  171. }
  172. };
  173. </script>
  174. <style lang="scss" scoped>
  175. .page {
  176. padding: 24rpx 30rpx;
  177. background-color: $app-theme-bg-color;
  178. .form {
  179. .value {
  180. display: flex;
  181. align-items: center;
  182. justify-content: flex-end;
  183. font-size: 28rpx;
  184. font-family: PingFangSC-Regular, PingFang SC;
  185. font-weight: 400;
  186. color: $app-theme-card-gray-deep-color;
  187. }
  188. }
  189. }
  190. .btn {
  191. padding: 60rpx 0rpx;
  192. }
  193. .slot-content {
  194. padding: 30rpx;
  195. }
  196. </style>