changepasswold.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view>
  3. <view style="position: fixed;z-index: 100;top: 0;">
  4. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="修改密码"></uni-nav-bar>
  5. </view>
  6. <u-form :model="form" ref="uForm" class="uForm">
  7. <view class="uFormbg">
  8. <u-form-item label="原始密码" left-icon="lock" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom"
  9. prop="name">
  10. <u-input v-model="form.oldpass" :clearable="clearable" input-align="right" placeholder="请输入原始密码" :type="type" @blur="oldpassblur"/>
  11. </u-form-item>
  12. </view>
  13. <p class="tishi" v-if="oldpassisnull">请输入原始密码!</p>
  14. <view class="uFormbg">
  15. <u-form-item label="新密码" left-icon="lock" :left-icon-style="lefticonstyle" label-width="160rpx" :border-bottom="borderbottom"
  16. prop="name">
  17. <u-input v-model="form.newpass" :clearable="clearable" input-align="right" placeholder="请输入新密码" :type="type" @blur="newpassblur"/>
  18. </u-form-item>
  19. </view>
  20. <p class="tishi" v-if="passisnull">请输入新密码!</p>
  21. <view class="uFormbg">
  22. <u-form-item label="确认新密码" left-icon="lock" :left-icon-style="lefticonstyle" label-width="200rpx" :border-bottom="borderbottom"
  23. prop="name">
  24. <u-input v-model="form.newpasstwo" :clearable="clearable" input-align="right" placeholder="请再次输入新密码" :type="type" @blur="tnewpassblur"/>
  25. </u-form-item>
  26. </view>
  27. <p class="tishi" v-if="tpassisnull">请输入新密码</p>
  28. <p class="tishi" v-if="passisdif">两次输入密码不一致!</p>
  29. </u-form>
  30. <view class="confirm">
  31. <button @click="confirm">确定</button>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. user_info: {},
  40. form: {
  41. oldpass: '',
  42. newpass: '',
  43. newpasstwo: ''
  44. },
  45. borderbottom: false,
  46. clearable: false,
  47. lefticonstyle: {
  48. 'color': '#57C878'
  49. },
  50. oldpassisnull:false,//旧密码为空提示
  51. passisdif: false,//俩次密码不一致提示
  52. tpassisnull:false,//第二次新密码为空提示
  53. passisnull:false,//第一次新密码为空提示
  54. type: 'password'
  55. }
  56. },
  57. methods: {
  58. clickLeft() {
  59. uni.navigateTo({
  60. url: './useroperation?item=' + JSON.stringify(this.user_info)
  61. })
  62. },
  63. async changepwd(data) { //分配设备
  64. const res = await this.$myRequest({
  65. url: '/api/api_gateway?method=user.login.changepwd',
  66. data: {
  67. uid: this.user_info.uid,
  68. old_password: this.form.oldpass,
  69. new_password: this.form.newpass,
  70. confirm_password: this.form.newpasstwo
  71. }
  72. })
  73. },
  74. confirm(){//确定按钮
  75. if(!(this.passisdif&&this.tpassisnull&&this.oldpassisnull&&this.passisnull)){
  76. this.changepwd()
  77. }
  78. },
  79. newpassblur(){//第一次新密码框提示
  80. if(this.form.newpass==""){
  81. this.passisnull=true
  82. }else{
  83. this.passisnull=false
  84. }
  85. },
  86. tnewpassblur(){//第二次新密码框提示
  87. if(this.form.newpasstwo==""){
  88. this.tpassisnull=true
  89. }else{
  90. this.tpassisnull=false
  91. if(this.form.newpass!=this.form.newpasstwo){
  92. this.passisdif=true
  93. }else{
  94. this.passisdif=false
  95. }
  96. }
  97. },
  98. oldpassblur(){//原始密码框提示
  99. if(this.form.oldpass==""){
  100. this.oldpassisnull=true
  101. }else{
  102. this.oldpassisnull=false
  103. }
  104. }
  105. },
  106. onLoad(option) {
  107. this.user_info = JSON.parse(option.item)
  108. }
  109. }
  110. </script>
  111. <style lang="scss">
  112. .uForm {
  113. width: 100%;
  114. position: relative;
  115. top: 44px;
  116. .uFormbg {
  117. width: 90%;
  118. background-color: #f3f3f3;
  119. margin: 20rpx auto 0;
  120. .u-form-item {
  121. width: 90%;
  122. padding: 10rpx 0;
  123. margin: 0 auto;
  124. }
  125. }
  126. .tishi {
  127. width: 100%;
  128. text-align: center;
  129. color: red;
  130. font-size: 12px;
  131. }
  132. }
  133. .confirm {
  134. width: 90%;
  135. position: relative;
  136. top: 150rpx;
  137. left: 50%;
  138. margin-left: -45%;
  139. button {
  140. height: 80rpx;
  141. line-height: 80rpx;
  142. background-color: $uni-color-success;
  143. color: white;
  144. }
  145. }
  146. </style>