index1.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <div v-loading="loadings" class="login-container">
  3. <div class="express">
  4. <h4 class="title">四川大友房地产评估咨询有限公司
  5. </h4>
  6. </div>
  7. <div class="login-form-box">
  8. <div class="title-container">
  9. <h3 class="title">土地规划项目管理系统</h3>
  10. </div>
  11. <el-form
  12. v-show="showboj"
  13. style="margin-top: -50px"
  14. ref="loginForm"
  15. :model="loginForm"
  16. :rules="loginRules"
  17. class="login-form"
  18. autocomplete="on"
  19. label-position="left"
  20. >
  21. <el-form-item/>
  22. <el-form-item prop="username">
  23. <el-input
  24. ref="username"
  25. v-model="loginForm.account"
  26. placeholder="工号"
  27. name="username"
  28. type="text"
  29. tabindex="1"
  30. autocomplete="on"
  31. >
  32. <i slot="prefix" class="el-input__icon el-icon-user"/>
  33. </el-input>
  34. </el-form-item>
  35. <el-form-item prop="password">
  36. <el-input
  37. :key="passwordType"
  38. ref="password"
  39. v-model="loginForm.pwd"
  40. :type="passwordType"
  41. placeholder="密码"
  42. name="password"
  43. tabindex="2"
  44. autocomplete="on"
  45. @keyup.native="checkCapslock"
  46. @blur="capsTooltip = false"
  47. @keyup.enter.native="handleLogin"
  48. >
  49. <i slot="prefix" class="el-input__icon el-icon-unlock"/>
  50. </el-input>
  51. <span class="show-pwd" @click="showPwd">
  52. <svg-icon style="color: #000;" :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'"/>
  53. </span>
  54. </el-form-item>
  55. <el-form-item>
  56. <div class="login-btn">
  57. <el-button
  58. round
  59. :loading="loading"
  60. type="primary"
  61. @click.native.prevent="handleLogin">
  62. 登录
  63. </el-button>
  64. </div>
  65. </el-form-item>
  66. </el-form>
  67. </div>
  68. <div class="tag">v2.0.0928</div>
  69. </div>
  70. </template>
  71. <script>
  72. import API from '@/api'
  73. export default {
  74. name: 'Login',
  75. data() {
  76. const validateUsername = (rule, value, callback) => {
  77. if (!value) {
  78. callback(new Error('请输入账号'))
  79. } else {
  80. callback()
  81. }
  82. }
  83. const validatePassword = (rule, value, callback) => {
  84. if (!value) {
  85. callback(new Error('请输入密码'))
  86. } else {
  87. callback()
  88. }
  89. }
  90. return {
  91. loadings:false,
  92. showboj:true,
  93. activeName: 'first',
  94. loginForm: {
  95. account: '',
  96. pwd: '',
  97. },
  98. loginRules: {
  99. account: [{
  100. required: true,
  101. trigger: 'blur',
  102. validator: validateUsername
  103. }],
  104. pwd: [{
  105. required: true,
  106. trigger: 'blur',
  107. validator: validatePassword
  108. }]
  109. },
  110. passwordType: 'password',
  111. capsTooltip: false,
  112. loading: false,
  113. showDialog: false,
  114. redirect: undefined,
  115. otherQuery: {},
  116. sysCfg: {},
  117. }
  118. },
  119. watch: {
  120. $route: {
  121. handler: function (route) {
  122. const query = route.query
  123. if (query) {
  124. this.redirect = query.redirect
  125. this.otherQuery = this.getOtherQuery(query)
  126. }
  127. },
  128. immediate: true
  129. }
  130. },
  131. created() {
  132. const that = this
  133. let tok = new RegExp('(^|&)token=([^&]*)(&|$)', 'i');
  134. let t = window.location.search.substr(1).match(tok);
  135. if (t != null) {
  136. let token = decodeURIComponent(t[2])
  137. console.log(token)
  138. }
  139. },
  140. mounted() {
  141. if (this.loginForm.account === '') {
  142. this.$refs.username.focus()
  143. } else if (this.loginForm.pws === '') {
  144. this.$refs.password.focus()
  145. }
  146. },
  147. destroyed() {
  148. // window.removeEventListener('storage', this.afterQRScan)
  149. },
  150. methods: {
  151. getConfig() {
  152. this.$api.globalConfig.getValuesByKey({ key: 'THIRD_CONFIG' }).then(res => {
  153. // this.postForm = res.data.fieldValues
  154. console.log(res)
  155. })
  156. },
  157. checkCapslock(e) {
  158. const { key } = e
  159. this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z')
  160. },
  161. showPwd() {
  162. if (this.passwordType === 'password') {
  163. this.passwordType = ''
  164. } else {
  165. this.passwordType = 'password'
  166. }
  167. this.$nextTick(() => {
  168. this.$refs.password.focus()
  169. })
  170. },
  171. handleLogin() {
  172. this.$refs.loginForm.validate(valid => {
  173. if (valid) {
  174. this.loading = true
  175. this.$store.dispatch('user/login', this.loginForm).then(() => {
  176. if (this.redirect && this.redirect !== 'undefined' && this.redirect !== undefined) {
  177. this.$router.push({
  178. path: this.redirect,
  179. query: this.otherQuery
  180. }, () => {}, () => {}) // Error via a navigation guard.
  181. } else {
  182. API.account.userInfo().then(response => {
  183. const { data } = response
  184. if (!data) {
  185. reject('Verification failed, please Login again.')
  186. } else{
  187. this.$router.push({
  188. path: '/home',
  189. query: this.otherQuery
  190. }, () => {}, () => {})
  191. this.loading = false
  192. }
  193. })
  194. }
  195. }).catch(() => {
  196. this.loading = false
  197. })
  198. } else {
  199. console.log('error submit!!')
  200. return false
  201. }
  202. })
  203. },
  204. getOtherQuery(query) {
  205. return Object.keys(query).reduce((acc, cur) => {
  206. if (cur !== 'redirect') {
  207. acc[cur] = query[cur]
  208. }
  209. return acc
  210. }, {})
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss" scoped>
  216. $bg: #ffffff;
  217. $dark_gray: #ffffff;
  218. $light_gray: #eee;
  219. $assets: '~@/assets/';
  220. .login-container {
  221. background-color: #6C74F7;
  222. background-size: 100% 100%;
  223. position: absolute;
  224. top: 0;
  225. left: 0;
  226. bottom: 0;
  227. right: 0;
  228. display: flex;
  229. justify-content: center;
  230. align-items: center;
  231. .express{
  232. background: url($assets + "images/express.png") 0 0 no-repeat;
  233. width: 500px;
  234. height: 55%;
  235. border-radius: 20px;
  236. margin-top: -80px;
  237. .title{
  238. font-size: 15px;
  239. margin: 0 auto 40px auto;
  240. font-weight: normal;
  241. color: #FFFFFF;
  242. text-align: center;
  243. letter-spacing: 5px;
  244. min-height: 64px;
  245. }
  246. }
  247. .login-form-box {
  248. /*position: absolute;*//*兼容360*/
  249. width: 500px;
  250. height: 55%;
  251. border-radius: 20px;
  252. margin-top: -80px;
  253. /*box-shadow: 0px 0px 10px 5px #ddd;*/
  254. }
  255. .login-form {
  256. width: 500px;
  257. height: 100%;
  258. padding: 10% 60px 60px;
  259. border-radius: 20px;
  260. background-color: #6C74F7;
  261. .login-btn {
  262. padding: 30px 0;
  263. .el-button {
  264. width: 100%;
  265. padding: 15px;
  266. background-color: #0216B8;
  267. border-color: #0216B8;
  268. font-size: medium;
  269. border-radius: 10px;
  270. }
  271. }
  272. .el-form-item {
  273. margin-bottom: 30px;
  274. }
  275. }
  276. .tips {
  277. font-size: 14px;
  278. color: #fff;
  279. margin-bottom: 10px;
  280. span {
  281. &:first-of-type {
  282. margin-right: 16px;
  283. }
  284. }
  285. }
  286. .svg-container {
  287. padding: 6px 5px 6px 15px;
  288. color: $dark_gray;
  289. vertical-align: middle;
  290. width: 30px;
  291. display: inline-block;
  292. }
  293. .title-container {
  294. position: relative;
  295. .title {
  296. font-size: 30px;
  297. margin: 0 auto 40px auto;
  298. font-weight: bold;
  299. color: #FFFFFF;
  300. text-align: center;
  301. letter-spacing: 5px;
  302. min-height: 64px;
  303. }
  304. }
  305. .show-pwd {
  306. position: absolute;
  307. right: 10px;
  308. top: 7px;
  309. font-size: 16px;
  310. color: $dark_gray;
  311. cursor: pointer;
  312. user-select: none;
  313. }
  314. .thirdparty-button {
  315. position: absolute;
  316. right: 0;
  317. bottom: 6px;
  318. }
  319. @media only screen and (max-width: 470px) {
  320. .thirdparty-button {
  321. display: none;
  322. }
  323. }
  324. }
  325. </style>
  326. <style scoped>
  327. .login-form >>> .el-input input {
  328. background: rgba(247, 247, 247, 1);
  329. }
  330. .login-form >>> .el-input--small .el-input__inner {
  331. height: 40px;
  332. line-height: 40px;
  333. }
  334. .login-form >>> .el-input__icon {
  335. font-size: 18px;
  336. }
  337. .tag {
  338. width: 100%;
  339. background-color: #6C74F7;
  340. position: fixed;
  341. bottom: 0;
  342. height: 20px;
  343. font-size: 10px;
  344. vertical-align: middle;
  345. padding-left: 5px;
  346. color: #fff;
  347. }
  348. </style>