Переглянути джерело

适配产城以及密码输入框自动填充问题

hangb 7 роки тому
батько
коміт
d0a73b88fd

+ 2 - 2
components/appeal/PasswordRestAppeal.vue

@@ -26,7 +26,7 @@
               <span v-show="codeErrorChecked" class="tip codeError-tip" >{{codeErrorMsg}}</span>
             </el-form-item>
             <el-form-item prop="password">
-              <el-input type="password" v-model="passwordRest.password" auto-complete="off" placeholder="新密码"></el-input>
+              <el-input type="password" v-model="passwordRest.password" auto-complete="new-password" placeholder="新密码"></el-input>
               <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
               <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
               <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
@@ -36,7 +36,7 @@
               <el-input type="password"
                         v-model="passwordRest.confirm"
                         v-bind:class="{active: showPasswordError}"
-                        auto-complete="off"
+                        auto-complete="new-password"
                         placeholder="密码确认"></el-input>
               <span class="tip passwordError" v-show="showPasswordError">两次输入密码不一致</span>
             </el-form-item>

+ 5 - 1
components/default/AccountCenterHeader.vue

@@ -4,7 +4,7 @@
       <div class="navbar-container container">
         <div class="navbar-header">
           <a href="http://www.ubtob.com" class="item navbar-link">
-            <img src="/images/logo/uas.png" class="navbar-logo">
+            <img :src="loginStyle.logoUrl" class="navbar-logo">
           </a>
           <a href=""><span class="navbar-slogan">账号中心</span></a>
         </div>
@@ -19,6 +19,10 @@
       return {}
     },
     computed: {
+      loginStyle () {
+        console.log('3333', this.$store.state.login.loginStyle.data)
+        return this.$store.state.login.loginStyle.data.content
+      }
 //      user () {
 //        return this.$store.state.option.user
 //      },

+ 46 - 60
components/login/Login.vue

@@ -4,13 +4,15 @@
     <nav class="x-navbar">
       <div class="container">
         <div class="navbar-header">
-          <input type="hidden" name="iconUrl" value="/static/img/icon_mall_index.png">
-          <a class="navbar-brand" id="navbar-brand">
-            欢迎登录
+          <input type="hidden" name="iconUrl" value="">
+          <a class="navbar-brand" :href="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="http://www.ubtob.com">优软云首页</a> <a href="http://uas.ubtob.com/serve#/">帮助</a>
+          <a :href="JSON.parse(loginStyle.returnHomeUrl).url || ''">{{JSON.parse(loginStyle.returnHomeUrl).name || ''}}</a>
+          <a href="http://uas.ubtob.com/serve#/" v-if="JSON.parse(loginStyle.returnHomeUrl).needHelp">帮助</a>
         </div>
       </div>
     </nav>
@@ -19,8 +21,16 @@
       <div class="x-banner-wrap">
         <div class="x-banner">
           <ul class="list-unstyled">
-            <li id="bgStyle">
-              <a>
+            <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>
@@ -120,6 +130,8 @@
       </div>
       <loading v-show="isShowLoading"/>
     </div>
+    <!--尾部-->
+    <div v-html="loginStyle.footUrl || ''" class="footer"></div>
   </div>
 </template>
 
@@ -216,16 +228,9 @@
     mounted () {
       this.$nextTick(() => {
         this.getUrl()
-      })
-      this.$nextTick(() => {
-        this.getLoginStyle()
-      })
-      this.$nextTick(() => {
         if (this.appId === 'mall' || this.appId === 'home') {
           this.getCookie()
         }
-      })
-      this.$nextTick(() => {
         this.validUserName()
       })
     },
@@ -233,11 +238,11 @@
       enterprise () {
         let chooseEnterprise = this.$store.state.login.chooseRegisterEnterprise.choose.data
         return chooseEnterprise
+      },
+      loginStyle () {
+        console.log('22222', this.$store.state.login.loginStyle.data)
+        return this.$store.state.login.loginStyle.data.content ? this.$store.state.login.loginStyle.data.content : ''
       }
-      // loginUrl () {
-      //   console.log(this.$store.state.login.loginStyle.loginStyle.data)
-      //   return this.$store.state.login.loginStyle.loginStyle.data
-      // }
     },
     methods: {
       // 获取用户错误次数
@@ -297,45 +302,10 @@
         this.appId = request['appId'] || ''
         this.returnUrl = request['returnURL'] || ''
         this.baseUrl = request['baseUrl'] || ''
-        if (this.appId === 'home') {
+        if (this.appId === 'home' || this.appId === 'mall') {
           this.checkedRemember = true
         }
       },
-      // 获取后台返回的数据
-      getLoginStyle () {
-        this.$http.get(`/sso/login/page/style`, {params: {appId: this.appId}})
-          .then(response => {
-            if (response.data.success) {
-              let logoUrlStyle = response.data.content.logoUrl
-              let bgUrl = response.data.content.bgUrl
-              let bgColor = response.data.content.bgColor
-              let bgLink = response.data.content.bgLink
-              let title = response.data.content.title || '欢迎登录'
-              let appId = response.data.content.appId
-              let nb = document.getElementById('navbar-brand')
-              nb.style.backgroundImage = 'url(' + logoUrlStyle + ')'
-              nb.innerHTML = title
-              if (appId === 'mall') {
-                this.checkedRemember = true
-                nb.href = 'https://www.usoftmall.com/'
-              }
-              let bg = document.getElementById('bgStyle')
-              bg.style.backgroundImage = 'url(' + bgUrl + ')'
-              bg.style.backgroundColor = bgColor
-              if (bgLink) {
-                bg.onclick = function () {
-                  window.location.href = bgLink
-                }
-              }
-            } else {
-              return Promise.reject(response.data)
-            }
-          }).catch(err => {
-            // console.log(err)
-            this.$message.error(err.errMsg)
-          })
-      },
-//      忘记密码
       goForgetPassword () {
         let url = `/reset/forgetPasswordValidationAccount?${this.queryLink}`
         document.getElementById('forget').href = url
@@ -489,8 +459,6 @@
       // 设置cookie
       setCookie (cName, cPwd, exdays) {
         let exdate = new Date()
-        // let len = cPwd.substring(0)
-        // cPwd = cPwd.replace(len, '***')
         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()
@@ -503,11 +471,9 @@
             let arr2 = arr[i].split('=')
             if (arr2[0].trim() === 'userName') {
               this.login.username = arr2[1]
-              // console.log('get', this.login.username)
             }
             if (arr2[0].trim() === 'userPwd') {
               this.login.password = arr2[1]
-              // console.log('get', this.login.password)
             }
             if (this.login.username && this.login.username) {
               this.checked = true
@@ -532,15 +498,30 @@
   .container{
     position: relative;
     width: 990px!important;
+    height: 80px;
+    .navbar-header{
+      height: 80px;
+      line-height: 80px;
+    }
   a.navbar-brand{
-    padding: 0 0 0 85px;
+    overflow: hidden;
+    padding: 0px;
     height: inherit;
     line-height: inherit;
     font-family: "\5FAE\8F6F\96C5\9ED1";
     font-size: 24px;
     font-weight: 400;
     color: #888;
-    background: url(/images/all/icon_brand.png) left center no-repeat;
+    img{
+      margin: 28px 8px 0 0;
+      max-width: 80px;
+      max-height: 27px;
+      vertical-align: middle;
+      float: left;
+    }
+    span{
+      float: left;
+    }
   }
   .collapse{
   a{
@@ -649,7 +630,9 @@
         li{
           width: 100%;
           height: 475px;
-          background: url(/images/all/banner.jpg) center center / auto 100% no-repeat rgb(202, 202, 214);
+          .inner{
+            height: 100%;
+          }
         }
       }
     }
@@ -748,4 +731,7 @@
       }
     }
   }
+  .footer{
+    padding: 50px 0;
+  }
 </style>

+ 18 - 4
components/register/EnterpriseRegistration.vue

@@ -67,7 +67,7 @@
               <el-input type="text" v-model="enterprise1.vipName" auto-complete="off" placeholder="管理员姓名"></el-input>
             </el-form-item>
             <el-form-item prop="password" v-if="!isHasRegister">
-              <el-input type="password" v-model="enterprise1.password" auto-complete="off" placeholder="登录密码"></el-input>
+              <el-input type="password" v-model="enterprise1.password" auto-complete="new-password" placeholder="登录密码"></el-input>
               <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
               <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
               <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
@@ -76,14 +76,14 @@
             <el-form-item prop="password" v-if="isHasRegister">
               <el-input type="password"
                         v-model="enterprise1.password"
-                        auto-complete="off"
+                        auto-complete="new-password"
                         placeholder="密码确认"
                         v-bind:class="{ correct: passwordChecked }"></el-input>
               <span class="sure" v-if="isHasRegister" v-show="phoneIsRegisterTip">该手机号已有优软账号,请输入原账号的登录密码进行校验确认</span>
             </el-form-item>
             <el-form-item prop="confirm" v-if="!isHasRegister">
               <el-input type="password"
-                        auto-complete="off"
+                        auto-complete="new-password"
                         placeholder="密码确认"
                         v-bind:class="{active: showPasswordError}"
                         v-model="enterprise1.confirm"></el-input>
@@ -107,9 +107,11 @@
           </el-form>
         </div>
       </div>
-      <div class="login">已有账号?<a href="/">立即登录</a></div>
+      <div class="login">已有账号?<a :href="returnLogin">立即登录</a></div>
       <loading v-show="isShowLoading"/>
     </div>
+    <!--尾部-->
+    <div v-html="loginStyle.footUrl" class="footer"></div>
   </div>
 </template>
 
@@ -508,6 +510,7 @@
         emailHasRegister: false,
         queryLink: '',
         appId: '',
+        returnLogin: '',
 //        企业注册第一步
         rules: {
           mobile: [
@@ -542,6 +545,12 @@
         }
       }
     },
+    computed: {
+      loginStyle () {
+        console.log('44444', this.$store.state.login.loginStyle.data)
+        return this.$store.state.login.loginStyle.data.content
+      }
+    },
     mounted () {
 //      获取链接
       this.$nextTick(() => {
@@ -552,6 +561,8 @@
       // 获取链接
       getUrl () {
         var url = window.location.search
+        var origin = window.location.origin
+        this.returnLogin = origin + url
         var request = {}
         if (url.indexOf('?' !== -1)) {
           var str = url.substr(1)
@@ -1005,4 +1016,7 @@
             }
     }
   }
+  .footer{
+    padding: 50px 0;
+  }
 </style>

+ 17 - 3
components/register/PersonalRegistration.vue

@@ -12,7 +12,7 @@
               <el-input type="text" v-model="item.vipName" auto-complete="off" placeholder="会员名"></el-input>
             </el-form-item>
             <el-form-item prop="password">
-              <el-input type="password" v-model="item.password" auto-complete="off" placeholder="登录密码"></el-input>
+              <el-input type="password" v-model="item.password" auto-complete="new-password" placeholder="登录密码"></el-input>
               <div class="pwd sm" v-show="showMsgTip1">密码强度 <em></em><em></em><em></em><span>弱</span></div>
               <div class="pwd md" v-show="showMsgTip2">密码强度 <em></em><em></em><em></em><span>中</span></div>
               <div class="pwd lar" v-show="showMsgTip3">密码强度 <em></em><em></em><em></em><span>强</span></div>
@@ -22,7 +22,7 @@
               <el-input type="password"
                         v-model="item.confirm"
                         v-bind:class="{active: showPasswordError}"
-                        auto-complete="off"
+                        auto-complete="new-password"
                         placeholder="密码确认"></el-input>
               <span class="tip passwordError" v-show="showPasswordError">两次输入密码不一致</span>
             </el-form-item>
@@ -54,9 +54,11 @@
           </el-form>
         </div>
       </div>
-      <div class="login">已有账号?<a href="/">立即登录</a></div>
+      <div class="login">已有账号?<a :href="returnLogin">立即登录</a></div>
       <loading v-show="isShowLoading"/>
     </div>
+    <!--尾部-->
+    <div v-html="loginStyle.footUrl" class="footer"></div>
   </div>
 </template>
 
@@ -329,6 +331,7 @@
         personal_time: 0,
         queryLink: '',
         appId: '',
+        returnLogin: '',
         rules2: {
           vipName: [
             { validator: validateName, trigger: 'blur' }
@@ -356,11 +359,19 @@
         this.getUrl()
       })
     },
+    computed: {
+      loginStyle () {
+        console.log('22222', this.$store.state.login.loginStyle.data)
+        return this.$store.state.login.loginStyle.data.content
+      }
+    },
     methods: {
       // 获取链接
       getUrl () {
         var url = window.location.search
         var request = {}
+        var origin = window.location.origin
+        this.returnLogin = origin + url
         if (url.indexOf('?' !== -1)) {
           var str = url.substr(1)
           var strs = str.split('&')
@@ -705,4 +716,7 @@
       }
     }
   }
+  .footer{
+    padding: 50px 0;
+  }
 </style>

+ 10 - 0
layouts/isCityFooter.vue

@@ -0,0 +1,10 @@
+<template>
+  <div>
+    <nuxt/>
+  </div>
+</template>
+<script>
+  export default {
+    name: 'isCityFooter'
+  }
+</script>

+ 4 - 1
pages/index.vue

@@ -14,7 +14,10 @@
   import {LoginMobile, HeaderMobile} from '~components/mobile'
   export default {
     layout (context) {
-      return context.store.state.option.isMobile ? 'mobile' : 'loginDefault'
+      return context.store.state.option.isMobile ? 'mobile' : 'isCityFooter'
+    },
+    fetch ({store, route}) {
+      return Promise.all([store.dispatch('GetLoginStyle', {appId: route.query.appId})])
     },
     components: {
       Login,

+ 4 - 1
pages/register/enterpriseRegistration.vue

@@ -18,7 +18,10 @@
   import registerEnterpriseMobile from '~components/mobile/registerEnterprise'
   export default {
     layout (context) {
-      return context.store.state.option.isMobile ? 'mobile' : 'default'
+      return context.store.state.option.isMobile ? 'mobile' : 'isCityFooter'
+    },
+    fetch ({store, route}) {
+      return Promise.all([store.dispatch('GetLoginStyle', {appId: route.query.appId})])
     },
     components: {
       AccountCenterHeader,

+ 4 - 6
pages/register/personalRegistration.vue

@@ -18,7 +18,10 @@
   import registerPersonalMobile from '~components/mobile/registerPersonal'
   export default {
     layout (context) {
-      return context.store.state.option.isMobile ? 'mobile' : 'default'
+      return context.store.state.option.isMobile ? 'mobile' : 'isCityFooter'
+    },
+    fetch ({store, route}) {
+      return Promise.all([store.dispatch('GetLoginStyle', {appId: route.query.appId})])
     },
     components: {
       AccountCenterHeader,
@@ -27,11 +30,6 @@
       FooterMobile,
       registerPersonalMobile
     },
-    fetch ({store, route}) {
-      return Promise.all([
-
-      ])
-    },
     computed: {
       isMobile () {
         return this.$store.state.option.isMobile

+ 5 - 1
plugins/axios.js

@@ -7,12 +7,16 @@ const service = axios.create({
   baseURL: '/'
 })
 
-service.interceptors.request.use(config => {
+service.interceptors.request.use((config, req) => {
+  console.log(config)
+  console.log('\n')
+  console.log(req)
   // is server render, use ${baseUrl} directly rather than ${proxyUrl}
   if (typeof window === 'undefined') {
     config.url = process.env.baseUrl + config.url
     config.headers.cookie = store.state.option.cookies + '; ' + store.state.option.sessionId
     config.headers['User-Agent'] = store.state.option.userAgent
+    // config.headers['X-Forwarded-Host'] = store.state.option.userAgent
   }
 
   return config

+ 9 - 0
store/index.js

@@ -120,5 +120,14 @@ export const actions = {
       }, err => {
         commit('formConfig/GET_FORMDATA_FAILURE', err)
       })
+  },
+  // 登录页样式
+  GetLoginStyle ({ commit }, params = {}) {
+    return axios.get('/sso/login/page/style', { params })
+      .then(response => {
+        commit('login/REQUEST_LOGIN_STYLE_SUCCESS', response.data)
+      }, err => {
+        commit('login/GET_LOGIN_STYLE_FAILURE', err)
+      })
   }
 }

+ 14 - 0
store/login.js

@@ -17,11 +17,25 @@
 export const state = () => ({
   token: {
     data: ''
+  },
+  loginStyle: {
+    fetching: false,
+    data: {}
   }
 })
 
 export const mutations = {
   GET_TOKEN (state, res) {
     state.token.data = res
+  },
+  REQUEST_LOGIN_STYLE (state) {
+    state.loginStyle.fetching = true
+  },
+  REQUEST_LOGIN_STYLE_SUCCESS (state, result) {
+    state.loginStyle.data = result
+    state.loginStyle.fetching = false
+  },
+  REQUEST_LOGIN_STYLE_FAILURE (state) {
+    state.loginStyle.fetching = false
   }
 }