password.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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 type="text" placeholder="请输入旧密码" v-model="oepwd" :password="isHidePassword"
  9. placeholder-style="color: #C5C5C5;font-size:26upx" />
  10. <view class=" position-absolute top-0 right-0 d-flex a-center j-center"
  11. style="padding-right: 10px;height: 100%;">
  12. <image
  13. :src="isHidePassword?'../../static/image/login/biyan.png':'../../static/image/login/zhengyan.png'"
  14. @tap="isHidePassword = !isHidePassword" mode="" style="width: 18px;height: 18px;">
  15. </view>
  16. </view>
  17. <view class="password">
  18. <view class="icon iconfont icon-icon-mima"></view>
  19. <input type="text" placeholder="请设置新密码(6-15位数字与字母组合)" v-model="pwd" :password="isHidePassword1"
  20. placeholder-style="color: #C5C5C5;font-size:26upx" />
  21. <view class=" position-absolute top-0 right-0 d-flex a-center j-center"
  22. style="padding-right: 10px;height: 100%;">
  23. <image
  24. :src="isHidePassword1?'../../static/image/login/biyan.png':'../../static/image/login/zhengyan.png'"
  25. @tap="isHidePassword1 = !isHidePassword1" mode="" style="width: 18px;height: 18px;">
  26. </view>
  27. </view>
  28. <view class="password">
  29. <view class="icon iconfont icon-icon-mima"></view>
  30. <input type="text" placeholder="再次输入新密码" v-model="repwd" :password="isHidePassword2"
  31. placeholder-style="color: #C5C5C5;font-size:26upx" />
  32. <view class=" position-absolute top-0 right-0 d-flex a-center j-center"
  33. style="padding-right: 10px;height: 100%;">
  34. <image
  35. :src="isHidePassword2?'../../static/image/login/biyan.png':'../../static/image/login/zhengyan.png'"
  36. @tap="isHidePassword2 = !isHidePassword2" mode="" style="width: 18px;height: 18px;">
  37. </view>
  38. </view>
  39. <button class="user-set-btn d-flex a-center j-center main-bg-color" :loading="loading"
  40. :class="{'main-bf-hover-color':disabled}" :disabled="disabled" type="primary" @tap="submit">完成</button>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. mapState,mapMutations
  47. } from "vuex"
  48. export default {
  49. data() {
  50. return {
  51. oepwd:'',
  52. pwd: "",
  53. repwd: "",
  54. loading: false,
  55. disabled: true,
  56. isHidePassword: true, //是否隐藏密码
  57. isHidePassword1: true, //是否隐藏密码
  58. isHidePassword2: true, //是否隐藏密码
  59. }
  60. },
  61. watch: {
  62. pwd(val) {
  63. this.OnBtnChange();
  64. },
  65. repwd(val) {
  66. this.OnBtnChange();
  67. },
  68. },
  69. computed: {
  70. ...mapState(['userInfo'])
  71. },
  72. methods: {
  73. ...mapMutations(['emptyUserInfo']),
  74. // 改变按钮状态
  75. OnBtnChange() {
  76. if (this.pwd && this.repwd) {
  77. this.disabled = false;
  78. return;
  79. }
  80. this.disabled = true;
  81. },
  82. async submit() {
  83. if (!this.$base.passwordRegular.test(this.pwd)) {
  84. return uni.showToast({
  85. title: '密码须6-15位数字与字母组合',
  86. icon: 'none'
  87. });
  88. }
  89. if (this.pwd != this.repwd) {
  90. return uni.showToast({
  91. title: '两次密码输入不一致',
  92. icon: "none"
  93. });
  94. }
  95. let res = await this.$http.post('/user/updatePartnerPwd?id=' + this.userInfo.sysUser.userId + '&password=' + this
  96. .pwd+'&oldPassword=' + this.oepwd);
  97. if (res.code == 200) {
  98. this.pwd = "";
  99. this.repwd = "";
  100. this.oepwd = "";
  101. uni.showToast({ title: res.msg, icon:"none",duration:2000 });
  102. setTimeout(() => {
  103. this.emptyUserInfo();
  104. uni.reLaunch({
  105. url:"/pages/login/login"
  106. })
  107. return true;
  108. }, 2000);
  109. }
  110. else{
  111. return uni.showToast({
  112. title: res.msg,
  113. icon: "none"
  114. });
  115. }
  116. }
  117. }
  118. }
  119. </script>
  120. <style>
  121. .body {
  122. position: absolute;
  123. width: 100%;
  124. height: 100vh;
  125. background-color: #F5F5F5;
  126. }
  127. .form {
  128. width: 100%;
  129. padding: 20upx 5%;
  130. font-size: 30upx;
  131. }
  132. .form .password {
  133. position: relative;
  134. width: 100%;
  135. height: 90upx;
  136. display: flex;
  137. align-items: center;
  138. border-radius: 5upx;
  139. background-color: #FFFFFF;
  140. padding: 0 0 0 100upx;
  141. margin: 30rpx 0rpx 50rpx;
  142. }
  143. .form .password input {
  144. width: 100%;
  145. height: 50rpx;
  146. color: rgba($color: #ffffff, $alpha: 0.8);
  147. font-weight: 200;
  148. }
  149. .icon {
  150. color: #999;
  151. height: 70upx;
  152. font-size: 40upx;
  153. z-index: 10;
  154. position: absolute;
  155. top: 10upx;
  156. left: 10upx;
  157. padding: 0 15upx;
  158. border-right: 2px solid #F5F5F5;
  159. }
  160. </style>