account-change.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <template>
  2. <view class="page-container">
  3. <view class="font40 font-bold text-align pad-t-40 mar-b-50">
  4. 昵称
  5. </view>
  6. <view class="inputBg ">
  7. <input v-model="user.nickName" placeholder="请输入昵称" />
  8. <view class="clear-button" @click="clearInput" v-if=" user.nickName">
  9. ×
  10. </view>
  11. </view>
  12. <button class="saveBtn" style="background-color: #007aff;" type="primary" @click="save">保存</button>
  13. </view>
  14. </template>
  15. <script>
  16. import {
  17. memberUpdate,
  18. memberDetail
  19. } from '@/config/api.js';
  20. export default {
  21. data() {
  22. return {
  23. user: {
  24. nickName: ""
  25. }
  26. }
  27. },
  28. methods: {
  29. clearInput() {
  30. this.user.nickName = ""
  31. },
  32. save() {
  33. console.log(this.user.nickName)
  34. console.log(this.user.account)
  35. memberUpdate(this.user).then((res) => {
  36. if (res.code == 200) {
  37. uni.$u.toast("操作成功")
  38. uni.navigateBack({
  39. delta: 1 // delta 表示返回的页面数,1 表示返回上一页
  40. });
  41. uni.setStorageSync('user', null)
  42. console.log(12)
  43. }
  44. })
  45. },
  46. async detail() {
  47. const data = await memberDetail()
  48. if (data.code == 200) {
  49. this.user = data.data
  50. }
  51. },
  52. },
  53. onLoad(op) {
  54. console.log(op, "op")
  55. this.user = op
  56. this.detail()
  57. }
  58. }
  59. </script>
  60. <style>
  61. .page-container {
  62. background-color: #FFFFFF;
  63. /* 设置页面背景色为白色 */
  64. min-height: 100vh;
  65. /* 确保背景色覆盖整个可视区域 */
  66. }
  67. .inputBg {
  68. background-color: #f3f3f3;
  69. width: 700rpx;
  70. margin-left: 25rpx;
  71. border-radius: 40rpx;
  72. font-size: 38rpx;
  73. padding: 20rpx;
  74. position: relative;
  75. }
  76. .saveBtn {
  77. margin-top: 50rpx;
  78. width: 700rpx;
  79. margin-left: 25rpx;
  80. border-radius: 10rpx;
  81. }
  82. .clear-button {
  83. position: absolute;
  84. right: 10px;
  85. top: 50%;
  86. transform: translateY(-50%);
  87. font-size: 20px;
  88. margin-right: 10rpx;
  89. color: #999;
  90. cursor: pointer;
  91. }
  92. </style>