index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view class="register-bg">
  3. <auth-wrap class="register-container" ref="authWrap">
  4. <view class="form-content" slot="content">
  5. <RegistForm
  6. v-if="rules"
  7. :rules="rules"
  8. :mode='mode'
  9. ref="registForm"
  10. @onSubmitHandle="onFormSubmit"
  11. :regist-info="model1.userInfo">
  12. </RegistForm>
  13. </view>
  14. </auth-wrap>
  15. </view>
  16. </template>
  17. <script>
  18. import { fetchUsrApplyDetail, formCfg, putUsrRegist } from '@/common/api';
  19. import { FORM_MOD, ICON_CFG, MEETING_TYPE, USR_TYPE_LIST } from '@/common/EnumConst';
  20. import AuthWrap from '@/components/AuthComp/index.vue';
  21. import RegistForm from '@/components/RegistForm';
  22. import SingleDropList from '@/components/SingleDropList/index.vue';
  23. const staticRules = {
  24. 'userInfo.email': {
  25. pattern: /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
  26. },
  27. };
  28. export default {
  29. name: 'login',
  30. components: {
  31. RegistForm,
  32. AuthWrap,
  33. SingleDropList,
  34. },
  35. props: {},
  36. data() {
  37. return {
  38. ICON_CFG,
  39. USR_TYPE_LIST,
  40. showEnterprise: false,
  41. loading: false,
  42. model1: {
  43. userInfo: {
  44. usrName: '',
  45. conferenceFlag: '0',
  46. usrType: '1',
  47. follows: [],
  48. },
  49. },
  50. rules: null,
  51. mode: null,
  52. };
  53. },
  54. created() {
  55. },
  56. async onLoad(res) {
  57. const { msg } = await formCfg('meet_form_cfg');
  58. if (msg) {
  59. const cfgJson = JSON.parse(msg);
  60. Object.keys(staticRules).forEach(item => {
  61. if (!cfgJson[item]) {
  62. Object.assign(cfgJson[item], staticRules[item]);
  63. }
  64. });
  65. this.rules = cfgJson;
  66. }
  67. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  68. this.$refs.authWrap.reloadPage();
  69. this.$refs.registForm?.setFormRules();
  70. if (res && res.mode === FORM_MOD.modify) {
  71. this.mode = FORM_MOD.modify;
  72. await this.getUsrMeetingInfo(res.apply);
  73. } else {
  74. this.$refs.registForm?.restForm();
  75. }
  76. },
  77. onReady() {
  78. },
  79. methods: {
  80. hideKeyboard() {
  81. uni.hideKeyboard();
  82. },
  83. async onFormSubmit(userInfo) {
  84. const params = {
  85. conferenceFlag: '',
  86. comInfo: '',
  87. backInfo: '',
  88. };
  89. Object.assign(params, userInfo);
  90. const { code } = await putUsrRegist(params, MEETING_TYPE.meeting.value);
  91. if (code !== 200) {
  92. return;
  93. }
  94. uni.showToast({
  95. mask: true,
  96. title: '报名完成',
  97. icon: 'success',
  98. success: async () => {
  99. let pages = getCurrentPages(); //获取当前页面
  100. let beforePage = pages[pages.length - 2]; //获取上一个页面的实例
  101. //1、调用上一个页面onLoad
  102. beforePage.onLoad();
  103. uni.navigateBack({
  104. delta: 1,
  105. });
  106. },
  107. });
  108. },
  109. async getUsrMeetingInfo(id) {
  110. const { data } = await fetchUsrApplyDetail(id);
  111. if (!data) {
  112. return;
  113. }
  114. this.model1.userInfo = data;
  115. },
  116. },
  117. };
  118. </script>
  119. <style lang="scss" src="./index.scss" />;