index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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="enterpriseList"
  70. placeholder="请选择参会企业"
  71. @onChange="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="tripList"
  87. placeholder="请选择参会行程"
  88. @onChange="enterpriseTripSelect"
  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 { fetchEnterpriseList, fetchEnterpriseTripList, 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. enterpriseList: [],
  148. tripList: [],
  149. rules: {
  150. 'userInfo.name': {
  151. type: 'string',
  152. required: true,
  153. message: '请填写姓名',
  154. trigger: ['blur', 'change'],
  155. },
  156. 'userInfo.tel': {
  157. type: 'string',
  158. max: 11,
  159. required: true,
  160. message: '请填写11位手机号',
  161. trigger: ['blur', 'change'],
  162. },
  163. },
  164. };
  165. },
  166. created() {
  167. },
  168. onLoad() {
  169. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  170. this.$refs.uForm.setRules(this.rules);
  171. this.$refs.authWrap.reloadPage();
  172. const user = getUserInfo();
  173. if (user) {
  174. this.model1.userInfo.name = user.usrName;
  175. }
  176. this.init();
  177. },
  178. onReady() {
  179. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  180. this.$refs.uForm.setRules(this.rules);
  181. },
  182. methods: {
  183. getImageUrl,
  184. enterpriseSelect(enterprise) {
  185. this.model1.userInfo.enterpriseId = enterprise.value;
  186. this.model1.userInfo.enterpriseName = enterprise.name;
  187. this.$refs.uForm.validateField('userInfo.enterpriseId');
  188. },
  189. enterpriseTripSelect(trip) {
  190. },
  191. async init() {
  192. const {
  193. code: enterpriseCode,
  194. rows: enterpriseData,
  195. } = await fetchEnterpriseList();
  196. const {
  197. code: tripCode,
  198. rows: tripData,
  199. } = await fetchEnterpriseTripList();
  200. this.enterpriseList = enterpriseData.map(item => {
  201. return {
  202. name: item.enterpriseName,
  203. value: item.id,
  204. };
  205. });
  206. this.tripList = tripData.map(item => {
  207. return {
  208. name: item.tripName,
  209. value: item.id,
  210. };
  211. });
  212. },
  213. onSubmit() {
  214. this.loading = true;
  215. this.$refs.uForm.validate().then(res => {
  216. putUsrRegist(this.model1.userInfo);
  217. this.loading = false;
  218. }).catch(errors => {
  219. uni.$u.toast('校验失败');
  220. this.loading = false;
  221. });
  222. },
  223. hideKeyboard() {
  224. uni.hideKeyboard();
  225. },
  226. },
  227. };
  228. </script>
  229. <style lang="scss" src="./index.scss" />;