matchDetail.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. <template>
  2. <custom-layout class="main">
  3. <el-col :span="24" class="one" v-loading="loading">
  4. <div class="w_1300">
  5. <div class="info_1">
  6. <h3 class="name">{{ info.name || '暂无' }}</h3>
  7. <p class="brief">{{ info.industry || '暂无' }}</p>
  8. <p class="money" v-if="info.money">{{ info.money || '暂无' }}</p>
  9. <p class="type" v-if="info.match_type">{{ getDict(info.match_type, 'type') || '暂无' }}</p>
  10. <div class="time">
  11. <el-image class="image" :src="time" fit="fill"></el-image>
  12. <span>{{ info.start_time || '暂无' }} ~ {{ info.end_time || '暂无' }}</span>
  13. </div>
  14. <div class="button" @click="toSign">活动报名</div>
  15. </div>
  16. <div class="info_2">
  17. <div class="title">活动介绍</div>
  18. <div class="content">
  19. <!-- 正文 -->
  20. <div class="content_1">
  21. <div v-if="info.brief" v-html="info.brief"></div>
  22. <div v-else>暂无简介</div>
  23. </div>
  24. <!-- 封面 -->
  25. <div class="image">
  26. <el-image class="images" :src="getUrl(info.file, 'array')" fit="fill"></el-image>
  27. </div>
  28. </div>
  29. </div>
  30. <div class="info_3">
  31. <div class="title">活动说明</div>
  32. <div class="content">
  33. <div class="thr_cont" v-if="info.rules && info.rules.rules1">
  34. <div class="thr_1">大赛背景</div>
  35. <div class="thr_2">
  36. <div v-html="info.rules.rules1"></div>
  37. </div>
  38. </div>
  39. <div class="thr_cont" v-if="info.rules && info.rules.rules2">
  40. <div class="thr_1">大赛主题和目标</div>
  41. <div class="thr_2">
  42. <div v-html="info.rules.rules2"></div>
  43. </div>
  44. </div>
  45. <div class="thr_cont" v-if="info.rules && info.rules.rules3">
  46. <div class="thr_1">大赛基本情况介绍</div>
  47. <div class="thr_2">
  48. <div v-html="info.rules.rules3"></div>
  49. </div>
  50. </div>
  51. <div class="thr_cont" v-if="info.rules && info.rules.rules4">
  52. <div class="thr_1">赛题任务</div>
  53. <div class="thr_2">
  54. <div v-html="info.rules.rules4"></div>
  55. </div>
  56. </div>
  57. <div class="thr_cont" v-if="info.rules && info.rules.rules5">
  58. <div class="thr_1">赛程安排</div>
  59. <div class="thr_2">
  60. <div v-html="info.rules.rules5"></div>
  61. </div>
  62. </div>
  63. <div class="thr_cont" v-if="info.rules && info.rules.rules6">
  64. <div class="thr_1">赛制阶段</div>
  65. <div class="thr_2">
  66. <div v-html="info.rules.rules6"></div>
  67. </div>
  68. </div>
  69. <div class="thr_cont" v-if="info.rules && info.rules.rules7">
  70. <div class="thr_1">参赛资格</div>
  71. <div class="thr_2">
  72. <div v-html="info.rules.rules7"></div>
  73. </div>
  74. </div>
  75. <div class="thr_cont" v-if="info.rules && info.rules.rules8">
  76. <div class="thr_1">参赛报名</div>
  77. <div class="thr_2">
  78. <div v-html="info.rules.rules8"></div>
  79. </div>
  80. </div>
  81. <div class="thr_cont" v-if="info.rules && info.rules.rules9">
  82. <div class="thr_1">奖项设置与奖励办法</div>
  83. <div class="thr_2">
  84. <div v-html="info.rules.rules9"></div>
  85. </div>
  86. </div>
  87. <div class="thr_cont" v-if="info.rules && info.rules.rules10">
  88. <div class="thr_1">组织单位</div>
  89. <div class="thr_2">
  90. <div v-html="info.rules.rules10"></div>
  91. </div>
  92. </div>
  93. <div class="thr_cont" v-if="info.rules && info.rules.rules11">
  94. <div class="thr_1">赛事联络</div>
  95. <div class="thr_2">
  96. <div v-html="info.rules.rules11"></div>
  97. </div>
  98. </div>
  99. <div class="thr_cont" v-if="info.rules && info.rules.rules12">
  100. <div class="thr_1">赛事交流</div>
  101. <div class="thr_2">
  102. <div v-html="info.rules.rules12"></div>
  103. </div>
  104. </div>
  105. <div class="button" @click="toSign">活动报名</div>
  106. </div>
  107. </div>
  108. </div>
  109. </el-col>
  110. </custom-layout>
  111. <el-dialog v-model="dialog" title="活动报名" :destroy-on-close="true" @close="toClose">
  112. <data-form></data-form>
  113. </el-dialog>
  114. </template>
  115. <script setup>
  116. import moment from 'moment'
  117. import { get, cloneDeep } from 'lodash-es'
  118. const $checkRes = inject('$checkRes')
  119. // 组件
  120. import dataForm from './parts/index.vue'
  121. import time from '/images/time.png'
  122. import { UserStore } from '@/store/user'
  123. const userStore = UserStore()
  124. const user = computed(() => userStore.user)
  125. // 接口
  126. import { DictDataStore } from '@/store/api/system/dictData'
  127. import { MatchStore } from '@/store/api/platform/match'
  128. import { SignStore } from '@/store/api/platform/sign'
  129. const dictDataStore = DictDataStore()
  130. const store = MatchStore()
  131. const signStore = SignStore()
  132. // 加载中
  133. const loading = ref(false)
  134. // 路由
  135. const route = useRoute()
  136. const info = ref({})
  137. // 弹框
  138. const cardTypeList = ref([])
  139. const typeList = ref([])
  140. const ruleFormRef = ref()
  141. const form = ref({})
  142. const validatePhoneNumber = (rule, value, callback) => {
  143. const reg = /^1[3-9]\d{9}$/
  144. if (!value) {
  145. return callback(new Error('手机号不能为空'))
  146. }
  147. if (!reg.test(value)) {
  148. return callback(new Error('请输入正确的手机号'))
  149. }
  150. callback()
  151. }
  152. const validateCardNumber = (rule, value, callback) => {
  153. var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  154. if (!value) {
  155. return callback(new Error('证件号码不能为空'))
  156. }
  157. if (!reg.test(value)) {
  158. return callback(new Error('请输入正确的证件号码'))
  159. }
  160. callback()
  161. }
  162. const rules = reactive({
  163. name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
  164. phone: [{ required: true, validator: validatePhoneNumber, trigger: 'blur' }],
  165. cardType: [{ required: true, message: '请选择证件类型', trigger: 'change' }],
  166. card: [{ required: true, validator: validateCardNumber, trigger: 'change' }],
  167. remark: [{ required: true, message: '请输入备注', trigger: 'blur' }]
  168. })
  169. const dialog = ref(false)
  170. // 请求
  171. onMounted(async () => {
  172. loading.value = true
  173. await searchOther()
  174. await search()
  175. loading.value = false
  176. })
  177. const searchOther = async () => {
  178. let result
  179. // 证件类型
  180. result = await dictDataStore.query({ code: 'cardType', is_use: '0' })
  181. if ($checkRes(result)) cardTypeList.value = result.data
  182. // 赛事类型
  183. result = await dictDataStore.query({ code: 'activeType', is_use: '0' })
  184. if ($checkRes(result)) typeList.value = result.data
  185. }
  186. const search = async () => {
  187. let id = route.query.id
  188. if (id) {
  189. let res = await store.fetch(id)
  190. if (res.errcode == '0') info.value = res.data
  191. }
  192. }
  193. // 字典数据转换
  194. const getDict = (data, model) => {
  195. if (data) {
  196. let res
  197. if (model == 'type') res = typeList.value.find((f) => f.value == data)
  198. return get(res, 'label')
  199. }
  200. }
  201. // 报名参赛
  202. const toSign = () => {
  203. if (info.value.match_type == '1') {
  204. window.open(info.value.href, '_blank') // 在新标签页中打开URL
  205. } else dialog.value = true
  206. }
  207. const toClose = () => {
  208. dialog.value = false
  209. form.value = {}
  210. }
  211. const getUrl = (item, type) => {
  212. if (item) {
  213. if (type == 'array') return `${import.meta.env.VITE_APP_HOST}${item[0].uri}`
  214. else return `${import.meta.env.VITE_APP_HOST}${item.uri}`
  215. }
  216. }
  217. // 报名
  218. const submitForm = async (formEl) => {
  219. if (user.value.id) {
  220. if (!formEl) return
  221. await formEl.validate(async (valid, fields) => {
  222. if (valid) {
  223. const data = cloneDeep(form.value)
  224. const other = {
  225. match: info.value.id,
  226. user: user.value.id,
  227. time: moment().format('YYYY-MM-DD')
  228. }
  229. let res = await signStore.create({ ...data, ...other })
  230. if ($checkRes(res, true)) toClose()
  231. } else {
  232. console.log('error submit!', fields)
  233. }
  234. })
  235. } else {
  236. ElMessage.error('用户未登录无法报名活动!')
  237. }
  238. }
  239. // provide
  240. provide('form', form)
  241. provide('rules', rules)
  242. provide('ruleFormRef', ruleFormRef)
  243. provide('cardTypeList', cardTypeList)
  244. provide('submitForm', submitForm)
  245. </script>
  246. <style scoped lang="scss">
  247. .main {
  248. .one {
  249. background: url(/images/matchBg.jpg) no-repeat;
  250. background-position: center top;
  251. .info_1 {
  252. padding: 90px 80px 0 80px;
  253. .name {
  254. font-size: $global-font-size-36;
  255. width: 50%;
  256. font-weight: bold;
  257. }
  258. .brief {
  259. font-size: $global-font-size-20;
  260. margin-top: 25px;
  261. color: #000;
  262. }
  263. .type {
  264. font-size: $global-font-size-12;
  265. overflow: hidden;
  266. text-overflow: ellipsis;
  267. white-space: nowrap;
  268. width: 70px;
  269. height: 25px;
  270. border-radius: 4px;
  271. text-align: center;
  272. line-height: 25px;
  273. font-weight: 700;
  274. color: #2a78ff;
  275. background: #eaf1ff;
  276. }
  277. .time {
  278. display: flex;
  279. margin-top: 60px !important;
  280. color: #666;
  281. font-size: $global-font-size-16;
  282. .image {
  283. width: 18px;
  284. height: 18px;
  285. margin: 0 5px 0 0;
  286. }
  287. }
  288. .button {
  289. margin-top: 70px !important;
  290. justify-content: center;
  291. display: flex !important;
  292. align-items: center;
  293. width: 136px;
  294. height: 44px;
  295. color: #fff;
  296. font-size: 16px;
  297. background-image: linear-gradient(90deg, #0455da 0%, #378cff 100%), linear-gradient(#0455da, #0455da);
  298. background-blend-mode: normal, normal;
  299. border-radius: 4px;
  300. }
  301. }
  302. .info_2 {
  303. padding: 0 80px;
  304. margin-top: 70px !important;
  305. .title {
  306. color: #000;
  307. display: inline-block;
  308. padding-bottom: 20px;
  309. font-size: $global-font-size-30;
  310. border-bottom: 5px solid #378cff;
  311. cursor: pointer;
  312. }
  313. .content {
  314. display: flex;
  315. margin-top: 50px;
  316. .content_1 {
  317. height: 200px;
  318. width: 630px;
  319. text-indent: 2em;
  320. font-size: 16px;
  321. line-height: 36px;
  322. color: #333333;
  323. overflow: hidden;
  324. }
  325. .image {
  326. margin-left: 66px;
  327. width: 331px;
  328. height: 182px;
  329. }
  330. }
  331. }
  332. .info_3 {
  333. padding: 80px !important;
  334. margin-top: 50px !important;
  335. background: #fff;
  336. .title {
  337. color: #000;
  338. display: inline-block;
  339. padding-bottom: 20px;
  340. font-size: $global-font-size-30;
  341. border-bottom: 5px solid #378cff;
  342. cursor: pointer;
  343. }
  344. .content {
  345. display: flex;
  346. flex-direction: column;
  347. justify-content: center;
  348. align-items: center;
  349. .thr_cont {
  350. text-align: center;
  351. margin: 10px 0;
  352. width: 100%;
  353. .thr_1 {
  354. color: #000;
  355. display: inline-block;
  356. padding-bottom: 10px;
  357. border-bottom: 5px solid #378cff;
  358. font-size: $global-font-size-20;
  359. cursor: pointer;
  360. }
  361. .thr_2 {
  362. padding: 20px;
  363. }
  364. }
  365. .button {
  366. margin-top: 70px !important;
  367. justify-content: center;
  368. display: flex !important;
  369. align-items: center;
  370. width: 136px;
  371. height: 44px;
  372. color: #fff;
  373. font-size: 16px;
  374. background-image: linear-gradient(90deg, #0455da 0%, #378cff 100%), linear-gradient(#0455da, #0455da);
  375. background-blend-mode: normal, normal;
  376. border-radius: 4px;
  377. }
  378. }
  379. }
  380. }
  381. }
  382. </style>