index.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. ref="registForm"
  9. @onSubmitHandle="onFormSubmit"
  10. :regist-info="model1.userInfo">
  11. </RegistForm>
  12. </view>
  13. </auth-wrap>
  14. </view>
  15. </template>
  16. <script>
  17. import { fetchUsrApplyDetail, fetchUsrInfo, formCfg, putUsrRegist } from '@/common/api';
  18. import { FORM_MOD, ICON_CFG, MEETING_TYPE, USR_TYPE_LIST } from '@/common/EnumConst';
  19. import AuthWrap from '@/components/AuthComp/index.vue';
  20. import RegistForm from '@/components/RegistForm';
  21. import SingleDropList from '@/components/SingleDropList/index.vue';
  22. import { getUserInfo, setUserInfo } from '@/util';
  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: '1',
  46. },
  47. },
  48. rules: null,
  49. };
  50. },
  51. created() {
  52. },
  53. async onLoad(res) {
  54. const { msg } = await formCfg('meet_form_cfg');
  55. if (msg) {
  56. const cfgJson = JSON.parse(msg);
  57. Object.keys(staticRules).forEach(item => {
  58. if (!cfgJson[item]) {
  59. Object.assign(cfgJson[item], staticRules[item]);
  60. }
  61. });
  62. this.rules = cfgJson;
  63. }
  64. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  65. this.$refs.authWrap.reloadPage();
  66. this.$refs.registForm?.setFormRules();
  67. if (res.mode === FORM_MOD.modify) {
  68. await this.getUsrMeetingInfo(res.apply);
  69. }
  70. },
  71. onReady() {
  72. },
  73. methods: {
  74. hideKeyboard() {
  75. uni.hideKeyboard();
  76. },
  77. async onFormSubmit(userInfo) {
  78. const { code } = await putUsrRegist(userInfo, MEETING_TYPE.meeting.value);
  79. if (code !== 200) {
  80. return;
  81. }
  82. uni.showToast({
  83. mask: true,
  84. title: '报名完成',
  85. icon: 'success',
  86. success: async () => {
  87. let pages = getCurrentPages(); //获取当前页面
  88. let beforePage = pages[pages.length - 2]; //获取上一个页面的实例
  89. //1、调用上一个页面onLoad
  90. beforePage.onLoad();
  91. uni.navigateBack({
  92. delta: 1,
  93. });
  94. },
  95. });
  96. },
  97. async getUsrMeetingInfo(id) {
  98. const { data } = await fetchUsrApplyDetail(id);
  99. if (!data) {
  100. return;
  101. }
  102. this.model1.userInfo = data;
  103. },
  104. },
  105. };
  106. </script>
  107. <style lang="scss" src="./index.scss" />;