index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view class="theme-regist-content-info-container">
  3. <view class="title-container">
  4. <view class="title-content-text">{{ title }}</view>
  5. <view class="title-content-date">{{ date }}</view>
  6. </view>
  7. <rich-text :content="content"></rich-text>
  8. <u-popup :show="show" :round="5" mode="bottom" :closeOnClickOverlay="true" :overlay="true" @close="popClose">
  9. <view class="pop-form-content">
  10. <u--form
  11. labelPosition="left"
  12. :model="model1"
  13. :rules="rules"
  14. ref="uForm"
  15. @submit="onSubmit"
  16. >
  17. <u-form-item
  18. label="姓名"
  19. prop="userInfo.usrName"
  20. borderBottom
  21. >
  22. <u--input
  23. placeholder="输入姓名"
  24. v-model="model1.userInfo.usrName"
  25. border="none"
  26. ></u--input>
  27. </u-form-item>
  28. <u-form-item
  29. label="单位名称"
  30. prop="userInfo.orgUnitName"
  31. borderBottom
  32. >
  33. <u--input
  34. placeholder="输入单位名称"
  35. v-model="model1.userInfo.orgUnitName"
  36. border="none"
  37. ></u--input>
  38. </u-form-item>
  39. <u-form-item
  40. label="职务"
  41. prop="userInfo.uniLevel"
  42. borderBottom
  43. >
  44. <u--input
  45. placeholder="输入职务"
  46. v-model="model1.userInfo.uniLevel"
  47. border="none"
  48. ></u--input>
  49. </u-form-item>
  50. <u-form-item
  51. label="联系电话"
  52. prop="userInfo.tel"
  53. borderBottom
  54. >
  55. <u--input
  56. placeholder="输入联系电话"
  57. border="none"
  58. type="number"
  59. maxlength="11"
  60. v-model="model1.userInfo.tel"
  61. ></u--input>
  62. </u-form-item>
  63. <u-form-item
  64. label="邮箱"
  65. prop="userInfo.email"
  66. borderBottom
  67. >
  68. <u--input
  69. placeholder="输入邮箱"
  70. border="none"
  71. v-model="model1.userInfo.email"
  72. ></u--input>
  73. </u-form-item>
  74. <u-form-item
  75. label="人员类型"
  76. prop="userInfo.usrType"
  77. borderBottom
  78. >
  79. <u-radio-group
  80. v-model="model1.userInfo.usrType"
  81. placement="row"
  82. >
  83. <u-radio
  84. :style="{
  85. marginRight: '20rpx'
  86. }"
  87. v-for="(item, index) in USR_TYPE_LIST"
  88. :key="index"
  89. :label="item.name"
  90. :name="item.value"
  91. >
  92. </u-radio>
  93. </u-radio-group>
  94. </u-form-item>
  95. </u--form>
  96. <u-button
  97. :style="{
  98. marginTop: 'auto',
  99. marginBottom: '80rpx'
  100. }"
  101. type="primary"
  102. text="提交"
  103. :disabled="loading"
  104. :loading="loading"
  105. loadingText="正在提交..."
  106. @click="onSubmit"
  107. >
  108. </u-button>
  109. </view>
  110. </u-popup>
  111. <view class="regist-btn">
  112. <u-button
  113. text="报名"
  114. size="normal"
  115. type="primary"
  116. @click="onRegistClick"
  117. ></u-button>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. import { fetchContentDetail, putUsrRegist } from '@/common/api';
  123. import { CONTENT_TYPE, USR_TYPE_LIST } from '@/common/EnumConst';
  124. import RichText from '@/components/RichText/index.vue';
  125. import { authLogin, getStorageObj, getUserInfo, storageKey } from '@/util';
  126. export default {
  127. name: 'content',
  128. components: {
  129. RichText,
  130. },
  131. props: {},
  132. data() {
  133. return {
  134. CONTENT_TYPE,
  135. content: null,
  136. queryParams: {},
  137. title: '',
  138. date: '',
  139. contentType: '',
  140. show: false,
  141. id: '',
  142. USR_TYPE_LIST,
  143. loading: false,
  144. model1: {
  145. userInfo: {
  146. usrName: '',
  147. conferenceFlag: '1',
  148. },
  149. },
  150. rules: {
  151. 'userInfo.usrName': {
  152. type: 'string',
  153. required: true,
  154. message: '请填写姓名',
  155. trigger: ['blur', 'change'],
  156. },
  157. 'userInfo.tel': {
  158. type: 'string',
  159. len: 11,
  160. required: true,
  161. message: '请填写11位手机号',
  162. trigger: ['blur', 'change'],
  163. },
  164. 'userInfo.email': {
  165. type: 'string',
  166. required: true,
  167. message: '请填写邮箱',
  168. pattern: /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/,
  169. trigger: ['blur', 'change'],
  170. },
  171. 'userInfo.orgUnitName': {
  172. type: 'string',
  173. required: true,
  174. message: '请填写单位名称',
  175. trigger: ['blur', 'change'],
  176. },
  177. 'userInfo.uniLevel': {
  178. type: 'string',
  179. required: true,
  180. message: '请填写职务',
  181. trigger: ['blur', 'change'],
  182. },
  183. 'userInfo.usrType': {
  184. type: 'string',
  185. required: true,
  186. message: '请填写人员类型',
  187. trigger: ['blur', 'change'],
  188. },
  189. },
  190. };
  191. },
  192. created() {
  193. },
  194. onLoad(res) {
  195. // 登录返回之后的页面
  196. this.queryParams = getStorageObj(storageKey.regtheme);
  197. this.getContentInfo();
  198. this.restForm();
  199. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  200. this.$refs.uForm.setRules(this.rules);
  201. },
  202. methods: {
  203. onSubmit() {
  204. this.loading = true;
  205. this.$refs.uForm.validate().then(async (res) => {
  206. const { code } = await putUsrRegist({
  207. ...this.model1.userInfo,
  208. contentId: this.queryParams.id,
  209. }, this.queryParams.type);
  210. this.loading = false;
  211. if (code !== 200) {
  212. return;
  213. }
  214. uni.showToast({
  215. mask: true,
  216. title: '报名完成',
  217. icon: 'success',
  218. success: async () => {
  219. this.show = false;
  220. },
  221. });
  222. }).catch(errors => {
  223. this.loading = false;
  224. });
  225. },
  226. popClose() {
  227. this.show = false;
  228. },
  229. async getContentInfo() {
  230. const {
  231. data: {
  232. content,
  233. title,
  234. createTime,
  235. contentType,
  236. id,
  237. },
  238. } = await fetchContentDetail(this.queryParams.id);
  239. this.content = content;
  240. this.title = title;
  241. this.contentType = contentType;
  242. this.id = id;
  243. uni.setNavigationBarTitle({
  244. title,
  245. });
  246. this.date = uni.$u.timeFormat(createTime, 'yyyy-mm-dd');
  247. },
  248. restForm() {
  249. this.model1 = {
  250. userInfo: {
  251. usrName: '',
  252. },
  253. };
  254. const user = getUserInfo();
  255. if (user) {
  256. this.model1.userInfo.usrName = user.usrName;
  257. this.model1.userInfo.tel = user.tel;
  258. }
  259. },
  260. onRegistClick() {
  261. authLogin(async (usr) => {
  262. this.show = true;
  263. this.restForm();
  264. this.$refs.uForm.clearValidate();
  265. });
  266. }
  267. }
  268. };
  269. </script>
  270. <style lang="scss" src="./index.scss" />;