password.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div class="app-content">
  3. <form @submit="formSubmit">
  4. <div class="module-com">
  5. <tui-list-cell class="line-cell" :hover="false">
  6. <div class="tui-title">旧密码</div>
  7. <input v-model="form.old" placeholder-class="phcolor" class="tui-input" name="old" placeholder="首次设置不需要填写" maxlength="50" type="password" />
  8. </tui-list-cell>
  9. <tui-list-cell class="line-cell" :hover="false">
  10. <div class="tui-title">密码</div>
  11. <input v-model="form.new" placeholder-class="phcolor" class="tui-input" name="new" placeholder="请输入密码" maxlength="50" type="password" />
  12. </tui-list-cell>
  13. <tui-list-cell class="line-cell" :hover="false">
  14. <div class="tui-title">确认密码</div>
  15. <input v-model="form.confirm" placeholder-class="phcolor" class="tui-input" name="confirm" placeholder="请输入确认密码" maxlength="50" type="password" />
  16. </tui-list-cell>
  17. <div class="prompt-text">提示:余额支付时需要用到支付密码</div>
  18. <div class="btn-wrap">
  19. <button class="button-com red big" formType="submit">确认</button>
  20. </div>
  21. </div>
  22. </form>
  23. </div>
  24. </template>
  25. <script>
  26. import TuiListCell from '@/components/plugin/list-cell'
  27. const form = require('@/utils/formValidation.js')
  28. // api
  29. import { modifyPassword } from '@/api/member'
  30. export default {
  31. name: 'password',
  32. components: {
  33. TuiListCell
  34. },
  35. data() {
  36. return {
  37. form: {
  38. old: '',
  39. new: '',
  40. confirm: ''
  41. }
  42. }
  43. },
  44. methods: {
  45. // 确认
  46. confirmFn() {
  47. modifyPassword(this.form).then(res => {
  48. this.$msg('修改成功!')
  49. setTimeout(() => {
  50. uni.switchTab({
  51. url: '/pages/home/user'
  52. })
  53. }, 1000)
  54. })
  55. },
  56. // 表单验证
  57. formSubmit(e) {
  58. // 表单规则
  59. let rules = [
  60. {
  61. name: 'old',
  62. rule: ['required'],
  63. msg: ['请输入旧密码']
  64. },
  65. {
  66. name: 'new',
  67. rule: ['required'],
  68. msg: ['请输入新密码']
  69. },
  70. {
  71. name: 'confirm',
  72. rule: ['required'],
  73. msg: ['请输入确认密码']
  74. }
  75. ]
  76. // 进行表单检查
  77. let formData = e.detail.value
  78. let checkRes = form.validation(formData, rules)
  79. // 验证通过!
  80. if (!checkRes) {
  81. this.confirmFn()
  82. } else {
  83. this.$msg(checkRes)
  84. }
  85. }
  86. }
  87. }
  88. </script>
  89. <style lang="scss" scoped>
  90. // 公共
  91. .line-cell {
  92. .tui-title {
  93. width: 210px;
  94. color: $fontColor2;
  95. }
  96. .tui-input {
  97. width: calc(100% - 210px);
  98. font-size: 28px;
  99. }
  100. .tui-placeholder {
  101. color: #ccc;
  102. }
  103. .phcolor {
  104. color: #ccc;
  105. }
  106. }
  107. .prompt-text {
  108. color: $fontColor3;
  109. margin-top: 20px;
  110. margin-left: 30px;
  111. }
  112. .btn-wrap {
  113. width: 90%;
  114. margin: 60px auto;
  115. .button-com {
  116. width: 100%;
  117. margin: 0 auto;
  118. }
  119. }
  120. </style>