updatePwd.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <view :style="{height: screenHeight == 0 ? '100%':screenHeight+'px'}">
  3. <view @click="keyHideStatus" style="height: 100%;">
  4. <uni-card>
  5. <uni-forms ref="baseForm" :rules="rules" :modelValue="baseFormData">
  6. <uni-forms-item label="旧密码" name="oldPassword">
  7. <!-- <uni-easyinput ref="oldPassword" type="password" v-model="baseFormData.oldPassword" @blur="close()" @focus="open(1)"></uni-easyinput> -->
  8. <uni-easyinput ref="oldPassword" type="password" v-model="baseFormData.oldPassword"></uni-easyinput>
  9. </uni-forms-item>
  10. <uni-forms-item label="新密码" name="newPassword">
  11. <!-- <uni-easyinput type="password" v-model="baseFormData.newPassword" @blur="close()" @focus="open(2)"></uni-easyinput> -->
  12. <uni-easyinput type="password" v-model="baseFormData.newPassword"></uni-easyinput>
  13. </uni-forms-item>
  14. <uni-forms-item label="确认密码" name="newPassword1">
  15. <!-- <uni-easyinput type="password" v-model="baseFormData.newPassword1" @blur="close()" @focus="open(3)"></uni-easyinput> -->
  16. <uni-easyinput type="password" v-model="baseFormData.newPassword1"></uni-easyinput>
  17. </uni-forms-item>
  18. <view>
  19. <button class="buttonClass" @click="save()">修改</button>
  20. </view>
  21. </uni-forms>
  22. </uni-card>
  23. </view>
  24. <!-- <view>
  25. <tki-float-keyboard ref="keyb" :mode="keyMode" :type="keyType" :title="title" @del="keyDel" @val="keyVal" @show="keyShow"
  26. @hide="keyHide"></tki-float-keyboard>
  27. </view> -->
  28. </view>
  29. </template>
  30. <script>
  31. import { UpdatePwd, updateLrPwd, unbind, logout } from '@/api/my.js'
  32. import { getUser } from '@/common/auth.js'
  33. import tkiFloatKeyboard from '@/components/tki-float-keyboard/tki-float-keyboard.vue'
  34. export default {
  35. components: {
  36. tkiFloatKeyboard
  37. },
  38. data() {
  39. return {
  40. screenHeight:"",
  41. userType: '',
  42. // 键盘
  43. // 键盘类型 keyboard 普通键盘,car 汽车键盘,number 数字键盘
  44. keyMode: 'keyboard',
  45. // type 键盘可用区域,配合mode属性使用 默认值:0
  46. //mode = keyboard 时 type = 0 全部、 1 字母加数字、 2 符号、 3 字母、 4 数字、 5 字母加符号、6 数字加符号
  47. //mode = car 时 type = 0 全部、 1 字母加数字、 2 省、 3 字母加数字加特、 4 字母、 5 数字
  48. //mode = number 时 type = 0 全部、 1 禁用.
  49. keyType: 0,
  50. title: '密码键盘',
  51. keyShowStatus: false,
  52. showType: 0,
  53. baseFormData: {
  54. oldPassword: '',
  55. newPassword: '',
  56. newPassword1: '',
  57. },
  58. rules: {
  59. oldPassword: {
  60. rules: [{
  61. required: true,
  62. errorMessage: '旧密码不能为空'
  63. }]
  64. },
  65. newPassword: {
  66. rules: [{
  67. required: true,
  68. errorMessage: '新密码不能为空'
  69. }]
  70. },
  71. newPassword1: {
  72. rules: [{
  73. required: true,
  74. errorMessage: '确认密码不能为空'
  75. }]
  76. },
  77. },
  78. }
  79. },
  80. onLoad() {
  81. // 老人07、员工04、监管00
  82. let userInfo = getUser()
  83. this.userType = userInfo.userType
  84. this.screenHeight = uni.getSystemInfoSync().windowHeight;
  85. },
  86. methods: {
  87. keyHideStatus() {
  88. if (this.keyShowStatus) this.$refs.keyb._keyHide()
  89. },
  90. keyVal(v) {
  91. if (this.showType == 1) {
  92. this.baseFormData.oldPassword += v
  93. } else if (this.showType == 2) {
  94. this.baseFormData.newPassword += v
  95. } else if (this.showType == 3) {
  96. this.baseFormData.newPassword1 += v
  97. }
  98. },
  99. keyDel(d) {
  100. if (this.showType == 1) {
  101. this.baseFormData.oldPassword = this.baseFormData.oldPassword.substring(0, this.baseFormData
  102. .oldPassword.length - 1)
  103. } else if (this.showType == 2) {
  104. this.baseFormData.newPassword = this.baseFormData.newPassword.substring(0, this.baseFormData
  105. .newPassword.length - 1)
  106. } else if (this.showType == 3) {
  107. this.baseFormData.newPassword1 = this.baseFormData.newPassword1.substring(0, this.baseFormData
  108. .newPassword1.length - 1)
  109. }
  110. },
  111. keyShow(h) {
  112. this.keyShowStatus = true
  113. },
  114. keyHide(h) {
  115. this.keyShowStatus = false
  116. },
  117. open(e) {
  118. this.showType = e
  119. uni.hideKeyboard()
  120. this.$refs.keyb._keyShow();
  121. },
  122. close() {},
  123. save() {
  124. if (this.keyShowStatus) this.$refs.keyb._keyHide()
  125. this.$refs['baseForm'].validate().then(res => {
  126. if (this.baseFormData.newPassword != this.baseFormData.newPassword1) {
  127. this.showConfirm('新密码与确认密码不同')
  128. return
  129. }
  130. uni.showLoading({
  131. title: '正在修改中...',
  132. mask:true,
  133. })
  134. if (['04', '07'].includes(this.userType)) {
  135. updateLrPwd(this.baseFormData).then(r => {
  136. uni.hideLoading()
  137. if (r.code == 200) {
  138. this.toast('修改成功')
  139. setTimeout(function() {
  140. uni.switchTab({
  141. url: '/pages/my/index'
  142. })
  143. }, 1000)
  144. }
  145. })
  146. } else {
  147. UpdatePwd(this.baseFormData).then(r => {
  148. uni.hideLoading()
  149. if (r.code == 200) {
  150. this.toast('修改成功')
  151. setTimeout(function() {
  152. uni.switchTab({
  153. url: '/pages/my/index'
  154. })
  155. }, 1000)
  156. }
  157. })
  158. }
  159. })
  160. }
  161. }
  162. }
  163. </script>
  164. <style>
  165. .buttonClass {
  166. margin-top: 22px;
  167. margin-left: 9vw;
  168. width: 68vw;
  169. height: 38px;
  170. border-radius: 5.8vw;
  171. /* border: 1px solid rgba(176, 179, 199, 1); */
  172. background: #28d87d;
  173. color: white;
  174. display: flex;
  175. align-items: center;
  176. justify-content: center;
  177. box-shadow: 0rpx 4rpx 10rpx 1rpx rgba(40, 216, 125, 0.4);
  178. }
  179. </style>