stepBefore.vue 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>密码重置</p>
  5. <a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>
  6. </div>
  7. <div class="f-form">
  8. <div class="page-part">
  9. <mt-field placeholder="请输入当前密码"
  10. auto-complete="off"
  11. :state="state.password"
  12. @blur.native.capture="hasPassword"
  13. v-model="password"></mt-field>
  14. </div>
  15. <div class="page-part">
  16. <mt-button size="large" type="primary" @click="sureAccount('new')">下一步</mt-button>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'step-before',
  24. data () {
  25. return {
  26. state: {
  27. password: 'error'
  28. },
  29. password: ''
  30. }
  31. },
  32. methods: {
  33. jump (type) {
  34. this.$emit('stepEvent', type)
  35. },
  36. // 警告弹窗
  37. downToast (type) {
  38. this.$toast({
  39. message: type,
  40. iconClass: 'el-icon-warning'
  41. })
  42. },
  43. // 验证密码
  44. hasPassword () {
  45. if (!this.password) {
  46. this.downToast('请填写当前密码')
  47. } else {
  48. this.state.password = 'success'
  49. }
  50. },
  51. sureAccount (type) {
  52. if (this.state.password !== 'success') {
  53. this.downToast('请确认填写部分是否有误')
  54. } else {
  55. this.$indicator.open('确认过程中...')
  56. let param = new FormData()
  57. param.append('password', this.password)
  58. let config = {
  59. headers: {'Content-Type': 'multipart/form-data'}
  60. }
  61. this.$http.post(`/sso/resetPwd/check/password`, param, config)
  62. .then(response => {
  63. this.$indicator.close()
  64. if (response.data.success) {
  65. this.$emit('stepEvent', type)
  66. this.$store.commit('login/GET_TOKEN', response.data.content.token)
  67. } else {
  68. this.downToast(response.data.errMsg)
  69. }
  70. }).catch(() => {
  71. this.$indicator.close()
  72. this.downToast('请检查网络是否正常或联系服务商')
  73. })
  74. }
  75. }
  76. }
  77. }
  78. </script>