changePass.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <template>
  2. <view>
  3. <view class="bg-white padding-left-40 padding-right-40">
  4. <u-form ref="uForm" >
  5. <u-form-item label="旧密码" :label-width="labelWidth">
  6. <u-input maxlength="12" placeholder="请输入旧密码" v-model="password" type="password"></u-input>
  7. </u-form-item>
  8. <u-form-item label="新密码" :label-width="labelWidth">
  9. <u-input maxlength="12" placeholder="请输入新密码" v-model="newPass" type="password"></u-input>
  10. </u-form-item>
  11. <u-form-item label="确认新密码" :label-width="labelWidth">
  12. <u-input maxlength="12" placeholder="再次输入新密码" v-model="confirmPass" type="password"></u-input>
  13. </u-form-item>
  14. </u-form>
  15. </view>
  16. <view @click="submit" class="footer-fixed cu-btn bg-blue flex" style="padding: 45rpx;">
  17. 确认修改
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. //企业信息
  26. dataDetail:{},
  27. labelWidth:180,
  28. password:'',
  29. newPass:''
  30. }
  31. },
  32. onShow() {
  33. let dataDetail=getApp().globalData.userInfo
  34. if (this.$isEmpty(dataDetail)) {
  35. this.fetchUserInfo()
  36. }else{
  37. this.dataDetail=dataDetail
  38. }
  39. },
  40. methods: {
  41. /**
  42. * 加载企业信息
  43. * getApp().globalData.userInfo正常都会有值,一般不会来到这一步
  44. */
  45. fetchUserInfo(){
  46. let creditCode=this.$cache.get('creditCode')
  47. this.$api.enterprise.detail({creditCode:creditCode}).then(res=>{
  48. this.dataDetail=res.data
  49. })
  50. },
  51. /**
  52. * 修改密码
  53. */
  54. submit(){
  55. if (this.$isEmpty(this.password)) {
  56. this.$u.toast("请输入旧密码")
  57. return
  58. }
  59. if (this.password!=this.dataDetail.password) {
  60. this.$u.toast("旧密码错误")
  61. return
  62. }
  63. if (this.$isEmpty(this.newPass)) {
  64. this.$u.toast('请输入新密码')
  65. return
  66. }
  67. if (this.newPass.length<6) {
  68. this.$u.toast('新密码密码不能少于6位')
  69. return
  70. }
  71. if (this.$isEmpty(this.confirmPass)) {
  72. this.$u.toast('请再次输入新密码')
  73. return
  74. }
  75. if (this.newPass!=this.confirmPass) {
  76. this.$u.toast('两次密码输入不一致')
  77. return
  78. }
  79. this.dataDetail.password=this.newPass
  80. this.$api.enterprise.submit(this.dataDetail).then(res=>{
  81. if (res.success) {
  82. this.$showModel('修改成功,请重新登陆!',false).then(res=>{
  83. this.$cache.clear()
  84. this.$Router.push('login')
  85. })
  86. }
  87. })
  88. }
  89. }
  90. }
  91. </script>
  92. <style>
  93. </style>