userInfo.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="content userInfo">
  3. <u--form labelPosition="left" :model="form" :rules="rules" ref="userForm">
  4. <u-form-item label="司机姓名" prop="driverName" label-width="80" borderBottom required>
  5. <u--input v-model="form.driverName" border="none"></u--input>
  6. </u-form-item>
  7. <u-form-item label="证件号码" prop="identificationNumber" label-width="80" borderBottom required>
  8. <u--input v-model="form.identificationNumber" border="none"></u--input>
  9. </u-form-item>
  10. <u-form-item label="手机号码" prop="mobileNumber" label-width="80" borderBottom required>
  11. <u--input v-model="form.mobileNumber" border="none"></u--input>
  12. </u-form-item>
  13. <u-form-item label="车辆类型" prop="vehicleType" label-width="80" borderBottom required
  14. @click="selectShow = true; hideKeyboard()">
  15. <u--input :value="form.vehicleName" placeholder="请选择车辆类型" border="none"></u--input>
  16. <u-icon slot="right" name="arrow-right"></u-icon>
  17. </u-form-item>
  18. <u-form-item label="车牌号" prop="licensePlateNumber" label-width="80" borderBottom required>
  19. <u--input v-model="form.licensePlateNumber" border="none"></u--input>
  20. </u-form-item>
  21. <u-form-item label="司机联系地址" prop="driverAddress" label-width="100" borderBottom>
  22. <u--input v-model="form.driverAddress" border="none"></u--input>
  23. </u-form-item>
  24. </u--form>
  25. <u-gap height="1" bgColor="#fff"></u-gap>
  26. <view>
  27. <u-checkbox-group>
  28. <u-checkbox :value="agreement" @change="agreementChange"></u-checkbox>
  29. 本人承诺以上所填写情况属实,本人愿承担相关法律责任
  30. </u-checkbox-group>
  31. </view>
  32. <u-action-sheet :actions="vehicleTypeList" :closeOnClickOverlay="true" :closeOnClickAction="true" title="选择车辆类型"
  33. :show="selectShow" @select="onVehicleSelect" @close="selectShow = false">
  34. </u-action-sheet>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. simpleRequired, mobileRule, idRule, carNoRule,
  40. mkRules
  41. } from '@/utils/rules.js'
  42. import {
  43. getVehicleTypes,
  44. } from '@/api/basic'
  45. export default {
  46. data() {
  47. return {
  48. vehicleTypeList: [],
  49. agreement: false,
  50. selectShow: false,
  51. form: {
  52. driverName: null,
  53. identificationNumber: null,
  54. mobileNumber: null,
  55. vehicleType: null,
  56. vehicleName: null,
  57. licensePlateNumber: null,
  58. driverAddress: null,
  59. },
  60. rules: {
  61. 'driverName': simpleRequired(),
  62. 'identificationNumber': [simpleRequired(), idRule],
  63. 'mobileNumber': [simpleRequired(), mobileRule],
  64. 'vehicleType': simpleRequired(),
  65. 'licensePlateNumber': [simpleRequired(), carNoRule]
  66. }
  67. }
  68. },
  69. onReady() {
  70. this.$refs.userForm.setRules(
  71. this.rules
  72. )
  73. },
  74. mounted() {
  75. getVehicleTypes().then(resp => {
  76. const list = resp.data || []
  77. list.forEach(d => {
  78. d.name = d.dictLabel
  79. })
  80. this.vehicleTypeList = list
  81. })
  82. },
  83. methods: {
  84. agreementChange(n) {
  85. this.agreement = n
  86. },
  87. onVehicleSelect(n) {
  88. this.form.vehicleType = n.id
  89. this.form.vehicleName = n.name
  90. },
  91. hideKeyboard() {
  92. uni.hideKeyboard()
  93. },
  94. getUserInfo() {
  95. return new Promise((resolve, reject) => {
  96. this.$refs.userForm.validate().then(res => {
  97. if (!this.agreement) {
  98. reject('请勾选用户协议')
  99. } else {
  100. resolve({
  101. ...this.form
  102. })
  103. }
  104. }).catch(err => {
  105. console.log('err', err);
  106. reject('请填写必输项')
  107. })
  108. })
  109. }
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .userInfo {
  115. margin-left: 15px;
  116. margin-right: 15px;
  117. }
  118. </style>