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.

240 lines
4.7 KiB

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 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. {{ 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 userInfoPromise = getUserInfo()
  73. userInfoPromise.then(res => {
  74. if (res.code === 200) {
  75. userInfoRes.value.dccode = res.data.dccode;
  76. userInfoRes.value.dcname = res.data.dcname;
  77. userInfoRes.value.hasPwd = res.data.hasPassword;
  78. console.log('用户信息', userInfoRes.value)
  79. } else {
  80. uni.showToast({
  81. title: '用户信息请求失败',
  82. icon: 'none',
  83. })
  84. }
  85. })
  86. const handleConfirmLogout = () => {
  87. userStore.clearUserInfo()
  88. showLogout.value = false
  89. uni.showToast({
  90. title: '退出登录成功',
  91. icon: 'none',
  92. })
  93. uni.navigateTo({
  94. url: '/pages/start/login/login'
  95. })
  96. }
  97. const goToBind = () => {
  98. uni.navigateTo({
  99. url: '../setting/bind'
  100. })
  101. }
  102. const goToPassword = () => {
  103. if (userInfoRes.value.hasPwd === 0) {
  104. uni.navigateTo({
  105. url: '../setting/createPwd'
  106. })
  107. } else {
  108. uni.navigateTo({
  109. url: '../setting/password'
  110. })
  111. }
  112. }
  113. onMounted(() => {
  114. iSMT.value = uni.getSystemInfoSync().statusBarHeight;
  115. })
  116. </script>
  117. <style scoped>
  118. .setting-list {
  119. height: 42vh;
  120. background-color: #fff;
  121. }
  122. .setting-item {
  123. display: flex;
  124. align-items: center;
  125. height: 7vh;
  126. padding: 0 40rpx;
  127. border-bottom: 1rpx solid #eee;
  128. }
  129. .setting-item:last-child {
  130. border-bottom: none;
  131. }
  132. .item-label {
  133. font-size: 28rpx;
  134. flex: 1;
  135. }
  136. .item-right {
  137. display: flex;
  138. align-items: center;
  139. }
  140. .avatar {
  141. width: 60rpx;
  142. height: 60rpx;
  143. border-radius: 50%;
  144. margin-right: 20rpx;
  145. background-color: #999;
  146. }
  147. .item-text {
  148. margin-right: 20rpx;
  149. font-size: 28rpx;
  150. }
  151. .arrow,
  152. .eye-icon {
  153. color: #999;
  154. }
  155. .logout {
  156. display: flex;
  157. justify-content: center;
  158. align-items: center;
  159. height: 7vh;
  160. font-size: 28rpx;
  161. color: #f56c6c;
  162. background-color: white;
  163. }
  164. .logout-confirm {
  165. position: fixed;
  166. top: 0;
  167. left: 0;
  168. width: 100%;
  169. height: 100%;
  170. background-color: rgba(0, 0, 0, 0.5);
  171. display: flex;
  172. justify-content: center;
  173. align-items: center;
  174. z-index: 999;
  175. }
  176. .logoutDialog {
  177. width: 500rpx;
  178. background-color: #fff;
  179. border-radius: 12rpx;
  180. padding: 40rpx;
  181. display: flex;
  182. flex-direction: column;
  183. align-items: center;
  184. }
  185. .tips {
  186. font-size: 32rpx;
  187. margin-bottom: 40rpx;
  188. }
  189. .tips-button {
  190. display: flex;
  191. width: 100%;
  192. justify-content: space-between;
  193. }
  194. .confirm-btn,
  195. .cancel-btn {
  196. width: 180rpx;
  197. height: 60rpx;
  198. line-height: 60rpx;
  199. border-radius: 30rpx;
  200. font-size: 28rpx;
  201. }
  202. .confirm-btn {
  203. background-color: #fff;
  204. color: #000;
  205. border: 1rpx solid #ddd;
  206. }
  207. .cancel-btn {
  208. background-color: #000;
  209. color: #fff;
  210. border: none;
  211. }
  212. </style>