form.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. {extend name="public/base"/}
  2. {block name="css"}
  3. {/block}
  4. {block name="body"}
  5. <van-nav-bar
  6. class="nav-theme"
  7. :fixed="true"
  8. :placeholder="true"
  9. left-text="返回"
  10. left-arrow
  11. @click-left="onBack"
  12. >
  13. <template #title>
  14. <span class="text-white">信息登记</span>
  15. </template>
  16. </van-nav-bar>
  17. <van-form @submit="onSubmit">
  18. <h2 class="lw-title">基础信息</h2>
  19. <van-cell-group inset>
  20. <!--专业类型-->
  21. <van-field
  22. v-model="type_text"
  23. is-link
  24. readonly
  25. required
  26. label="专业类型"
  27. placeholder="选择专业类型"
  28. @click="show_type = true"
  29. ></van-field>
  30. <van-popup v-model:show="show_type" round position="bottom">
  31. <van-picker
  32. :columns="type_list"
  33. @cancel="show_type = false"
  34. @confirm="onTypeConfirm"
  35. ></van-picker>
  36. </van-popup>
  37. <van-field
  38. required
  39. v-model="form.name"
  40. label="姓名"
  41. placeholder="请填写姓名"
  42. :rules="[{ required: true, message: '请填写姓名' }]"
  43. ></van-field>
  44. <van-field required label="性别">
  45. <template #input>
  46. <van-radio-group v-model="form.sex" direction="horizontal">
  47. <van-radio name="1">男</van-radio>
  48. <van-radio name="2">女</van-radio>
  49. </van-radio-group>
  50. </template>
  51. </van-field>
  52. <van-field
  53. required
  54. v-model="form.mobile"
  55. label="手机号"
  56. placeholder="请填写手机号"
  57. :rules="[
  58. { required: true, message: '请填写电话' },
  59. { validator, message: '请输入正确的手机号'}
  60. ]"
  61. ></van-field>
  62. </van-cell-group>
  63. <h2 class="lw-title">学校信息</h2>
  64. <van-cell-group inset>
  65. <van-field
  66. required
  67. v-model="form.school"
  68. label="毕业学校"
  69. placeholder="请填写毕业学校"
  70. :rules="[{ required: true, message: '请填写毕业学校' }]"
  71. ></van-field>
  72. <van-field
  73. required
  74. v-model="form.major"
  75. label="专业"
  76. placeholder="请填写专业"
  77. :rules="[{ required: true, message: '请填写专业' }]"
  78. ></van-field>
  79. <van-field
  80. required
  81. v-model="form.company"
  82. label="意向单位"
  83. placeholder="请填写意向单位"
  84. :rules="[{ required: true, message: '请填写意向单位' }]"
  85. ></van-field>
  86. <van-field
  87. required
  88. v-model="form.introduction"
  89. rows="3"
  90. autosize
  91. label="个人简介"
  92. type="textarea"
  93. placeholder="请填写个人简介"
  94. :rules="[{ required: true, message: '请填写个人简介' }]"
  95. ></van-field>
  96. <van-field
  97. v-model="form.awards"
  98. rows="3"
  99. autosize
  100. label="获得的奖项"
  101. type="textarea"
  102. placeholder="请填写获得的奖项"
  103. ></van-field>
  104. </van-cell-group>
  105. <div style="margin: 16px;">
  106. <van-button round block type="primary" native-type="submit">
  107. 提交
  108. </van-button>
  109. </div>
  110. </van-form>
  111. {/block}
  112. {block name="script"}
  113. <script>
  114. function v_setup() {
  115. let base = {};
  116. base.form = Vue.reactive({$info});
  117. base.onBack = () => {
  118. history.back();
  119. };
  120. // 专业类型
  121. base.type_list = {$type_list};
  122. base.type_text = Vue.ref('{$type_text}');
  123. base.show_type = Vue.ref(false);
  124. base.toggleType = (val) => {
  125. base.showType.value = val;
  126. };
  127. base.onTypeConfirm = (op) => {
  128. base.form.type = op.selectedValues[0];
  129. base.type_text.value = op.selectedOptions[0].text;
  130. base.show_type.value = false;
  131. };
  132. //手机号验证
  133. base.validator = (val) => {
  134. return /^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/.test(val);
  135. };
  136. //表单提交
  137. base.onSubmit = (form) => {
  138. if (base.form.type === '') {
  139. vant.showToast('请选择类型');
  140. return false;
  141. }
  142. postJson("{:url('info/formPost')}",base.form).then(({data}) => {
  143. location.href = "{:url('info/index')}";
  144. });
  145. };
  146. return base;
  147. }
  148. </script>
  149. {/block}