password.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <template>
  2. <view>
  3. <view class="uni-common-mt">
  4. <view class="uni-form-item uni-column">
  5. <view class="title">输入原密码</view>
  6. <view class="with-fun">
  7. <input class="uni-input" placeholder="请输入密码" :password="showPassword[0]" v-model="formData.pass1" />
  8. <view class="uni-icon uni-icon-eye" :class="[!showPassword[0] ? 'uni-active' : '']" @click="changePassword(0)"></view>
  9. </view>
  10. </view>
  11. <view class="uni-form-item uni-column">
  12. <view class="title">输入新密码</view>
  13. <view class="with-fun">
  14. <input class="uni-input" placeholder="请输入密码" :password="showPassword[1]" v-model="formData.pass2" />
  15. <view class="uni-icon uni-icon-eye" :class="[!showPassword[1] ? 'uni-active' : '']" @click="changePassword(1)"></view>
  16. </view>
  17. </view>
  18. <view class="uni-form-item uni-column">
  19. <view class="title">确认新密码</view>
  20. <view class="with-fun">
  21. <input class="uni-input" placeholder="请输入密码" :password="showPassword[2]" v-model="formData.pass3" />
  22. <view class="uni-icon uni-icon-eye" :class="[!showPassword[2] ? 'uni-active' : '']" @click="changePassword(2)"></view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import _action from '../../common/_action';
  30. import _hook from '../../common/_hook';
  31. export default {
  32. data() {
  33. return {
  34. showPassword: [ true,true,true ],
  35. formData: {
  36. pass1: '',
  37. pass2: '',
  38. pass3: '',
  39. }
  40. }
  41. },
  42. computed: {
  43. },
  44. onShow(){
  45. _hook.routeSonHook();
  46. },
  47. onLoad() {
  48. this.platform = uni.getSystemInfoSync().platform
  49. },
  50. methods: {
  51. changePassword(num) {
  52. this.$set(this.showPassword,num,!this.showPassword[num]);
  53. },
  54. send(){
  55. let _this = this;
  56. if(!_this.formData.pass1 || _this.formData.pass1.length < 6){
  57. uni.showModal({
  58. content: '请输入原密码,不能小于6位',
  59. });
  60. return;
  61. }
  62. if(!_this.formData.pass2 || _this.formData.pass2.length < 6){
  63. uni.showModal({
  64. content: '请输入新密码,不能小于6位',
  65. });
  66. return;
  67. }
  68. if(!_this.formData.pass3 || _this.formData.pass3.length < 6){
  69. uni.showModal({
  70. content: '请确认新密码,不能小于6位',
  71. });
  72. return;
  73. }
  74. if(_this.formData.pass2 !== _this.formData.pass3){
  75. uni.showModal({
  76. content: '两次新密码不一致',
  77. });
  78. return;
  79. }
  80. _this.$httpSend({
  81. path: '/im/set/password',
  82. data: _this.formData,
  83. success() {
  84. uni.showToast({
  85. title: '已修改,请重新登陆',
  86. });
  87. setTimeout(() => {
  88. _action.checkFail();
  89. },2000);
  90. }
  91. });
  92. },
  93. },
  94. onNavigationBarButtonTap(e) {
  95. this.send();
  96. },
  97. }
  98. </script>
  99. <style scoped>
  100. .title {
  101. padding: 10upx 25upx;
  102. }
  103. .uni-icon-clear,
  104. .uni-icon-eye {
  105. color: #999;
  106. }
  107. </style>