modifypassword.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view style="width: 100%;height: 100%;">
  3. <view style="margin-top: 20rpx;background-color: #FFFFFF;">
  4. <view style="padding: 45rpx 28rpx;" v-if="state==0">
  5. <input placeholder="请输入原密码" style="height: 30rpx" @blur="blur1" />
  6. </view>
  7. <view style="padding: 45rpx 28rpx;">
  8. <input placeholder="请输入新密码" style="height: 30rpx" @blur="blur2" />
  9. </view>
  10. <view style="padding: 45rpx 28rpx;">
  11. <input placeholder="请再次输入密码" style="height: 30rpx" @blur="blur3" />
  12. </view>
  13. </view>
  14. <!-- 底部按钮 -->
  15. <view class="bottomButton" @click="bc">
  16. 保存
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. onLoad(obj) {
  23. this.state = obj.state
  24. console.log(state.state)
  25. },
  26. data() {
  27. return {
  28. //0没有有密码
  29. state: 0, //判断状态,如果有密码就显示原密码框
  30. //原密码
  31. value1: '',
  32. //新密码
  33. value2: '',
  34. //二次新密码
  35. value3: ''
  36. }
  37. },
  38. methods: {
  39. //失去焦点事件
  40. blur1({
  41. detail
  42. }) {
  43. console.log(detail.value)
  44. this.value1 = detail.value
  45. },
  46. blur2({
  47. detail
  48. }) {
  49. console.log(detail.value)
  50. this.value2 = detail.value
  51. },
  52. blur3({
  53. detail
  54. }) {
  55. console.log(detail.value)
  56. this.value3 = detail.value
  57. },
  58. //保存按钮
  59. bc: async function(e) {
  60. console.log(this.value1)
  61. console.log(this.value2)
  62. console.log(this.value3)
  63. console.log(this.value1.length,this.value2.size,this.value3)
  64. if (this.value2 != this.value3) {
  65. console.log('密码不相同')
  66. uni.showToast({
  67. title: '密码不相同',
  68. icon: 'none'
  69. })
  70. } else if(this.value2.length <6){
  71. uni.showToast({
  72. title: '密码必须为六个字符以上',
  73. icon: 'none'
  74. })
  75. }else{
  76. let res = await this.$request.post('doctor/passwordEdit', {
  77. 'lis': this.state != 0 ?"123":this.value1,
  78. 'newpassword': this.value3
  79. });
  80. if (res.status == 0) {
  81. uni.showToast({
  82. title: "修改成功",
  83. duration: 2000,
  84. icon: 'none'
  85. });
  86. uni.switchTab({
  87. url: '/pages/index/index'
  88. })
  89. } else {
  90. uni.showToast({
  91. title: res.message,
  92. duration: 2000,
  93. icon: 'none'
  94. });
  95. }
  96. }
  97. }
  98. }
  99. }
  100. </script>
  101. <style>
  102. page {
  103. background-color: #e1e1e1;
  104. }
  105. .bottomButton {
  106. width: 100%;
  107. height: 100rpx;
  108. position: fixed;
  109. bottom: 0;
  110. left: 0;
  111. display: flex;
  112. align-items: center;
  113. justify-content: center;
  114. background-color: #0B73B9;
  115. color: #FFFFFF;
  116. font-size: 32rpx;
  117. z-index: 1;
  118. }
  119. </style>