password.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="box">
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">修改登录密码</block>
  5. <block slot="content"></block>
  6. <block slot="right">
  7. <view class=" flex justify-center">
  8. <!-- <button class="margin-top-ssm cu-btn round bg-blue text-blue"><text class="cuIcon-add"></text></button> -->
  9. </view>
  10. </block>
  11. </cu-custom>
  12. <view class="cu-list menu shadow-lg">
  13. <form>
  14. <!-- <view class="cu-form-group">
  15. <view class="title">登录账号</view>
  16. <input :value="account" name="input" disabled=""></input>
  17. </view> -->
  18. <view class="cu-form-group_1">
  19. <view class="title">原密码</view>
  20. <input placeholder="请输入原密码" placeholder-style="color:#AEAEAE;font-size:30rpx" password="true" v-model="oldPassword" name="input"></input>
  21. </view>
  22. <view class="cu-form-group_1 cu-form-group_2">
  23. <view class="title">新密码</view>
  24. <input placeholder="请输入新密码" placeholder-style="color:#AEAEAE;font-size:30rpx" @input="newPasswordConfig" password="true" v-model="newPassword" name="input"></input>
  25. </view>
  26. <view class="cu-form-group_1">
  27. <view class="title">确认密码</view>
  28. <input placeholder="请再输入一次新密码" placeholder-style="color:#AEAEAE;font-size:30rpx" @input="confirmPassword" v-model="confirmNewPwd" password="true" name="input"></input>
  29. <image v-if="reslut" src="/static/index/unfill-blue.png" class="menuImageTask"></image>
  30. </view>
  31. </form>
  32. </view>
  33. <view style="padding-top: 62rpx;text-align: center;">
  34. <button @click="submit" style="width: 560rpx;height: 88rpx;font-size: 32rpx;" class="cu-btn bg-blue lg round" >提交</button>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. export default {
  40. data() {
  41. return {
  42. account:"",
  43. oldPassword:"",
  44. newPassword:"",
  45. confirmNewPwd:"",
  46. reslut:false,
  47. userInfo:"",
  48. }
  49. },
  50. onLoad() {
  51. var userInfo = uni.getStorageSync("userInfo")
  52. if(userInfo!=null){
  53. this.account = userInfo.account;
  54. this.userInfo =userInfo;
  55. }
  56. },
  57. methods: {
  58. confirmPassword(e){
  59. if(e.detail.value){
  60. if(e.detail.value==this.newPassword){
  61. this.reslut=true;
  62. }else{
  63. this.reslut=false;
  64. }
  65. }
  66. },
  67. newPasswordConfig(e){
  68. if(e.detail.value){
  69. if(e.detail.value==this.confirmNewPwd){
  70. this.reslut=true;
  71. }else{
  72. this.reslut=false;
  73. }
  74. }
  75. },
  76. submit(){
  77. var that =this;
  78. if(that.oldPassword.trim()==""){
  79. that.$prompt.none("请输入原密码");return;
  80. }
  81. if(that.newPassword.length<6 || that.newPassword.length>20){
  82. that.$prompt.none("请设置6-20位的新密码!");return;
  83. return;
  84. }else{
  85. if(that.reslut!=true){
  86. that.$prompt.none("两次输入的密码不一致");return;
  87. }
  88. }
  89. that.http.request('/app/updatePassword', {
  90. userId:that.userInfo.id,
  91. oldPassword:that.oldPassword,
  92. newPwd:that.newPassword,
  93. confirmNewPwd:that.confirmNewPwd,}).then((result)=>{
  94. if(result.result=="1"){
  95. that.$prompt.none("修改成功,请重新登录")
  96. /* 清除缓存 */
  97. uni.removeStorageSync('porject');
  98. uni.removeStorageSync('userInfo');
  99. setTimeout(() => {
  100. uni.reLaunch({
  101. url:"/pages/user/login/login"
  102. })
  103. }, 500);
  104. }else{
  105. that.$prompt.none("原密码错误!")
  106. }
  107. })
  108. }
  109. },
  110. }
  111. </script>
  112. <style>
  113. .menuImageTask{
  114. height: 40rpx;
  115. width: 40rpx;
  116. }
  117. .cu-form-group_1 {
  118. display: flex;
  119. align-items: center;
  120. padding: 0 24rpx;
  121. height: 88rpx;
  122. background-color: #fff;
  123. }
  124. .cu-form-group_2{margin-top: 20rpx;border-bottom: 2rpx solid #E3E1E1;}
  125. .cu-form-group_1 .title {
  126. width: 148rpx;
  127. font-size: 30rpx;
  128. color: #101010;
  129. }
  130. .cu-form-group_1 input {
  131. width: 554rpx;
  132. color: #8a8a8a;
  133. font-size: 30rpx;
  134. }
  135. </style>