detail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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-else>
  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)">修改报名信息</button>
  158. </view>
  159. </view>
  160. </view>
  161. </view>
  162. </tabs>
  163. </view>
  164. </template>
  165. <script>
  166. import tabs from '../../components/tabs/index.vue';
  167. export default {
  168. components: {
  169. tabs
  170. },
  171. data() {
  172. return {
  173. id: '',
  174. tabs: {
  175. active: '0',
  176. bgColor: '#ffffff',
  177. menu: [{
  178. title: '活动内容',
  179. active: '0'
  180. }, {
  181. title: '报名信息',
  182. active: '1'
  183. }]
  184. },
  185. user: {},
  186. config: {},
  187. info: {},
  188. sign: {},
  189. // 字典表
  190. statusList: [],
  191. typeList: [],
  192. }
  193. },
  194. onLoad: async function(e) {
  195. const that = this;
  196. that.$set(that, `id`, e && e.id || '');
  197. that.searchConfig();
  198. that.searchToken();
  199. await that.searchOther();
  200. await that.search();
  201. },
  202. methods: {
  203. // 用户信息
  204. searchToken() {
  205. const that = this;
  206. try {
  207. const res = uni.getStorageSync('token');
  208. if (res) {
  209. const user = that.$jwt(res);
  210. that.$set(that, `user`, user);
  211. }
  212. } catch (e) {}
  213. },
  214. searchConfig() {
  215. const that = this;
  216. try {
  217. const res = uni.getStorageSync('config');
  218. if (res) that.$set(that, `config`, res);
  219. } catch (e) {}
  220. },
  221. // 查询其他信息
  222. async searchOther() {
  223. const that = this;
  224. let res;
  225. // 查询状态
  226. res = await that.$api(`/dictData`, 'GET', {
  227. code: 'matchStatus',
  228. is_use: '0',
  229. })
  230. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  231. // 查询证件类型
  232. res = await that.$api(`/dictData`, 'GET', {
  233. code: 'cardType',
  234. is_use: '0',
  235. })
  236. if (res.errcode == '0') that.$set(that, `typeList`, res.data);
  237. },
  238. // 查询
  239. async search() {
  240. const that = this;
  241. if (that.id) {
  242. let res;
  243. res = await that.$api(`/sign/${that.id}`, 'GET', {})
  244. if (res.errcode == '0') {
  245. that.$set(that, `sign`, res.data)
  246. if (res.data.match) {
  247. const arr = await that.$api(`/match/${res.data.match}`, 'GET', {})
  248. if (res.errcode == '0') that.$set(that, `info`, arr.data)
  249. }
  250. } else {
  251. uni.showToast({
  252. title: res.errmsg,
  253. });
  254. }
  255. }
  256. },
  257. // 选择选项卡
  258. tabsChange(e) {
  259. const that = this;
  260. that.$set(that.tabs, `active`, e.active)
  261. },
  262. // 处理时间
  263. getTime(start_time, end_time) {
  264. if (start_time && end_time) {
  265. const start = new Date(start_time);
  266. const end = new Date(end_time);
  267. const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  268. const day = start.getDate();
  269. const weekday = weekdays[start.getDay()];
  270. const month = start.getMonth();
  271. const start_hours = start.getHours();
  272. const start_minutes = start.getMinutes();
  273. const end_hours = end.getHours();
  274. const end_minutes = end.getMinutes();
  275. 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')} `;
  276. }
  277. },
  278. // 修改报名信息
  279. toEdit(item) {
  280. uni.navigateTo({
  281. url: `/pagesMy/activity/add?id=${item.signId}`
  282. })
  283. },
  284. // 图片处理
  285. getUrl(e) {
  286. const that = this;
  287. if (e && e.length > 0) return that.$config.serverFile + e[0].url
  288. else return '/static/match.png'
  289. },
  290. // 处理字典表
  291. getDict(item, model) {
  292. const that = this;
  293. let res
  294. if (model == 'status') res = that.statusList.find(i => i.value == item)
  295. else if (model == 'cardType') res = that.typeList.find(i => i.value == item)
  296. if (res) return res.label
  297. else return '暂无'
  298. },
  299. // 处理富文本
  300. formatRichText(html) {
  301. if (html) {
  302. html = html.replace(/<table[^>]*>/gi, match => {
  303. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  304. return match.replace(/style="[^"]+"/gi,
  305. `style="border-collapse: collapse; width: 100%;text-align: center;"`)
  306. .replace(/<table/gi,
  307. `<table style="border-collapse: collapse; width: 100%;text-align: center;"`);
  308. });
  309. html = html.replace(/<th[^>]*>/gi, match => {
  310. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  311. return match.replace(/style="[^"]+"/gi,
  312. `style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  313. )
  314. .replace(/<table/gi,
  315. `<table style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  316. );
  317. });
  318. html = html.replace(/<td[^>]*>/gi, match => {
  319. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  320. return match.replace(/style="[^"]+"/gi,
  321. `style="border: 1px solid #ddd; padding: 8px;text-align: center;"`)
  322. .replace(/<table/gi,
  323. `<table style="border: 1px solid #ddd; padding: 8px;text-align: center;"`);
  324. });
  325. // 富文本内容格式化
  326. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  327. // 查找所有的 img 元素
  328. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  329. '')
  330. // 删除找到的所有 img 元素中的 style 属性
  331. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  332. }
  333. },
  334. }
  335. }
  336. </script>
  337. <style lang="scss" scoped>
  338. .main {
  339. background-color: var(--f9Color);
  340. .one {
  341. .image {
  342. width: 100%;
  343. height: 50vw;
  344. }
  345. }
  346. .two {
  347. padding: 0 2vw;
  348. margin: 0 0 3vw 0;
  349. background-color: var(--mainColor);
  350. .two_1 {
  351. display: flex;
  352. align-items: center;
  353. padding: 3vw 0;
  354. border-bottom: 1px solid var(--f5Color);
  355. font-size: var(--font14Size);
  356. span {
  357. margin: 0 0 0 1vw;
  358. }
  359. .t-icon {
  360. width: var(--font15Size) !important;
  361. height: var(--font15Size) !important;
  362. }
  363. }
  364. .name {
  365. font-weight: bold;
  366. font-size: var(--font16Size);
  367. }
  368. .text_color {
  369. color: var(--f69Color);
  370. }
  371. }
  372. .tabsList {
  373. .thr {
  374. background-color: var(--mainColor);
  375. .thr_cont {
  376. padding: 2vw 0 0 0;
  377. .thr_1 {
  378. text-indent: 10px;
  379. border-left: 3px solid var(--f3CColor);
  380. font-weight: bold;
  381. font-size: var(--font16Size);
  382. }
  383. .thr_2 {
  384. padding: 2vw;
  385. .thr_label {
  386. display: flex;
  387. justify-content: space-between;
  388. padding: 4vw;
  389. border-bottom: 1px solid var(--f9Color);
  390. font-size: var(--font14Size);
  391. color: var(--f69Color);
  392. .right {
  393. text-align: right;
  394. width: 60vw;
  395. }
  396. }
  397. }
  398. }
  399. .button {
  400. text-align: center;
  401. }
  402. }
  403. }
  404. }
  405. </style>