forgetpassword.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <div class="content">
  3. <back :title="titlename"></back>
  4. <div class="login">
  5. <!-- <div class="item">
  6. <van-cell-group>
  7. <van-field v-model="name" placeholder="请输入用户名或邮箱" />
  8. </van-cell-group>
  9. </div> -->
  10. <div class="item">
  11. <van-cell-group>
  12. <van-field v-model="password" type="password" placeholder="请输入密码" />
  13. </van-cell-group>
  14. </div>
  15. <div class="item">
  16. <van-cell-group>
  17. <van-field v-model="password2" type="password" placeholder="请再次输入密码" />
  18. </van-cell-group>
  19. </div>
  20. <div class="btn">
  21. <van-button type="primary" @click="save()" color="#00c4b8">保存</van-button>
  22. </div>
  23. <!-- <div class="register">
  24. <router-link to="">新用户注册</router-link>
  25. <router-link to="">忘记密码</router-link>
  26. </div> -->
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { LJYforgetPassword } from '../api/index'
  32. import { Toast, Dialog } from 'vant'
  33. export default {
  34. data() {
  35. return {
  36. titlename: "修改密码",
  37. name: "",
  38. password: "",
  39. password2: "",
  40. yzm: "",
  41. userId: "",
  42. }
  43. },
  44. created: function () {
  45. this.userId = localStorage.getItem('userId');
  46. },
  47. methods: {
  48. async save() {
  49. if (this.password == '' || this.password == undefined) {
  50. Toast('请输入密码!');
  51. return;
  52. }
  53. if (this.password2 == '' || this.password2 == undefined) {
  54. Toast('请再次输入密码!');
  55. return;
  56. }
  57. if (this.password2 != this.password) {
  58. Toast('两次输入密码不相同!');
  59. return;
  60. }
  61. const res = await LJYforgetPassword({
  62. userId: this.userId,
  63. password: this.password
  64. })
  65. if (res.msg == 'success') {
  66. localStorage.removeItem("userId");
  67. this.$router.push({ path: '/' });
  68. } else {
  69. Toast('修改失败!');
  70. }
  71. }
  72. }
  73. }
  74. </script>
  75. <style scoped lang="less">
  76. .content {
  77. .loginimg {
  78. width: 3.48rem;
  79. margin: 0 auto;
  80. display: block;
  81. padding: 2.15rem .8rem;
  82. }
  83. .login {
  84. width: 5.8rem;
  85. margin: 0.3rem auto 0px;
  86. .item {
  87. border: .01rem solid #bfbfbf;
  88. border-radius: .1rem;
  89. margin-bottom: .3rem;
  90. background: white;
  91. overflow: hidden;
  92. color: #999999;
  93. }
  94. .item:nth-of-type(3) {
  95. margin-bottom: .2rem;
  96. }
  97. .btn {
  98. button {
  99. width: 100%;
  100. }
  101. }
  102. .register {
  103. font-size: .24rem;
  104. display: flex;
  105. justify-content: space-between;
  106. margin-top: .2rem;
  107. a {
  108. color: #999999;
  109. }
  110. a:nth-of-type(1) {
  111. color: #02bfb3;
  112. }
  113. }
  114. }
  115. }
  116. </style>