changepasswold.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. this.form.newpass = this.form.newpass.replace(/[\u4E00-\u9FA5]/g,'')
  92. },
  93. tnewpassblur() { //第二次新密码框提示
  94. if (this.form.newpasstwo == "") {
  95. this.tpassisnull = true
  96. } else {
  97. this.tpassisnull = false
  98. if (this.form.newpass != this.form.newpasstwo) {
  99. this.passisdif = true
  100. } else {
  101. this.passisdif = false
  102. }
  103. }
  104. this.form.newpasstwo = this.form.newpasstwo.replace(/[\u4E00-\u9FA5]/g,'')
  105. },
  106. oldpassblur() { //原始密码框提示
  107. if (this.form.oldpass == "") {
  108. this.oldpassisnull = true
  109. } else {
  110. this.oldpassisnull = false
  111. }
  112. this.form.oldpass = this.form.oldpass.replace(/[\u4E00-\u9FA5]/g,'')
  113. }
  114. },
  115. onLoad(option) {
  116. this.user_info = JSON.parse(option.item)
  117. }
  118. }
  119. </script>
  120. <style lang="scss">
  121. .uForm {
  122. width: 100%;
  123. position: relative;
  124. top: 54px;
  125. .uFormbg {
  126. width: 90%;
  127. background-color: #f3f3f3;
  128. margin: 20rpx auto 0;
  129. .u-form-item {
  130. width: 90%;
  131. padding: 10rpx 0;
  132. margin: 0 auto;
  133. }
  134. }
  135. .tishi {
  136. width: 100%;
  137. text-align: center;
  138. color: red;
  139. font-size: 12px;
  140. }
  141. }
  142. .confirm {
  143. width: 90%;
  144. position: relative;
  145. top: 150rpx;
  146. left: 50%;
  147. margin-left: -45%;
  148. button {
  149. height: 80rpx;
  150. line-height: 80rpx;
  151. background-color: $uni-color-success;
  152. color: white;
  153. }
  154. }
  155. </style>