detail.vue 12 KB

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