You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
4.3 KiB

  1. <template>
  2. <view class="main">
  3. <view :style="{height:iSMT+'px'}"></view>
  4. <view style="height:1.5vh;"></view>
  5. <view class="setting-list">
  6. <view class="setting-item">
  7. <text class="item-label">头像</text>
  8. <view class="item-right">
  9. <image src="/static/avatar.png" class="avatar" mode="aspectFill"></image>
  10. <uni-icons type="arrowright" size="16"></uni-icons>
  11. </view>
  12. </view>
  13. <view class="setting-item">
  14. <text class="item-label">昵称</text>
  15. <view class="item-right">
  16. <text class="item-text">{{userInfoRes.dcname}}</text>
  17. <uni-icons type="arrowright" size="16"></uni-icons>
  18. </view>
  19. </view>
  20. <view class="setting-item">
  21. <text class="item-label">ID</text>
  22. <view class="item-right">
  23. <text class="item-text">{{ userInfoRes.dccode }}</text>
  24. </view>
  25. </view>
  26. <view class="setting-item" @click="goToPassword">
  27. <text class="item-label">
  28. <template #default>
  29. {{ userInfoRes.hasPwd === 0 ? '创建密码' : '修改密码' }}
  30. </template>
  31. </text>
  32. <uni-icons type="arrowright" size="16"></uni-icons>
  33. </view>
  34. <view class="setting-item">
  35. <text class="item-label">注销账号</text>
  36. <uni-icons type="arrowright" size="16"></uni-icons>
  37. </view>
  38. <view class="setting-item" @click="goToBind">
  39. <text class="item-label">绑定账号</text>
  40. <uni-icons type="arrowright" size="16"></uni-icons>
  41. </view>
  42. </view>
  43. <view style="height:1.5vh;"></view>
  44. <view class="logout" @click="showLogout = true">
  45. <text>退出登录</text>
  46. </view>
  47. <view class="logout-confirm" v-if="showLogout">
  48. <view class="logoutDialog">
  49. <view class="tips">是否退出登录</view>
  50. <view class="tips-button">
  51. <button class="confirm-btn" @click="handleConfirmLogout">确认</button>
  52. <button class="cancel-btn" @click="showLogout = false">取消</button>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. </template>
  58. <script setup>
  59. import {
  60. ref,
  61. onMounted
  62. } from 'vue'
  63. import {useUserStore} from "../../stores/modules/userInfo"
  64. import {
  65. getUserInfo
  66. } from "@/api/member";
  67. const iSMT = ref(0)
  68. // const dccode = ref('')
  69. const userInfoRes = ref({})
  70. const showLogout = ref(false)
  71. const userStore = useUserStore()
  72. const handleConfirmLogout = () => {
  73. userStore.clearUserInfo()
  74. showLogout.value = false
  75. uni.showToast({
  76. title: '退出登录成功',
  77. icon: 'none',
  78. })
  79. uni.navigateTo({
  80. url: '/pages/start/login/login'
  81. })
  82. }
  83. const goToBind = () => {
  84. uni.navigateTo({
  85. url: '../setting/bind'
  86. })
  87. }
  88. const goToPassword = () => {
  89. if (userInfoRes.value.hasPwd === 0) {
  90. uni.navigateTo({
  91. url: '../setting/createPwd'
  92. })
  93. } else {
  94. uni.navigateTo({
  95. url: '../setting/password'
  96. })
  97. }
  98. }
  99. onMounted(() => {
  100. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  101. })
  102. </script>
  103. <style scoped>
  104. .setting-list {
  105. height: 42vh;
  106. background-color: #fff;
  107. }
  108. .setting-item {
  109. display: flex;
  110. align-items: center;
  111. height: 7vh;
  112. padding: 0 40rpx;
  113. border-bottom: 1rpx solid #eee;
  114. }
  115. .setting-item:last-child {
  116. border-bottom: none;
  117. }
  118. .item-label {
  119. font-size: 28rpx;
  120. flex: 1;
  121. }
  122. .item-right {
  123. display: flex;
  124. align-items: center;
  125. }
  126. .avatar {
  127. width: 60rpx;
  128. height: 60rpx;
  129. border-radius: 50%;
  130. margin-right: 20rpx;
  131. background-color: #999;
  132. }
  133. .item-text {
  134. margin-right: 20rpx;
  135. font-size: 28rpx;
  136. }
  137. .arrow,
  138. .eye-icon {
  139. color: #999;
  140. }
  141. .logout {
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. height: 7vh;
  146. font-size: 28rpx;
  147. color: #f56c6c;
  148. background-color: white;
  149. }
  150. .logout-confirm {
  151. position: fixed;
  152. top: 0;
  153. left: 0;
  154. width: 100%;
  155. height: 100%;
  156. background-color: rgba(0, 0, 0, 0.5);
  157. display: flex;
  158. justify-content: center;
  159. align-items: center;
  160. z-index: 999;
  161. }
  162. .logoutDialog {
  163. width: 500rpx;
  164. background-color: #fff;
  165. border-radius: 12rpx;
  166. padding: 40rpx;
  167. display: flex;
  168. flex-direction: column;
  169. align-items: center;
  170. }
  171. .tips {
  172. font-size: 32rpx;
  173. margin-bottom: 40rpx;
  174. }
  175. .tips-button {
  176. display: flex;
  177. width: 100%;
  178. justify-content: space-between;
  179. }
  180. .confirm-btn,
  181. .cancel-btn {
  182. width: 180rpx;
  183. height: 60rpx;
  184. line-height: 60rpx;
  185. border-radius: 30rpx;
  186. font-size: 28rpx;
  187. }
  188. .confirm-btn {
  189. background-color: #fff;
  190. color: #000;
  191. border: 1rpx solid #ddd;
  192. }
  193. .cancel-btn {
  194. background-color: #000;
  195. color: #fff;
  196. border: none;
  197. }
  198. </style>