| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499 |
- <template>
- <div class="page-account">
- <div class="container" :class="[fullWidth > 768 ? 'containerSamll' : 'containerBig']">
- <swiper :options="swiperOption" class="swiperPross" v-if="fullWidth > 768">
- <swiper-slide class="swiperPic" v-for="(item, index) in swiperList" :key="index">
- <img :src="item.slide" alt="" />
- </swiper-slide>
- <div class="swiper-pagination" slot="pagination"></div>
- </swiper>
- <div class="index_from page-account-container from-wh">
- <div class="page-account-top">
- <div class="page-account-top-logo">
- <img :src="login_logo" alt="logo" style="width: 100%; height: 74px" />
- </div>
- </div>
- <Form ref="formInline" :model="formInline" :rules="ruleInline" @keyup.enter="handleSubmit('formInline')">
- <FormItem prop="username">
- <Input
- type="text"
- v-model="formInline.username"
- prefix="ios-contact-outline"
- placeholder="请输入用户名"
- size="large"
- />
- </FormItem>
- <FormItem prop="password">
- <Input
- type="password"
- v-model="formInline.password"
- prefix="ios-lock-outline"
- placeholder="请输入密码"
- size="large"
- />
- </FormItem>
- <!-- <FormItem prop="code">
- <div class="code">
- <Input
- type="text"
- v-model="formInline.code"
- prefix="ios-keypad-outline"
- placeholder="请输入验证码"
- size="large"
- />
- <img :src="imgcode" class="pictrue" @click="captchas" />
- </div>
- </FormItem> -->
- <FormItem class="pt10">
- <Button type="primary" long :loading="loading" size="large" @click="handleSubmit('formInline')" class="btn"
- >登录</Button
- >
- </FormItem>
- </Form>
- </div>
- </div>
- <Verify
- @success="success"
- captchaType="blockPuzzle"
- :imgSize="{ width: '330px', height: '155px' }"
- ref="verify"
- ></Verify>
- <div class="footer">
- <div class="pull-right" v-if="copyright">{{ copyright }}</div>
- <div class="pull-right" v-else>
- Copyright © 2014-2023 <a href="https://www.crmeb.com" target="_blank">{{ version }}</a>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { AccountLogin, loginInfoApi } from '@/api/account';
- import { getWorkermanUrl } from '@/api/kefu';
- import { setCookies } from '@/libs/util';
- import '@/assets/js/canvas-nest.min';
- import Verify from '@/components/verifition/Verify';
- import { PrevLoading } from '@/utils/loading.js';
- import { formatFlatteningRoutes, findFirstNonNullChildren } from '@/libs/system';
- export default {
- components: {
- Verify,
- },
- data() {
- return {
- fullWidth: document.documentElement.clientWidth,
- swiperOption: {
- pagination: '.swiper-pagination',
- autoplay: true,
- },
- loading: false,
- isShow: false,
- autoLogin: true,
- imgcode: '',
- formInline: {
- username: '',
- password: '',
- },
- ruleInline: {
- username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
- password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
- },
- login_captcha: 0,
- // jigsaw: null,
- login_logo: '',
- swiperList: [],
- defaultSwiperList: require('@/assets/images/sw.jpg'),
- key: '',
- copyright: '',
- version: '',
- };
- },
- created() {
- const _this = this;
- document.onkeydown = function () {
- if (_this.$route.name === 'login') {
- let key = window.event.keyCode;
- if (key === 13) {
- _this.handleSubmit('formInline');
- }
- }
- };
- window.addEventListener('resize', this.handleResize);
- },
- watch: {
- fullWidth(val) {
- // 为了避免频繁触发resize函数导致页面卡顿,使用定时器
- if (!this.timer) {
- // 一旦监听到的screenWidth值改变,就将其重新赋给data里的screenWidth
- this.screenWidth = val;
- this.timer = true;
- let that = this;
- setTimeout(function () {
- // 打印screenWidth变化的值
- that.timer = false;
- }, 400);
- }
- },
- $route(n) {},
- },
- mounted: function () {
- this.$nextTick(() => {
- // /* eslint-disable */
- let that = this;
- // this.jigsaw = jigsaw.init({
- // el: this.$refs.captcha,
- // onSuccess() {
- // that.modals = false;
- // that.closeModel();
- // },
- // onFail: this.closefail,
- // onRefresh() {},
- // });
- if (this.screenWidth < 768) {
- document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
- } else {
- document.getElementsByTagName('canvas')[0].className = 'index_bg';
- }
- this.swiperData();
- });
- },
- methods: {
- swiperData() {
- loginInfoApi()
- .then((res) => {
- window.document.title = `${res.data.site_name} - 登录`;
- localStorage.setItem('ADMIN_TITLE', res.data.site_name || '');
- this.$store.commit('setAdminTitle', res.data.site_name);
- let data = res.data || {};
- this.login_logo = data.login_logo ? data.login_logo : require('@/assets/images/logo.png');
- this.swiperList = data.slide.length ? data.slide : [{ slide: this.defaultSwiperList }];
- this.key = data.key;
- this.copyright = data.copyright;
- this.version = data.version;
- this.login_captcha = data.login_captcha;
- })
- .catch((err) => {
- this.$Message.error(err);
- this.login_logo = require('@/assets/images/logo.png');
- this.swiperList = [{ slide: this.defaultSwiperList }];
- });
- },
- success(params) {
- this.closeModel(params);
- },
- // 关闭模态框
- closeModel(params) {
- this.isShow = false;
- // noinspection JSVoidFunctionReturnValueUsed
- let msg = this.$Message.loading({
- content: '登录中...',
- duration: 0,
- });
- this.loading = true;
- AccountLogin({
- account: this.formInline.username,
- pwd: this.formInline.password,
- key: this.key,
- captchaType: 'blockPuzzle',
- captchaVerification: params ? params.captchaVerification : '',
- })
- .then(async (res) => {
- msg();
- let data = res.data;
- let expires = this.getExpiresTime(data.expires_time);
- // 记录用户登陆信息
- setCookies('uuid', data.user_info.id, expires);
- setCookies('token', data.token, expires);
- setCookies('expires_time', data.expires_time, expires);
- this.$store.commit('userInfo/uniqueAuth', data.unique_auth);
- this.$store.commit('userInfo/userInfo', data.user_info);
- // 保存菜单信息
- this.$store.commit('menus/setopenMenus', []);
- this.$store.commit('menus/getmenusNav', data.menus);
- this.$store.dispatch('routesList/setRoutesList', data.menus);
- let arr = formatFlatteningRoutes(this.$router.options.routes);
- this.formatTwoStageRoutes(arr);
- this.$store.commit('menus/setOneLvMenus', arr);
- let routes = formatFlatteningRoutes(data.menus);
- this.$store.commit('menus/setOneLvRoute', routes);
- // 记录用户信息
- this.$store.commit('userInfo/name', data.user_info.account);
- this.$store.commit('userInfo/avatar', data.user_info.head_pic);
- this.$store.commit('userInfo/access', data.unique_auth);
- this.$store.commit('userInfo/logo', data.logo);
- this.$store.commit('userInfo/logoSmall', data.logo_square);
- this.$store.commit('userInfo/version', data.version);
- this.$store.commit('userInfo/newOrderAudioLink', data.newOrderAudioLink);
- this.login_captcha = 0;
- try {
- if (data.queue === false) {
- this.$Notice.warning({
- title: '温馨提示',
- desc: '您的【消息队列】未开启,没有开启会导致异步任务无法执行。请尽快执行命令开启!!<a href="https://doc.crmeb.com/single/crmeb_v4/7217" target="_blank">点击查看开启方法</a>',
- duration: 30,
- });
- }
- if (data.timer === false) {
- this.$Notice.warning({
- title: '温馨提示',
- desc: '您的【定时任务】未开启,没有开启会导致自动收货、未支付自动取消订单、订单自动好评、拼团到期退款等任务无法正常执行。请尽快执行命令开启!!<a href="https://doc.crmeb.com/single/crmeb_v4/7211" target="_blank">点击查看开启方法</a>',
- duration: 30,
- });
- }
- this.checkSocket();
- } catch (e) {}
- PrevLoading.start();
- return this.$router.push({
- path: findFirstNonNullChildren(res.data.menus).path || this.$routeProStr + '/',
- });
- })
- .catch((res) => {
- msg();
- let data = res === undefined ? {} : res;
- this.$Message.error(data.msg || '登录失败');
- this.login_captcha = res.data.login_captcha;
- });
- setTimeout((e) => {
- this.loading = false;
- }, 1000);
- },
- formatTwoStageRoutes(arr) {
- if (arr.length <= 0) return false;
- const newArr = [];
- const cacheList = [];
- arr.forEach((v) => {
- if (v && v.meta && v.meta.keepAlive) {
- newArr.push({ ...v });
- cacheList.push(v.name);
- this.$store.dispatch('keepAliveNames/setCacheKeepAlive', cacheList);
- }
- });
- return newArr;
- },
- checkSocket() {
- getWorkermanUrl().then((res) => {
- let url = res.data.admin;
- let isNotice = false;
- let socket = new WebSocket(url);
- socket.onopen = () => {
- isNotice = true;
- socket.close();
- };
- socket.onerror = (err) => {
- if (!isNotice) {
- isNotice = true;
- this.$Notice.warning({
- title: '温馨提示',
- desc: '您的【长连接】未开启,没有开启会导致系统默认客服无法使用,后台订单通知无法收到。请尽快执行命令开启!!<a href="https://doc.crmeb.com/single/crmeb_v4/7219" target="_blank">点击查看开启方法</a>',
- duration: 30,
- });
- }
- };
- socket.onclose = (err) => {
- if (!isNotice) {
- isNotice = true;
- this.$Notice.warning({
- title: '温馨提示',
- desc: '您的【长连接】未开启,没有开启会导致系统默认客服无法使用,后台订单通知无法收到。请尽快执行命令开启!!<a href="https://doc.crmeb.com/single/crmeb_v4/7219" target="_blank">点击查看开启方法</a>',
- duration: 30,
- });
- }
- };
- });
- },
- getExpiresTime(expiresTime) {
- let nowTimeNum = Math.round(new Date() / 1000);
- let expiresTimeNum = expiresTime - nowTimeNum;
- return parseFloat(parseFloat(parseFloat(expiresTimeNum / 60) / 60) / 24);
- },
- closefail() {
- // if (this.jigsaw) this.jigsaw.reset();
- this.$Message.error('校验错误');
- },
- handleResize(event) {
- this.fullWidth = document.documentElement.clientWidth;
- if (this.fullWidth < 768) {
- document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
- } else {
- document.getElementsByTagName('canvas')[0].className = 'index_bg';
- }
- },
- handleSubmit(name) {
- this.$refs[name].validate((valid) => {
- if (valid) {
- if (this.login_captcha == 1) {
- this.$refs.verify.show();
- } else {
- this.closeModel();
- }
- }
- });
- },
- },
- beforeCreate() {
- if (this.fullWidth < 768) {
- document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
- } else {
- document.getElementsByTagName('canvas')[0].className = 'index_bg';
- }
- },
- beforeDestroy: function () {
- window.removeEventListener('resize', this.handleResize);
- document.getElementsByTagName('canvas')[0].removeAttribute('class', 'index_bg');
- },
- };
- </script>
- <style scoped lang="stylus">
- .page-account {
- display: flex;
- width: 100%;
- background-image: url('../../../assets/images/bg.jpg');
- background-size: cover;
- background-position: center;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- height: 100vh;
- overflow: auto;
- }
- .page-account .code {
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .page-account .code .pictrue {
- height: 40px;
- }
- .swiperPross {
- border-radius: 12px 0px 0px 12px;
- }
- .swiperPross, .swiperPic, .swiperPic img {
- width: 510px;
- height: 100%;
- }
- .swiperPic img {
- width: 100%;
- height: 100%;
- }
- .container {
- height: 400px !important;
- padding: 0 !important;
- border-radius: 12px;
- z-index: 1;
- display: flex;
- }
- .containerSamll {
- /* width: 56% !important; */
- background: #fff !important;
- }
- .containerBig {
- width: auto !important;
- background: #f7f7f7 !important;
- }
- .index_from {
- padding: 32px 40px 32px 40px;
- height: 400px;
- box-sizing: border-box;
- }
- .page-account-top {
- padding: 20px 0 24px 0!important;
- box-sizing: border-box !important;
- display: flex;
- justify-content: center;
- }
- .page-account-container {
- border-radius: 0px 6px 6px 0px;
- }
- .btn {
- background: linear-gradient(90deg, rgba(25, 180, 241, 1) 0%, rgba(14, 115, 232, 1) 100%) !important;
- }
- .captchaBox {
- width: 310px;
- }
- input {
- display: block;
- width: 290px;
- line-height: 40px;
- margin: 10px 0;
- padding: 0 10px;
- outline: none;
- border: 1px solid #c8cccf;
- border-radius: 4px;
- color: #6a6f77;
- }
- #msg {
- width: 100%;
- line-height: 40px;
- font-size: 14px;
- text-align: center;
- }
- a:link, a:visited, a:hover, a:active {
- margin-left: 100px;
- color: #0366D6;
- }
- .index_from >>> .ivu-input-large {
- font-size: 14px !important;
- }
- .from-wh {
- width: 400px;
- }
- .pull-right {
- float: right!important;
- }
- .footer{
- position: fixed;
- bottom: 0;
- width: 100%;
- left: 0;
- margin: 0;
- background: rgba(255,255,255,.8);
- border-top: 1px solid #e7eaec;
- overflow: hidden;
- padding: 10px 20px;
- height: 36px;
- z-index: 999;
- }
- .pull-right {
- float: right!important;
- color: #666;
- }
- .pull-right a {
- margin-left: 0;
- color: #666;
- }
- .footer{
- position: fixed;
- bottom: 0;
- width: 100%;
- left: 0;
- margin: 0;
- background: rgba(255,255,255,.8);
- border-top: 1px solid #e7eaec;
- overflow: hidden;
- padding: 10px 20px;
- height: 36px;
- }
- </style>
|