| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321 |
- <template>
- <div>
- <!--头部-->
- <nav class="x-navbar">
- <div class="container">
- <div class="navbar-header">
- <input type="hidden" name="iconUrl" value="">
- <a class="navbar-brand" :href="!loginStyle || (loginStyle && (JSON.parse(loginStyle.returnHomeUrl).url)) || ''">
- <img :src="loginStyle.logoUrl" alt="">
- <span>{{loginStyle.title || ''}}</span>
- </a>
- </div>
- <div class="collapse navbar-collapse navbar-right">
- <a :href="loginStyle ? JSON.parse(loginStyle.returnHomeUrl).url : ''">{{loginStyle ? JSON.parse(loginStyle.returnHomeUrl).name : ''}}</a>
- <a href="http://uas.ubtob.com/serve#/" v-if="!loginStyle || (loginStyle && (JSON.parse(loginStyle.returnHomeUrl).needHelp))">帮助</a>
- </div>
- </div>
- </nav>
- <div class="x-container">
- <!-- background slider -->
- <div class="x-banner-wrap">
- <div class="x-banner">
- <ul class="list-unstyled">
- <li id="bgStyle" v-bind:style="{ background: `url(${loginStyle.bgUrl}) center center/auto 100% no-repeat ${loginStyle.bgColor}` }">
- <a :href="loginStyle.bgLink" v-if="loginStyle.bgLink">
- <div class="inner">
- <div class="x-title x-text-0"></div>
- <div class="x-subtitle x-text-0"></div>
- <div class="x-btn-group">
- </div>
- </div>
- </a>
- <a v-else style="cursor: default">
- <div class="inner">
- <div class="x-title x-text-0"></div>
- <div class="x-subtitle x-text-0"></div>
- <div class="x-btn-group">
- </div>
- </div>
- </a>
- </li>
- </ul>
- </div>
- </div>
- <div class="x-login-wrap">
- <!--用户名短息登录-->
- <div class="x-login" v-if="loginWay === 0">
- <div id="form-wrap" class="x-login-form">
- <!--账号密码登录-->
- <div v-show="activeTab === 0">
- <el-form :model="login" :rules="rules2" ref="login" class="demo-ruleForm login-form">
- <el-form-item prop="username">
- <el-input type="text" v-model="login.username" auto-complete="new-password" placeholder="手机号/邮箱"></el-input>
- <i class="fa fa-user"></i>
- </el-form-item>
- <el-form-item prop="password">
- <input autocomplete="new-password"
- type="password" style="display: none;width:0;height:0;">
- <el-input type="password"
- v-model="login.password"
- auto-complete="new-password"
- placeholder="密码"
- @keyup.enter.native="isLogin(true)"></el-input>
- <i class="fa fa-lock"></i>
- </el-form-item>
- <el-form-item prop="captcha" class="captcha" v-show="showCheckCode">
- <el-input type="text"
- v-model="login.captcha"
- auto-complete="off"
- class="code-input"
- @keyup.enter.native="isLogin(true)"></el-input>
- <img id="captchaImage" class="code-img" src="/sso/login/checkCode"/>
- <a class="code-click" @click="getCode">看不清换一张</a>
- </el-form-item>
- <el-form-item class="text-position">
- <div class="page-part" v-if="loginStyle.needRememberPwd">
- <el-checkbox v-model="checked">记住密码</el-checkbox>
- </div>
- <a class="forget" id='forget' @click="goForgetPassword">忘记密码?</a>
- </el-form-item>
- <el-form-item>
- <a class="btn login"
- @click="isLogin(true)"
- :disabled="isLoginDisabled">登录</a>
- </el-form-item>
- </el-form>
- </div>
- <!--短信快捷登录-->
- <div v-show="activeTab === 1">
- <el-form :model="fastLogin" :rules="rules3" ref="fastLogin" class="demo-ruleForm login-form loginForm">
- <el-form-item prop="mobile">
- <el-input type="text" v-model="fastLogin.mobile" auto-complete="off" placeholder="请输入手机号"></el-input>
- </el-form-item>
- <el-form-item prop="code" class="fastMsg">
- <el-input type="text" v-model="fastLogin.code"
- auto-complete="off" placeholder="验证码"></el-input>
- <el-button type="primary" class="fastCode"
- v-show="sendLoginCode"
- @click="getCheckCode">获取验证码</el-button>
- <el-button type="primary" v-show="!sendLoginCode" class="fastCode code-send">已发送({{login_time}}s)</el-button>
- </el-form-item>
- <el-form-item>
- <a class="btn login"
- @click="fastToLogin(true)">登录</a>
- </el-form-item>
- </el-form>
- </div>
- <div class="warn-text-area">
- 为确保您账户的安全及正常使用,依《网络安全法》相关要求,6月1日起会员账户需绑定手机、设置密码保护。感谢您的理解和支持!
- </div>
- <div class="link-go">
- <a @click="changeManage" class="first">更换管理员</a>
- <a class='change' @click="activeTab = 1" v-show="activeTab === 0">短信快捷登录</a>
- <a class='change' @click="activeTab = 0" v-show="activeTab === 1">用户密码登录</a>
- <a id="register" @click="goRegister" class="second">
- <i class="fa fa-arrow-circle-o-right"></i>免费注册</a>
- </div>
- <!--微信-->
- <div class="scavenging">
- <div @click="getScan"><img src="/images/logo/weixin.png" alt=""/>微信</div>
- </div>
- </div>
- </div>
- <!--微信扫码登录-->
- <div>
- <!--<div class="x-login scan-login" v-if="loginWay === 1">-->
- <!--<div class="x-login-form">-->
- <!--<div class="scan-header">-->
- <!--<span>微信登录</span>-->
- <!--<img src="images/logo/saoma.png" alt="" @click="loginWay = 0"/>-->
- <!--</div>-->
- <!--<div class="scan-body">-->
- <!--<div class="img">-->
- <!--<img src="/images/logo/sao.png" alt=""/>-->
- <!--</div>-->
- <!--<div class="content">-->
- <!--<img src="/images/logo/saosao.png" alt="">-->
- <!--<div>-->
- <!--<span>打开 <b>微信</b></span>-->
- <!--<div>扫一扫登录</div>-->
- <!--</div>-->
- <!--</div>-->
- <!--</div>-->
- <!--</div>-->
- <!--</div>-->
- </div>
- <!--绑定账号-->
- <div class="x-login bind-login" v-if="loginWay === 2">
- <div class="x-login-form">
- <div class="bind-header">
- <span>绑定已有账号</span>
- <span @click="loginWay = 0">返回</span>
- </div>
- <div class="bind-body">
- <div class="img"><img :src="wxImg" alt=""/><span>{{wxName}}</span></div>
- <div>
- <el-form :model="bindAccount" :rules="rules4" ref="bindAccount" class="demo-ruleForm login-form">
- <el-form-item prop="username">
- <el-input type="text"
- v-model="bindAccount.username"
- auto-complete="off"
- placeholder="请输入用户名、手机号或邮箱"></el-input>
- </el-form-item>
- <el-form-item prop="password">
- <input autocomplete="new-password"
- type="password" style="display: none;width:0;height:0;">
- <el-input type="password"
- v-model="bindAccount.password"
- auto-complete="new-password"
- placeholder="密码"
- @keyup.enter.native="wxBind"></el-input>
- </el-form-item>
- <el-form-item>
- <a class="btn login"
- @click="wxBind">确定绑定已有账号</a>
- </el-form-item>
- </el-form>
- </div>
- <div class="set">还没有优软账号,直接 <a :href="`/register/enterpriseRegistration${this.$store.state.option.fullPath}&tk=${wxToken}`">创建新账号</a></div>
- </div>
- </div>
- </div>
- </div>
- <!--选择企业弹出框-->
- <div>
- <el-dialog class="dialog"
- :visible.sync="dialogVisible"
- size="tiny">
- <div class="x-floating x-list" v-show="dialogVisible">
- <div class="x-list-header">您要登录的公司是:</div>
- <div class="x-list-content">
- <ul class="list-unstyled" >
- <template v-for="space in this.enterprise">
- <li v-text="space.name" @click="chooseOneEnterprise(false, space.id)">华商龙科技有限公司</li>
- </template>
- </ul>
- </div>
- </div>
- </el-dialog>
- </div>
- <loading v-show="isShowLoading"/>
- </div>
- <!--尾部-->
- <div v-html="loginStyle.footUrl || ''" class="footer"></div>
- </div>
- </template>
- <script>
- import Loading from '~components/common/loading/Loading.vue'
- export default {
- name: 'login',
- components: {
- Loading
- },
- data () {
- // 用户名密码登录
- var validateUsername = (rule, value, callback) => {
- if (value === '') {
- this.checkUsername = false
- this.showCheckCode = false
- } else {
- if (this.login.username !== '') {
- // 获取密码输错次数
- this.$http.get(`/sso/login/getPwdErrorCount`, {params: {username: this.login.username}})
- .then(response => {
- if (response.data.success) {
- this.showCheckCode = false
- let getPasswordErrorCount = response.data.content || ''
- if (getPasswordErrorCount >= 5) {
- this.$message.error('密码错误次数已达上限,今日无法登陆')
- this.isLoginDisabled = true
- this.showCheckCode = false
- } else if (getPasswordErrorCount < 3) {
- this.isLoginDisabled = false
- this.checkUsername = true
- this.showCheckCode = false
- } else if (getPasswordErrorCount >= 3 && getPasswordErrorCount < 5) {
- if (getPasswordErrorCount === 3) {
- this.$message.error('当前已输错密码3次,若达到5次今日将无法登陆')
- }
- if (getPasswordErrorCount === 4) {
- this.$message.error('当前已输错密码4次,若达到5次今日将无法登陆')
- }
- this.isLoginDisabled = false
- this.checkUsername = true
- this.showCheckCode = true
- } else {
- this.checkUsername = false
- this.showCheckCode = false
- }
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- this.$message.error(err.errMsg)
- })
- }
- callback()
- }
- }
- var validatePassword = (rule, value, callback) => {
- if (value === '') {
- this.checkPassword = false
- } else {
- if (this.login.password !== '') {
- this.checkPassword = true
- }
- callback()
- }
- }
- // 短信便捷登录
- var validateMobile = (rule, value, callback) => {
- if (value === '') {
- this.checkMobile = false
- } else {
- this.checkMobile = true
- callback()
- }
- }
- var validateCode = (rule, value, callback) => {
- if (value === '') {
- this.checkCode = false
- } else {
- if (this.fastLogin.code !== '') {
- this.checkCode = true
- }
- callback()
- }
- }
- // 微信扫码登录
- var validateWeiUsername = (rule, value, callback) => {
- if (value === '') {
- this.checkWeiUsername = false
- } else {
- if (this.bindAccount.username !== '') {
- this.checkWeiUsername = true
- }
- callback()
- }
- }
- var validateWeiPassword = (rule, value, callback) => {
- if (value === '') {
- this.checkWeiPassword = false
- } else {
- if (this.bindAccount.password !== '') {
- this.checkWeiPassword = true
- }
- callback()
- }
- }
- return {
- login: {
- username: '',
- password: '',
- captcha: '',
- spaceUU: ''
- },
- fastLogin: {
- mobile: '',
- code: ''
- },
- bindAccount: {
- username: '',
- password: ''
- },
- activeTab: 0,
- loginWay: 0,
- checked: false,
- isShowLoading: false,
- checkUsername: false,
- checkPassword: false,
- showCheckCode: false,
- isLoginDisabled: false,
- dialogVisible: false,
- queryLink: '',
- checkMobile: false,
- getCodeBtnIsDisabled: true,
- sendLoginCode: true,
- login_time: 0,
- token: '',
- checkCode: false,
- checkWeiUsername: false,
- checkWeiPassword: false,
- wxToken: '',
- wxImg: '',
- wxName: '',
- wxUrl: '',
- // 用户名密码登录
- rules2: {
- username: [
- {validator: validateUsername, trigger: 'blur'}
- ],
- password: [
- {validator: validatePassword, trigger: 'blur'}
- ]
- },
- // 短信快捷登录
- rules3: {
- mobile: [
- {validator: validateMobile, trigger: 'blur'}
- ],
- code: [
- {validator: validateCode, trigger: 'blur'}
- ]
- },
- // 微信扫码登录
- rules4: {
- username: [
- {validator: validateWeiUsername, trigger: 'blur'}
- ],
- password: [
- {validator: validateWeiPassword, trigger: 'blur'}
- ]
- }
- }
- },
- mounted () {
- this.$nextTick(() => {
- this.getUrl()
- if (this.appId === 'mall' || this.appId === 'home') {
- this.getCookie()
- }
- this.validUserName()
- if (this.$route.query.code) {
- this.bindOrEnterprise()
- }
- })
- },
- computed: {
- enterprise () {
- let chooseEnterprise = this.$store.state.login.chooseRegisterEnterprise.choose.data
- return chooseEnterprise
- },
- loginStyle () {
- return this.$store.state.login.loginStyle.data.content ? this.$store.state.login.loginStyle.data.content : ''
- }
- },
- methods: {
- // 获取用户错误次数
- validUserName () {
- if (this.login.username) {
- // 获取密码输错次数
- this.$http.get(`/sso/login/getPwdErrorCount`, {params: {username: this.login.username}})
- .then(response => {
- if (response.data.success) {
- let getPasswordErrorCount = response.data.content || ''
- if (getPasswordErrorCount >= 5) {
- this.$message.error('密码错误次数已达上限,今日无法登陆')
- this.isLoginDisabled = true
- this.showCheckCode = false
- } else if (getPasswordErrorCount < 3) {
- this.isLoginDisabled = false
- this.checkUsername = true
- this.showCheckCode = false
- } else if (getPasswordErrorCount >= 3 && getPasswordErrorCount < 5) {
- if (getPasswordErrorCount === 3) {
- this.$message.error('当前已输错密码3次,若达到5次今日将无法登陆')
- }
- if (getPasswordErrorCount === 4) {
- this.$message.error('当前已输错密码4次,若达到5次今日将无法登陆')
- }
- this.isLoginDisabled = false
- this.checkUsername = true
- this.showCheckCode = true
- } else {
- this.checkUsername = false
- this.showCheckCode = false
- }
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.$message.error(err.errMsg)
- })
- }
- },
- // 更换管理员
- changeManage () {
- window.location.href = `appeals/changeManagerAppeal${this.$store.state.option.fullPath}`
- },
- // 获取url参数
- getUrl () {
- console.log(this.$route, '111')
- let wxUrl = ''
- if (this.$route.query) {
- for (var key in this.$route.query) {
- if (key !== 'code' && key !== 'state') {
- wxUrl += `${key}=${this.$route.query[key]}&`
- }
- }
- }
- if (this.$route.query === '') {
- this.wxUrl = `${window.location.origin}?${wxUrl.substr(0, wxUrl.length - 1)}`
- } else {
- this.wxUrl = `${window.location.origin}`
- }
- var url = window.location.search
- var request = {}
- if (url.indexOf('?' !== -1)) {
- var str = url.substr(1)
- var strs = str.split('&')
- this.queryLink = str
- for (var i = 0; i < strs.length; i++) {
- request[strs[i].split('=')[0]] = decodeURI(strs[i].split('=')[1])
- }
- }
- this.appId = request['appId'] || ''
- this.returnUrl = request['returnURL'] || ''
- this.baseUrl = request['baseUrl'] || ''
- },
- goForgetPassword () {
- let url = `/reset/forgetPasswordValidationAccount?${this.queryLink}`
- document.getElementById('forget').href = url
- },
- // 去注册
- goRegister () {
- document.getElementById('register').href = `/register/enterpriseRegistration?${this.queryLink}`
- },
- // 获取验证码
- getCode () {
- var imgSrc = document.getElementById('captchaImage')
- imgSrc.setAttribute('src', '/sso/login/checkCode?timestamp=' + (new Date()).valueOf())
- },
- // 登录
- isLogin (flag) {
- this.isShowLoading = true
- if (!this.login.username) {
- this.isShowLoading = false
- this.$message.error('请填写账号')
- } else if (!this.login.password) {
- this.isShowLoading = false
- this.$message.error('请填写密码')
- } else {
- let param = new FormData()
- param.append('username', this.login.username)
- param.append('password', this.login.password)
- param.append('captcha', this.login.captcha)
- param.append('spaceUU', this.login.spaceUU ? this.login.spaceUU : '')
- param.append('appId', this.appId ? this.appId : '')
- param.append('returnUrl', this.returnUrl ? this.returnUrl : '')
- param.append('baseUrl', this.baseUrl ? this.baseUrl : '')
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/sso/login', param, config)
- .then(response => {
- this.isShowLoading = false
- if (response.data.success) {
- if (response.data.content.spaces) {
- // 弹框让用户选择企业
- this.$store.commit('login/chooseRegisterEnterprise/GET_ENTERPRISE_SUCCESS', response.data.content.spaces)
- this.dialogVisible = flag
- } else if (response.data.content.loginUrls) {
- // 遍历登录url循环让各应用登录(需要跨域)
- let param = response.data.content.data
- let a = ''
- for (let n in param) {
- a += (n + '=' + encodeURIComponent(param[n]) + '&')
- }
- let params = a.substr(0, a.length - 1)
- this.isShowLoading = true
- if (response.data.content.currentUrl) {
- this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
- name: 'successCallback',
- timeout: 3000
- }, (err, data) => {
- if (err) {
- this.$message.error('登录超时,请重试')
- this.isShowLoading = false
- throw err
- } else {
- this.loginOther(response, params)
- }
- })
- } else {
- this.loginOther(response, params, 3000)
- }
- }
- } else {
- this.$message.error(response.data)
- var count = response.data.errorCount
- if (count < 3) {
- this.showCheckCode = false
- this.isLoginDisabled = false
- } else if (count >= 5) {
- this.$message.error('密码错误次数已达上限,今日无法登陆')
- this.isLoginDisabled = true
- this.showCheckCode = false
- } else if (count >= 3 && count < 5) {
- this.getCode()
- if (count === 3) {
- this.$message.error('当前已输错密码3次,若达到5次今日将无法登陆')
- }
- this.showCheckCode = true
- this.isLoginDisabled = false
- }
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- let _this = this
- setTimeout(function () {
- _this.getCode()
- }, 100)
- this.$message.error(err.errMsg)
- })
- }
- },
- // 选择账套
- chooseOneEnterprise (flag, spaceUU) {
- this.login.spaceUU = spaceUU
- this.dialogVisible = false
- if (this.$route.query.code) {
- this.wxEnterprise(flag)
- } else {
- if (this.activeTab === 0) {
- this.isLogin(flag)
- }
- if (this.activeTab === 1) {
- this.fastToLogin(flag)
- }
- }
- if (this.appId === 'mall' || this.appId === 'home') {
- if (this.checked) {
- this.setCookie(this.login.username, this.login.password, 7)
- } else {
- this.clearCookie()
- }
- }
- },
- // 短信快捷登录
- fastToLogin (flag) {
- this.isShowLoading = true
- if (!this.fastLogin.mobile) {
- this.isShowLoading = false
- this.$message.error('请填写手机号')
- } else {
- let param = new FormData()
- param.append('mobile', this.fastLogin.mobile)
- param.append('code', this.fastLogin.code)
- param.append('appId', this.appId)
- param.append('token', this.token)
- param.append('spaceUU', this.login.spaceUU ? this.login.spaceUU : '')
- param.append('returnUrl', this.returnUrl ? this.returnUrl : '')
- param.append('baseUrl', this.baseUrl ? this.baseUrl : '')
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/sso/login/sms', param, config)
- .then(response => {
- this.isShowLoading = false
- if (response.data.success) {
- if (response.data.content.spaces) {
- // 弹框让用户选择企业
- this.$store.commit('login/chooseRegisterEnterprise/GET_ENTERPRISE_SUCCESS', response.data.content.spaces)
- this.dialogVisible = flag
- } else if (response.data.content.loginUrls) {
- // 遍历登录url循环让各应用登录(需要跨域)
- let param = response.data.content.data
- let a = ''
- for (let n in param) {
- a += (n + '=' + encodeURIComponent(param[n]) + '&')
- }
- let params = a.substr(0, a.length - 1)
- this.isShowLoading = true
- if (response.data.content.currentUrl) {
- this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
- name: 'successCallback',
- timeout: 3000
- }, (err, data) => {
- if (err) {
- this.$message.error('登录超时,请重试')
- this.isShowLoading = false
- throw err
- } else {
- this.loginOther(response, params)
- }
- })
- } else {
- this.loginOther(response, params, 3000)
- }
- }
- } else {
- this.$message.error(response.data)
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- let _this = this
- setTimeout(function () {
- _this.getCode()
- }, 100)
- this.$message.error(err.errMsg)
- })
- }
- },
- getJsonp: function (url, timeout = 500) {
- return new Promise((resolve, reject) => {
- this.$jsonp(url, {
- name: 'successCallback',
- timeout: timeout
- }, function (err, data) {
- if (err) {
- reject(err)
- throw err
- } else {
- resolve(data)
- }
- })
- })
- },
- crossAfter (url) {
- try {
- window.location.href = url
- } catch (err) {
- console.log(err)
- }
- },
- loginOther (response, a, timeout) {
- const crossAfter = this.crossAfter
- let promises = []
- for (let i in response.data.content.loginUrls) {
- promises.push(this.getJsonp(`${response.data.content.loginUrls[i]}?${a}`))
- }
- Promise.all(promises).then(() => {
- crossAfter(response.data.content.returnUrl || 'http://www.ubtob.com', timeout)
- }).catch(() => {
- crossAfter(response.data.content.returnUrl || 'http://www.ubtob.com', timeout)
- })
- },
- // 设置cookie
- setCookie (cName, cPwd, exdays) {
- let exdate = new Date()
- exdate.setTime(exdate.getTime() + 24 * 60 * 60 * 1000 * exdays)
- window.document.cookie = 'userName' + '=' + cName + ';path=/;expires=' + exdate.toGMTString()
- window.document.cookie = 'userPwd' + '=' + cPwd + ';path=/;expires=' + exdate.toGMTString()
- },
- // 读取cookies
- getCookie () {
- if (document.cookie.length > 0) {
- let arr = document.cookie.split(';')
- for (var i = 0; i < arr.length; i++) {
- let arr2 = arr[i].split('=')
- if (arr2[0].trim() === 'userName') {
- this.login.username = arr2[1]
- }
- if (arr2[0].trim() === 'userPwd') {
- this.login.password = arr2[1]
- }
- if (this.login.username && this.login.username) {
- this.checked = true
- }
- }
- }
- },
- // 清除cookie
- clearCookie () {
- this.setCookie('', '', -1)
- },
- // 获取校验码
- getCheckCode () {
- this.isShowLoading = true
- if (!this.fastLogin.mobile) {
- this.isShowLoading = false
- this.$message.error('请先填写手机号')
- } else {
- if (this.checkMobile) {
- this.$http.get(`/sso/login/sendSmsCode`, {params: {mobile: this.fastLogin.mobile}})
- .then(response => {
- this.isShowLoading = false
- if (response.data) {
- if (response.data.success) {
- this.token = response.data.content.token
- this.$message({
- message: '验证码已经发送到您的手机,请注意查收',
- type: 'success'
- })
- this.sendLoginCode = false
- this.login_time = 60
- var loginTime = setInterval(() => {
- this.login_time--
- if (this.login_time <= 0) {
- this.sendLoginCode = true
- clearInterval(loginTime)
- }
- }, 1000)
- } else {
- this.$message.error(response.data.errMsg)
- }
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- this.$message.error(err.errMsg)
- })
- } else {
- this.isShowLoading = false
- }
- }
- },
- // 微信判断企业账套
- wxEnterprise () {
- let param = new FormData()
- param.append('code', this.$route.query.code ? this.$route.query.code : '')
- param.append('state', this.$route.query.state ? this.$route.query.state : '')
- param.append('appId', this.$route.query.appId ? this.$route.query.appId : '')
- param.append('returnUrl', this.$route.query.returnURL ? this.$route.query.returnURL : '')
- param.append('baseUrl', this.$route.query.baseUrl ? this.$route.query.baseUrl : '')
- param.append('spaceUU', this.login.spaceUU ? this.login.spaceUU : '')
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/sso/login/wxqrLogin', param, config)
- .then(response => {
- this.isShowLoading = false
- if (response.data.success) {
- if (response.data.content.spaces) {
- // 弹框让用户选择企业
- this.$store.commit('login/chooseRegisterEnterprise/GET_ENTERPRISE_SUCCESS', response.data.content.spaces)
- this.dialogVisible = true
- } else if (response.data.content.loginUrls) {
- // 遍历登录url循环让各应用登录(需要跨域)
- let param = response.data.content.data
- let a = ''
- for (let n in param) {
- a += (n + '=' + encodeURIComponent(param[n]) + '&')
- }
- let params = a.substr(0, a.length - 1)
- this.isShowLoading = true
- if (response.data.content.currentUrl) {
- this.$jsonp(`${response.data.content.currentUrl}?${params}`, {
- name: 'successCallback',
- timeout: 3000
- }, (err, data) => {
- if (err) {
- this.$message.error('登录超时,请重试')
- this.isShowLoading = false
- throw err
- } else {
- this.loginOther(response, params)
- }
- })
- } else {
- this.loginOther(response, params, 3000)
- }
- }
- } else {
- this.$message.error(response.data)
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- let _this = this
- setTimeout(function () {
- _this.getCode()
- }, 100)
- this.$message.error(err.errMsg)
- })
- },
- // 微信扫码登录
- getScan () {
- // this.loginWay = 1
- this.isShowLoading = true
- this.$http.get('/weChat/getQrUrl', {params: {appId: this.$route.query.appId, url: this.wxUrl}})
- .then(response => {
- this.isShowLoading = false
- if (response.data.success) {
- window.location.href = response.data.content
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- this.$message.error(err.errMsg)
- })
- },
- // 判断是否绑定企业
- bindOrEnterprise () {
- this.isShowLoading = true
- if (this.$route.query.code) {
- let param = new FormData()
- param.append('code', this.$route.query.code ? this.$route.query.code : '')
- param.append('state', this.$route.query.state ? this.$route.query.state : '')
- param.append('appId', this.$route.query.appId ? this.$route.query.appId : '')
- param.append('returnUrl', this.$route.query.returnURL ? this.$route.query.returnURL : '')
- param.append('baseUrl', this.$route.query.baseUrl ? this.$route.query.baseUrl : '')
- param.append('spaceUU', this.login.spaceUU ? this.login.spaceUU : '')
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/sso/login/wxqrLogin', param, config)
- .then(response => {
- this.isShowLoading = false
- if (response.data.success) {
- if (!response.data.content.hasRegister && response.data.content.token) {
- this.loginWay = 2
- this.wxToken = response.data.content.token
- this.$http.get(`/weChat/userInfo/${this.wxToken}`, {params: {token: this.wxToken}})
- .then(response => {
- if (response.data.success) {
- this.wxImg = response.data.content.headimgurl
- this.wxName = response.data.content.nickname
- console.log(response.data, '333')
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.$message.error(err.errMsg)
- })
- } else {
- this.wxEnterprise()
- }
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- this.$message.error(err.errMsg)
- })
- }
- },
- // 绑定企业
- wxBind () {
- this.isShowLoading = true
- if (!this.bindAccount.username) {
- this.isShowLoading = false
- this.$message.error('请填写账号')
- } else if (!this.bindAccount.password) {
- this.isShowLoading = false
- this.$message.error('请填写密码')
- } else {
- let param = new FormData()
- param.append('t', this.wxToken)
- param.append('username', this.bindAccount.username)
- param.append('password', this.bindAccount.password)
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/weChat/addAccount', param, config)
- .then(response => {
- this.isShowLoading = false
- if (response.data.success) {
- this.wxEnterprise()
- } else {
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.isShowLoading = false
- this.$message.error(err.errMsg)
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" type="text/scss" scoped>
- @import '~assets/scss/mixins';
- @import '~assets/scss/variables';
- .x-navbar{
- height: 80px;
- line-height: 80px;
- margin: 0;
- .container{
- position: relative;
- width: 990px!important;
- height: 80px;
- .navbar-header{
- height: 80px;
- line-height: 80px;
- }
- a.navbar-brand{
- overflow: hidden;
- padding: 0px;
- height: inherit;
- line-height: inherit;
- font-family: "\5FAE\8F6F\96C5\9ED1";
- font-size: 24px;
- font-weight: 400;
- color: #888;
- img{
- margin: 28px 8px 0 0;
- max-width: 80px;
- max-height: 27px;
- vertical-align: middle;
- float: left;
- }
- span{
- float: left;
- }
- }
- .collapse{
- a{
- padding-left: 12px;
- margin-right: 10px;
- color: #666;
- outline: 0;
- border-left: 1px solid #ddd;
- &:first-child{
- border-width: 0;
- }
- }
- }
- }
- }
- .x-container{
- position: relative;
- height: 475px;
- div.link-go {
- text-align: right;
- margin-top: 7px;
- a{
- font-size: 12px;
- color: #2d8cf0;
- background: 0 0;
- text-decoration: none;
- outline: 0;
- cursor: pointer;
- transition: color .2s ease;
- }
- a.first{
- float: left;
- margin-top: 2px;
- font-size: 12px;
- }
- a.change{
- margin:2px 0 0 50px;
- float: left;
- font-size: 12px;
- }
- }
- /*微信登录*/
- .scavenging {
- margin-top:22px;
- div{
- font-size: 12px;
- color: #666;
- cursor: pointer;
- img{
- margin-right: 10px;
- }
- }
- }
- /*登录弹出框*/
- .x-floating {
- position: fixed;
- top: 80px;
- left: 50%;
- z-index: 100000;
- opacity: 1;
- -webkit-transition: all .5s;
- -moz-transition: all .5s;
- transition: all .5s;
- }
- .x-list {
- width: 60%;
- height:420px;
- margin-left: -30%;
- background: #fff;
- border-top: 1px solid #e7e7e7;
- cursor: pointer;
- .x-list-header {
- padding: 10px 20px;
- background: #e0e0e0;
- height: 42px;
- line-height: 21px;
- font-size: 14px;
- font-weight: 700;
- color: #505050;
- }
- .x-list-content{
- overflow-y: auto;
- height:375px;
- ul{
- margin-bottom: 0;
- li{
- display:inline-block;
- padding: 10px 20px;
- width: 33%;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
- height: 42px;
- line-height: 21px;
- font-size: 12px;
- color: #505050;
- border-bottom: 1px solid #e7e7e7;
- &:hover{
- background: #e7e7e7;
- }
- }
- }
- }
- .x-list .x-list-header, .x-list li {
- padding: 10px 20px;
- border-bottom: 1px solid #e7e7e7;
- }
- }
- .x-floating.in {
- top: 80px;
- opacity: 1;
- }
- .x-banner-wrap {
- position: absolute;
- left: 0;
- top: 0;
- width: 100%;
- height: 475px;
- .x-banner {
- position: relative;
- overflow: auto;
- height: 475px;
- text-align: center;
- li{
- width: 100%;
- height: 475px;
- .inner{
- height: 100%;
- }
- }
- }
- }
- .x-login-wrap{
- position: absolute;
- top: 10px;
- right: 50%;
- margin-right: -495px;
- height: 475px;
- z-index: 5;
- .x-login {
- position: relative;
- top: 40px;
- width: 346px;
- background: #fff;
- overflow: visible;
- z-index: 4;
- .x-login-form, .x-login-qrcode {
- padding: 20px;
- .btn{
- background: #5078cb;
- color: #fff;
- font-weight: 700;
- letter-spacing: 4px;
- border-radius: 0;
- }
- .x-has-feedback-right {
- float: right;
- display: inline-block;
- a{
- color: #5078cb;
- }
- }
- .x-has-feedback-left {
- position: relative;
- .x-input {
- padding-left: 30px;
- line-height: 18px;
- color: #555;
- border-color: #ccc;
- border-radius: 0;
- box-shadow: none;
- }
- i.fa{
- position: absolute;
- top: 2px;
- left: 0;
- z-index: 2;
- display: block;
- width: 30px;
- height: 34px;
- line-height: 34px;
- text-align: center;
- pointer-events: none;
- color: #999;
- font-size: 18px;
- }
- }
- i.fa-keyboard-o{
- position: absolute;
- right: 10px;
- top: 10px;
- }
- i.fa-arrow-circle-o-right{
- margin-right: 5px;
- font-size: 12px;
- color: #5078cb;
- }
- .warn-text-area{
- margin-top: 5px;
- font-size: 13px;
- color: #000;
- }
- .text-position {
- overflow: hidden;
- .page-part {
- float: left;
- margin-bottom: 0;
- .el-checkbox {
- margin: 0;
- span.el-checkbox__inner{
- width: 14px;
- height: 14px;
- }
- }
- }
- .forget {
- float: right;
- color: #2d8cf0;
- }
- }
- }
- }
- .scan-login {
- box-shadow: -2px 1px 6px 0px rgba(0, 0, 0, 0.06);
- border-radius: 6px;
- .x-login-form{
- padding: 0;
- .scan-header {
- position: relative;
- height: 50px;
- line-height: 50px;
- font-size: 18px;
- font-weight: bold;
- color: #666;
- border: solid 1px #e5e5e5;
- span{
- position: absolute;
- top: -3px;
- padding-left: 10px;
- display: inline-block;
- width: 90px;
- border-bottom: 2px solid #0076ff;
- }
- img{
- position: absolute;
- top: -3px;
- right: -1px;
- height: 50px;
- cursor: pointer;
- }
- }
- .scan-body {
- margin: 22px auto 0;
- padding-bottom: 38px;
- text-align: center ;
- div.img{
- margin: 0 auto;
- width: 180px;
- height: 182px;
- line-height: 182px;
- text-align: center;
- border: 1px solid #dcdcdc;
- img{
- width: 162px;
- height: 165px;
- }
- }
- div.content {
- width: 138px;
- margin: 58px auto 0;
- text-align: center;
- overflow: hidden;
- img{
- float: left;
- margin-right: 25px;
- width: 32px;
- height: 27px;
- }
- div{
- float: left;
- width: 80px;
- text-align: left;
- span{
- font-size: 14px;
- color: #999;
- b{
- color: #0076ff;
- }
- }
- div{
- font-size: 14px;
- color: #999;
- }
- }
- }
- }
- }
- }
- .bind-login {
- box-shadow: -2px 1px 6px 0px rgba(0, 0, 0, 0.06);
- border-radius: 6px;
- .x-login-form{
- padding: 0;
- .bind-header {
- overflow: hidden;
- padding: 0 20px;
- height: 50px;
- line-height: 50px;
- font-size: 18px;
- font-weight: bold;
- color: #666;
- border: solid 1px #e5e5e5;
- span {
- &:first-child {
- float: left;
- border-bottom: 2px solid #5078cb;
- }
- &:last-child{
- float: right;
- font-size: 14px;
- color: #5078cb;
- font-weight: normal;
- cursor: pointer;
- }
- }
- }
- .bind-body {
- margin: 22px auto 0;
- padding-bottom: 20px;
- text-align: center ;
- .img{
- margin: 0 auto;
- width: 60px;
- text-align: center;
- img{
- margin-bottom: 10px;
- width: 100%;
- height: 60px;
- border-radius: 50%;
- }
- span{
- font-size: 14px;
- color: #999;
- }
- }
- .set{
- margin-top: 40px;
- font-size: 12px;
- color: #999;
- a{
- display: inline-block;
- width: 90px;
- line-height: 23px;
- height: 24px;
- text-align: center;
- font-size: 14px;
- color: #5078cb;
- border-radius: 13px;
- border: solid 1px #5078cb;
- }
- }
- }
- }
- }
- }
- }
- .footer{
- padding: 50px 0;
- }
- </style>
|