editPwd.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view>
  3. <view class="content">
  4. <view class="info-item">
  5. <view class="label">旧密码</view>
  6. <view class="right">
  7. <input type="safe-password" v-model="oldPassword" placeholder="请输入旧密码" class="input"></text>
  8. </view>
  9. </view>
  10. <view class="info-item">
  11. <view class="label">新密码</view>
  12. <view class="right">
  13. <input type="safe-password" v-model="password" placeholder="请输入新密码" class="input"></text>
  14. </view>
  15. </view>
  16. <view class="info-item">
  17. <view class="label">确认密码</view>
  18. <view class="right">
  19. <input type="safe-password" v-model="password1" placeholder="请输入确认密码" class="input"></text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="btn-box">
  24. <view class="sub-btn" @click="submit()">保存修改</view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {setPwd,setHeadImg,setUserInfo,getUserInfo} from '@/api/user.js';
  30. export default {
  31. data() {
  32. return {
  33. oldPassword:"",
  34. password:"",
  35. password1:"",
  36. }
  37. },
  38. onLoad() {
  39. },
  40. methods: {
  41. submit(){
  42. if (this.utils.isEmpty(this.oldPassword)) {
  43. uni.showToast({
  44. title: "请输入旧密码",
  45. icon: 'none',
  46. });
  47. return
  48. }
  49. if (this.utils.isEmpty(this.password)) {
  50. uni.showToast({
  51. title: "请输入新密码",
  52. icon: 'none',
  53. });
  54. return
  55. }
  56. if (this.password!=this.password1) {
  57. uni.showToast({
  58. title: "两次密码输入不正确",
  59. icon: 'none',
  60. });
  61. return
  62. }
  63. console.log(this.password);
  64. var patrn=/^(\w){6,20}$/;
  65. if (!patrn.exec(this.password)) {
  66. uni.showToast({
  67. title: "密码只能输入6-20个字母、数字、下划线",
  68. icon: 'none',
  69. });
  70. return
  71. }
  72. var data = {oldPassword:this.oldPassword,password:this.password};
  73. setPwd(data).then(
  74. res => {
  75. if(res.code==200){
  76. uni.showToast({
  77. title: '密码修改成功',
  78. duration: 2000
  79. });
  80. setTimeout(function() {
  81. uni.navigateBack({
  82. success: () => {
  83. }
  84. })
  85. }, 500);
  86. }
  87. else{
  88. uni.showToast({
  89. title: res.msg,
  90. icon: 'none',
  91. });
  92. }
  93. },
  94. rej => {}
  95. );
  96. }
  97. }
  98. }
  99. </script>
  100. <style scoped lang="scss">
  101. .content{
  102. padding-top: 20rpx;
  103. border-top: 1px solid #F5F6FA;
  104. }
  105. .info-item{
  106. height: 104upx;
  107. background: #FFFFFF;
  108. padding: 0 30upx;
  109. display: flex;
  110. align-items: center;
  111. justify-content: flex-start;
  112. border-bottom: 1px solid #F5F6FA;
  113. &:last-child{
  114. border-bottom: none;
  115. }
  116. .label{
  117. width: 150rpx;
  118. font-size: 30upx;
  119. font-family: PingFang SC;
  120. font-weight: 400;
  121. color: #0F1826;
  122. }
  123. .right{
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. .text{
  128. font-size: 30upx;
  129. font-family: PingFang SC;
  130. font-weight: 400;
  131. color: #0F1826;
  132. }
  133. .image{
  134. margin-left: 10upx;
  135. width: 30upx;
  136. height: 30upx;
  137. }
  138. .input{
  139. text-align: left;
  140. font-size: 30upx;
  141. font-family: PingFang SC;
  142. font-weight: 400;
  143. color: #0F1826;
  144. }
  145. }
  146. }
  147. .btn-box{
  148. margin-top: 15rpx;
  149. height: 120upx;
  150. padding: 0 30upx;
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. .sub-btn{
  155. width: 100%;
  156. height: 88upx;
  157. line-height: 88upx;
  158. text-align: center;
  159. font-size: 30upx;
  160. font-family: PingFang SC;
  161. font-weight: bold;
  162. color: #FFFFFF;
  163. background: #4BC9B1;
  164. border-radius: 44upx;
  165. }
  166. }
  167. </style>