index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="register-bg">
  3. <view class="bg-container">
  4. 参会报名
  5. </view>
  6. <auth-wrap class="register-container" ref="authWrap">
  7. <view class="form-content" slot="content">
  8. <u--form
  9. labelPosition="left"
  10. :model="model1"
  11. :rules="rules"
  12. ref="uForm"
  13. >
  14. <u-form-item
  15. prop="userInfo.name"
  16. borderBottom
  17. ref="item1"
  18. >
  19. <u--input
  20. prefixIcon="account"
  21. v-model="model1.userInfo.name"
  22. border="none"
  23. ></u--input>
  24. </u-form-item>
  25. <u-form-item
  26. prop="userInfo.tel"
  27. borderBottom
  28. ref="item1"
  29. >
  30. <u--input
  31. prefixIcon="phone"
  32. placeholder="输入手机号"
  33. border="none"
  34. v-model="model1.userInfo.tel"
  35. ></u--input>
  36. </u-form-item>
  37. <u-form-item
  38. label="性别"
  39. prop="userInfo.sex"
  40. borderBottom
  41. >
  42. <u-radio-group
  43. v-model="model1.userInfo.sex"
  44. placement="row"
  45. >
  46. <u-radio
  47. :style="{
  48. marginRight: '20rpx'
  49. }"
  50. v-for="(item, index) in sexList"
  51. :key="index"
  52. :label="item.name"
  53. :name="item.value"
  54. >
  55. </u-radio>
  56. </u-radio-group>
  57. </u-form-item>
  58. <u-form-item
  59. label="参会企业"
  60. prop="userInfo.enterpriseId"
  61. borderBottom
  62. ref="item1"
  63. >
  64. <SingleDropList
  65. :style="{
  66. marginLeft: '20rpx'
  67. }"
  68. defaultValue="1"
  69. :src="sexList"
  70. placeholder="请选择参会企业"
  71. :on-change="enterpriseSelect"
  72. >
  73. </SingleDropList>
  74. </u-form-item>
  75. <u-form-item
  76. label="参会行程"
  77. prop="userInfo.tripId"
  78. borderBottom
  79. ref="item1"
  80. >
  81. <SingleDropList
  82. :style="{
  83. marginLeft: '20rpx'
  84. }"
  85. defaultValue="1"
  86. :src="sexList"
  87. placeholder="请选择参会行程"
  88. :on-change="enterpriseSelect"
  89. >
  90. </SingleDropList>
  91. </u-form-item>
  92. </u--form>
  93. <u-button
  94. :style="{
  95. marginTop: '120rpx'
  96. }"
  97. type="primary"
  98. text="提交"
  99. :disabled="loading"
  100. :loading="loading"
  101. loadingText="正在提交..."
  102. @click="onSubmit"
  103. >
  104. </u-button>
  105. </view>
  106. </auth-wrap>
  107. </view>
  108. </template>
  109. <script>
  110. import { putUsrRegist } from '@/common/api';
  111. import { ICON_CFG } from '@/common/EnumConst';
  112. import AuthWrap from '@/components/AuthComp/index.vue';
  113. import SingleDropList from '@/components/SingleDropList/index.vue';
  114. import { getImageUrl, getUserInfo } from '@/util';
  115. export default {
  116. name: 'login',
  117. components: {
  118. AuthWrap,
  119. SingleDropList
  120. },
  121. props: {},
  122. data() {
  123. return {
  124. ICON_CFG,
  125. showEnterprise: false,
  126. loading: false,
  127. model1: {
  128. userInfo: {
  129. name: '',
  130. sex: '',
  131. },
  132. },
  133. sexList: [
  134. {
  135. value: '0',
  136. name: '男',
  137. },
  138. {
  139. value: '1',
  140. name: '女',
  141. },
  142. {
  143. value: '2',
  144. name: '保密',
  145. },
  146. ],
  147. rules: {
  148. 'userInfo.name': {
  149. type: 'string',
  150. required: true,
  151. message: '请填写姓名',
  152. trigger: ['blur', 'change'],
  153. },
  154. 'userInfo.tel': {
  155. type: 'string',
  156. max: 11,
  157. required: true,
  158. message: '请填写11位手机号',
  159. trigger: ['blur', 'change'],
  160. },
  161. },
  162. };
  163. },
  164. created() {
  165. },
  166. onLoad() {
  167. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  168. this.$refs.uForm.setRules(this.rules);
  169. this.$refs.authWrap.reloadPage();
  170. const user = getUserInfo();
  171. if (user) {
  172. this.model1.userInfo.name = user.usrName;
  173. }
  174. },
  175. onReady() {
  176. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  177. this.$refs.uForm.setRules(this.rules);
  178. },
  179. methods: {
  180. getImageUrl,
  181. enterpriseSelect(enterprise) {
  182. this.model1.userInfo.enterpriseId = enterprise.value;
  183. this.model1.userInfo.enterpriseName = enterprise.name;
  184. this.$refs.uForm.validateField('userInfo.enterpriseId');
  185. },
  186. onSubmit() {
  187. this.loading = true;
  188. this.$refs.uForm.validate().then(res => {
  189. putUsrRegist(this.model1.userInfo);
  190. this.loading = false;
  191. }).catch(errors => {
  192. uni.$u.toast('校验失败');
  193. this.loading = false;
  194. });
  195. },
  196. hideKeyboard() {
  197. uni.hideKeyboard();
  198. },
  199. },
  200. };
  201. </script>
  202. <style lang="scss" src="./index.scss" />;