change_pwd.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view class="change">
  3. <u-form label-width='150'>
  4. <u-form-item label="新密码">
  5. <u-input v-model="password" type="password"/>
  6. </u-form-item>
  7. <u-form-item label="确认密码">
  8. <u-input v-model="sure_password" type="password"/>
  9. </u-form-item>
  10. </u-form>
  11. <view class="submit" @click="submit">
  12. 确认修改
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. data() {
  19. return {
  20. password: '',
  21. sure_password: ''
  22. }
  23. },
  24. methods: {
  25. submit() {
  26. if (!this.password) {
  27. uni.showToast({
  28. title: '请输入新密码',
  29. icon: 'none'
  30. })
  31. return
  32. }
  33. if (!this.sure_password) {
  34. uni.showToast({
  35. title: '请输入确认密码',
  36. icon: 'none'
  37. })
  38. return
  39. }
  40. if (this.password != this.sure_password) {
  41. uni.showToast({
  42. title: '您两次输入的密码不一致',
  43. icon: 'none'
  44. })
  45. return
  46. }
  47. this.$u.post('/page/update-password', {
  48. password: this.password
  49. }).then(res => {
  50. this.$u.vuex('vuex_token', '');
  51. this.$u.vuex('vuex_user', '');
  52. console.log(res)
  53. uni.showToast({
  54. title: '修改成功,请重新登录',
  55. icon: 'none'
  56. })
  57. setTimeout(function() {
  58. uni.reLaunch({
  59. url: '../login/index'
  60. })
  61. }, 2000)
  62. })
  63. }
  64. }
  65. }
  66. </script>
  67. <style scoped lang="scss">
  68. .change {
  69. padding: 0 20px;
  70. .submit {
  71. height: 45px;
  72. width: 60%;
  73. line-height: 45px;
  74. margin: 0 auto;
  75. margin-top: 100px;
  76. background-color: #7d5c43;
  77. text-align: center;
  78. color: #fff;
  79. border-radius: 22px;
  80. font-size: 16px;
  81. }
  82. }
  83. </style>