passwordForm.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="content">
  3. <u-navbar back-text="返回" title="修改密码" back-icon-color="#ffffff" :back-text-style="{color: '#ffffff'}" title-color="#ffffff"
  4. :background="{backgroundColor: mainColor}"></u-navbar>
  5. <u-form :model="form" ref="form" label-width="140">
  6. <u-form-item label="账号" prop="userAccount" required>
  7. <u-input v-model="form.userAccount" placeholder="请输入账号" type="text" />
  8. </u-form-item>
  9. <u-form-item label="旧密码" prop="pwd" required>
  10. <u-input v-model="form.pwd" placeholder="请输入旧密码" type="text" />
  11. </u-form-item>
  12. <u-form-item label="新密码" prop="newPwd" required>
  13. <u-input v-model="form.newPwd" placeholder="请输入新密码" type="text" />
  14. </u-form-item>
  15. </u-form>
  16. <view class="handle-fix-box">
  17. <u-button type="primary" :ripple="true" :custom-style="customStyle" @click="submitForm()">提交</u-button>
  18. </view>
  19. <u-top-tips ref="uTips" :navbar-height="statusBarHeight + navbarHeight"></u-top-tips>
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. mapGetters
  25. } from 'vuex'
  26. const NET = require('@/utils/request')
  27. const API = require('@/config/api')
  28. export default {
  29. computed: {
  30. ...mapGetters([
  31. 'mainColor',
  32. 'customStyle',
  33. ])
  34. },
  35. data() {
  36. return {
  37. statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
  38. navbarHeight: 44,
  39. form: {
  40. userAccount: '',
  41. pwd: '',
  42. newPwd: '',
  43. },
  44. rules: {
  45. userAccount: [{
  46. required: true,
  47. message: '请输入账号',
  48. trigger: 'change'
  49. }],
  50. pwd: [{
  51. required: true,
  52. message: '请输入旧密码',
  53. trigger: 'change'
  54. }],
  55. newPwd: [{
  56. required: true,
  57. message: '请输入新密码',
  58. trigger: 'change'
  59. }],
  60. },
  61. }
  62. },
  63. onLoad(options) {},
  64. onReady() {
  65. this.$refs.form.setRules(this.rules);
  66. },
  67. methods: {
  68. // 提交表单
  69. submitForm() {
  70. this.$refs.form.validate(valid => {
  71. if (valid) {
  72. NET.request(API.submitPasswordForm, {
  73. ...this.form
  74. }, 'POST').then(res => {
  75. this.$refs.uTips.show({
  76. title: '修改成功',
  77. type: 'success',
  78. })
  79. setTimeout(() => {
  80. uni.navigateBack()
  81. }, 1000)
  82. }).catch(error => {
  83. this.$refs.uTips.show({
  84. title: error.message,
  85. type: 'warning',
  86. })
  87. })
  88. }
  89. });
  90. },
  91. },
  92. }
  93. </script>
  94. <style>
  95. page {
  96. width: 100%;
  97. height: 100%;
  98. position: relative;
  99. }
  100. </style>
  101. <style lang="scss" scoped>
  102. @import "@/static/css/themes.scss";
  103. .content {
  104. width: 100%;
  105. float: left;
  106. padding: 0 15px 60px 15px;
  107. box-sizing: border-box;
  108. }
  109. </style>