index.vue 7.2 KB

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