matchDetail.vue 15 KB

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