Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <template lang="pug">
  2. .container
  3.   .alert.alert-danger(role='alert', v-if='errors.length')
  4.     b Пожалуйста исправьте указанные ошибки:
  5.       ul
  6.         li(v-for='error in errors') {{ error }}
  7.  
  8.   .d-flex.justify-content-center.h-100
  9.     .card
  10.       .card-header
  11.         h3 Авторизация
  12.         .d-flex.justify-content-end.social_icon
  13.           span
  14.             i.fab.fa-facebook-square
  15.           span
  16.             i.fab.fa-google-plus-square
  17.           span
  18.             i.fab.fa-twitter-square
  19.       .card-body
  20.         form
  21.           .input-group.form-group
  22.             .input-group-prepend
  23.               span.input-group-text
  24.                 i.fas.fa-user
  25.             input.form-control(type='text', placeholder='Логин' v-model='login')
  26.           .input-group.form-group
  27.             .input-group-prepend
  28.               span.input-group-text
  29.                 i.fas.fa-key
  30.             input.form-control(type='password', placeholder='Пароль' v-model='password')
  31.           .row.align-items-center.remember
  32.             input(type='checkbox')
  33.             | Запомнить меня
  34.           .form-group
  35.             input.btn.float-right.login_btn(type='button', value='Войти' v-on:click='loginAction')
  36.       .card-footer
  37.         .d-flex.justify-content-center.links
  38.           | Нет аккаунта? Зарегистрируйтесь сейчас!
  39.           a(href='#') Войти
  40.         .d-flex.justify-content-center
  41.           a(href='#') Забыли свой пароль?
  42. </template>
  43.  
  44. <script>
  45. export default{
  46.   data () {
  47.     return {
  48.       errors: [],
  49.       login: null,
  50.       password: null,
  51.       data: ''
  52.     }
  53.   },
  54.   created () {
  55.     // console.log(this.$cookies.get('rpc-api-session'))
  56.     // Получить доступ к списку каналов
  57.     /* this.$http.get('http://192.168.85.3/android/rpc/get-tv-contents?result_format=json&type=unicast&mode=internet&options=0', {withCredentials: true})
  58.       .then(response => console.log(response.data)) */
  59.   },
  60.   methods: {
  61.     validateForm: function (event) {
  62.       if (this.login && this.password) {
  63.         return true
  64.       }
  65.  
  66.       this.errors = []
  67.  
  68.       if (!this.login) {
  69.         this.errors.push('Требуется ввести логин!')
  70.       }
  71.  
  72.       if (!this.password) {
  73.         this.errors.push('Требуется ввести пароль!')
  74.       }
  75.     },
  76.     loginAction: function () {
  77.       this.validateForm()
  78.  
  79.       var dataReq = new FormData()
  80.       dataReq.set('login', this.login)
  81.       dataReq.set('password', this.password)
  82.  
  83.       this.$http.post('http://192.168.85.3/android/rpc/login?result_format=json', dataReq, {
  84.         headers: {
  85.           'Accept': 'application/json, text/plain, */*',
  86.           'Accept-Language': 'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3',
  87.           'Content-Type': 'application/x-www-form-urlencoded'
  88.         }
  89.       })
  90.         .then((response) => {
  91.           this.$cookies.set('isLoggedIn', true)
  92.           this.$cookies.set('rpc-api-session', response.data.session_id)
  93.         })
  94.         .catch((error) => {
  95.           console.log(error)
  96.         })
  97.     }
  98.   }
  99. }
  100. </script>
  101.  
  102. <style lang="stylus" scoped>
  103. .container
  104.   margin-top 35px
  105. </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement