stepBefore.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. type="password"
  11. auto-complete="off"
  12. :state="state.password"
  13. @blur.native.capture="hasPassword"
  14. v-model="password"></mt-field>
  15. </div>
  16. <div class="page-part">
  17. <mt-button size="large" type="primary" @click="sureAccount('security')">下一步</mt-button>
  18. </div>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'step-before',
  25. data () {
  26. return {
  27. state: {
  28. password: 'error'
  29. },
  30. password: ''
  31. }
  32. },
  33. methods: {
  34. jump (type) {
  35. this.$emit('stepEvent', type)
  36. },
  37. // 警告弹窗
  38. downToast (type) {
  39. this.$toast({
  40. message: type,
  41. iconClass: 'el-icon-warning'
  42. })
  43. },
  44. // 验证密码
  45. hasPassword () {
  46. if (!this.password) {
  47. this.downToast('请填写当前密码')
  48. this.state.password = 'error'
  49. } else {
  50. this.state.password = 'success'
  51. }
  52. },
  53. sureAccount (type) {
  54. if (this.state.password !== 'success') {
  55. this.downToast('请确认填写部分是否有误')
  56. } else {
  57. this.$indicator.open('确认过程中...')
  58. let param = new FormData()
  59. param.append('password', this.password)
  60. let config = {
  61. headers: {'Content-Type': 'multipart/form-data'}
  62. }
  63. this.$http.post(`/sso/resetPwd/check/password`, param, config)
  64. .then(response => {
  65. this.$indicator.close()
  66. if (response.data.success) {
  67. this.$emit('stepEvent', type)
  68. this.$emit('tokenEvent', response.data.content.token)
  69. } else {
  70. this.downToast(response.data.errMsg)
  71. }
  72. }).catch((err) => {
  73. this.$indicator.close()
  74. this.downToast(err.errMsg)
  75. })
  76. }
  77. }
  78. }
  79. }
  80. </script>