index.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <template>
  2. <view class="content">
  3. <view class="r-nickname-card">
  4. <view class="r-nickinput">
  5. <input type="text" v-model="username" maxlength="10" placeholder="请输入新昵称" />
  6. </view>
  7. <view class="r-clear-icon" v-if="username!==''" @click="username=''">
  8. <zzx-icon name="m-clear" size="16"></zzx-icon>
  9. </view>
  10. </view>
  11. <view class="r-tips">限2-10个汉字</view>
  12. </view>
  13. <view class="r-bottom-btn">
  14. <view class="submit-btn" @click="submit">确定</view>
  15. </view>
  16. </template>
  17. <script lang="ts" setup>
  18. import { ref, onMounted,computed } from 'vue'
  19. import { http } from '@/utils/http'
  20. import { RouterUtils, TipsUtils } from '@/utils/util';
  21. import { useCacheStore } from '@/stores/cache'
  22. const cache = useCacheStore()
  23. const username=ref('')
  24. const submit=()=>{
  25. if(username.value=='') return TipsUtils.tips_toast('请输入昵称')
  26. http.get('/user/updateUserInfo',{data:{nickName:username.value,avatarUrl:'https://c-ssl.dtstatic.com/uploads/blog/202107/11/20210711174826_ba57b.thumb.1000_0.jpg'},loading:true}).then((res)=>{
  27. get_userinfo()
  28. })
  29. }
  30. const get_userinfo=()=>{
  31. http.get('/user/getUserInfo', { loading: true }).then(res => {
  32. cache.set('USER_INFO',res.result)
  33. TipsUtils.tips_toast('修改成功')
  34. RouterUtils.back()
  35. })
  36. }
  37. </script>
  38. <style lang="less" scoped>
  39. .r-nickname-card{
  40. background: #FFFFFF;
  41. border-radius: 32rpx;
  42. display: flex;
  43. align-items: center;
  44. justify-content: space-between;
  45. padding: 20rpx;
  46. margin-top: 20rpx;
  47. .r-nickinput{
  48. font-weight: bold;
  49. font-size: 28rpx;
  50. color: #222222;
  51. }
  52. }
  53. .r-tips{
  54. margin-top: 14rpx;
  55. font-size: 24rpx;
  56. color: #AAAAAA;
  57. }
  58. .r-bottom-btn{
  59. position: fixed;
  60. bottom: 0;
  61. width: 750rpx;
  62. height: 166rpx;
  63. background: #FFFFFF;
  64. box-shadow: 0rpx -6rpx 12rpx 2rpx rgba(0,0,0,0.09);
  65. border-radius: 32rpx 32rpx 0rpx 0rpx;
  66. display: flex;
  67. align-items: center;
  68. justify-content: center;
  69. .submit-btn{
  70. width: 686rpx;
  71. height: 100rpx;
  72. background: #C8FF0C;
  73. border-radius: 60rpx;
  74. font-weight: bold;
  75. font-size: 32rpx;
  76. color: #222222;
  77. text-align: center;
  78. line-height: 100rpx;
  79. }
  80. }
  81. </style>