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.isLogin();
  46. this.userId = localStorage.getItem('userId');
  47. },
  48. methods: {
  49. async save() {
  50. if (this.password == '' || this.password == undefined) {
  51. Toast('请输入密码!');
  52. return;
  53. }
  54. if (this.password2 == '' || this.password2 == undefined) {
  55. Toast('请再次输入密码!');
  56. return;
  57. }
  58. if (this.password2 != this.password) {
  59. Toast('两次输入密码不相同!');
  60. return;
  61. }
  62. const res = await LJYforgetPassword({
  63. userId: this.userId,
  64. password: this.password
  65. })
  66. if (res.msg == 'success') {
  67. localStorage.removeItem("userId");
  68. this.$router.push({ path: '/' });
  69. } else {
  70. Toast('修改失败!');
  71. }
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped lang="less">
  77. .content {
  78. .loginimg {
  79. width: 3.48rem;
  80. margin: 0 auto;
  81. display: block;
  82. padding: 2.15rem .8rem;
  83. }
  84. .login {
  85. width: 5.8rem;
  86. margin: 0.3rem auto 0px;
  87. .item {
  88. border: .01rem solid #bfbfbf;
  89. border-radius: .1rem;
  90. margin-bottom: .3rem;
  91. background: white;
  92. overflow: hidden;
  93. color: #999999;
  94. }
  95. .item:nth-of-type(3) {
  96. margin-bottom: .2rem;
  97. }
  98. .btn {
  99. button {
  100. width: 100%;
  101. }
  102. }
  103. .register {
  104. font-size: .24rem;
  105. display: flex;
  106. justify-content: space-between;
  107. margin-top: .2rem;
  108. a {
  109. color: #999999;
  110. }
  111. a:nth-of-type(1) {
  112. color: #02bfb3;
  113. }
  114. }
  115. }
  116. }
  117. </style>