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.

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