userinfo.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <view class="content">
  3. <view class="row b-b">
  4. <text class="tit">昵称</text>
  5. <input class="input" type="text" v-model="name" placeholder="修改昵称" placeholder-class="placeholder" />
  6. </view>
  7. <button class="add-btn" @click="confirm">提交</button>
  8. </view>
  9. </template>
  10. <script>
  11. import { mapState } from 'vuex';
  12. import { userEdit } from '@/api/set.js';
  13. export default {
  14. data() {
  15. return {
  16. name: ''
  17. };
  18. },
  19. computed: {
  20. ...mapState('user', ['userInfo'])
  21. },
  22. onShow(option) {
  23. this.name = this.userInfo.nickname + '';
  24. },
  25. methods: {
  26. switchChange(e) {
  27. this.addressData.default = e.value;
  28. },
  29. confirm() {
  30. userEdit({ nickname: this.name, avatar: this.userInfo.avatar })
  31. .then(e => {
  32. this.$api.msg('修改成功');
  33. setTimeout(()=> {
  34. uni.switchTab({
  35. url:'/pages/user/user'
  36. });
  37. }, 1000);
  38. console.log(e);
  39. })
  40. .catch(e => {
  41. console.log(e);
  42. });
  43. }
  44. }
  45. };
  46. </script>
  47. <style lang="scss">
  48. page {
  49. background: $page-color-base;
  50. padding-top: 16upx;
  51. }
  52. .row {
  53. display: flex;
  54. align-items: center;
  55. position: relative;
  56. padding: 0 30upx;
  57. height: 110upx;
  58. background: #fff;
  59. .tit {
  60. flex-shrink: 0;
  61. width: 120upx;
  62. font-size: 30upx;
  63. color: $font-color-dark;
  64. }
  65. .input {
  66. flex: 1;
  67. font-size: 30upx;
  68. color: $font-color-dark;
  69. }
  70. .iconlocation {
  71. font-size: 36upx;
  72. color: $font-color-light;
  73. }
  74. }
  75. .add-btn {
  76. display: flex;
  77. align-items: center;
  78. justify-content: center;
  79. width: 690upx;
  80. height: 80upx;
  81. margin: 60upx auto;
  82. font-size: $font-lg;
  83. color: #fff;
  84. background-color: $base-color;
  85. border-radius: 10upx;
  86. // box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  87. }
  88. </style>