about-us.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 class="" v-model="user.account" placeholder="请输入昵称" />
  8. <view class="clear-button" @click="clearInput" v-if=" user.account.length> 0">
  9. ×
  10. </view>
  11. </view>
  12. <button class="saveBtn" style="background-color: #3C86F7;" 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. account: ""
  25. }
  26. }
  27. },
  28. methods: {
  29. clearInput() {
  30. this.user.account = ""
  31. },
  32. save() {
  33. memberUpdate(this.user).then((res) => {
  34. if (res.code == 200) {
  35. uni.$u.toast("操作成功")
  36. uni.navigateBack({
  37. delta: 1 // delta 表示返回的页面数,1 表示返回上一页
  38. });
  39. }
  40. })
  41. },
  42. async detail() {
  43. const data = await memberDetail()
  44. if (data.code == 200) {
  45. this.user = data.data
  46. }
  47. },
  48. },
  49. onLoad(op) {
  50. console.log(op, "op")
  51. this.user = op
  52. this.detail()
  53. }
  54. }
  55. </script>
  56. <style>
  57. .page-container {
  58. background-color: #FFFFFF;
  59. /* 设置页面背景色为白色 */
  60. min-height: 100vh;
  61. /* 确保背景色覆盖整个可视区域 */
  62. }
  63. .inputBg {
  64. background-color: #f3f3f3;
  65. width: 700rpx;
  66. margin-left: 25rpx;
  67. border-radius: 40rpx;
  68. font-size: 38rpx;
  69. padding: 20rpx;
  70. position: relative;
  71. }
  72. .saveBtn {
  73. margin-top: 50rpx;
  74. width: 700rpx;
  75. margin-left: 25rpx;
  76. border-radius: 10rpx;
  77. }
  78. .clear-button {
  79. position: absolute;
  80. right: 10px;
  81. top: 50%;
  82. transform: translateY(-50%);
  83. font-size: 20px;
  84. margin-right: 10rpx;
  85. color: #999;
  86. cursor: pointer;
  87. }
  88. </style>