detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <view class="container main">
  3. <view class="one">
  4. <image class="image" :src="getUrl(info.file)"></image>
  5. </view>
  6. <view class="two">
  7. <view class="two_1 name">{{info.name||'暂无活动名称'}}</view>
  8. <view class="two_1 text_color">
  9. <text class="t-icon t-icon-shizhong"></text>
  10. <span>{{getTime(info.start_time,info.end_time)||'暂无'}}</span>
  11. </view>
  12. <view class="two_1 text_color">
  13. <text class="t-icon t-icon-gonglve"></text>
  14. <span>{{getDict(info.match_type,'type')||'自办'}}</span>
  15. </view>
  16. <view class="two_1 text_color">
  17. <text class="t-icon t-icon-gongsi"></text>
  18. <span>{{info.work||'暂无组织单位'}}</span>
  19. </view>
  20. </view>
  21. <tabs :tabs="tabs" @tabsChange="tabsChange">
  22. <view class="tabsList">
  23. <view v-if="tabs.active=='0'">
  24. <view class="thr">
  25. <view class="thr_cont" v-if="info.rules&&info.rules.rules1">
  26. <view class="thr_1">大赛背景</view>
  27. <view class="thr_2">
  28. <rich-text :nodes="formatRichText(info.rules.rules1)"></rich-text>
  29. </view>
  30. </view>
  31. <view class="thr_cont" v-if="info.rules&&info.rules.rules2">
  32. <view class="thr_1">大赛主题和目标</view>
  33. <view class="thr_2">
  34. <rich-text :nodes="formatRichText(info.rules.rules2)"></rich-text>
  35. </view>
  36. </view>
  37. <view class="thr_cont" v-if="info.rules&&info.rules.rules3">
  38. <view class="thr_1">大赛基本情况介绍</view>
  39. <view class="thr_2">
  40. <rich-text :nodes="formatRichText(info.rules.rules3)"></rich-text>
  41. </view>
  42. </view>
  43. <view class="thr_cont" v-if="info.rules&&info.rules.rules4">
  44. <view class="thr_1">赛题任务</view>
  45. <view class="thr_2">
  46. <rich-text :nodes="formatRichText(info.rules.rules4)"></rich-text>
  47. </view>
  48. </view>
  49. <view class="thr_cont" v-if="info.rules&&info.rules.rules5">
  50. <view class="thr_1">赛程安排</view>
  51. <view class="thr_2">
  52. <rich-text :nodes="formatRichText(info.rules.rules5)"></rich-text>
  53. </view>
  54. </view>
  55. <view class="thr_cont" v-if="info.rules&&info.rules.rules6">
  56. <view class="thr_1">赛制阶段</view>
  57. <view class="thr_2">
  58. <rich-text :nodes="formatRichText(info.rules.rules6)"></rich-text>
  59. </view>
  60. </view>
  61. <view class="thr_cont" v-if="info.rules&&info.rules.rules7">
  62. <view class="thr_1">参赛资格</view>
  63. <view class="thr_2">
  64. <rich-text :nodes="formatRichText(info.rules.rules7)"></rich-text>
  65. </view>
  66. </view>
  67. <view class="thr_cont" v-if="info.rules&&info.rules.rules8">
  68. <view class="thr_1">参赛报名</view>
  69. <view class="thr_2">
  70. <rich-text :nodes="formatRichText(info.rules.rules8)"></rich-text>
  71. </view>
  72. </view>
  73. <view class="thr_cont" v-if="info.rules&&info.rules.rules9">
  74. <view class="thr_1">奖项设置与奖励办法</view>
  75. <view class="thr_2">
  76. <rich-text :nodes="formatRichText(info.rules.rules9)"></rich-text>
  77. </view>
  78. </view>
  79. <view class="thr_cont" v-if="info.rules&&info.rules.rules10">
  80. <view class="thr_1">组织单位</view>
  81. <view class="thr_2">
  82. <rich-text :nodes="formatRichText(info.rules.rules10)"></rich-text>
  83. </view>
  84. </view>
  85. <view class="thr_cont" v-if="info.rules&&info.rules.rules11">
  86. <view class="thr_1">赛事联络</view>
  87. <view class="thr_2">
  88. <rich-text :nodes="formatRichText(info.rules.rules11)"></rich-text>
  89. </view>
  90. </view>
  91. <view class="thr_cont" v-if="info.rules&&info.rules.rules12">
  92. <view class="thr_1">赛事交流</view>
  93. <view class="thr_2">
  94. <rich-text :nodes="formatRichText(info.rules.rules12)"></rich-text>
  95. </view>
  96. </view>
  97. </view>
  98. <view class="thr">
  99. <view class="thr_cont" v-if="info.brief">
  100. <view class="thr_1">常见问题</view>
  101. <view class="thr_2">
  102. <rich-text :nodes="formatRichText(info.brief)"></rich-text>
  103. </view>
  104. </view>
  105. </view>
  106. </view>
  107. <view v-if="tabs.active=='1'">
  108. <view class="thr">
  109. <view class="thr_cont">
  110. <view class="thr_1">报名信息</view>
  111. <view class="thr_2">
  112. <view class="thr_label">
  113. <view class="left">姓名</view>
  114. <view class="right textOne">
  115. <text>{{sign.name||'暂无姓名'}}</text>
  116. </view>
  117. </view>
  118. <view class="thr_label">
  119. <view class="left">证件类型</view>
  120. <view class="right textOne">
  121. <text>{{getDict(sign.cardType,'cardType')||'暂无证件类型'}}</text>
  122. </view>
  123. </view>
  124. <view class="thr_label">
  125. <view class="left">证件号码</view>
  126. <view class="right textOne">
  127. <text>{{sign.card||'暂无证件号码'}}</text>
  128. </view>
  129. </view>
  130. <view class="thr_label">
  131. <view class="left">手机号</view>
  132. <view class="right textOne">
  133. <text>{{sign.phone||'暂无手机号'}}</text>
  134. </view>
  135. </view>
  136. <view class="thr_label">
  137. <view class="left">电子邮箱</view>
  138. <view class="right textOne">
  139. <text>{{sign.email||'暂无电子邮箱'}}</text>
  140. </view>
  141. </view>
  142. <view class="thr_label">
  143. <view class="left">微信/QQ</view>
  144. <view class="right textOne">
  145. <text>{{sign.communication||'暂无微信/QQ'}}</text>
  146. </view>
  147. </view>
  148. <view class="thr_label">
  149. <view class="left">报名时间</view>
  150. <view class="right textOne">
  151. <text>{{sign.time||'暂无报名时间'}}</text>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. <view class="button">
  157. <button class="danger" size="mini" type="warn" @tap.stop="toEdit(sign)"
  158. v-if="sign.status!=='1'">修改报名信息</button>
  159. </view>
  160. </view>
  161. </view>
  162. <view v-else>
  163. <view class="list" v-for="(item, index) in score" :key="index">
  164. <view class="value">
  165. <view class="title">流程名称:</view>
  166. <view class="label">{{item.matchPath_name||'暂无'}}</view>
  167. </view>
  168. <view class="value">
  169. <view class="title">分数:</view>
  170. <view class="label">{{item.score||'暂无'}}</view>
  171. </view>
  172. <view class="value">
  173. <view class="title">时间:</view>
  174. <view class="label">{{item.time||'暂无'}}</view>
  175. </view>
  176. </view>
  177. </view>
  178. </view>
  179. </tabs>
  180. </view>
  181. </template>
  182. <script>
  183. import tabs from '../../components/tabs/index.vue';
  184. export default {
  185. components: {
  186. tabs
  187. },
  188. data() {
  189. return {
  190. id: '',
  191. tabs: {
  192. active: '0',
  193. bgColor: '#ffffff',
  194. menu: [{
  195. title: '活动内容',
  196. active: '0'
  197. }, {
  198. title: '报名信息',
  199. active: '1'
  200. }]
  201. },
  202. user: {},
  203. config: {},
  204. info: {},
  205. // 报名信息
  206. sign: {},
  207. // 分数信息
  208. score: {},
  209. // 字典表
  210. statusList: [],
  211. cTypeList: [],
  212. typeList: [],
  213. }
  214. },
  215. onLoad: async function(e) {
  216. const that = this;
  217. that.$set(that, `id`, e && e.id || '');
  218. that.searchConfig();
  219. that.searchToken();
  220. await that.searchOther();
  221. await that.search();
  222. },
  223. methods: {
  224. // 用户信息
  225. searchToken() {
  226. const that = this;
  227. try {
  228. const res = uni.getStorageSync('token');
  229. if (res) {
  230. const user = that.$jwt(res);
  231. that.$set(that, `user`, user);
  232. }
  233. } catch (e) {}
  234. },
  235. searchConfig() {
  236. const that = this;
  237. try {
  238. const res = uni.getStorageSync('config');
  239. if (res) that.$set(that, `config`, res);
  240. } catch (e) {}
  241. },
  242. // 查询其他信息
  243. async searchOther() {
  244. const that = this;
  245. let res;
  246. // 查询状态
  247. res = await that.$api(`/dictData`, 'GET', {
  248. code: 'matchStatus',
  249. is_use: '0',
  250. })
  251. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  252. // 查询证件类型
  253. res = await that.$api(`/dictData`, 'GET', {
  254. code: 'cardType',
  255. is_use: '0',
  256. })
  257. if (res.errcode == '0') that.$set(that, `cTypeList`, res.data);
  258. // 赛事类型
  259. res = await that.$api(`/dictData`, 'GET', {
  260. code: 'activeType',
  261. is_use: '0',
  262. })
  263. if (res.errcode == '0') that.$set(that, `typeList`, res.data)
  264. },
  265. // 查询
  266. async search() {
  267. const that = this;
  268. if (that.id) {
  269. let res;
  270. res = await that.$api(`/sign/${that.id}`, 'GET', {})
  271. if (res.errcode == '0') {
  272. that.$set(that, `sign`, res.data)
  273. if (res.data.match) {
  274. const arr = await that.$api(`/match/${res.data.match}`, 'GET', {})
  275. if (res.errcode == '0') {
  276. that.$set(that, `info`, arr.data)
  277. if (arr.data.match_status == '2' || arr.data.match_status == '3') {
  278. await that.searchPath()
  279. }
  280. }
  281. }
  282. } else {
  283. uni.showToast({
  284. title: res.errmsg,
  285. });
  286. }
  287. }
  288. },
  289. async searchPath() {
  290. const that = this;
  291. that.$set(that.tabs, `menu`, [...that.tabs.menu, {
  292. title: '分数信息',
  293. active: '2'
  294. }])
  295. const arr = await that.$api(`/score/list`, 'GET', {
  296. match: that.info.id,
  297. sign: that.sign.id
  298. })
  299. if (arr.errcode == '0') that.$set(that, `score`, arr.data)
  300. },
  301. // 选择选项卡
  302. tabsChange(e) {
  303. const that = this;
  304. that.$set(that.tabs, `active`, e.active)
  305. },
  306. // 处理时间
  307. getTime(start_time, end_time) {
  308. if (start_time && end_time) {
  309. const start = new Date(start_time);
  310. const end = new Date(end_time);
  311. const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  312. const day = start.getDate();
  313. const weekday = weekdays[start.getDay()];
  314. const month = start.getMonth();
  315. const start_hours = start.getHours();
  316. const start_minutes = start.getMinutes();
  317. const end_hours = end.getHours();
  318. const end_minutes = end.getMinutes();
  319. return `${month}/${day < 10 ? '0' + day : day} ${weekday} ${start_hours.toString().padStart(2, '0')}:${start_minutes.toString().padStart(2, '0')} - ${end_hours.toString().padStart(2, '0')}:${end_minutes.toString().padStart(2, '0')} `;
  320. }
  321. },
  322. // 修改报名信息
  323. toEdit(item) {
  324. uni.navigateTo({
  325. url: `/pagesMy/activity/add?id=${item.id}`
  326. })
  327. },
  328. // 图片处理
  329. getUrl(e) {
  330. const that = this;
  331. if (e && e.length > 0) return that.$config.serverFile + e[0].url
  332. else return '/static/match.png'
  333. },
  334. // 处理字典表
  335. getDict(item, model) {
  336. const that = this;
  337. let res
  338. if (model == 'status') res = that.statusList.find(i => i.value == item)
  339. else if (model == 'cardType') res = that.cTypeList.find(i => i.value == item)
  340. else if (model == 'type') res = that.typeList.find(i => i.value == item)
  341. if (res) return res.label
  342. else return '暂无'
  343. },
  344. // 处理富文本
  345. formatRichText(html) {
  346. if (html) {
  347. html = html.replace(/<table[^>]*>/gi, match => {
  348. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  349. return match.replace(/style="[^"]+"/gi,
  350. `style="border-collapse: collapse; width: 100%;text-align: center;"`)
  351. .replace(/<table/gi,
  352. `<table style="border-collapse: collapse; width: 100%;text-align: center;"`);
  353. });
  354. html = html.replace(/<th[^>]*>/gi, match => {
  355. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  356. return match.replace(/style="[^"]+"/gi,
  357. `style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  358. )
  359. .replace(/<table/gi,
  360. `<table style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  361. );
  362. });
  363. html = html.replace(/<td[^>]*>/gi, match => {
  364. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  365. return match.replace(/style="[^"]+"/gi,
  366. `style="border: 1px solid #ddd; padding: 8px;text-align: center;"`)
  367. .replace(/<table/gi,
  368. `<table style="border: 1px solid #ddd; padding: 8px;text-align: center;"`);
  369. });
  370. // 富文本内容格式化
  371. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  372. // 查找所有的 img 元素
  373. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  374. '')
  375. // 删除找到的所有 img 元素中的 style 属性
  376. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  377. }
  378. },
  379. }
  380. }
  381. </script>
  382. <style lang="scss" scoped>
  383. .main {
  384. background-color: var(--f9Color);
  385. .one {
  386. .image {
  387. width: 100%;
  388. height: 50vw;
  389. }
  390. }
  391. .two {
  392. padding: 0 2vw;
  393. margin: 0 0 3vw 0;
  394. background-color: var(--mainColor);
  395. .two_1 {
  396. display: flex;
  397. align-items: center;
  398. padding: 3vw 0;
  399. border-bottom: 1px solid var(--f5Color);
  400. font-size: var(--font14Size);
  401. span {
  402. margin: 0 0 0 1vw;
  403. }
  404. .t-icon {
  405. width: var(--font15Size) !important;
  406. height: var(--font15Size) !important;
  407. }
  408. }
  409. .name {
  410. font-weight: bold;
  411. font-size: var(--font16Size);
  412. }
  413. .text_color {
  414. color: var(--f69Color);
  415. }
  416. }
  417. .tabsList {
  418. .list {
  419. background-color: var(--mainColor);
  420. border-bottom: 1px solid var(--f5Color);
  421. margin: 2vw 2vw 0 2vw;
  422. border-radius: 4px;
  423. padding: 3vw;
  424. .value {
  425. display: flex;
  426. align-items: center;
  427. .title {
  428. font-size: var(--font14Size);
  429. font-weight: bold;
  430. }
  431. .label {
  432. font-size: var(--font12Size);
  433. color: var(--f85Color);
  434. }
  435. }
  436. }
  437. .thr {
  438. background-color: var(--mainColor);
  439. .thr_cont {
  440. padding: 2vw 0 0 0;
  441. .thr_1 {
  442. text-indent: 10px;
  443. border-left: 3px solid var(--f3CColor);
  444. font-weight: bold;
  445. font-size: var(--font16Size);
  446. }
  447. .thr_2 {
  448. padding: 2vw;
  449. .thr_label {
  450. display: flex;
  451. justify-content: space-between;
  452. padding: 4vw;
  453. border-bottom: 1px solid var(--f9Color);
  454. font-size: var(--font14Size);
  455. color: var(--f69Color);
  456. .right {
  457. text-align: right;
  458. width: 60vw;
  459. }
  460. }
  461. }
  462. }
  463. .button {
  464. text-align: center;
  465. }
  466. }
  467. }
  468. }
  469. </style>