changePass.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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="oldPassword" type="password"></u-input>
  7. </u-form-item>
  8. <u-form-item label="新密码" :label-width="labelWidth">
  9. <u-input maxlength="8" placeholder="请输入新密码" v-model="newPassword" type="password"></u-input>
  10. </u-form-item>
  11. <u-form-item label="确认新密码" :label-width="labelWidth">
  12. <u-input maxlength="8" placeholder="再次输入新密码" v-model="confirmPassword" type="password"></u-input>
  13. </u-form-item>
  14. </u-form>
  15. </view>
  16. <view @click="submit" class=" footer-fixed cu-btn base-bg-color flex " style="padding: 45rpx;" :style="{marginBottom:safeAreaBottom}">
  17. 确认修改
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. export default {
  23. data() {
  24. return {
  25. loginType:'',
  26. account:'',
  27. dataDetail:{},
  28. labelWidth:180,
  29. oldPassword:'',
  30. newPassword:'',
  31. confirmPassword:''
  32. }
  33. },
  34. onLoad() {
  35. this.$loginType=this.$cache.get('loginType')
  36. if (!this.$cache.get('loginAccount')) {
  37. uni.showModal({
  38. content:"系统异常",
  39. showCancel:false,
  40. success() {
  41. uni.navigateBack({
  42. delta:1
  43. })
  44. }
  45. })
  46. }else{
  47. this.account=this.$cache.get('loginAccount')
  48. }
  49. },
  50. computed: {
  51. //ios底部安全区域
  52. safeAreaBottom() {
  53. let info = uni.getSystemInfoSync()
  54. let safe = 20
  55. if (
  56. info &&
  57. ['devtools', 'ios'].includes(info.platform) &&
  58. info.statusBarHeight > safe
  59. ) {
  60. return info.statusBarHeight - safe+'px'
  61. }
  62. return 0
  63. }
  64. },
  65. methods: {
  66. /**
  67. * 修改密码
  68. */
  69. submit(){
  70. if (this.$isEmpty(this.oldPassword)) {
  71. this.$u.toast("请输入旧密码")
  72. return
  73. }
  74. if (this.$isEmpty(this.newPassword)) {
  75. this.$u.toast('请输入新密码')
  76. return
  77. }
  78. if (this.newPassword.length<6) {
  79. this.$u.toast('新密码不能少于6位')
  80. return
  81. }
  82. if (this.$isEmpty(this.confirmPassword)) {
  83. this.$u.toast('请再次输入新密码')
  84. return
  85. }
  86. if (this.newPassword!=this.confirmPassword) {
  87. this.$u.toast('两次密码输入不一致')
  88. return
  89. }
  90. let loginType=''
  91. if (this.loginType==this.$loginType.AGENCY) {
  92. //园区
  93. loginType=2
  94. }else{
  95. //企业
  96. loginType=1
  97. }
  98. let params={
  99. loginType,
  100. account:this.account,
  101. oldPassword:this.oldPassword,
  102. newPassword:this.newPassword
  103. }
  104. this.$api.updatePassword(this.$u.queryParams(params)).then(res=>{
  105. if (res.data==true) {
  106. this.$showModel('修改成功,请重新登陆!',false).then(res=>{
  107. this.$cache.clear()
  108. uni.reLaunch({
  109. url:"/pages/login/login"
  110. })
  111. })
  112. }else{
  113. this.$u.toast(res.data)
  114. }
  115. })
  116. if (this.loginType==this.$loginType.AGENCY) {
  117. //修改园区密码
  118. this.$api.agency.submit(this.dataDetail).then(res=>{
  119. if (res.success) {
  120. }
  121. })
  122. }else if (this.loginType==this.$loginType.ENTERPRISE) {
  123. //修改企业密码
  124. this.$api.enterprise.submit(this.dataDetail).then(res=>{
  125. if (res.success) {
  126. this.$showModel('修改成功,请重新登陆!',false).then(res=>{
  127. this.$cache.clear()
  128. uni.navigateTo({
  129. url:"/pages/login/login"
  130. })
  131. })
  132. }
  133. })
  134. }
  135. }
  136. }
  137. }
  138. </script>
  139. <style>
  140. </style>