profile.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <view class="page">
  3. <view class="form">
  4. <u-form :model="form" ref="uForm">
  5. <u-form-item label-width="150" label="修改头像" prop="nickname" @click.native="pageTo('/pages/user/setting/avatar')">
  6. <u-icon name="arrow-right" style="float: right;" size="24" label="请选择" labelPos="left"></u-icon>
  7. </u-form-item>
  8. <u-form-item label-width="150" label="昵称" prop="nickname">
  9. <u-input placeholder="请输入昵称" v-model="form.nickname" inputAlign="right" type="text"></u-input>
  10. </u-form-item>
  11. </u-form>
  12. <u-gap height="60"></u-gap>
  13. <u-button type="primary" @click="submitHandle">提交</u-button>
  14. <u-gap></u-gap>
  15. </view>
  16. <!-- utoast -->
  17. <u-toast ref="uToast" />
  18. </view>
  19. </template>
  20. <script>
  21. var that;
  22. export default {
  23. data() {
  24. return {
  25. maskShow: false,
  26. form: {
  27. nickname: null,
  28. },
  29. rules: {
  30. nickname: [
  31. {
  32. required: true,
  33. message: '昵称不得为空',
  34. trigger: ['change', 'blur']
  35. },
  36. ],
  37. },
  38. };
  39. },
  40. onLoad(params) {
  41. const userInfo2 = uni.getStorageSync('MD_userInfo2')
  42. this.form.nickname = userInfo2.nickname
  43. },
  44. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  45. onReady() {
  46. this.$refs.uForm.setRules(this.rules);
  47. },
  48. methods: {
  49. pageTo(path) {
  50. // console.log(path)
  51. if (path === 'dev') {
  52. uni.$msg('开发中~')
  53. return
  54. }
  55. uni.navigateTo({
  56. url: path
  57. })
  58. },
  59. submitHandle() {
  60. this.$refs.uForm.validate(valid => {
  61. if (valid) {
  62. uni.api.base.apiuseredit({
  63. nickname: this.form.nickname
  64. }).then(res => {
  65. uni.$msg('修改成功~')
  66. })
  67. }
  68. })
  69. }
  70. }
  71. };
  72. </script>
  73. <style lang="scss">
  74. .page {
  75. background-color: #ffffff;
  76. }
  77. .form {
  78. border-radius: 10rpx;
  79. padding: 0 40rpx;
  80. }
  81. .popup-body {
  82. .tips-title {
  83. font-size: $u-p;
  84. margin-bottom: 20rpx;
  85. }
  86. .tips-content {
  87. font-size: $u-p2;
  88. color: $u-tips-color;
  89. margin-bottom: 60rpx;
  90. }
  91. }
  92. .id_card {
  93. color: #606266;
  94. width: 100%;
  95. height: 350rpx;
  96. display: flex;
  97. flex-direction: column;
  98. align-items: center;
  99. justify-content: center;
  100. background-color: #f4f5f6;
  101. font-size: $u-p2;
  102. border-radius: 10rpx;
  103. image {
  104. border-radius: 10rpx;
  105. }
  106. }
  107. .footer {
  108. position: relative;
  109. text-align: center;
  110. font-size: $u-p2;
  111. left: 0;
  112. bottom: 20rpx;
  113. .agreement {
  114. color: $u-theme-color;
  115. }
  116. }
  117. .slot-content {
  118. font-size: 28rpx;
  119. color: $u-content-color;
  120. padding: 20rpx;
  121. }
  122. .warp {
  123. display: flex;
  124. flex-direction: column;
  125. align-items: center;
  126. justify-content: center;
  127. height: 100%;
  128. }
  129. .rect {
  130. width: 400rpx;
  131. height: 400rpx;
  132. background-color: #fff;
  133. }
  134. </style>