index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <div v-loading="loading" class="" style="position: relative">
  3. <common-header />
  4. <div class="bg absolute">
  5. <img src="/images/personal/bg.png" />
  6. </div>
  7. <div class="personalMain">
  8. <famous-teacher v-if="isFamous" :userInfo="userInfo" :proData="proData" />
  9. <el-card style="margin: 15px 0">
  10. <ordinary-teacher v-if="!isFamous" :userInfo="userInfo" :proData="proData" />
  11. <div class="menuDiv" v-if="!isStudent">
  12. <div class="list pointer font-size-16" :class="activeMenu == item.url ? 'active' : ''" v-for="item in menuData" :key="item.name" @click="goToPage(item.url, item.type)">
  13. {{ item.name }}
  14. </div>
  15. </div>
  16. <div class="menuDiv" v-if="isStudent">
  17. <div class="list pointer font-size-16" :class="activeMenu == item.url ? 'active' : ''" v-for="item in menuData1" :key="item.name" @click="goToPage(item.url, item.type)">
  18. {{ item.name }}
  19. </div>
  20. </div>
  21. </el-card>
  22. <router-view />
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. import CommonHeader from "@/components/CommonHeader/index.vue";
  28. import OrdinaryTeacher from "./components/main/OrdinaryTeacher.vue";
  29. import FamousTeacher from "./components/main/FamousTeacher.vue";
  30. import { user_info } from "./components/MyCourse/api";
  31. export default {
  32. components: { CommonHeader, OrdinaryTeacher, FamousTeacher },
  33. data() {
  34. return {
  35. userInfo: {},
  36. isFamous: false,
  37. isStudent: true,
  38. proData: [],
  39. proData1: [
  40. {
  41. name: "我的课程",
  42. key: "kc_num",
  43. value: "",
  44. },
  45. {
  46. name: "观看数量",
  47. key: "watch_num",
  48. value: "2698",
  49. },
  50. {
  51. name: "被关注数",
  52. key: "followed",
  53. value: "2021",
  54. },
  55. {
  56. name: "总积分",
  57. key: "user_score",
  58. value: "2021",
  59. },
  60. ],
  61. proData2: [
  62. {
  63. name: "优秀作业",
  64. key: "kc_num",
  65. value: "20",
  66. },
  67. {
  68. name: "被关注数",
  69. key: "watch_num",
  70. value: "2698",
  71. },
  72. {
  73. name: "总积分",
  74. key: "followed",
  75. value: "2021",
  76. },
  77. ],
  78. activeMenu: "",
  79. menuData: [
  80. {
  81. name: "我的课程",
  82. url: "mycourse",
  83. },
  84. {
  85. name: "我参与的组",
  86. url: "participate",
  87. },
  88. // {
  89. // name: "赞与收藏",
  90. // url: "collection",
  91. // },
  92. {
  93. name: "我关注的人",
  94. url: "attention",
  95. },
  96. {
  97. name: "作业",
  98. url: "homework",
  99. },
  100. {
  101. name: "互评记录",
  102. url: "mutualRecord",
  103. },
  104. {
  105. name: "我的积分",
  106. url: "credits",
  107. },
  108. {
  109. name: "申请成为名师",
  110. url: "masterTeacher",
  111. },
  112. {
  113. name: "约课",
  114. url: "personal_yk",
  115. },
  116. {
  117. name: "同步课堂",
  118. url: "http://www.txhlwxx.com/index.php?mod=txwx&action=hdhy&do=index&api=html",
  119. type: 1
  120. },
  121. ],
  122. menuData1: [
  123. {
  124. name: "我的足迹",
  125. url: "xs-track",
  126. },
  127. {
  128. name: "我的作业",
  129. url: "xs-homework",
  130. },
  131. {
  132. name: "我的积分",
  133. url: "xs-credits",
  134. },
  135. {
  136. name: "我关注的人",
  137. url: "xs-attention",
  138. },
  139. ],
  140. loading: true,
  141. };
  142. },
  143. methods: {
  144. goToPage(url, type) {
  145. if (type == 1) {
  146. window.open(url);
  147. } else {
  148. this.activeMenu = url;
  149. this.$router.push({ name: url });
  150. }
  151. },
  152. initUserInfo() {
  153. user_info().then((res) => {
  154. if (res.code == 1) {
  155. this.userInfo = res.data;
  156. this.isStudent = this.userInfo.user_role_id == 76 ? true : false;
  157. if (!this.isStudent) {
  158. this.proData = this.proData1;
  159. } else {
  160. this.proData = this.proData2;
  161. }
  162. this.isFamous = this.userInfo.ext.ue_is_ms == 1 ? true : false;
  163. this.proData.map((item) => {
  164. for (let key in this.userInfo) {
  165. if (item.key == key) {
  166. item.value = this.userInfo[key];
  167. }
  168. }
  169. });
  170. this.loading = false;
  171. }
  172. });
  173. },
  174. },
  175. created() {
  176. this.activeMenu = this.$route.name.indexOf("course") != -1 ? "mycourse" : this.$route.name;
  177. this.initUserInfo();
  178. },
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. .personalMain {
  183. width: 1440px;
  184. margin: auto;
  185. position: relative;
  186. z-index: 10;
  187. .pointer {
  188. cursor: pointer;
  189. }
  190. .el-card {
  191. border-radius: 12px;
  192. .menuDiv {
  193. display: flex;
  194. margin-bottom: -10px;
  195. .list {
  196. margin: 0 20px;
  197. color: #949494;
  198. position: relative;
  199. line-height: 40px;
  200. &::after {
  201. content: "";
  202. width: 0;
  203. height: 2px;
  204. background: rgba(0, 131, 197, 0.8);
  205. position: absolute;
  206. bottom: -10px;
  207. left: 50%;
  208. transform: translateX(-50%);
  209. transition: width linear 0.1s;
  210. }
  211. &:hover {
  212. color: rgba(0, 131, 197, 0.8);
  213. }
  214. &.active {
  215. color: rgba(0, 131, 197, 0.8);
  216. &::after {
  217. width: 100%;
  218. }
  219. }
  220. }
  221. }
  222. }
  223. }
  224. </style>