nickname.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view class="body">
  3. <view class="header-bg">
  4. </view>
  5. <view class="header">
  6. <view class="title">
  7. 昵称
  8. </view>
  9. </view>
  10. <view class="main">
  11. <view class="input-item inline-form">
  12. <input class="input" type="text" placeholder="请输入新昵称" v-model="form.nickname">
  13. </view>
  14. </view>
  15. <view class="submit-btn-wrapper">
  16. <button class="btn submit-btn" type="default" @tap="submit">确认修改</button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. form: {
  25. nickname: ""
  26. }
  27. }
  28. },
  29. onLoad() {
  30. this.form.nickname = this.$store.state.user.nickname
  31. },
  32. methods: {
  33. submit() {
  34. if (this.$verified.required(this.form.nickname, "请输入新昵称")) {
  35. this.$http.post({
  36. url: "/user/profile",
  37. data: this.form,
  38. success: (res) => {
  39. uni.$emit("refresh_userinfo")
  40. uni.showToast({
  41. title:"昵称修改成功",
  42. icon:"none",
  43. success() {
  44. setTimeout(uni.navigateBack(),1000)
  45. }
  46. })
  47. }
  48. })
  49. }
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .body {
  56. position: relative;
  57. overflow: hidden;
  58. }
  59. .header-bg {
  60. background: $primary-color;
  61. height: 100upx;
  62. position: absolute;
  63. top: 0;
  64. width: 100%;
  65. }
  66. .header {
  67. margin: 20upx;
  68. background: white;
  69. text-align: center;
  70. border-radius: 20upx;
  71. position: relative;
  72. z-index: 1;
  73. .title {
  74. height: 100upx;
  75. font-size: 32upx;
  76. line-height: 100upx;
  77. // font-weight: bold;
  78. }
  79. }
  80. .main {
  81. margin: 20upx;
  82. background: white;
  83. border-radius: 10upx;
  84. }
  85. .input-item.inline-form {
  86. display: flex;
  87. align-items: center;
  88. height: 80upx;
  89. font-size: 28upx;
  90. padding: 0 20upx;
  91. position: relative;
  92. color: #999999;
  93. .label {
  94. width: 160upx;
  95. // flex: 1 1 160upx;
  96. }
  97. .input {
  98. flex-grow: 1;
  99. font-size: 28upx;
  100. }
  101. }
  102. .submit-btn-wrapper {
  103. margin-top: 80upx;
  104. .submit-btn {
  105. font-size: 30upx;
  106. line-height: 60upx;
  107. width: 250upx;
  108. background: $primary-color;
  109. color: white;
  110. }
  111. }
  112. </style>