index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view class="client-my-page">
  3. <view class="my-head-box">
  4. <img class="head-img-box" :src="myInfoData.userImg" v-if="myInfoData.userImg">
  5. <icon class="head-icon-box" v-else></icon>
  6. <view class="head-content-box">
  7. <text>{{myInfoData.realName}}</text>
  8. <view class="idcard-row-box" v-if="myInfoData.idcard">
  9. <icon class="idcard-icon"></icon>
  10. <text class="idcard-text" >{{myInfoData.idcard}}</text>
  11. </view>
  12. </view>
  13. </view>
  14. <view class="my-num-box">
  15. <view class="num-item-box" @click="goToPage('ks')">
  16. <uni-badge class="uni-badge-left-margin my-num-badge" v-if="myInfoData.kaoshiCount"
  17. :customStyle="{background: '#ff2527'}" :text="myInfoData.kaoshiCount" />
  18. <icon class="ks-icon"></icon>
  19. <text class="num-title">考试管理</text>
  20. </view>
  21. <view class="num-item-box" @click="goToPage('lx')">
  22. <uni-badge class="uni-badge-left-margin my-num-badge" v-if="myInfoData.lianxiCount"
  23. :customStyle="{background: '#ff2527'}" :text="myInfoData.lianxiCount" />
  24. <icon class="lx-icon"></icon>
  25. <text class="num-title">练习管理</text>
  26. </view>
  27. <view class="num-item-box" @click="goToPage('kc')">
  28. <uni-badge class="uni-badge-left-margin my-num-badge" v-if="myInfoData.kechengCount"
  29. :customStyle="{background: '#ff2527'}" :text="myInfoData.kechengCount" />
  30. <icon class="kc-icon"></icon>
  31. <text class="num-title">课程管理</text>
  32. </view>
  33. </view>
  34. <view class="my-list-box">
  35. <view class="list-row" @click="goToPage('grcj')">
  36. <icon class="list-icon user-icon"></icon>
  37. <text>修改个人信息</text>
  38. </view>
  39. <view class="list-row" @click="goToPage('cj')">
  40. <icon class="list-icon score-icon"></icon>
  41. <text>成绩列表</text>
  42. </view>
  43. <view class="list-row" @click="exitLogin">
  44. <icon class="list-icon login-out-icon"></icon>
  45. <text>退出登录</text>
  46. </view>
  47. </view>
  48. <!-- 底部区域 -->
  49. <customTabbarClient :currentTab="1"></customTabbarClient>
  50. <common-dialog ref="commonDialogRef" :title="exitTitle" :content="exitContent"@confirm-btn="exitBtn"></common-dialog>
  51. </view>
  52. </template>
  53. <script setup>
  54. import {toast} from "@/utils/common";
  55. import {onLoad} from '@dcloudio/uni-app';
  56. import cacheManager from '@/utils/cacheManager.js';
  57. import {getMineUser,getMineInfo,getMineLogout} from '@/api/my.js'
  58. import {reactive,ref} from "vue";
  59. import customTabbarClient from "@/components/custom-tabbar/custom-tabbar-client.vue"
  60. import commonDialog from '@/components/dialog/commonDialog.vue';
  61. let myInfoData = reactive({
  62. userImg: '',
  63. realName: '',
  64. idcard: '',
  65. kaoshiCount: '',
  66. kechengCount: '',
  67. lianxiCount: '',
  68. });
  69. const commonDialogRef = ref(null);
  70. const exitContent = '你确定要执行这个操作吗?';
  71. const exitTitle = '退出登录';
  72. function getMyInit() {
  73. getUserInfo();
  74. getNumInfo();
  75. }
  76. // 获取用户头像
  77. function goToPage(data){
  78. switch (data) {
  79. case 'ks':
  80. uni.redirectTo({
  81. url:'/pages/client/Kaoshi/list?from=my'
  82. })
  83. break;
  84. case 'lx':
  85. uni.redirectTo({
  86. url:'/pages/client/Lianxi/list?from=my'
  87. })
  88. break;
  89. case 'kc':
  90. uni.redirectTo({
  91. url:'/pages/client/Kecheng/list?from=my'
  92. })
  93. break;
  94. case 'cj':
  95. uni.redirectTo({
  96. url:'/pages/client/Chengji/list?from=my'
  97. })
  98. break;
  99. case 'grcj':
  100. uni.redirectTo({
  101. url:'/pages/client/my/myInfo?from=my'
  102. })
  103. break;
  104. }
  105. }
  106. function getUserInfo(){
  107. getMineUser({}).then(res => {
  108. myInfoData.userImg= res.data.icon;
  109. myInfoData.realName = res.data.realName;
  110. myInfoData.idcard = res.data.idcard;
  111. })
  112. }
  113. function getNumInfo(){
  114. getMineInfo({}).then(res => {
  115. myInfoData.kaoshiCount = res.data.kaoshiCount;
  116. myInfoData.kechengCount = res.data.kechengCount;
  117. myInfoData.lianxiCount = res.data.lianxiCount;
  118. })
  119. }
  120. function exitLogin(){
  121. commonDialogRef.value.handleShow();
  122. }
  123. function exitBtn(){
  124. getMineLogout().then(res => {
  125. console.log(res,'res');
  126. toast('退出登录成功')
  127. cacheManager.clearAll();
  128. uni.reLaunch({
  129. url: '/pages/Login/index'
  130. });
  131. }).catch(err => {
  132. toast('退出登录失败,请稍后重试')
  133. })
  134. }
  135. onLoad(() => {
  136. getMyInit()
  137. })
  138. </script>
  139. <style>
  140. </style>