settings.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="settings-root">
  3. <!-- 1. 自定义导航栏:解决蓝线顽疾 -->
  4. <view class="custom-navbar" :style="{ paddingTop: statusBarHeight + 'px' }">
  5. <view class="nav-content">
  6. <view class="back-area" @click="goBack">
  7. <text class="back-arrow"></text>
  8. </view>
  9. <view class="nav-title">个人资料设置</view>
  10. <view class="right-placeholder"></view>
  11. </view>
  12. </view>
  13. <!-- 2. 资料列表 -->
  14. <view class="settings-list" :style="{ marginTop: '10px' }">
  15. <view class="item-row avatar-row" @click="doChooseImage">
  16. <text class="item-label">头像</text>
  17. <view class="item-right">
  18. <image class="avatar-img" :src="myInfo.avatarUrl" mode="aspectFill"></image>
  19. <text class="icon-more"></text>
  20. </view>
  21. </view>
  22. <view class="item-row" @click="doEditName">
  23. <text class="item-label">用户昵称</text>
  24. <view class="item-right">
  25. <text class="item-value">{{myInfo.nickName}}</text>
  26. <text class="icon-more"></text>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="settings-list mt-30">
  31. <view class="item-row no-tap">
  32. <text class="item-label">手机号码</text>
  33. <view class="item-right">
  34. <text class="item-value readonly">{{myInfo.phoneNum}}</text>
  35. </view>
  36. </view>
  37. <view class="item-row no-tap">
  38. <text class="item-label">授权客户</text>
  39. <view class="item-right">
  40. <text class="item-value readonly">{{myInfo.orgName}}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="footer-bar">
  45. <button class="btn-confirm" @click="saveProfile">确认保存</button>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. statusBarHeight: 20,
  54. myInfo: {
  55. avatarUrl: 'https://img.icons8.com/clouds/200/manager.png',
  56. nickName: '张经理',
  57. phoneNum: '138-8888-8888',
  58. orgName: '广东粤铝材实业有限公司'
  59. }
  60. }
  61. },
  62. onLoad() {
  63. const info = uni.getSystemInfoSync();
  64. this.statusBarHeight = info.statusBarHeight;
  65. },
  66. methods: {
  67. goBack() { uni.navigateBack(); },
  68. doChooseImage() {
  69. uni.chooseImage({
  70. count: 1,
  71. success: (res) => {
  72. this.myInfo.avatarUrl = res.tempFilePaths[0];
  73. uni.showToast({ title: '头像已选好', icon: 'none' });
  74. }
  75. });
  76. },
  77. doEditName() {
  78. uni.showModal({
  79. title: '设置昵称',
  80. content: this.myInfo.nickName,
  81. editable: true,
  82. confirmColor: '#C1001C', // 重点修复点:弹窗确认按钮强制采用主题红
  83. success: (res) => {
  84. if (res.confirm) {
  85. this.myInfo.nickName = res.content || '未命名';
  86. }
  87. }
  88. });
  89. },
  90. saveProfile() {
  91. uni.showLoading({ title: '保存中' });
  92. setTimeout(() => {
  93. uni.hideLoading();
  94. uni.showToast({ title: '保存成功' });
  95. setTimeout(() => { uni.navigateBack(); }, 1200);
  96. }, 600);
  97. }
  98. }
  99. }
  100. </script>
  101. <style scoped>
  102. .settings-root { width: 100vw; height: 100vh; background: #f8fafb; display: flex; flex-direction: column; }
  103. /* 自定义导航栏样式 */
  104. .custom-navbar { background: #fff; flex-shrink: 0; }
  105. .nav-content { height: 44px; display: flex; align-items: center; justify-content: space-between; padding: 0 30rpx; }
  106. .back-area { width: 60rpx; height: 44px; display: flex; align-items: center; }
  107. .back-arrow { width: 22rpx; height: 22rpx; border-left: 4rpx solid #333; border-bottom: 4rpx solid #333; transform: rotate(45deg); margin-left: 10rpx; }
  108. .nav-title { font-size: 34rpx; font-weight: bold; color: #333; }
  109. .right-placeholder { width: 60rpx; }
  110. .settings-list { background: #fff; padding: 0 40rpx; }
  111. .mt-30 { margin-top: 30rpx; }
  112. .item-row { display: flex; justify-content: space-between; align-items: center; min-height: 110rpx; border-bottom: 2rpx solid #f9f9f9; }
  113. .item-row:last-child { border-bottom: none; }
  114. .avatar-row { height: 180rpx; }
  115. .item-label { font-size: 32rpx; color: #333; }
  116. .item-right { display: flex; align-items: center; }
  117. .avatar-img { width: 110rpx; height: 110rpx; border-radius: 50%; background: #eee; margin-right: 20rpx; }
  118. .item-value { font-size: 30rpx; color: #666; margin-right: 15rpx; }
  119. .item-value.readonly { color: #aaa; margin-right: 0; }
  120. .icon-more { width: 14rpx; height: 14rpx; border-top: 3rpx solid #ccc; border-right: 3rpx solid #ccc; transform: rotate(45deg); }
  121. .footer-bar { padding: 40rpx; margin-top: auto; padding-bottom: calc(40rpx + env(safe-area-inset-bottom)); }
  122. .btn-confirm { width: 100%; height: 90rpx; background: #C1001C; color: #fff; border-radius: 45rpx; font-size: 32rpx; font-weight: bold; display: flex; align-items: center; justify-content: center; }
  123. </style>