password.vue 2.6 KB

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