3
0

login.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div style="text-align:center">
  3. <img src="../assets/images/logo.png"
  4. style="width: 200px;" />
  5. <!-- <x-header style="background-color:#1AAD19;" title="账号绑定" :left-options="{showBack: false}"> -->
  6. <!-- </x-header> -->
  7. <!-- <div class="side-nav" >
  8. <h3 style="text-align:center">
  9. <span>账号绑定</span>
  10. </h3>
  11. </div> -->
  12. <div style="margin-top:50px">
  13. <x-input title="账号"
  14. placeholder="请输入账号"
  15. v-model="model.username"></x-input>
  16. <x-input type="password"
  17. title="密码"
  18. placeholder="请输入账号密码"
  19. v-model="model.password"></x-input>
  20. </div>
  21. <!-- <div style="margin-top:30px">
  22. <x-button type="primary" style="width:300px;background-color:#7D9EC0" action-type="button" @click.native="handleLogin" >登录</x-button>
  23. </div > -->
  24. <box gap="10px 10px">
  25. <x-button type="primary"
  26. style="width:300px;background-color:#7D9EC0"
  27. @click.native="handleLogin">登录</x-button>
  28. </box>
  29. <div style="margin-top:150px">
  30. <load-more :show-loading="false"
  31. :tip="'Copyright © 2019 DASHOO'"
  32. background-color="#fbf9fe"></load-more>
  33. </div>
  34. <div style="text-align:center;font-size:13px;color:red;">{{errmessage}}</div>
  35. </div>
  36. <!-- <group style="margin-top:-20px;">
  37. <x-input placeholder="账号" type="text" v-model="model.username"></x-input>
  38. <x-input placeholder="密码" type="password" v-model="model.password"></x-input>
  39. </group>
  40. <box gap="10px 10px">
  41. <x-button type="primary" @click.native="handleLogin">登录</x-button>
  42. </box>
  43. <div style="text-align:center;font-size:13px;color:red;">{{errmessage}}</div>
  44. </div> -->
  45. </template>
  46. <script>
  47. import { XInput, Group, XButton, Cell, Box, XHeader } from 'vux'
  48. import store from 'store'
  49. export default {
  50. name: 'login',
  51. components: {
  52. XInput,
  53. XButton,
  54. Group,
  55. Cell,
  56. Box,
  57. XHeader
  58. },
  59. data () {
  60. const model = {
  61. username: '',
  62. password: '',
  63. openid: ''
  64. }
  65. return {
  66. model: model,
  67. errmessage: ''
  68. }
  69. },
  70. mounted () {
  71. // 开发
  72. // let openid = 'oZ2X-weExJP7jTGlhknsxAnf12r4'
  73. // let nick = 'All%20is%20Well'
  74. // 线上
  75. let openid = this.$route.query.openid
  76. let nick = this.$route.query.nick
  77. if (openid && openid !== '') {
  78. this.model.openid = openid
  79. store.set('ygopenid', this.model.openid)
  80. store.set('ygnick', nick)
  81. } else {
  82. this.model.openid = store.get('ygopenid')
  83. }
  84. },
  85. methods: {
  86. handleLogin () {
  87. console.info('[Login] 发送登录请求', this.model)
  88. this.$store.dispatch('createToken', this.model)
  89. .then(token => {
  90. this.$router.push('/')
  91. this.errmessage = ''
  92. })
  93. .catch(err => {
  94. this.errmessage = '出现异常,请稍后再试!'
  95. switch (err.response && err.response.status) {
  96. case 401:
  97. this.errmessage = '用户名或密码错误!'
  98. break
  99. case 403:
  100. this.errmessage = '访问出错,禁止访问!'
  101. break
  102. case 500:
  103. this.errmessage = '服务器内部异常,请稍后再试!'
  104. break
  105. }
  106. })
  107. }
  108. }
  109. }
  110. </script>
  111. <style type="text/css">
  112. .vux-demo-header-box {
  113. color: red;
  114. }
  115. </style>