index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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">
  44. <icon class="list-icon sxtcs-icon"></icon>
  45. <text>摄像头测试</text>
  46. </view>
  47. <view class="list-row">
  48. <icon class="list-icon sxtsm-icon"></icon>
  49. <text>摄像头说明</text>
  50. </view>
  51. <view class="list-row" @click="exitLogin">
  52. <icon class="list-icon login-out-icon"></icon>
  53. <text>退出登录</text>
  54. </view>
  55. </view>
  56. <!-- 底部区域 -->
  57. <customTabbarClient :currentTab="1"></customTabbarClient>
  58. <common-dialog ref="commonDialogRef" :title="exitTitle" :content="exitContent"@confirm-btn="exitBtn"></common-dialog>
  59. </view>
  60. </template>
  61. <script setup>
  62. import {toast} from "@/utils/common";
  63. import {onLoad,onShow} from '@dcloudio/uni-app';
  64. import cacheManager from '@/utils/cacheManager.js';
  65. import {getMineUser,getMineInfo,getMineLogout} from '@/api/my.js'
  66. import {reactive,ref} from "vue";
  67. import customTabbarClient from "@/components/custom-tabbar/custom-tabbar-client.vue"
  68. import commonDialog from '@/components/dialog/commonDialog.vue';
  69. let myInfoData = reactive({
  70. userImg: '',
  71. realName: '',
  72. idcard: '',
  73. kaoshiCount: '',
  74. kechengCount: '',
  75. lianxiCount: '',
  76. from:''
  77. });
  78. const commonDialogRef = ref(null);
  79. const exitContent = '你确定要执行这个操作吗?';
  80. const exitTitle = '退出登录';
  81. function getMyInit() {
  82. getUserInfo();
  83. getNumInfo();
  84. }
  85. // 获取用户头像
  86. function goToPage(data){
  87. switch (data) {
  88. case 'ks':
  89. uni.navigateTo({
  90. url:'/pages/client/Kaoshi/list?from=my'
  91. })
  92. break;
  93. case 'lx':
  94. uni.navigateTo({
  95. url:'/pages/client/Lianxi/list?from=my'
  96. })
  97. break;
  98. case 'kc':
  99. uni.navigateTo({
  100. url:'/pages/client/Kecheng/list?from=my'
  101. })
  102. break;
  103. case 'cj':
  104. uni.navigateTo({
  105. url:'/pages/client/Chengji/list?from=my'
  106. })
  107. break;
  108. case 'grcj':
  109. uni.navigateTo({
  110. url:'/pages/client/my/myInfo?from=my'
  111. })
  112. break;
  113. }
  114. }
  115. function getUserInfo(){
  116. getMineUser({}).then(res => {
  117. myInfoData.userImg= res.data.icon;
  118. myInfoData.realName = res.data.realName;
  119. myInfoData.idcard = res.data.idcard;
  120. })
  121. }
  122. function getNumInfo(){
  123. getMineInfo({}).then(res => {
  124. myInfoData.kaoshiCount = res.data.kaoshiCount;
  125. myInfoData.kechengCount = res.data.kechengCount;
  126. myInfoData.lianxiCount = res.data.lianxiCount;
  127. })
  128. }
  129. function exitLogin(){
  130. commonDialogRef.value.handleShow();
  131. }
  132. function exitBtn(){
  133. getMineLogout().then(res => {
  134. toast('退出登录成功')
  135. cacheManager.clearAll();
  136. uni.reLaunch({
  137. url: '/pages/Login/index'
  138. });
  139. }).catch(err => {
  140. toast('退出登录失败,请稍后重试')
  141. })
  142. }
  143. onLoad(() => {
  144. })
  145. onShow(() => {
  146. getMyInit()
  147. })
  148. </script>
  149. <style>
  150. </style>