index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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 {
  336. uni.navigateTo({
  337. url: `/pagesHome/match/sign?id=${that.id}`
  338. })
  339. }
  340. } else {
  341. uni.navigateTo({
  342. url: `/pagesHome/login/index`
  343. })
  344. }
  345. } else if (that.info.match_status == '2') {
  346. uni.showToast({
  347. title: '活动进行中 暂不支持报名!',
  348. icon: 'none'
  349. })
  350. } else {
  351. uni.showToast({
  352. title: '比赛已结束!',
  353. icon: 'none'
  354. })
  355. }
  356. },
  357. // 分享给好友
  358. toShare() {
  359. const that = this;
  360. let info = that.info;
  361. let imageUrl = that.config?.logoUrl[0]?.url || info.file[0]?.url;
  362. that.$config.share = {
  363. title: info.name,
  364. path: `/pagesHome/match/index?id=${that.id}`,
  365. imageUrl: imageUrl
  366. }
  367. },
  368. // 生成海报
  369. toPoster() {
  370. console.log('生成海报');
  371. },
  372. // 获取联系方式
  373. toChat(item) {
  374. const that = this;
  375. if (that.user.id) {
  376. uni.showModal({
  377. title: '提示',
  378. content: '您确认要获取联系方式?',
  379. success: async function(res) {
  380. if (res.confirm) {
  381. let source_id = item.id
  382. let source = 'sign'
  383. let apply_user = that.user.id
  384. const res = await that.$api(`/contactApply/sign`, 'POST', {
  385. source_id,
  386. source,
  387. apply_user
  388. })
  389. if (res.errcode == 0) {
  390. uni.showToast({
  391. title: '申请获取联系方式成功,等待发送消息',
  392. icon: 'none'
  393. })
  394. } else {
  395. uni.showToast({
  396. title: res.errmsg,
  397. icon: 'none'
  398. })
  399. }
  400. } else if (res.cancel) {
  401. console.log('用户点击取消');
  402. }
  403. }
  404. });
  405. } else {
  406. uni.navigateTo({
  407. url: `/pagesHome/login/index`
  408. })
  409. }
  410. }
  411. }
  412. }
  413. </script>
  414. <style lang="scss" scoped>
  415. .main {
  416. .info {
  417. position: relative;
  418. flex-grow: 1;
  419. background-color: var(--f9Color);
  420. .one {
  421. .image {
  422. width: 100%;
  423. height: 50vw;
  424. }
  425. }
  426. .two {
  427. padding: 0 2vw;
  428. background-color: var(--mainColor);
  429. .two_1 {
  430. display: flex;
  431. align-items: center;
  432. padding: 3vw 0;
  433. border-bottom: 1px solid var(--f5Color);
  434. font-size: var(--font14Size);
  435. span {
  436. margin: 0 0 0 1vw;
  437. }
  438. .t-icon {
  439. width: var(--font15Size) !important;
  440. height: var(--font15Size) !important;
  441. }
  442. }
  443. .name {
  444. font-weight: bold;
  445. font-size: var(--font16Size);
  446. }
  447. .text_color {
  448. color: var(--f69Color);
  449. }
  450. }
  451. .thr {
  452. margin: 3vw 0 0 0;
  453. background-color: var(--mainColor);
  454. .thr_cont {
  455. margin: 2vw 0 0 0;
  456. .thr_1 {
  457. text-indent: 10px;
  458. border-left: 3px solid var(--f3CColor);
  459. font-weight: bold;
  460. font-size: var(--font16Size);
  461. }
  462. .thr_2 {
  463. padding: 2vw;
  464. }
  465. }
  466. }
  467. }
  468. .foot {
  469. width: 100%;
  470. height: 8vh;
  471. overflow: hidden;
  472. display: flex;
  473. align-items: center;
  474. .foot_text {
  475. display: flex;
  476. justify-content: center;
  477. align-items: center;
  478. width: 50%;
  479. height: 100%;
  480. color: var(--mainColor);
  481. }
  482. .foot_1 {
  483. background: linear-gradient(90deg, #FFCD1E, #FF8A18);
  484. }
  485. .foot_2 {
  486. background: linear-gradient(90deg, #1E83FF, #1071e6);
  487. }
  488. }
  489. .popup_cont {
  490. .popup_title {
  491. display: flex;
  492. flex-direction: row;
  493. align-items: center;
  494. justify-content: center;
  495. height: 40px;
  496. font-size: var(--font14Size);
  497. color: #666;
  498. }
  499. .popup_share {
  500. display: flex;
  501. align-items: center;
  502. padding: 2vw 0;
  503. .share_1 {
  504. width: 50%;
  505. button {
  506. background: none;
  507. border: none;
  508. display: flex;
  509. flex-direction: column;
  510. justify-content: center;
  511. align-items: center;
  512. .t-icon {
  513. width: 8vw;
  514. height: 8vw;
  515. }
  516. text {
  517. margin-top: 10px;
  518. font-size: var(--font14Size);
  519. color: #3B4144;
  520. }
  521. }
  522. }
  523. }
  524. }
  525. }
  526. .scroll-view {
  527. position: absolute;
  528. top: 0;
  529. left: 0;
  530. right: 0;
  531. bottom: 0;
  532. .list-scroll-view {
  533. display: flex;
  534. flex-direction: column;
  535. }
  536. }
  537. </style>