index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <div class="l-con">
  3. <div class="l-top">
  4. <h1>四维指房宝</h1>
  5. </div>
  6. <div class="l_center">
  7. <vcenter>
  8. <div class="lc-l">
  9. <img :src="logoImg" alt="">
  10. <div class="text_01">10分钟搞定实景VR</div>
  11. <div class="text_02">自助720度实景VR发布管理</div>
  12. <div class="text_03">自助、简单、安全、高效</div>
  13. </div>
  14. <div class="lc-r">
  15. <div class="lc-title">
  16. <span>后台登录</span>
  17. </div>
  18. <div class="lc-form">
  19. <el-form label-position="top" :model="ruleForm2" status-icon :rules="rules2" ref="ruleForm2" label-width="100px" class="demo-ruleForm">
  20. <el-form-item prop="username">
  21. <el-input type="username" placeholder="账号" v-model="ruleForm2.username" auto-complete="off"></el-input>
  22. </el-form-item>
  23. <el-form-item prop="pass" id='no-bottom'>
  24. <el-input type="password" placeholder="密码" @keyup.enter.native="submitForm('ruleForm2')" v-model="ruleForm2.pass" auto-complete="off"></el-input>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-checkbox v-model="checked">记住密码(在公共场所电脑请勿勾选)</el-checkbox>
  28. </el-form-item>
  29. </el-form>
  30. <div class="lc-btn">
  31. <el-button type="primary" v-loading.fullscreen.lock="fullscreenLoading" @click="submitForm('ruleForm2')">登录</el-button>
  32. </div>
  33. </div>
  34. </div>
  35. </vcenter>
  36. </div>
  37. <div class="l_footer">
  38. <div>杭州天门科技有限公司 版权所有 © 2018 Inc. 浙ICP备18054719号-1</div>
  39. <div class="sub">Design by TianMen Technology Co.Ltd.</div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import vcenter from '@/components/vcenter'
  45. import {serverName} from '@/utils/http'
  46. export default {
  47. name: 'login',
  48. components: {
  49. vcenter
  50. },
  51. data () {
  52. var validateUser = (rule, value, callback) => {
  53. if (!value) {
  54. return callback(new Error('用户名不能为空'))
  55. } else if (value.length < 3) {
  56. callback(new Error('用户名不合法'))
  57. } else {
  58. callback()
  59. }
  60. }
  61. var validatePass = (rule, value, callback) => {
  62. if (value === '') {
  63. return callback(new Error('请输入密码'))
  64. } else if (value.length < 4) {
  65. callback(new Error('密码不能小于4位'))
  66. } else {
  67. callback()
  68. }
  69. }
  70. return {
  71. serverName,
  72. fullscreenLoading: false,
  73. checked: true,
  74. logoImg: require('@/assets/images/4d_zfb_logo.png'),
  75. ruleForm2: {
  76. username: '',
  77. pass: ''
  78. },
  79. rules2: {
  80. username: [{
  81. validator: validateUser,
  82. trigger: 'blur'
  83. }],
  84. pass: [{
  85. validator: validatePass,
  86. trigger: 'blur'
  87. }]
  88. }
  89. }
  90. },
  91. mounted () {
  92. this.ruleForm2.username = window.localStorage.getItem('zfb_username') || ''
  93. this.ruleForm2.pass = window.localStorage.getItem('zfb_pass') || ''
  94. },
  95. methods: {
  96. login () {
  97. this.$http.post('loginBackground', {
  98. userName: this.ruleForm2.username,
  99. userPassword: this.ruleForm2.pass
  100. }).then(res => {
  101. this.fullscreenLoading = true
  102. if (res.code === 200) {
  103. window.localStorage.setItem('zfb_token', String(res.message.token))
  104. window.localStorage.setItem('token', String(res.message.token))
  105. window.localStorage.setItem('zfb_roleType', res.message.type)
  106. if (this.checked) {
  107. window.localStorage.setItem('zfb_username', this.ruleForm2.username)
  108. window.localStorage.setItem('zfb_pass', this.ruleForm2.pass)
  109. } else {
  110. window.localStorage.setItem('zfb_username', '')
  111. window.localStorage.setItem('zfb_pass', '')
  112. }
  113. this.$router.push('/scene')
  114. } else {
  115. this.fullscreenLoading = false
  116. this.$notify.error({
  117. title: '错误',
  118. message: res.message
  119. })
  120. }
  121. })
  122. },
  123. submitForm (formName) {
  124. this.$refs[formName].validate((valid) => {
  125. if (valid) {
  126. this.login()
  127. } else {
  128. this.$alert('请填写正确信息', '提示', {
  129. confirmButtonText: '确定',
  130. callback: action => {}
  131. })
  132. return false
  133. }
  134. })
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .l-con{
  141. width: 100%;
  142. .l-top{
  143. color: #333;
  144. text-align: center;
  145. padding: 50px 0;
  146. }
  147. .l_center {
  148. height: 600px;
  149. width: 100%;
  150. padding: 0 10% 0 20%;
  151. background: url('~@/assets/images/img_login_banbg.jpg') center center no-repeat;
  152. .lc-l{
  153. display: inline-block;
  154. color: #fff;
  155. img{
  156. width: 120px;
  157. }
  158. .text_01{
  159. font-size: 60px;
  160. font-weight: bold;
  161. margin-top: 20px;
  162. }
  163. .text_02{
  164. font-size: 40px;
  165. margin: 30px 0;
  166. }
  167. .text_03{
  168. font-size: 20px;
  169. }
  170. }
  171. .lc-r{
  172. float: right;
  173. width: 345px;
  174. height: 370px;
  175. background-color: #fff;
  176. padding: 28px 30px;
  177. .lc-title{
  178. text-align: center;
  179. border-bottom: 2px solid #0175dc;
  180. padding-bottom: 20px;
  181. span{
  182. color: #333;
  183. font-size: 16px;
  184. }
  185. }
  186. .lc-form{
  187. margin-top: 40px;
  188. .lc-btn{
  189. width: 100%;
  190. .el-button--primary{
  191. width: 100%;
  192. }
  193. }
  194. }
  195. }
  196. }
  197. .l_footer{
  198. font-size: 14px;
  199. text-align: center;
  200. margin-top: 45px;
  201. line-height: 1.5;
  202. .sub{
  203. font-size: 12px;
  204. color: #999;
  205. margin-top: 10px;
  206. }
  207. }
  208. }
  209. </style>