editNickName.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view class="content">
  3. <view class="row1 flex">
  4. <view class="left">
  5. 昵称
  6. </view>
  7. <u-input v-model="userInfo.nickname" :border="false" focus class="input" />
  8. </view>
  9. <view class="row2">
  10. <view class="btn" @click="edit">
  11. 保存
  12. </view>
  13. </view>
  14. <u-toast ref="uToast"></u-toast>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. value: '',
  22. userInfo: {
  23. nickname: ''
  24. }
  25. };
  26. },
  27. onLoad() {
  28. this.userInfo = uni.getStorageSync("userInfo")
  29. },
  30. methods: {
  31. edit() {
  32. this.$request.baseRequest('commonUserApp', 'edit', {
  33. commonUserInfo: JSON.stringify(this.userInfo)
  34. }, failres => {
  35. this.$refs.uToast.show({
  36. type: 'error',
  37. message: failres.errmsg,
  38. })
  39. uni.hideLoading()
  40. }).then(res => {
  41. this.userInfo = res.data
  42. uni.setStorageSync("userInfo", this.userInfo)
  43. let params = {
  44. type: 'success',
  45. message: "修改成功",
  46. url: '/pages/mySet/mySet'
  47. }
  48. this.$refs.uToast.show({
  49. ...params,
  50. complete() {
  51. params.url && uni.switchTab({
  52. url: params.url
  53. })
  54. }
  55. })
  56. })
  57. }
  58. }
  59. }
  60. </script>
  61. <style lang="scss">
  62. .row1 {
  63. background: #fff;
  64. padding: 20rpx;
  65. }
  66. .input {
  67. font-size: 28rpx;
  68. }
  69. .row2 {
  70. padding: 20rpx;
  71. }
  72. .btn {
  73. color: #fff;
  74. padding: 20rpx;
  75. border-radius: 8px;
  76. background: rgba(17, 34, 83, 1);
  77. text-align: center;
  78. font-size: 36rpx;
  79. }
  80. </style>