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.

242 lines
4.8 KiB

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