detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485
  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-zuobiao"></text>
  14. <span>{{info.address||'在线活动'}}</span>
  15. </view>
  16. <view class="two_1 text_color">
  17. <text class="t-icon t-icon-dianzan"></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. typeList: [],
  212. }
  213. },
  214. onLoad: async function(e) {
  215. const that = this;
  216. that.$set(that, `id`, e && e.id || '');
  217. that.searchConfig();
  218. that.searchToken();
  219. await that.searchOther();
  220. await that.search();
  221. },
  222. methods: {
  223. // 用户信息
  224. searchToken() {
  225. const that = this;
  226. try {
  227. const res = uni.getStorageSync('token');
  228. if (res) {
  229. const user = that.$jwt(res);
  230. that.$set(that, `user`, user);
  231. }
  232. } catch (e) {}
  233. },
  234. searchConfig() {
  235. const that = this;
  236. try {
  237. const res = uni.getStorageSync('config');
  238. if (res) that.$set(that, `config`, res);
  239. } catch (e) {}
  240. },
  241. // 查询其他信息
  242. async searchOther() {
  243. const that = this;
  244. let res;
  245. // 查询状态
  246. res = await that.$api(`/dictData`, 'GET', {
  247. code: 'matchStatus',
  248. is_use: '0',
  249. })
  250. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  251. // 查询证件类型
  252. res = await that.$api(`/dictData`, 'GET', {
  253. code: 'cardType',
  254. is_use: '0',
  255. })
  256. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  257. },
  258. // 查询
  259. async search() {
  260. const that = this;
  261. if (that.id) {
  262. let res;
  263. res = await that.$api(`/sign/${that.id}`, 'GET', {})
  264. if (res.errcode == '0') {
  265. that.$set(that, `sign`, res.data)
  266. if (res.data.match) {
  267. const arr = await that.$api(`/match/${res.data.match}`, 'GET', {})
  268. if (res.errcode == '0') {
  269. that.$set(that, `info`, arr.data)
  270. if (arr.data.match_status == '2' || arr.data.match_status == '3') {
  271. await that.searchPath()
  272. }
  273. }
  274. }
  275. } else {
  276. uni.showToast({
  277. title: res.errmsg,
  278. });
  279. }
  280. }
  281. },
  282. async searchPath() {
  283. const that = this;
  284. that.$set(that.tabs, `menu`, [...that.tabs.menu, {
  285. title: '分数信息',
  286. active: '2'
  287. }])
  288. const arr = await that.$api(`/score/list`, 'GET', {
  289. match: that.info.id,
  290. sign: that.sign.id
  291. })
  292. if (arr.errcode == '0') that.$set(that, `score`, arr.data)
  293. },
  294. // 选择选项卡
  295. tabsChange(e) {
  296. const that = this;
  297. that.$set(that.tabs, `active`, e.active)
  298. },
  299. // 处理时间
  300. getTime(start_time, end_time) {
  301. if (start_time && end_time) {
  302. const start = new Date(start_time);
  303. const end = new Date(end_time);
  304. const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  305. const day = start.getDate();
  306. const weekday = weekdays[start.getDay()];
  307. const month = start.getMonth();
  308. const start_hours = start.getHours();
  309. const start_minutes = start.getMinutes();
  310. const end_hours = end.getHours();
  311. const end_minutes = end.getMinutes();
  312. 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')} `;
  313. }
  314. },
  315. // 修改报名信息
  316. toEdit(item) {
  317. uni.navigateTo({
  318. url: `/pagesMy/activity/add?id=${item.id}`
  319. })
  320. },
  321. // 图片处理
  322. getUrl(e) {
  323. const that = this;
  324. if (e && e.length > 0) return that.$config.serverFile + e[0].url
  325. else return '/static/match.png'
  326. },
  327. // 处理字典表
  328. getDict(item, model) {
  329. const that = this;
  330. let res
  331. if (model == 'status') res = that.statusList.find(i => i.value == item)
  332. else if (model == 'cardType') res = that.typeList.find(i => i.value == item)
  333. if (res) return res.label
  334. else return '暂无'
  335. },
  336. // 处理富文本
  337. formatRichText(html) {
  338. if (html) {
  339. html = html.replace(/<table[^>]*>/gi, match => {
  340. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  341. return match.replace(/style="[^"]+"/gi,
  342. `style="border-collapse: collapse; width: 100%;text-align: center;"`)
  343. .replace(/<table/gi,
  344. `<table style="border-collapse: collapse; width: 100%;text-align: center;"`);
  345. });
  346. html = html.replace(/<th[^>]*>/gi, match => {
  347. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  348. return match.replace(/style="[^"]+"/gi,
  349. `style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  350. )
  351. .replace(/<table/gi,
  352. `<table style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  353. );
  354. });
  355. html = html.replace(/<td[^>]*>/gi, match => {
  356. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  357. return match.replace(/style="[^"]+"/gi,
  358. `style="border: 1px solid #ddd; padding: 8px;text-align: center;"`)
  359. .replace(/<table/gi,
  360. `<table style="border: 1px solid #ddd; padding: 8px;text-align: center;"`);
  361. });
  362. // 富文本内容格式化
  363. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  364. // 查找所有的 img 元素
  365. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  366. '')
  367. // 删除找到的所有 img 元素中的 style 属性
  368. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  369. }
  370. },
  371. }
  372. }
  373. </script>
  374. <style lang="scss" scoped>
  375. .main {
  376. background-color: var(--f9Color);
  377. .one {
  378. .image {
  379. width: 100%;
  380. height: 50vw;
  381. }
  382. }
  383. .two {
  384. padding: 0 2vw;
  385. margin: 0 0 3vw 0;
  386. background-color: var(--mainColor);
  387. .two_1 {
  388. display: flex;
  389. align-items: center;
  390. padding: 3vw 0;
  391. border-bottom: 1px solid var(--f5Color);
  392. font-size: var(--font14Size);
  393. span {
  394. margin: 0 0 0 1vw;
  395. }
  396. .t-icon {
  397. width: var(--font15Size) !important;
  398. height: var(--font15Size) !important;
  399. }
  400. }
  401. .name {
  402. font-weight: bold;
  403. font-size: var(--font16Size);
  404. }
  405. .text_color {
  406. color: var(--f69Color);
  407. }
  408. }
  409. .tabsList {
  410. .list {
  411. background-color: var(--mainColor);
  412. border-bottom: 1px solid var(--f5Color);
  413. margin: 2vw 2vw 0 2vw;
  414. border-radius: 4px;
  415. padding: 3vw;
  416. .value {
  417. display: flex;
  418. align-items: center;
  419. .title {
  420. font-size: var(--font14Size);
  421. font-weight: bold;
  422. }
  423. .label {
  424. font-size: var(--font12Size);
  425. color: var(--f85Color);
  426. }
  427. }
  428. }
  429. .thr {
  430. background-color: var(--mainColor);
  431. .thr_cont {
  432. padding: 2vw 0 0 0;
  433. .thr_1 {
  434. text-indent: 10px;
  435. border-left: 3px solid var(--f3CColor);
  436. font-weight: bold;
  437. font-size: var(--font16Size);
  438. }
  439. .thr_2 {
  440. padding: 2vw;
  441. .thr_label {
  442. display: flex;
  443. justify-content: space-between;
  444. padding: 4vw;
  445. border-bottom: 1px solid var(--f9Color);
  446. font-size: var(--font14Size);
  447. color: var(--f69Color);
  448. .right {
  449. text-align: right;
  450. width: 60vw;
  451. }
  452. }
  453. }
  454. }
  455. .button {
  456. text-align: center;
  457. }
  458. }
  459. }
  460. }
  461. </style>