Header.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <div class="header" ref="headerMenu">
  3. <el-dialog title="绑定邮箱" center width="450px" :visible.sync="bindEmailData.dialogShow">
  4. <bindEmail
  5. :rowsData="rowsData"
  6. @update-showEmailSuccess="updateShowEmailSuccess"
  7. ></bindEmail>
  8. </el-dialog>
  9. <!-- 重置密码 -->
  10. <el-dialog
  11. title="修改密码"
  12. center
  13. class="page_dialog"
  14. width="450px"
  15. :append-to-body="true"
  16. :visible.sync="editPassWordData.dialogShow"
  17. >
  18. <div class="dialog_center padding_20">
  19. <el-form :model="editPassWordData" label-width="120px" :rules="editPassWordDataRules" ref="editPassWordData">
  20. <el-form-item label="原始密码: " prop="passWord">
  21. <el-input v-model="editPassWordData.passWord" show-password/>
  22. </el-form-item>
  23. <el-form-item label="新密码:" prop="newPassWord">
  24. <el-input v-model="editPassWordData.newPassWord" show-password/>
  25. </el-form-item>
  26. <el-form-item label="确认密码:" prop="confirmNewPassWord">
  27. <el-input v-model="editPassWordData.confirmNewPassWord" show-password/>
  28. </el-form-item>
  29. </el-form>
  30. </div>
  31. <div slot="footer" class="dialog-footer">
  32. <el-button @click="editPassWordData.dialogShow = false">取 消</el-button>
  33. <el-button type="primary" @click="confirmPassWord">确 定</el-button>
  34. </div>
  35. </el-dialog>
  36. <!-- 绑定邮箱 -->
  37. <el-dialog
  38. title="绑定邮箱"
  39. width="480px"
  40. :append-to-body="true"
  41. :visible.sync="editBindEmail.dialogShow"
  42. >
  43. <div v-if="userEmail" ref="emailInfo">
  44. <div>
  45. <p style="color: #000; font-size: 16px; padding: 16px 65px">
  46. 已绑定邮箱
  47. </p>
  48. <div
  49. style="
  50. border: 1px solid #e4e7ed;
  51. border-radius: 6px;
  52. padding: 16px 20px;
  53. width: 389px;
  54. margin-left: 0px;
  55. "
  56. >
  57. <div style="display: inline-block">
  58. <p style="color: #303133; font-size: 18px">
  59. {{ userEmail }}
  60. </p>
  61. </div>
  62. <div style="display: inline-block; margin-left: 85px">
  63. <el-button type="primary" plain @click="setClearEmail"
  64. >解除绑定</el-button
  65. >
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. <div v-if="!userEmail">
  71. <div
  72. style="
  73. border-radius: 6px;
  74. padding: 16px 20px;
  75. width: 389px;
  76. text-align: center;
  77. margin-left: 0px;
  78. "
  79. >
  80. <p style="color: #606266; font-size: 18px; margin-bottom: 10px">
  81. 暂未绑定邮箱
  82. </p>
  83. <el-button type="primary" @click="setEmail">立即绑定</el-button>
  84. </div>
  85. </div>
  86. <p style="color: #909399; font-size: 12px; margin-top: 66px">
  87. *每个账号仅允许绑定一个邮箱号,每个邮箱号仅支持绑定一个账号
  88. </p>
  89. </el-dialog>
  90. <div class="headerBox">
  91. <div class="logo">
  92. <img alt="" :src="schoolLogo" class="header_icon" v-if="schoolLogo"/>
  93. <img src="@/assets/head_icon.svg" alt="" class="header_icon" v-else/>
  94. <div class="top_title_blod">大数据精准教学诊断平台</div>
  95. <img class="version_icon" src="@/assets/version.webp" alt="">
  96. </div>
  97. <div class="headerMenu">
  98. <div class="menuList">
  99. <el-menu
  100. :default-active="activeMenuName"
  101. class="el-menu-wrap"
  102. mode="horizontal"
  103. :router="true"
  104. @select="menuSelect"
  105. background-color="#2E64FA"
  106. text-color="#fff"
  107. active-text-color="#fff"
  108. >
  109. <el-menu-item
  110. :index="item.externalLink"
  111. v-for="(item, index) in menuList"
  112. :class="{report:item.versions}"
  113. :key="index"
  114. >
  115. <span class="menuName">{{ item.menuName }}</span>
  116. <!-- <div class="versions" v-if="item.versions"><span>V</span><span>{{ item.versions }}</span></div> -->
  117. </el-menu-item>
  118. </el-menu>
  119. </div>
  120. </div>
  121. <div class="user_info">
  122. <el-dropdown
  123. @command="UserCommand"
  124. placement="top-start"
  125. trigger="click"
  126. >
  127. <span class="user_name">
  128. {{ studentName }}<i class="el-icon-arrow-down"></i>
  129. </span>
  130. <el-dropdown-menu slot="dropdown">
  131. <!-- <el-dropdown-item command="bindUserEmail">绑定邮箱</el-dropdown-item> -->
  132. <el-dropdown-item command="setPassWord">修改密码</el-dropdown-item>
  133. <el-dropdown-item command="logout">退出登录</el-dropdown-item>
  134. </el-dropdown-menu>
  135. </el-dropdown>
  136. </div>
  137. </div>
  138. </div>
  139. </template>
  140. <script>
  141. import { mapGetters } from "vuex";
  142. import bindEmail from "@/views/userInfo/components/userSetting/bindEmail.vue";
  143. import { encrypt } from "@/utils/jsencrypt";
  144. import { removeToken } from "@/utils/auth";
  145. export default {
  146. computed: {
  147. ...mapGetters(["userInfo"]),
  148. // 用户名
  149. studentName() {
  150. return this.userInfo.userName;
  151. },
  152. // 用户邮箱
  153. userEmail() {
  154. return this.userInfo.userEmail;
  155. },
  156. schoolLogo() {
  157. return this.$store.state.user.schoolLogo || "";
  158. }
  159. },
  160. components: {
  161. bindEmail,
  162. },
  163. data() {
  164. return {
  165. activeMenuName: "/userInfo/personInfo",
  166. editPassWordData: {
  167. dialogShow: false,
  168. confirmNewPassWord: "",
  169. newPassWord: "",
  170. passWord: "",
  171. },
  172. editPassWordDataRules: {
  173. newPassWord: [
  174. { required: true, message: "请输入新密码", trigger: "blur" },
  175. ],
  176. confirmNewPassWord: [
  177. { required: true, message: "请输入确认新密码", trigger: "blur" },
  178. ],
  179. passWord: [
  180. { required: true, message: "请输入原密码", trigger: "blur" },
  181. ],
  182. },
  183. editBindEmail: {
  184. dialogShow: false,
  185. email: "",
  186. },
  187. bindEmailData: {
  188. dialogShow: false,
  189. },
  190. rowsData: {},
  191. menuList: [],
  192. };
  193. },
  194. created() {
  195. this.activeMenu();
  196. //学生端默认 个人中心 和分析报告两个菜单
  197. const baseMenuList = [
  198. {
  199. menuName: "分析报告",
  200. externalLink: "/jointStudentAnalysisReport/list",
  201. },
  202. {
  203. menuName: "靶向提升",
  204. externalLink: "/targetImprove",
  205. },
  206. {
  207. menuName: "个人中心",
  208. externalLink: "/userInfo",
  209. },
  210. ];
  211. this.menuList = baseMenuList;
  212. },
  213. methods: {
  214. updateShowEmailSuccess(show) {
  215. this.$refs.headerMenu.style.zIndex = 600;
  216. this.bindEmailData.dialogShow = show;
  217. },
  218. setClearEmail() {
  219. this.$confirm(`确认要解绑邮箱?`, "提示", {
  220. confirmButtonText: "确定",
  221. cancelButtonText: "取消",
  222. type: "warning",
  223. })
  224. .then(() => {
  225. let param = { ids: [this.userInfo.id] };
  226. this.$api.school
  227. .batchUnBindUserEmail(param)
  228. .then((res) => {
  229. if (res.code == 200) {
  230. this.$message({
  231. message: "解绑成功!",
  232. type: "success",
  233. offset:100
  234. });
  235. this.editBindEmail.dialogShow = false;
  236. location.reload();
  237. }
  238. })
  239. .catch((err) => {});
  240. })
  241. .catch(() => {
  242. //取消
  243. });
  244. },
  245. setEmail() {
  246. this.rowsData = this.userInfo;
  247. this.editBindEmail.dialogShow = false;
  248. this.$refs.headerMenu.style.zIndex = 8888;
  249. setTimeout(() => {
  250. this.bindEmailData.dialogShow = true;
  251. }, 500);
  252. },
  253. activeMenu() {
  254. const path = this.$route.path;
  255. sessionStorage.setItem('student_currentPath', path);//当前页面路由
  256. // 按优先级匹配
  257. if(path == '/jointStudentAnalysisReport/list'){
  258. sessionStorage.setItem('schoolType', 2);//联校
  259. this.activeMenuName = '/jointStudentAnalysisReport/list';
  260. }else if(path == '/targetImprove' || path.startsWith('/targetImprove/')){
  261. this.activeMenuName = '/targetImprove';
  262. }
  263. else if (path === '/userInfo' || path.startsWith('/userInfo/')) {
  264. this.activeMenuName = '/userInfo';
  265. } else {
  266. // 默认选中分析报告
  267. const schoolType = sessionStorage.getItem('schoolType');
  268. if(schoolType == 1){//单校
  269. this.activeMenuName = '/studentAnalysisReport/list';
  270. }else if(schoolType == 2){
  271. this.activeMenuName = '/jointStudentAnalysisReport/list';
  272. }
  273. }
  274. },
  275. menuSelect(key, keyPath) {
  276. // let pathMenu = ["/examMarking","/userInfo","/analysisReportList/list","/knowTopic"];
  277. // // let toPathMenu = ["/userInfo/personInfo"]
  278. // if(key == "/userInfo"){
  279. // key = "/userInfo"
  280. // }
  281. // this.activeMenuName = key;
  282. },
  283. UserCommand(command) {
  284. if (command == "logout") {
  285. this.Logout();
  286. } else if (command == "setPassWord") {
  287. this.OpenUpdatePassWord();
  288. } else if (command == "bindUserEmail") {
  289. this.setBindEmail();
  290. }
  291. },
  292. // 退出登录
  293. Logout() {
  294. this.$store.dispatch("user/logout");
  295. localStorage.clear();
  296. let url=process.env.VUE_APP_BASE+'/marking/#/login';//退出到考阅登录页
  297. window.location.replace(url)
  298. window.parent.location.href = `${process.env.VUE_APP_BASE}/marking/#/login`;//兼容父级iframe
  299. },
  300. //打开修改密码弹窗
  301. OpenUpdatePassWord()
  302. {
  303. this.editPassWordData.dialogShow = true;
  304. },
  305. setBindEmail() {
  306. this.editBindEmail.dialogShow = true;
  307. },
  308. confirmPassWord() {
  309. this.$refs.editPassWordData.validate((valid) => {
  310. if (valid) {
  311. let { newPassWord, passWord, confirmNewPassWord } =
  312. this.editPassWordData;
  313. if (newPassWord != confirmNewPassWord) {
  314. this.$message({
  315. message: "两次输入密码不一致",
  316. type: "warning",
  317. offset:100
  318. });
  319. return;
  320. }
  321. let param = {
  322. newPassword: encrypt(newPassWord.trim()),
  323. oldPassword: encrypt(passWord),
  324. // confirmNewPassword: encrypt(confirmNewPassWord),
  325. };
  326. this.$api.user
  327. .changeMinePassword(param)
  328. .then((res) => {
  329. if (res.code == 200) {
  330. this.$message({
  331. message: "修改成功",
  332. type: "success",
  333. offset:100
  334. });
  335. this.editPassWordData = {
  336. dialogShow: false,
  337. confirmNewPassWord: "",
  338. newPassWord: "",
  339. passWord: "",
  340. };
  341. }
  342. else
  343. {
  344. this.$message({
  345. message: "修改失败!"+res.msg,
  346. type: "error",
  347. offset:100
  348. });
  349. }
  350. })
  351. .catch(() => {
  352. this.$message({
  353. message: "修改失败",
  354. type: "error",
  355. offset:100
  356. });
  357. });
  358. }
  359. });
  360. },
  361. },
  362. };
  363. </script>
  364. <style lang="scss" scoped>
  365. .header {
  366. width: 100%;
  367. height: 60px;
  368. font-size: 22px;
  369. color: #fff;
  370. box-sizing: border-box;
  371. z-index: 9;
  372. position: fixed;
  373. top: 0;
  374. left: 0;
  375. // background-color: #2365ae;
  376. background-color: #2e64fa;
  377. }
  378. .headerBox {
  379. // margin: 0 auto;
  380. box-sizing: border-box;
  381. height: 60px;
  382. display: flex;
  383. flex-direction: row;
  384. justify-content: space-between;
  385. align-items: center;
  386. padding: 0 20px;
  387. .logo {
  388. min-width: 430px;
  389. width: auto;
  390. display: inline-flex;
  391. align-items: center;
  392. margin-right: 60px;
  393. div.top_title_blod {
  394. font-size: 26px;
  395. font-weight: 500;
  396. color: #fff;
  397. text-align: center;
  398. vertical-align: middle;
  399. margin: 0 10px;
  400. }
  401. p.top_subTitle {
  402. font-size: 14px;
  403. font-weight: 400;
  404. color: #ffffff;
  405. margin-bottom: 2px;
  406. }
  407. img.header_icon {
  408. width: 48px;
  409. height: 48px;
  410. border-radius: 50%;
  411. }
  412. img.project_title {
  413. width: 207px;
  414. height: 27px;
  415. }
  416. img.version_icon {
  417. width: 75px;
  418. }
  419. }
  420. .headerMenu {
  421. flex: 1;
  422. // margin-left:100px;
  423. // width:816px;
  424. display: flex;
  425. }
  426. .el-menu-wrap {
  427. height: 60px;
  428. li {
  429. font-size: 18px;
  430. border-bottom: 0;
  431. padding: 0 20px;
  432. line-height: 60px;
  433. height: 60px;
  434. position: relative;
  435. &.report{
  436. padding: 0 60px 0 20px;
  437. }
  438. &.is-active {
  439. font-weight: bold;
  440. background-color: rgba(0, 0, 0, 0.2) !important;
  441. }
  442. .versions{
  443. position: absolute;
  444. right: 24px;
  445. top:8px;
  446. width: 34px;
  447. height: 18px;
  448. border-radius: 25px;
  449. border: 1px solid #FFFFFF;
  450. display: inline-flex;
  451. justify-content: center;
  452. align-items: center;
  453. span{
  454. display: inline-flex;
  455. justify-content: center;
  456. align-items: center;
  457. box-sizing: border-box;
  458. line-height: normal;
  459. transform: scale(0.9);
  460. &:first-child{
  461. font-size: 12px;
  462. margin-right: 2px;
  463. line-height: 12px;
  464. }
  465. &:nth-child(2){
  466. font-size: 12px;
  467. }
  468. }
  469. }
  470. }
  471. }
  472. .userName {
  473. display: inline-flex;
  474. justify-content: center;
  475. align-items: center;
  476. font-size: 14px;
  477. white-space: nowrap;
  478. overflow: hidden;
  479. text-overflow: ellipsis;
  480. color: #fff;
  481. cursor: pointer;
  482. .userIconSty {
  483. margin-left: 6px;
  484. font-size: 20px;
  485. }
  486. }
  487. }
  488. .user_info
  489. {
  490. width: auto;
  491. // background-color: red;
  492. // margin-right: -10px;
  493. line-height: 30px;
  494. .user_name
  495. {
  496. font-size: 15px;
  497. color:#fff;
  498. cursor: pointer;
  499. i
  500. {
  501. margin-left: 10px;
  502. }
  503. }
  504. }
  505. .el-dropdown-menu {
  506. left: auto !important; /* 取消默认左对齐 */
  507. right: 30px !important; /* 右对齐 */
  508. }
  509. :deep() .el-menu.el-menu--horizontal {
  510. border-bottom: 0px;
  511. }
  512. button.el-button {
  513. height: 36px;
  514. display: inline-flex;
  515. align-items: center;
  516. justify-content: center;
  517. }
  518. .edit_pass_word {
  519. padding: 20px;
  520. .dialog_footer {
  521. padding: 0 !important;
  522. width: calc(100% - 40px);
  523. margin: auto;
  524. height: 64px;
  525. display: flex;
  526. justify-content: space-between;
  527. .footer_left {
  528. width: auto;
  529. height: 64px;
  530. }
  531. .footer_right {
  532. width: auto;
  533. height: 64px;
  534. display: flex;
  535. justify-content: flex-end;
  536. align-items: center;
  537. }
  538. }
  539. }
  540. </style>