updatpaw.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="updat" :style="'padding-top:'+padtop+'px'">
  3. <!-- 头部 -->
  4. <navbar :back="false" title="修改密码" :bgcolor="backgroundColor" color="#fff" fixed zIndex="1010" :center="true"
  5. :custom='true' @getTop="getTop" back="true" />
  6. <view>
  7. <view class="updatb">
  8. <view class="updatba">新密码</view>
  9. <input placeholder="请输入新密码" v-model="newpassword" class="updatbi" />
  10. </view>
  11. <view class="updatb">
  12. <view class="updatba">再次确认密码</view>
  13. <input placeholder="请再次输入新密码" v-model="password" class="updatbi" />
  14. </view>
  15. </view>
  16. <view class="login_btn btn1" @click="getSureFn">确认修改</view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. padtop: this.$http._GET.customBarH||0,
  24. backgroundColor: 'linear-gradient(90deg, #A00517, #E93030)',
  25. newpassword: '',
  26. password: '',
  27. }
  28. },
  29. onLoad(e) {
  30. this.userName=e.userName
  31. },
  32. methods: {
  33. getTop(e) {
  34. this.padtop = e
  35. },
  36. getSureFn() {
  37. if(!this.newpassword||!this.password){
  38. uni.showToast({
  39. title:"请输入完整",
  40. icon:'none'
  41. })
  42. return
  43. }
  44. if(this.newpassword.length<6){
  45. uni.showToast({
  46. title: '请输入至少六位数密码',
  47. icon: 'none'
  48. })
  49. return
  50. }
  51. if (this.newpassword != this.password) {
  52. uni.showToast({
  53. title: '两次密码输入不同,请修改',
  54. icon: 'none'
  55. })
  56. return
  57. }
  58. var userId = uni.getStorageSync('userId')
  59. var params={
  60. userId:userId,
  61. password:this.password,
  62. userName:this.userName
  63. }
  64. this.$http.post('system/user/updatePwd',params).then(res=>{
  65. if(res.code == 200 ) {
  66. uni.showToast({
  67. title:"修改成功,请重新登录",
  68. duration: 1000,
  69. icon: 'none'
  70. })
  71. setTimeout(function(){
  72. uni.removeStorageSync("userId")
  73. uni.removeStorageSync("token")
  74. uni.reLaunch({
  75. url:"/pages/login/login"
  76. })
  77. },1000)
  78. }else{
  79. uni.showToast({
  80. title: res.msg,
  81. duration: 1000,
  82. icon: 'none'
  83. });
  84. }
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style scoped>
  91. .updat {
  92. padding: 0 32rpx;
  93. min-height: 100vh;
  94. box-sizing: border-box;
  95. background: #ffffff;
  96. }
  97. .updatb {
  98. min-height: 100rpx;
  99. display: flex;
  100. align-items: center;
  101. padding: 18rpx 0;
  102. border-bottom: 2rpx solid #f5f5f5;
  103. box-sizing: border-box;
  104. }
  105. .updatba {
  106. font-size: 28rpx;
  107. font-weight: bold;
  108. color: #000000;
  109. flex: 0 0 auto;
  110. }
  111. .updatbi {
  112. flex: 1;
  113. text-align: right;
  114. font-size: 28rpx;
  115. color: #000;
  116. }
  117. .login_btn {
  118. width: 100%;
  119. height: 90rpx;
  120. display: flex;
  121. align-items: center;
  122. justify-content: center;
  123. font-size: 30rpx;
  124. border-radius: 48rpx;
  125. background: linear-gradient(90deg, #A00517, #E93030);
  126. color: #ffffff;
  127. margin-top: 120rpx;
  128. }
  129. </style>