stepBefore.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. this.state.password = 'error'
  48. } else {
  49. this.state.password = 'success'
  50. }
  51. },
  52. sureAccount (type) {
  53. if (this.state.password !== 'success') {
  54. this.downToast('请确认填写部分是否有误')
  55. } else {
  56. this.$indicator.open('确认过程中...')
  57. let param = new FormData()
  58. param.append('password', this.password)
  59. let config = {
  60. headers: {'Content-Type': 'multipart/form-data'}
  61. }
  62. this.$http.post(`/sso/resetPwd/check/password`, param, config)
  63. .then(response => {
  64. this.$indicator.close()
  65. if (response.data.success) {
  66. this.$emit('stepEvent', type)
  67. this.$store.commit('login/GET_TOKEN', response.data.content.token)
  68. } else {
  69. this.downToast(response.data.errMsg)
  70. }
  71. }).catch(() => {
  72. this.$indicator.close()
  73. this.downToast('请检查网络是否正常或联系服务商')
  74. })
  75. }
  76. }
  77. }
  78. }
  79. </script>