123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- <template>
- <div id="navBar">
- <el-menu class="navbar" mode="horizontal">
- <div class="user-profile-container">
- <div class="user-profile-content">
- <div class="menu-icons">
- <!-- <span class="menu-icon"><i class="el-icon-search icon"></i></span>
- <span class="menu-icon"><i class="el-icon-message icon"></i></span> -->
- <span class="menu-icon">
- <mission v-if="user.type === '0'"></mission>
- </span>
- </div>
- <el-dropdown @command="handleCommand" style="z-index:99">
- <div class="user-profile-body">
- <img class="user-avatar" src="https://img.alicdn.com/tfs/TB1ONhloamWBuNjy1XaXXXCbXXa-200-200.png" />
- <span class="user-name" v-if="user && user.userid">欢迎,{{ (user && user.name) || '' }}</span>
- <span class="user-name" v-else @click="toLogin">请登录</span>
- </div>
- <el-dropdown-menu class="user-dropdown" slot="dropdown" v-if="user && user.userid">
- <el-dropdown-item :divided="true" command="weixin"> <img :src="weixin" style="zoom:0.1" /> 绑定/更绑微信 </el-dropdown-item>
- <!-- <el-dropdown-item :divided="true" icon="el-icon-key" command="passwd">
- 修改密码
- </el-dropdown-item> -->
- <el-dropdown-item :divided="true" icon="el-icon-back" command="backHome">
- 业务切换
- </el-dropdown-item>
- <el-dropdown-item :divided="true" icon="el-icon-guide" command="logout">
- 退出
- </el-dropdown-item>
- </el-dropdown-menu>
- </el-dropdown>
- </div>
- </div>
- <div>
- <def-sel @refresh="toRefresh" :key="defSelKey" v-on="$listeners"></def-sel>
- </div>
- </el-menu>
- <el-dialog title="修改密码" :visible.sync="dialog" center @close="toClose" :destroy-on-close="true">
- <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="true"> </data-form>
- </el-dialog>
- <el-dialog :visible.sync="wxDialog" title="绑定微信" width="30%" center :destroy-on-close="true">
- <el-row type="flex" justify="center">
- <el-col :span="24" style="text-align:center">
- <qrcode exchange="qrcode.bind" v-if="qrUri" :uri="qrUri" :config="config" :qrcode="qrcode" @toReturn="toReturn"> </qrcode>
- </el-col>
- </el-row>
- </el-dialog>
- </div>
- </template>
- <script>
- import mission from '@frame/components/mission-icon.vue';
- import Vue from 'vue';
- import defSel from '@frame/layout/admin/navBar/default-select.vue';
- import '@frame/plugins/setting';
- import qrcode from '@frame/components/qrcode.vue';
- import dataForm from '@frame/components/form';
- import { mapState, mapMutations, createNamespacedHelpers } from 'vuex';
- import _ from 'lodash';
- const { mapActions } = createNamespacedHelpers('login');
- export default {
- name: 'navBar',
- props: {},
- components: { dataForm, qrcode, defSel, mission },
- data: () => ({
- weixin: require('@frame/assets/wechat.png'),
- dataUrl: '',
- info: {},
- dialog: false,
- wxDialog: false,
- fields: [{ label: '密码', required: true, model: 'passwd', type: 'password', tip: '密码至少6位' }],
- rules: {
- passwd: [
- { required: true, message: '请输入密码' },
- { min: 6, message: '密码最少6位', trigger: 'blur' },
- ],
- },
- qrUri: '',
- config: {},
- qrcode: '',
- defSelKey: new Date().getTime(),
- }),
- created() {},
- computed: {
- ...mapState(['user']),
- },
- methods: {
- ...mapMutations(['deleteUser', 'changeOption']),
- ...mapActions(['login', 'update', 'getQrcode', 'logout']),
- async toLogout() {
- // 云就业退出
- const res = await this.logout(this.user.id);
- console.log(res);
- if (res.data) {
- this.deleteUser();
- this.$notify({
- title: '注销成功',
- type: 'success',
- });
- console.log(res.data);
- window.location.replace(res.data);
- }
- // this.toLogin();
- },
- handleCommand(type) {
- if (type === 'logout') this.toLogout();
- if (type === 'passwd') this.toPasswd();
- if (type === 'weixin') this.bind();
- if (type === 'backHome') this.backHome();
- },
- async toLogin() {
- this.$router.push({ name: 'login' });
- },
- toPasswd() {
- this.dialog = true;
- },
- backHome() {
- window.location.replace('https://zhjy.jilinjobs.cn:8080/dist/school.html#/navi');
- },
- toClose() {
- this.info = {};
- this.dialog = false;
- },
- async handleSave({ data }) {
- data.id = this.user.id;
- let res = await this.update(data);
- if (this.$checkRes(res, '修改成功', '修改失败')) this.toClose();
- },
- async bind() {
- let res = await this.getQrcode();
- this.$set(this, `qrcode`, res);
- this.$set(this, `config`, { weixin: Vue.config.weixin, stomp: Vue.config.stomp });
- let user_id = this.user.id;
- if (!user_id) {
- let localuser = localStorage.getItem('user');
- if (localuser) {
- localuser = JSON.parse(localuser);
- user_id = localuser.id;
- }
- }
- let uri = `/api/train/auth?redirect_uri=${Vue.config.weixin.target}/confirm?uid=${user_id}&type=1&qrcode=${res}`;
- this.$set(this, `qrUri`, uri);
- this.wxDialog = true;
- },
- toReturn(message) {
- this.$notify({
- type: 'success',
- message: message.body,
- });
- },
- toRefresh() {
- this.defSelKey = new Date().getTime();
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .navbar {
- height: 4rem;
- box-shadow: 0 0.0625rem 0.25rem rgba(0, 21, 41, 0.08);
- .user-profile-container {
- position: absolute;
- right: 1.25rem;
- cursor: pointer;
- .user-profile-content {
- display: flex;
- padding: 1.25rem 0;
- }
- .menu-icons {
- display: flex;
- align-items: center;
- .menu-icon {
- padding: 0 0.75rem;
- .icon {
- display: inline-block;
- font-size: 1.125rem;
- text-align: center;
- }
- }
- }
- .user-profile-body {
- position: relative;
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- text-align: center;
- padding-right: 0.875rem;
- }
- .user-avatar {
- width: 1.5rem;
- height: 1.5rem;
- margin: 0 0.5rem 0 0.75rem;
- border-radius: 0.25rem;
- }
- .user-name {
- color: rgba(0, 0, 0, 0.65);
- }
- .user-department {
- font-size: 0.75rem;
- color: rgba(102, 102, 102, 0.65);
- }
- .el-icon-caret-bottom {
- position: absolute;
- right: 0;
- top: 0.8125rem;
- font-size: 0.75rem;
- }
- }
- }
- </style>
|