index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <view class="container main">
  3. <view class="info">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <view class="one">
  7. <image class="image" :src="getUrl(info.file)"></image>
  8. </view>
  9. <view class="two">
  10. <view class="two_1 name">{{info.name||'暂无活动名称'}}</view>
  11. <view class="two_1 text_color">
  12. <text class="t-icon t-icon-shizhong"></text>
  13. <span>{{getTime(info.start_time,info.end_time)||'暂无'}}</span>
  14. </view>
  15. <view class="two_1 text_color">
  16. <text class="t-icon t-icon-gonglve"></text>
  17. <span>{{getDict(info.match_type,'type')||'自办'}}</span>
  18. </view>
  19. <view class="two_1 text_color">
  20. <text class="t-icon t-icon-gongsi"></text>
  21. <span>{{info.work||'暂无组织单位'}}</span>
  22. </view>
  23. </view>
  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" v-if="info.brief">
  99. <view class="thr_cont">
  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 class="thr" v-if="info.form == '3'&&info.match_status == '3' && signList.length > 0">
  107. <view class="thr_cont">
  108. <uni-section title="参演方信息" type="line">
  109. <uni-group mode="card" v-for="(item, index) in signList" :key="index">
  110. <view class="card_title" style="font-weight: bold;">{{ item.name || '暂无' }} </view>
  111. <view class="card_title"> <span>路演名称:</span>{{ item.project_name || '暂无' }} </view>
  112. <view class="card_title"> <span>路演介绍:</span>{{ item.project_brief || '暂无' }} </view>
  113. <view class="card_title" v-if="info.is_show == '0'">
  114. <span>联系方式:</span>{{ item.phone || '暂无' }}
  115. </view>
  116. <view class="card_button" v-else style="text-align: center;margin: 10px 0 0 0;">
  117. <button class="button" size="mini" type="primary"
  118. @tap.stop="toChat(item)">获取联系方式</button>
  119. </view>
  120. </uni-group>
  121. </uni-section>
  122. </view>
  123. </view>
  124. </view>
  125. </scroll-view>
  126. </view>
  127. <view class="foot">
  128. <view class="foot_text foot_1" @tap="toFriend()">分享给好友</view>
  129. <view class="foot_text foot_2" @tap="toSign()">报名活动</view>
  130. </view>
  131. <uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
  132. <view class="popup_cont">
  133. <view class="popup_title">
  134. <text>分享到</text>
  135. </view>
  136. <view class="popup_share">
  137. <view class="share_1">
  138. <button type="primary" plain="true" open-type="share" @click="toShare">
  139. <text class="t-icon t-icon-weixin"></text>
  140. <text>分享给好友</text>
  141. </button>
  142. </view>
  143. <view class="share_1">
  144. <button type="primary" plain="true" open-type="share" @click="toPoster">
  145. <text class="t-icon t-icon-iconfontzhizuobiaozhunbduan36"></text>
  146. <text>生成活动海报</text>
  147. </button>
  148. </view>
  149. </view>
  150. </view>
  151. </uni-popup>
  152. </view>
  153. </template>
  154. <script>
  155. export default {
  156. data() {
  157. return {
  158. id: '',
  159. user: {},
  160. config: {},
  161. info: {},
  162. // 字典表
  163. statusList: [],
  164. typeList: [],
  165. // 参演方
  166. signList: [],
  167. }
  168. },
  169. onLoad: async function(e) {
  170. const that = this;
  171. that.$set(that, `id`, e && e.id || '');
  172. that.searchConfig();
  173. await that.searchOther();
  174. await that.search();
  175. },
  176. onShow: async function() {
  177. const that = this;
  178. that.searchToken();
  179. },
  180. onUnload: function() {
  181. // 页面卸载,重新部署分享内容
  182. const that = this;
  183. if (that.config) {
  184. // 赋值默认值
  185. that.$config.share = {
  186. title: that.config.zhTitle,
  187. path: '/pages/index/index',
  188. imageUrl: that.config?.logoUrl[0]?.url
  189. }
  190. }
  191. },
  192. methods: {
  193. // 用户信息
  194. searchToken() {
  195. const that = this;
  196. try {
  197. const res = uni.getStorageSync('token');
  198. if (res) {
  199. const user = that.$jwt(res);
  200. that.$set(that, `user`, user);
  201. }
  202. } catch (e) {}
  203. },
  204. searchConfig() {
  205. const that = this;
  206. try {
  207. const res = uni.getStorageSync('config');
  208. if (res) that.$set(that, `config`, res);
  209. } catch (e) {}
  210. },
  211. // 查询其他信息
  212. async searchOther() {
  213. const that = this;
  214. let res;
  215. // 查询类型
  216. res = await that.$api(`/dictData`, 'GET', {
  217. code: 'matchStatus',
  218. is_use: '0',
  219. })
  220. if (res.errcode == '0') that.$set(that, `statusList`, res.data);
  221. // 赛事类型
  222. res = await that.$api(`/dictData`, 'GET', {
  223. code: 'activeType',
  224. is_use: '0',
  225. })
  226. if (res.errcode == '0') that.$set(that, `typeList`, res.data)
  227. },
  228. // 查询
  229. async search() {
  230. const that = this;
  231. if (that.id) {
  232. let res;
  233. res = await that.$api(`/match/${that.id}`, 'GET', {})
  234. if (res.errcode == '0') {
  235. that.$set(that, `info`, res.data)
  236. if (res.data.form == '3') {
  237. const arr = await that.$api(`/sign`, 'GET', {
  238. match: res.data.id,
  239. status: '1',
  240. type: '1'
  241. })
  242. if (arr.errcode == '0') that.$set(that, `signList`, arr.data)
  243. }
  244. } else {
  245. uni.showToast({
  246. title: res.errmsg,
  247. });
  248. }
  249. }
  250. },
  251. // 处理时间
  252. getTime(start_time, end_time) {
  253. if (start_time && end_time) {
  254. const start = new Date(start_time);
  255. const end = new Date(end_time);
  256. const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  257. const day = start.getDate();
  258. const weekday = weekdays[start.getDay()];
  259. const month = start.getMonth();
  260. const start_hours = start.getHours();
  261. const start_minutes = start.getMinutes();
  262. const end_hours = end.getHours();
  263. const end_minutes = end.getMinutes();
  264. 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')} `;
  265. }
  266. },
  267. // 处理字典表
  268. getDict(item, model) {
  269. const that = this;
  270. let res
  271. if (model == 'type') res = that.typeList.find(i => i.value == item)
  272. if (res) return res.label
  273. else return '暂无'
  274. },
  275. // 图片处理
  276. getUrl(e) {
  277. const that = this;
  278. if (e && e.length > 0) return that.$config.serverFile + e[0].url
  279. else return '/static/match.png'
  280. },
  281. // 处理富文本
  282. formatRichText(html) {
  283. if (html) {
  284. html = html.replace(/<table[^>]*>/gi, match => {
  285. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  286. return match.replace(/style="[^"]+"/gi,
  287. `style="border-collapse: collapse; width: 100%;text-align: center;"`)
  288. .replace(/<table/gi,
  289. `<table style="border-collapse: collapse; width: 100%;text-align: center;"`);
  290. });
  291. html = html.replace(/<th[^>]*>/gi, match => {
  292. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  293. return match.replace(/style="[^"]+"/gi,
  294. `style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  295. )
  296. .replace(/<table/gi,
  297. `<table style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
  298. );
  299. });
  300. html = html.replace(/<td[^>]*>/gi, match => {
  301. // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
  302. return match.replace(/style="[^"]+"/gi,
  303. `style="border: 1px solid #ddd; padding: 8px;text-align: center;"`)
  304. .replace(/<table/gi,
  305. `<table style="border: 1px solid #ddd; padding: 8px;text-align: center;"`);
  306. });
  307. // 富文本内容格式化
  308. return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
  309. // 查找所有的 img 元素
  310. return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
  311. '')
  312. // 删除找到的所有 img 元素中的 style 属性
  313. }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
  314. }
  315. },
  316. // 分享给好友
  317. toFriend() {
  318. const that = this;
  319. that.$refs.share.open()
  320. },
  321. // 活动报名
  322. toSign() {
  323. const that = this;
  324. if (that.info.match_status == '0') {
  325. uni.showToast({
  326. title: '活动未开始 暂不支持报名!',
  327. icon: 'none'
  328. })
  329. } else if (that.info.match_status == '1') {
  330. if (that.user && that.user.id) {
  331. if (that.info.form == '3') {
  332. uni.navigateTo({
  333. url: `/pagesHome/match/active?id=${that.id}`
  334. })
  335. } else if (that.info.form == '4') {
  336. uni.navigateTo({
  337. url: `/pagesHome/investigate/index?id=${that.id}`
  338. })
  339. } else {
  340. uni.navigateTo({
  341. url: `/pagesHome/match/sign?id=${that.id}`
  342. })
  343. }
  344. } else {
  345. if (that.info.form == '4') {
  346. uni.navigateTo({
  347. url: `/pagesHome/investigate/index?id=${that.id}`
  348. })
  349. } else {
  350. uni.navigateTo({
  351. url: `/pagesHome/login/index`
  352. })
  353. }
  354. }
  355. } else if (that.info.match_status == '2') {
  356. uni.showToast({
  357. title: '活动进行中 暂不支持报名!',
  358. icon: 'none'
  359. })
  360. } else {
  361. uni.showToast({
  362. title: '比赛已结束!',
  363. icon: 'none'
  364. })
  365. }
  366. },
  367. // 分享给好友
  368. toShare() {
  369. const that = this;
  370. let info = that.info;
  371. let imageUrl = that.config?.logoUrl[0]?.url || info.file[0]?.url;
  372. that.$config.share = {
  373. title: info.name,
  374. path: `/pagesHome/match/index?id=${that.id}`,
  375. imageUrl: imageUrl
  376. }
  377. },
  378. // 生成海报
  379. toPoster() {
  380. console.log('生成海报');
  381. },
  382. // 获取联系方式
  383. toChat(item) {
  384. const that = this;
  385. if (that.user.id) {
  386. uni.showModal({
  387. title: '提示',
  388. content: '您确认要获取联系方式?',
  389. success: async function(res) {
  390. if (res.confirm) {
  391. let source_id = item.id
  392. let source = 'sign'
  393. let apply_user = that.user.id
  394. const res = await that.$api(`/contactApply/sign`, 'POST', {
  395. source_id,
  396. source,
  397. apply_user
  398. })
  399. if (res.errcode == 0) {
  400. uni.showToast({
  401. title: '申请获取联系方式成功,等待发送消息',
  402. icon: 'none'
  403. })
  404. } else {
  405. uni.showToast({
  406. title: res.errmsg,
  407. icon: 'none'
  408. })
  409. }
  410. } else if (res.cancel) {
  411. console.log('用户点击取消');
  412. }
  413. }
  414. });
  415. } else {
  416. uni.navigateTo({
  417. url: `/pagesHome/login/index`
  418. })
  419. }
  420. }
  421. }
  422. }
  423. </script>
  424. <style lang="scss" scoped>
  425. .main {
  426. .info {
  427. position: relative;
  428. flex-grow: 1;
  429. background-color: var(--f9Color);
  430. .one {
  431. .image {
  432. width: 100%;
  433. height: 50vw;
  434. }
  435. }
  436. .two {
  437. padding: 0 2vw;
  438. background-color: var(--mainColor);
  439. .two_1 {
  440. display: flex;
  441. align-items: center;
  442. padding: 3vw 0;
  443. border-bottom: 1px solid var(--f5Color);
  444. font-size: var(--font14Size);
  445. span {
  446. margin: 0 0 0 1vw;
  447. }
  448. .t-icon {
  449. width: var(--font15Size) !important;
  450. height: var(--font15Size) !important;
  451. }
  452. }
  453. .name {
  454. font-weight: bold;
  455. font-size: var(--font16Size);
  456. }
  457. .text_color {
  458. color: var(--f69Color);
  459. }
  460. }
  461. .thr {
  462. margin: 3vw 0 0 0;
  463. background-color: var(--mainColor);
  464. .thr_cont {
  465. margin: 2vw 0 0 0;
  466. .thr_1 {
  467. text-indent: 10px;
  468. border-left: 3px solid var(--f3CColor);
  469. font-weight: bold;
  470. font-size: var(--font16Size);
  471. }
  472. .thr_2 {
  473. padding: 2vw;
  474. }
  475. }
  476. }
  477. }
  478. .foot {
  479. width: 100%;
  480. height: 8vh;
  481. overflow: hidden;
  482. display: flex;
  483. align-items: center;
  484. .foot_text {
  485. display: flex;
  486. justify-content: center;
  487. align-items: center;
  488. width: 50%;
  489. height: 100%;
  490. color: var(--mainColor);
  491. }
  492. .foot_1 {
  493. background: linear-gradient(90deg, #FFCD1E, #FF8A18);
  494. }
  495. .foot_2 {
  496. background: linear-gradient(90deg, #1E83FF, #1071e6);
  497. }
  498. }
  499. .popup_cont {
  500. .popup_title {
  501. display: flex;
  502. flex-direction: row;
  503. align-items: center;
  504. justify-content: center;
  505. height: 40px;
  506. font-size: var(--font14Size);
  507. color: #666;
  508. }
  509. .popup_share {
  510. display: flex;
  511. align-items: center;
  512. padding: 2vw 0;
  513. .share_1 {
  514. width: 50%;
  515. button {
  516. background: none;
  517. border: none;
  518. display: flex;
  519. flex-direction: column;
  520. justify-content: center;
  521. align-items: center;
  522. .t-icon {
  523. width: 8vw;
  524. height: 8vw;
  525. }
  526. text {
  527. margin-top: 10px;
  528. font-size: var(--font14Size);
  529. color: #3B4144;
  530. }
  531. }
  532. }
  533. }
  534. }
  535. }
  536. .scroll-view {
  537. position: absolute;
  538. top: 0;
  539. left: 0;
  540. right: 0;
  541. bottom: 0;
  542. .list-scroll-view {
  543. display: flex;
  544. flex-direction: column;
  545. }
  546. }
  547. </style>