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.

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