mytheme.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view class="theme-regist-content-info-container">
  3. <u-empty
  4. mode="data"
  5. text="暂未报名,前去报名"
  6. v-if="isEmpty"
  7. >
  8. </u-empty>
  9. <template v-else>
  10. <view class="title-container">
  11. <view class="title-content-text">{{ title }}</view>
  12. <view class="title-content-date">{{ date }}</view>
  13. </view>
  14. <rich-text :content="content"></rich-text>
  15. <u-popup :show="show" :round="5" mode="bottom" :closeOnClickOverlay="true" :overlay="true" @close="popClose">
  16. <view class="pop-form-content">
  17. <RegistForm
  18. v-if="rules"
  19. :rules="rules"
  20. ref="registForm"
  21. @onSubmitHandle="onFormSubmit"
  22. :regist-info="model1.userInfo"
  23. >
  24. <template v-slot:footer>
  25. <view class="review-msg" v-if="REVIEW_STATUS.noPass.value === model1.userInfo.reviewState">
  26. 审核信息:{{ model1.userInfo.reviewMsg }}
  27. </view>
  28. </template>
  29. </RegistForm>
  30. </view>
  31. </u-popup>
  32. <view class="regist-btn">
  33. <u-button
  34. v-if="REVIEW_STATUS[model1.userInfo.reviewState]"
  35. :text="REVIEW_STATUS[model1.userInfo.reviewState].name"
  36. size="normal"
  37. type="primary"
  38. :disabled="REVIEW_STATUS.pass.value === model1.userInfo.reviewState"
  39. @click="onRegistClick"
  40. ></u-button>
  41. </view>
  42. </template>
  43. <view class="regist-btn" v-if="isEmpty">
  44. <u-button
  45. text="我要报名"
  46. size="normal"
  47. type="primary"
  48. throttle-time="500"
  49. @click="toRegistClick"
  50. ></u-button>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. import { fetchUsrThemeMeetingInfo, formCfg, putUsrRegist } from '@/common/api';
  56. import { CONTENT_TYPE, MEETING_TYPE, REVIEW_STATUS, USR_TYPE_LIST } from '@/common/EnumConst';
  57. import RegistForm from '@/components/RegistForm/index.vue';
  58. import RichText from '@/components/RichText/index.vue';
  59. import SingleDropList from '@/components/SingleDropList/index.vue';
  60. import { authLogin, getStorageObj, storageKey } from '@/util';
  61. const staticRules = {
  62. 'userInfo.email': {
  63. pattern: /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
  64. },
  65. };
  66. export default {
  67. name: 'content',
  68. computed: {
  69. REVIEW_STATUS() {
  70. return REVIEW_STATUS;
  71. },
  72. },
  73. components: {
  74. SingleDropList,
  75. RichText,
  76. RegistForm,
  77. },
  78. props: {},
  79. data() {
  80. return {
  81. CONTENT_TYPE,
  82. content: null,
  83. queryParams: {},
  84. title: '',
  85. date: '',
  86. contentType: '',
  87. show: false,
  88. isEmpty: false,
  89. id: '',
  90. USR_TYPE_LIST,
  91. loading: false,
  92. model1: {
  93. userInfo: {
  94. usrName: '',
  95. conferenceFlag: '1',
  96. },
  97. },
  98. rules: null,
  99. };
  100. },
  101. created() {
  102. },
  103. async onLoad(res) {
  104. // 登录返回之后的页面
  105. this.queryParams = getStorageObj(storageKey.regtheme);
  106. this.getUsrContent();
  107. const { msg } = await formCfg('theme_form_cfg');
  108. if (msg) {
  109. const cfgJson = JSON.parse(msg);
  110. Object.keys(staticRules).forEach(item => {
  111. if (!cfgJson[item]) {
  112. Object.assign(cfgJson[item], staticRules[item]);
  113. }
  114. });
  115. this.rules = cfgJson;
  116. }
  117. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  118. this.$refs.registForm?.setFormRules();
  119. },
  120. methods: {
  121. async onFormSubmit(usrInfo) {
  122. await putUsrRegist({
  123. ...usrInfo,
  124. contentId: this.id,
  125. }, this.queryParams.type);
  126. uni.showToast({
  127. mask: true,
  128. title: '报名完成',
  129. icon: 'success',
  130. });
  131. },
  132. popClose() {
  133. this.show = false;
  134. },
  135. async getUsrContent() {
  136. const {
  137. data,
  138. } = await fetchUsrThemeMeetingInfo({}, this.queryParams.type);
  139. if (!data) {
  140. this.isEmpty = true;
  141. return;
  142. }
  143. const {
  144. content: {
  145. title,
  146. content,
  147. createTime,
  148. id,
  149. contentType,
  150. },
  151. ...usrInfoApply
  152. } = data;
  153. this.content = content;
  154. this.title = title;
  155. this.contentType = contentType;
  156. this.model1 = {
  157. userInfo: { ...usrInfoApply },
  158. };
  159. this.id = id;
  160. uni.setNavigationBarTitle({
  161. title,
  162. });
  163. this.date = uni.$u.timeFormat(createTime, 'yyyy-mm-dd');
  164. },
  165. onRegistClick() {
  166. authLogin(async (usr) => {
  167. this.show = true;
  168. this.$refs.registForm?.clearValidate();
  169. });
  170. },
  171. toRegistClick() {
  172. if (this.queryParams.type == MEETING_TYPE.theme.value) {
  173. uni.$u.route({
  174. type: 'reLaunch',
  175. url: '/pages/tabbar/index/index',
  176. });
  177. }
  178. if (this.queryParams.type == MEETING_TYPE.conference.value) {
  179. uni.$u.route({
  180. type: 'navigateTo',
  181. url: '/pasb/pages/meeting-info/index',
  182. });
  183. }
  184. },
  185. },
  186. };
  187. </script>
  188. <style lang="scss" src="./index.scss" />;