MainLayout.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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. >
  68. {{ isEpcc ? "返回" : "退出登录" }}
  69. </a>
  70. </header>
  71. <transition name="fade" appear>
  72. <main :key="$route.path" class="content">
  73. <slot></slot>
  74. </main>
  75. </transition>
  76. <nav class="nav">
  77. <img :src="getLogo" class="qm-logo" />
  78. <ul>
  79. <li>
  80. <router-link class="link" to="/online-exam">
  81. 在线考试
  82. </router-link>
  83. </li>
  84. <li v-if="!isEpcc">
  85. <router-link class="link" to="/online-practice">
  86. 在线练习
  87. </router-link>
  88. </li>
  89. <li v-if="!isEpcc">
  90. <router-link class="link" to="/offline-exam">
  91. {{ isCug ? "考查课考核" : "离线考试" }}
  92. </router-link>
  93. </li>
  94. <li v-if="!isEpcc">
  95. <router-link class="link" to="/site-message">
  96. <Badge :count="messageUnread" :offset="[20, -20]">
  97. 公告通知
  98. </Badge>
  99. </router-link>
  100. </li>
  101. <li v-if="!isEpcc">
  102. <router-link class="link" to="/password">
  103. 修改密码
  104. </router-link>
  105. </li>
  106. </ul>
  107. </nav>
  108. <footer class="footer">©️2019 启明泰和</footer>
  109. <SiteMessagePopup />
  110. </div>
  111. </template>
  112. <script>
  113. import { mapState, mapGetters } from "vuex";
  114. import VueQrcode from "@chenfengyuan/vue-qrcode";
  115. import SiteMessagePopup from "./SiteMessagePopup.vue";
  116. export default {
  117. name: "MainLayout",
  118. components: {
  119. qrcode: VueQrcode,
  120. SiteMessagePopup,
  121. },
  122. data() {
  123. return {
  124. appDownloadUrl: "fetching...",
  125. ifShowQr: false,
  126. };
  127. },
  128. computed: {
  129. ...mapState(["user", "siteMessages", "QECSConfig"]),
  130. ...mapGetters(["isEpcc", "isCug"]),
  131. messageUnread() {
  132. return this.siteMessages.filter(v => v.hasRead === false).length;
  133. },
  134. qrValue() {
  135. const { rootOrgId, studentCodeList, identityNumber } = this.user;
  136. return JSON.stringify({
  137. rootOrgId,
  138. studentCode: studentCodeList.join(","),
  139. identityNumber,
  140. });
  141. },
  142. // ifShowQr() {
  143. // const shouldShow = this.QECSConfig.SHOW_STUDENT_CLIENT_APP_QRCODE;
  144. // return shouldShow === "true";
  145. // },
  146. getLogo() {
  147. return this.isEpcc
  148. ? require("./epcc-logo.png")
  149. : require("./qm-logo.png");
  150. },
  151. },
  152. async created() {
  153. const r = await this.$http.get(
  154. "/api/ecs_core/systemProperty/APP_DOWNLOAD_URL"
  155. );
  156. this.appDownloadUrl = r.data;
  157. const r2 = await this.$http.get(
  158. `/api/ecs_core/org/property/${this.user.rootOrgId}/APP_ENABLED`
  159. );
  160. this.ifShowQr = r2.data;
  161. },
  162. methods: {
  163. goChangePwd() {
  164. this.$router.push("/password");
  165. },
  166. },
  167. };
  168. </script>
  169. <style scoped>
  170. .main-layout {
  171. display: grid;
  172. grid-template-areas: "nav header" "nav content" "nav footer";
  173. min-height: 100vh;
  174. grid-template-columns: 180px 1fr;
  175. grid-template-rows: auto 1fr auto;
  176. }
  177. .header {
  178. grid-area: header;
  179. height: 50px;
  180. background-color: #ffffff;
  181. box-shadow: 0px 1px 0px 0px #eeeeee;
  182. text-align: right;
  183. line-height: 50px;
  184. }
  185. .user-avatar {
  186. display: inline-block;
  187. width: 80px;
  188. height: 80px;
  189. object-fit: contain;
  190. }
  191. .info {
  192. width: 260px;
  193. }
  194. .info > div {
  195. min-height: 50px;
  196. }
  197. .hr {
  198. border-bottom: 1px solid #eeeeee;
  199. }
  200. .info-row {
  201. display: grid;
  202. grid-template-columns: 1fr 2fr;
  203. align-items: center;
  204. }
  205. .info-row > div:nth-of-type(odd) {
  206. justify-self: left;
  207. }
  208. .info-row > div:nth-of-type(even) {
  209. justify-self: right;
  210. }
  211. .name-arrow:hover .ivu-icon-md-arrow-dropdown::before {
  212. content: "\F343";
  213. }
  214. .nav {
  215. grid-area: nav;
  216. background-color: rgb(113, 113, 113);
  217. background-repeat: repeat;
  218. width: 180px;
  219. min-height: 100vh;
  220. display: flex;
  221. flex-direction: column;
  222. }
  223. .qm-logo {
  224. width: 80px;
  225. height: 68px;
  226. margin: 30px auto;
  227. }
  228. .flex-center {
  229. display: flex;
  230. flex-direction: column;
  231. align-items: center;
  232. }
  233. .link {
  234. background-image: url(./link.png);
  235. background-repeat: no-repeat;
  236. background-position: 30px 50%;
  237. padding-left: 45px;
  238. text-align: left;
  239. padding-right: 20px;
  240. line-height: 40px;
  241. width: 100%;
  242. display: inline-block;
  243. color: #ffffff;
  244. }
  245. .link >>> .ivu-badge-count {
  246. z-index: 1;
  247. }
  248. .router-link-active,
  249. .link:hover {
  250. background-image: url(./link-active.png);
  251. background-color: rgba(255, 255, 255, 0.5);
  252. color: #fafafa;
  253. }
  254. .footer {
  255. grid-area: footer;
  256. margin-bottom: 10px;
  257. }
  258. </style>