MainLayout.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. <template>
  2. <div class="main-layout">
  3. <header class="header qm-primary-text">
  4. <Poptip v-if="ifShowQr" trigger="hover" width="280">
  5. <span class="name-arrow">手机端登录(Android)</span>
  6. <div slot="content">
  7. <Tabs type="card">
  8. <TabPane label="下载安卓apk">
  9. <div class="qm-primary-text flex-center">
  10. <qrcode :value="qrValue" :options="{ width: 200 }"></qrcode>
  11. </div>
  12. </TabPane>
  13. <TabPane label="绑定用户">
  14. <div class="qm-primary-text flex-center">
  15. <qrcode :value="qrValue" :options="{ width: 200 }"></qrcode>
  16. <div>请使用“云考”App扫描</div>
  17. </div>
  18. </TabPane>
  19. </Tabs>
  20. </div>
  21. </Poptip>
  22. <span v-if="ifShowQr" style="margin: auto 20px">|</span>
  23. <Poptip trigger="hover" width="300">
  24. <span class="name-arrow"
  25. >{{ user.displayName }} &nbsp;
  26. <i
  27. class="ivu-icon ivu-icon-md-arrow-dropdown"
  28. style="vertical-align: middle;"
  29. ></i>
  30. </span>
  31. <div slot="content">
  32. <div class="info qm-primary-text">
  33. <div class="hr info-row">
  34. <div>底照</div>
  35. <div>
  36. <img class="user-avatar" :src="user.photoPath" alt="无底照" />
  37. </div>
  38. </div>
  39. <div class="hr info-row">
  40. <div>学号</div>
  41. <div>{{ user.studentCodeList.join(",") }}</div>
  42. </div>
  43. <div class="hr info-row">
  44. <div>身份证号</div>
  45. <div>{{ user.identityNumber }}</div>
  46. </div>
  47. <div class="hr info-row">
  48. <div>学习中心</div>
  49. <div>{{ user.orgName }}</div>
  50. </div>
  51. <div
  52. v-if="!isEpcc"
  53. style="grid-column: span 2; place-self: center; width: 100%; padding-top: 10px"
  54. >
  55. <i-button class="qm-primary-button" long @click="goChangePwd">
  56. 修改密码
  57. </i-button>
  58. </div>
  59. </div>
  60. </div>
  61. </Poptip>
  62. <span style="margin: auto 20px">|</span>
  63. <a
  64. class="qm-primary-text"
  65. style="display: inline-block; margin-right: 20px; text-align: center;"
  66. @click="() => logout('?LogoutReason=正常退出')"
  67. >退出登录</a
  68. >
  69. </header>
  70. <transition name="fade" appear>
  71. <main :key="$route.path" class="content">
  72. <slot></slot>
  73. </main>
  74. </transition>
  75. <nav class="nav">
  76. <img :src="getLogo" class="qm-logo" />
  77. <ul>
  78. <li>
  79. <router-link class="link" to="/online-exam">
  80. 在线考试
  81. </router-link>
  82. </li>
  83. <li v-if="!isEpcc">
  84. <router-link class="link" to="/online-practice">
  85. 在线练习
  86. </router-link>
  87. </li>
  88. <li v-if="!isEpcc">
  89. <router-link class="link" to="/offline-exam">
  90. 离线考试
  91. </router-link>
  92. </li>
  93. <li v-if="!isEpcc">
  94. <router-link class="link" to="/site-message">
  95. <Badge :count="messageUnread" :offset="[20, -20]">
  96. 公告通知
  97. </Badge>
  98. </router-link>
  99. </li>
  100. <li v-if="!isEpcc">
  101. <router-link class="link" to="/password">
  102. 修改密码
  103. </router-link>
  104. </li>
  105. </ul>
  106. </nav>
  107. <footer class="footer">©️2019 启明泰和</footer>
  108. <SiteMessagePopup />
  109. </div>
  110. </template>
  111. <script>
  112. import { mapState, mapGetters } from "vuex";
  113. import VueQrcode from "@chenfengyuan/vue-qrcode";
  114. import SiteMessagePopup from "./SiteMessagePopup.vue";
  115. export default {
  116. name: "MainLayout",
  117. components: {
  118. qrcode: VueQrcode,
  119. SiteMessagePopup,
  120. },
  121. data() {
  122. return {
  123. appDownloadUrl: "fetching...",
  124. };
  125. },
  126. computed: {
  127. ...mapState(["user", "siteMessages", "QECSConfig"]),
  128. ...mapGetters(["isEpcc"]),
  129. messageUnread() {
  130. return this.siteMessages.filter(v => v.hasRead === false).length;
  131. },
  132. qrValue() {
  133. const { rootOrgId, studentCodeList, identityNumber } = this.user;
  134. return JSON.stringify({
  135. rootOrgId,
  136. studentCode: studentCodeList.join(","),
  137. identityNumber,
  138. });
  139. },
  140. ifShowQr() {
  141. const shouldShow = this.QECSConfig.SHOW_STUDENT_CLIENT_APP_QRCODE;
  142. return shouldShow === "true";
  143. },
  144. getLogo() {
  145. return this.isEpcc
  146. ? require("./epcc-logo.png")
  147. : require("./qm-logo.png");
  148. },
  149. },
  150. async created() {
  151. const r = await this.$http.get(
  152. "/api/ecs_core/systemProperty/APP_DOWNLOAD_URL"
  153. );
  154. this.appDownloadUrl = r.data;
  155. },
  156. methods: {
  157. goChangePwd() {
  158. this.$router.push("/password");
  159. },
  160. },
  161. };
  162. </script>
  163. <style scoped>
  164. .main-layout {
  165. display: grid;
  166. grid-template-areas: "nav header" "nav content" "nav footer";
  167. min-height: 100vh;
  168. grid-template-columns: 180px 1fr;
  169. grid-template-rows: auto 1fr auto;
  170. }
  171. .header {
  172. grid-area: header;
  173. height: 50px;
  174. background-color: #ffffff;
  175. box-shadow: 0px 1px 0px 0px #eeeeee;
  176. text-align: right;
  177. line-height: 50px;
  178. }
  179. .user-avatar {
  180. display: inline-block;
  181. width: 80px;
  182. height: 80px;
  183. object-fit: contain;
  184. }
  185. .info {
  186. width: 260px;
  187. }
  188. .info > div {
  189. min-height: 50px;
  190. }
  191. .hr {
  192. border-bottom: 1px solid #eeeeee;
  193. }
  194. .info-row {
  195. display: grid;
  196. grid-template-columns: 1fr 2fr;
  197. align-items: center;
  198. }
  199. .info-row > div:nth-of-type(odd) {
  200. justify-self: left;
  201. }
  202. .info-row > div:nth-of-type(even) {
  203. justify-self: right;
  204. }
  205. .name-arrow:hover .ivu-icon-md-arrow-dropdown::before {
  206. content: "\F343";
  207. }
  208. .nav {
  209. grid-area: nav;
  210. background-color: rgb(113, 113, 113);
  211. background-repeat: repeat;
  212. width: 180px;
  213. min-height: 100vh;
  214. display: flex;
  215. flex-direction: column;
  216. }
  217. .qm-logo {
  218. width: 80px;
  219. height: 68px;
  220. margin: 30px auto;
  221. }
  222. .flex-center {
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. }
  227. .link {
  228. background-image: url(./link.png);
  229. background-repeat: no-repeat;
  230. background-position: 30px 50%;
  231. /* margin-left: -40px; */
  232. padding-right: 20px;
  233. line-height: 40px;
  234. width: 100%;
  235. display: inline-block;
  236. color: #ffffff;
  237. }
  238. .link >>> .ivu-badge-count {
  239. z-index: 1;
  240. }
  241. .router-link-active,
  242. .link:hover {
  243. background-image: url(./link-active.png);
  244. background-color: rgba(255, 255, 255, 0.5);
  245. color: #fafafa;
  246. }
  247. .footer {
  248. grid-area: footer;
  249. margin-bottom: 10px;
  250. }
  251. </style>