editNickName.vue 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. uni.hideLoading()
  36. uni.showToast({
  37. icon:"none",
  38. title: failres.errmsg,
  39. duration: 3000
  40. });
  41. }).then(res => {
  42. this.userInfo = res.data
  43. uni.setStorageSync("userInfo", this.userInfo)
  44. uni.showToast({
  45. icon:"success",
  46. title: '修改成功!',
  47. duration: 2000,
  48. complete:function(){
  49. uni.switchTab({
  50. url: "/pages/mySet/mySet"
  51. })
  52. }
  53. })
  54. })
  55. }
  56. }
  57. }
  58. </script>
  59. <style lang="scss">
  60. .row1 {
  61. background: #fff;
  62. padding: 20rpx;
  63. }
  64. .input {
  65. font-size: 28rpx;
  66. }
  67. .row2 {
  68. padding: 20rpx;
  69. }
  70. .btn {
  71. color: #fff;
  72. padding: 20rpx;
  73. border-radius: 8px;
  74. background: rgba(17, 34, 83, 1);
  75. text-align: center;
  76. font-size: 36rpx;
  77. }
  78. </style>