mmxg.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view>
  3. <!-- 注意,如果需要兼容微信小程序,最好通过setRules方法设置rules规则 -->
  4. <u--form labelPosition="left" :model="model" :rules="rules" ref="form1">
  5. <div style="display:none;">
  6. <u-form-item label="新密码" label-width="150" prop="userid">
  7. <u-input :password-icon="true" type="password" v-model="model.userid" placeholder="请输入密码"></u-input>
  8. </u-form-item>
  9. </div>
  10. <u-form-item label="新密码:" prop="password" borderBottom ref="item1" label-width="150">
  11. <u--input v-model="model.password" border="none" placeholder="请输入密码"></u--input>
  12. </u-form-item>
  13. <u-form-item label="重复密码:" prop="repassword" borderBottom ref="item1" label-width="150">
  14. <u--input v-model="model.repassword" border="none" placeholder="请输入密码"></u--input>
  15. </u-form-item>
  16. </u--form>
  17. <br>
  18. <u-button @click="submit">提交</u-button>
  19. </view>
  20. </template>
  21. <script>
  22. import {loginRes1} from '@/config/api.js';
  23. export default {
  24. data() {
  25. return {
  26. model: {
  27. userid:'',
  28. },
  29. rules: {
  30. 'password': [
  31. {
  32. required: true,
  33. message: '请输入密码',
  34. trigger: ['change','blur'],
  35. },
  36. {
  37. // 正则不能含有两边的引号
  38. pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]+\S{5,12}$/,
  39. message: '需同时含有字母和数字,长度在6-12之间',
  40. trigger: ['change','blur'],
  41. }
  42. ],
  43. 'repassword': [
  44. {
  45. required: true,
  46. message: '请重新输入密码',
  47. trigger: ['change','blur'],
  48. },
  49. {
  50. validator: (rule, value, callback) => {
  51. return value === this.model.password;
  52. },
  53. message: '两次输入的密码不相等',
  54. trigger: ['change','blur'],
  55. }
  56. ],
  57. },
  58. switchVal: false
  59. };
  60. },
  61. methods: {
  62. // 隐藏键盘
  63. hideKeyboard() {
  64. uni.hideKeyboard()
  65. },
  66. submit() {
  67. this.$refs.form1.validate().then(res => {
  68. console.log("提交表单信息:" + JSON.stringify(this.model.password))
  69. // uni.$u.toast('校验通过')
  70. // 调用服务端入表接口
  71. //处理登录用的参数
  72. const params={
  73. id:this.model.userid,
  74. password:this.model.password,
  75. }
  76. this.tjxg(params)
  77. // const res= await loginRes(params)
  78. // console.log(params)
  79. }).catch(errors => {
  80. // console.log("失败信息:" + JSON.stringify(errors))
  81. uni.$u.toast('校验失败')
  82. })
  83. },
  84. async tjxg(params){
  85. const res= await loginRes1(params)
  86. console.log(res)
  87. }
  88. },
  89. async onLoad() {
  90. if(!this.$u.utils.isLogin()) return
  91. },
  92. onReady() {
  93. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  94. this.$refs.form1.setRules(this.rules)
  95. }
  96. };
  97. </script>
  98. <style lang="scss">
  99. </style>