changePass.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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="8" placeholder="请输入旧密码" v-model="password" type="password"></u-input>
  7. </u-form-item>
  8. <u-form-item label="新密码" :label-width="labelWidth">
  9. <u-input maxlength="8" placeholder="请输入新密码" v-model="newPass" type="password"></u-input>
  10. </u-form-item>
  11. <u-form-item label="确认新密码" :label-width="labelWidth">
  12. <u-input maxlength="8" 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-color-base flex" style="padding: 45rpx;">
  17. 确认修改
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. loginType:'',
  26. dataDetail:{},
  27. labelWidth:180,
  28. password:'',
  29. newPass:'',
  30. confirmPass:''
  31. }
  32. },
  33. onShow() {
  34. let dataDetail=getApp().globalData.userInfo
  35. this.loginType=this.$cache.get('loginType')
  36. if (this.$isEmpty(dataDetail)) {
  37. if (this.$loginType.AGENCY==this.loginType) {
  38. //加载园区信息
  39. this.fetchAgencyInfo()
  40. }else if(this.$loginType.ENTERPRISE==this.loginType){
  41. //加载企业信息
  42. this.fetchEnterpriseInfo()
  43. }
  44. }else{
  45. this.dataDetail=dataDetail
  46. }
  47. },
  48. methods: {
  49. /**
  50. * 加载园区信息
  51. */
  52. fetchAgencyInfo(){
  53. let agencyId=this.$cache.get('agencyId')
  54. this.$api.agency.page({id:agencyId}).then(res=>{
  55. this.dataDetail=res.data[0]
  56. })
  57. },
  58. /**
  59. * 加载企业信息
  60. */
  61. fetchEnterpriseInfo(){
  62. let creditCode=this.$cache.get('creditCode')
  63. this.$api.enterprise.detail({creditCode:creditCode}).then(res=>{
  64. this.dataDetail=res.data
  65. })
  66. },
  67. /**
  68. * 修改密码
  69. */
  70. submit(){
  71. if (this.$isEmpty(this.password)) {
  72. this.$u.toast("请输入旧密码")
  73. return
  74. }
  75. if (this.password!=this.dataDetail.password) {
  76. this.$u.toast("旧密码错误")
  77. return
  78. }
  79. if (this.$isEmpty(this.newPass)) {
  80. this.$u.toast('请输入新密码')
  81. return
  82. }
  83. if (this.newPass.length<6) {
  84. this.$u.toast('新密码不能少于6位')
  85. return
  86. }
  87. if (this.$isEmpty(this.confirmPass)) {
  88. this.$u.toast('请再次输入新密码')
  89. return
  90. }
  91. if (this.newPass!=this.confirmPass) {
  92. this.$u.toast('两次密码输入不一致')
  93. return
  94. }
  95. this.dataDetail.password=this.newPass
  96. if (this.loginType==this.$loginType.AGENCY) {
  97. //修改园区密码
  98. this.$api.agency.submit(this.dataDetail).then(res=>{
  99. if (res.success) {
  100. this.$showModel('修改成功,请重新登陆!',false).then(res=>{
  101. this.$cache.clear()
  102. this.$Router.push('login')
  103. })
  104. }
  105. })
  106. }else if (this.loginType==this.$loginType.ENTERPRISE) {
  107. //修改企业密码
  108. this.$api.enterprise.submit(this.dataDetail).then(res=>{
  109. if (res.success) {
  110. this.$showModel('修改成功,请重新登陆!',false).then(res=>{
  111. this.$cache.clear()
  112. this.$Router.push('login')
  113. })
  114. }
  115. })
  116. }
  117. }
  118. }
  119. }
  120. </script>
  121. <style>
  122. </style>