changepasswold.vue 4.2 KB

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