password.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <view class="app-page pa-24 bg-white">
  3. <view class="app-page-content round-12 bg-white pa-46 pl-0 pr-0">
  4. <view v-if="false" class="mb-24 text-align-center text-weight-b text-size-g text-grey-darken-3">修改登录密码</view>
  5. <tm-form @submit="fnSubmit">
  6. <tm-sheet :shadow="0" :margin="[0, 0]" :padding="[0, 0]">
  7. <tm-input
  8. :password="true"
  9. name="oldPassword"
  10. input-type="password"
  11. required
  12. title="旧密码"
  13. placeholder="请输入旧密码"
  14. bg-color="grey-lighten-5"
  15. :border-bottom="false"
  16. :vertical="true"
  17. v-model="form.oldPassword"
  18. :verify="verifyOldPassword"
  19. ></tm-input>
  20. <tm-input
  21. :password="true"
  22. name="newPassword"
  23. input-type="password"
  24. required
  25. title="新密码"
  26. placeholder="请输入新密码"
  27. bg-color="grey-lighten-5"
  28. :border-bottom="false"
  29. :vertical="true"
  30. v-model="form.newPassword"
  31. :verify="verifyNewPassword"
  32. ></tm-input>
  33. <tm-input
  34. :password="true"
  35. name="confirmPassword"
  36. input-type="password"
  37. required
  38. title="确认密码"
  39. placeholder="请再次确认新密码"
  40. bg-color="grey-lighten-5"
  41. :border-bottom="false"
  42. :vertical="true"
  43. v-model="form.confirmPassword"
  44. :verify="verifyConfirmPassword"
  45. ></tm-input>
  46. <view class="pa-30"><tm-button navtie-type="form" theme="bg-gradient-blue-accent" block>确认修改</tm-button></view>
  47. </tm-sheet>
  48. </tm-form>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import tmForm from '@/tm-vuetify/components/tm-form/tm-form.vue';
  54. import tmSheet from '@/tm-vuetify/components/tm-sheet/tm-sheet.vue';
  55. import tmButton from '@/tm-vuetify/components/tm-button/tm-button.vue';
  56. import tmInput from '@/tm-vuetify/components/tm-input/tm-input.vue';
  57. import tmCountdown from '@/tm-vuetify/components/tm-countdown/tm-countdown.vue';
  58. export default {
  59. components: {
  60. tmForm,
  61. tmSheet,
  62. tmButton,
  63. tmInput,
  64. tmCountdown
  65. },
  66. data() {
  67. return {
  68. loading: 'loading',
  69. form: {
  70. oldPassword: undefined,
  71. newPassword: undefined,
  72. confirmPassword: undefined
  73. },
  74. verifyOldPassword: () => {
  75. return val => {
  76. return {
  77. check: val != '',
  78. text: '请输入旧密码!'
  79. };
  80. };
  81. },
  82. verifyNewPassword: () => {
  83. return val => {
  84. return {
  85. check: val != '',
  86. text: '请输入新密码!'
  87. };
  88. };
  89. },
  90. verifyConfirmPassword: () => {
  91. return val => {
  92. return {
  93. check: this.form.newPassword == this.form.confirmPassword,
  94. text: '两次新密码不一致!'
  95. };
  96. };
  97. }
  98. };
  99. },
  100. onLoad() {
  101. this.fnSetPageTitle('修改密码');
  102. },
  103. methods: {
  104. fnSubmit(e) {
  105. if (e === false) return uni.$tm.toast('请填写必填项。');
  106. uni.showLoading({
  107. title: '保存中...'
  108. });
  109. this.$httpApi.admin
  110. .modifyAdminPassword(this.form)
  111. .then(res => {
  112. if (res.status == 200) {
  113. uni.$tm.toast('密码修改成功!');
  114. this.form = {
  115. oldPassword: undefined,
  116. newPassword: undefined,
  117. confirmPassword: undefined
  118. };
  119. } else {
  120. uni.$tm.toast('密码修改失败:' + res.message);
  121. }
  122. })
  123. .catch(err => {
  124. uni.$tm.toast('密码修改失败:' + err.message);
  125. });
  126. }
  127. }
  128. };
  129. </script>
  130. <style lang="scss" scoped>
  131. .app-page {
  132. width: 100vw;
  133. min-height: 100vh;
  134. box-sizing: border-box;
  135. }
  136. .app-page-content {
  137. width: 100%;
  138. box-sizing: border-box;
  139. // box-shadow: 0rpx 6rpx 24rpx rgba(0, 0, 0, 0.03);
  140. }
  141. </style>