forgetpassword.vue 2.5 KB

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