password.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view class="body">
  3. <!-- 公共组件-每个页面必须引入 -->
  4. <public-module></public-module>
  5. <view class="form">
  6. <view class="password">
  7. <view class="icon iconfont icon-icon-mima"></view>
  8. <input placeholder="请设置新密码(6-15位数字与字母组合)" v-model="pwd" password=true placeholder-style="color: #C5C5C5;font-size:26upx"/>
  9. </view>
  10. <view class="password">
  11. <view class="icon iconfont icon-icon-mima"></view>
  12. <input placeholder="再次输入新密码" v-model="repwd" password=true placeholder-style="color: #C5C5C5;font-size:26upx"/>
  13. </view>
  14. <button class="user-set-btn d-flex a-center j-center main-bg-color" :loading="loading" :class="{'main-bf-hover-color':disabled}" :disabled="disabled" type="primary" @tap="submit">完成</button>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. import {mapState} from "vuex"
  20. export default {
  21. data() {
  22. return {
  23. pwd:"",
  24. repwd:"",
  25. loading:false,
  26. disabled:true,
  27. }
  28. },
  29. watch:{
  30. pwd(val){
  31. this.OnBtnChange();
  32. },
  33. repwd(val){
  34. this.OnBtnChange();
  35. },
  36. },
  37. computed:{
  38. ...mapState(['userInfo'])
  39. },
  40. methods: {
  41. // 改变按钮状态
  42. OnBtnChange(){
  43. if(this.pwd && this.repwd){
  44. this.disabled=false; return;
  45. }
  46. this.disabled=true;
  47. },
  48. async submit(){
  49. if (!this.$base.passwordRegular.test(this.pwd)) {
  50. return uni.showToast({title: '密码须6-15位数字与字母组合',icon: 'none'});
  51. }
  52. if(this.pwd != this.repwd){
  53. return uni.showToast({ title: '两次密码输入不一致', icon:"none" });
  54. }
  55. let res = await this.$http.post('/user/updatePwd?id='+this.userInfo.sysUser.id+'&password='+this.pwd);
  56. if (res.code == 200){
  57. this.pwd = "";
  58. this.repwd = "";
  59. return uni.showToast({ title: "修改密码成功", icon:"none" });
  60. }
  61. }
  62. }
  63. }
  64. </script>
  65. <style>
  66. .body{
  67. position: absolute;
  68. width: 100%;
  69. height:100vh;
  70. background-color: #F5F5F5;
  71. }
  72. .form{
  73. width: 90%;
  74. padding: 20upx 5%;
  75. font-size: 30upx;
  76. }
  77. .form .password{
  78. position: relative;
  79. width: calc(100% - 100upx);
  80. height: 90upx;
  81. display: flex;
  82. align-items: center;
  83. border-radius: 5upx;
  84. background-color: #FFFFFF;
  85. padding: 0 0 0 100upx;
  86. margin: 30upx 0upx 50upx;
  87. }
  88. .form .password input{
  89. width: 100%;
  90. height: 50upx;
  91. color: rgba($color: #ffffff, $alpha: 0.8);
  92. font-weight: 200;
  93. }
  94. .icon{
  95. color: #999;
  96. height: 70upx;
  97. font-size: 40upx;
  98. z-index: 10;
  99. position: absolute;
  100. top: 10upx;
  101. left: 10upx;
  102. padding: 0 15upx;
  103. border-right: 2px solid #F5F5F5;
  104. }
  105. </style>