123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- <template>
- <view class="container main">
- <view class="info">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list-scroll-view">
- <view class="one">
- <image class="image" :src="getUrl(info.file)"></image>
- </view>
- <view class="two">
- <view class="two_1 name">{{info.name||'暂无活动名称'}}</view>
- <view class="two_1 text_color">
- <text class="t-icon t-icon-shizhong"></text>
- <span>{{getTime(info.start_time,info.end_time)||'暂无'}}</span>
- </view>
- <view class="two_1 text_color">
- <text class="t-icon t-icon-gonglve"></text>
- <span>{{getDict(info.match_type,'type')||'自办'}}</span>
- </view>
- <view class="two_1 text_color">
- <text class="t-icon t-icon-gongsi"></text>
- <span>{{info.work||'暂无组织单位'}}</span>
- </view>
- </view>
- <view class="thr">
- <view class="thr_cont" v-if="info.rules&&info.rules.rules1">
- <view class="thr_1">大赛背景</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules1)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules2">
- <view class="thr_1">大赛主题和目标</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules2)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules3">
- <view class="thr_1">大赛基本情况介绍</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules3)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules4">
- <view class="thr_1">赛题任务</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules4)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules5">
- <view class="thr_1">赛程安排</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules5)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules6">
- <view class="thr_1">赛制阶段</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules6)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules7">
- <view class="thr_1">参赛资格</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules7)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules8">
- <view class="thr_1">参赛报名</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules8)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules9">
- <view class="thr_1">奖项设置与奖励办法</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules9)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules10">
- <view class="thr_1">组织单位</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules10)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules11">
- <view class="thr_1">赛事联络</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules11)"></rich-text>
- </view>
- </view>
- <view class="thr_cont" v-if="info.rules&&info.rules.rules12">
- <view class="thr_1">赛事交流</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.rules.rules12)"></rich-text>
- </view>
- </view>
- </view>
- <view class="thr" v-if="info.brief">
- <view class="thr_cont">
- <view class="thr_1">常见问题</view>
- <view class="thr_2">
- <rich-text :nodes="formatRichText(info.brief)"></rich-text>
- </view>
- </view>
- </view>
- <view class="thr" v-if="info.form == '3'&&info.match_status == '3' && signList.length > 0">
- <view class="thr_cont">
- <uni-section title="参演方信息" type="line">
- <uni-group mode="card" v-for="(item, index) in signList" :key="index">
- <view class="card_title" style="font-weight: bold;">{{ item.name || '暂无' }} </view>
- <view class="card_title"> <span>路演名称:</span>{{ item.project_name || '暂无' }} </view>
- <view class="card_title"> <span>路演介绍:</span>{{ item.project_brief || '暂无' }} </view>
- <view class="card_title" v-if="info.is_show == '0'">
- <span>联系方式:</span>{{ item.phone || '暂无' }}
- </view>
- <view class="card_button" v-else style="text-align: center;margin: 10px 0 0 0;">
- <button class="button" size="mini" type="primary"
- @tap.stop="toChat(item)">获取联系方式</button>
- </view>
- </uni-group>
- </uni-section>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="foot">
- <view class="foot_text foot_1" @tap="toFriend()">分享给好友</view>
- <view class="foot_text foot_2" @tap="toSign()">报名活动</view>
- </view>
- <uni-popup ref="share" type="share" safeArea backgroundColor="#fff">
- <view class="popup_cont">
- <view class="popup_title">
- <text>分享到</text>
- </view>
- <view class="popup_share">
- <view class="share_1">
- <button type="primary" plain="true" open-type="share" @click="toShare">
- <text class="t-icon t-icon-weixin"></text>
- <text>分享给好友</text>
- </button>
- </view>
- <view class="share_1">
- <button type="primary" plain="true" open-type="share" @click="toPoster">
- <text class="t-icon t-icon-iconfontzhizuobiaozhunbduan36"></text>
- <text>生成活动海报</text>
- </button>
- </view>
- </view>
- </view>
- </uni-popup>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- id: '',
- user: {},
- config: {},
- info: {},
- // 字典表
- statusList: [],
- typeList: [],
- // 参演方
- signList: [],
- }
- },
- onLoad: async function(e) {
- const that = this;
- that.$set(that, `id`, e && e.id || '');
- that.searchConfig();
- await that.searchOther();
- await that.search();
- },
- onShow: async function() {
- const that = this;
- that.searchToken();
- },
- onUnload: function() {
- // 页面卸载,重新部署分享内容
- const that = this;
- if (that.config) {
- // 赋值默认值
- that.$config.share = {
- title: that.config.zhTitle,
- path: '/pages/index/index',
- imageUrl: that.config?.logoUrl[0]?.url
- }
- }
- },
- methods: {
- // 用户信息
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) {
- const user = that.$jwt(res);
- that.$set(that, `user`, user);
- }
- } catch (e) {}
- },
- searchConfig() {
- const that = this;
- try {
- const res = uni.getStorageSync('config');
- if (res) that.$set(that, `config`, res);
- } catch (e) {}
- },
- // 查询其他信息
- async searchOther() {
- const that = this;
- let res;
- // 查询类型
- res = await that.$api(`/dictData`, 'GET', {
- code: 'matchStatus',
- is_use: '0',
- })
- if (res.errcode == '0') that.$set(that, `statusList`, res.data);
- // 赛事类型
- res = await that.$api(`/dictData`, 'GET', {
- code: 'activeType',
- is_use: '0',
- })
- if (res.errcode == '0') that.$set(that, `typeList`, res.data)
- },
- // 查询
- async search() {
- const that = this;
- if (that.id) {
- let res;
- res = await that.$api(`/match/${that.id}`, 'GET', {})
- if (res.errcode == '0') {
- that.$set(that, `info`, res.data)
- if (res.data.form == '3') {
- const arr = await that.$api(`/sign`, 'GET', {
- match: res.data.id,
- status: '1',
- type: '1'
- })
- if (arr.errcode == '0') that.$set(that, `signList`, arr.data)
- }
- } else {
- uni.showToast({
- title: res.errmsg,
- });
- }
- }
- },
- // 处理时间
- getTime(start_time, end_time) {
- if (start_time && end_time) {
- const start = new Date(start_time);
- const end = new Date(end_time);
- const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
- const day = start.getDate();
- const weekday = weekdays[start.getDay()];
- const month = start.getMonth();
- const start_hours = start.getHours();
- const start_minutes = start.getMinutes();
- const end_hours = end.getHours();
- const end_minutes = end.getMinutes();
- 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')} `;
- }
- },
- // 处理字典表
- getDict(item, model) {
- const that = this;
- let res
- if (model == 'type') res = that.typeList.find(i => i.value == item)
- if (res) return res.label
- else return '暂无'
- },
- // 图片处理
- getUrl(e) {
- const that = this;
- if (e && e.length > 0) return that.$config.serverFile + e[0].url
- else return '/static/match.png'
- },
- // 处理富文本
- formatRichText(html) {
- if (html) {
- html = html.replace(/<table[^>]*>/gi, match => {
- // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
- return match.replace(/style="[^"]+"/gi,
- `style="border-collapse: collapse; width: 100%;text-align: center;"`)
- .replace(/<table/gi,
- `<table style="border-collapse: collapse; width: 100%;text-align: center;"`);
- });
- html = html.replace(/<th[^>]*>/gi, match => {
- // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
- return match.replace(/style="[^"]+"/gi,
- `style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
- )
- .replace(/<table/gi,
- `<table style="border: 1px solid #ddd; padding: 8px; background-color: #f2f2f2;text-align: center;"`
- );
- });
- html = html.replace(/<td[^>]*>/gi, match => {
- // 如果已有 style 属性,替换为新的样式;如果没有,添加新的 style 属性
- return match.replace(/style="[^"]+"/gi,
- `style="border: 1px solid #ddd; padding: 8px;text-align: center;"`)
- .replace(/<table/gi,
- `<table style="border: 1px solid #ddd; padding: 8px;text-align: center;"`);
- });
- // 富文本内容格式化
- return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
- // 查找所有的 img 元素
- return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
- '')
- // 删除找到的所有 img 元素中的 style 属性
- }).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
- }
- },
- // 分享给好友
- toFriend() {
- const that = this;
- that.$refs.share.open()
- },
- // 活动报名
- toSign() {
- const that = this;
- if (that.info.match_status == '0') {
- uni.showToast({
- title: '活动未开始 暂不支持报名!',
- icon: 'none'
- })
- } else if (that.info.match_status == '1') {
- if (that.user && that.user.id) {
- if (that.info.form == '3') {
- uni.navigateTo({
- url: `/pagesHome/match/active?id=${that.id}`
- })
- } else {
- uni.navigateTo({
- url: `/pagesHome/match/sign?id=${that.id}`
- })
- }
- } else {
- uni.navigateTo({
- url: `/pagesHome/login/index`
- })
- }
- } else if (that.info.match_status == '2') {
- uni.showToast({
- title: '活动进行中 暂不支持报名!',
- icon: 'none'
- })
- } else {
- uni.showToast({
- title: '比赛已结束!',
- icon: 'none'
- })
- }
- },
- // 分享给好友
- toShare() {
- const that = this;
- let info = that.info;
- let imageUrl = that.config?.logoUrl[0]?.url || info.file[0]?.url;
- that.$config.share = {
- title: info.name,
- path: `/pagesHome/match/index?id=${that.id}`,
- imageUrl: imageUrl
- }
- },
- // 生成海报
- toPoster() {
- console.log('生成海报');
- },
- // 获取联系方式
- toChat(item) {
- const that = this;
- if (that.user.id) {
- uni.showModal({
- title: '提示',
- content: '您确认要获取联系方式?',
- success: async function(res) {
- if (res.confirm) {
- let source_id = item.id
- let source = 'sign'
- let apply_user = that.user.id
- const res = await that.$api(`/contactApply/sign`, 'POST', {
- source_id,
- source,
- apply_user
- })
- if (res.errcode == 0) {
- uni.showToast({
- title: '申请获取联系方式成功,等待发送消息',
- icon: 'none'
- })
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- } else {
- uni.navigateTo({
- url: `/pagesHome/login/index`
- })
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- .info {
- position: relative;
- flex-grow: 1;
- background-color: var(--f9Color);
- .one {
- .image {
- width: 100%;
- height: 50vw;
- }
- }
- .two {
- padding: 0 2vw;
- background-color: var(--mainColor);
- .two_1 {
- display: flex;
- align-items: center;
- padding: 3vw 0;
- border-bottom: 1px solid var(--f5Color);
- font-size: var(--font14Size);
- span {
- margin: 0 0 0 1vw;
- }
- .t-icon {
- width: var(--font15Size) !important;
- height: var(--font15Size) !important;
- }
- }
- .name {
- font-weight: bold;
- font-size: var(--font16Size);
- }
- .text_color {
- color: var(--f69Color);
- }
- }
- .thr {
- margin: 3vw 0 0 0;
- background-color: var(--mainColor);
- .thr_cont {
- margin: 2vw 0 0 0;
- .thr_1 {
- text-indent: 10px;
- border-left: 3px solid var(--f3CColor);
- font-weight: bold;
- font-size: var(--font16Size);
- }
- .thr_2 {
- padding: 2vw;
- }
- }
- }
- }
- .foot {
- width: 100%;
- height: 8vh;
- overflow: hidden;
- display: flex;
- align-items: center;
- .foot_text {
- display: flex;
- justify-content: center;
- align-items: center;
- width: 50%;
- height: 100%;
- color: var(--mainColor);
- }
- .foot_1 {
- background: linear-gradient(90deg, #FFCD1E, #FF8A18);
- }
- .foot_2 {
- background: linear-gradient(90deg, #1E83FF, #1071e6);
- }
- }
- .popup_cont {
- .popup_title {
- display: flex;
- flex-direction: row;
- align-items: center;
- justify-content: center;
- height: 40px;
- font-size: var(--font14Size);
- color: #666;
- }
- .popup_share {
- display: flex;
- align-items: center;
- padding: 2vw 0;
- .share_1 {
- width: 50%;
- button {
- background: none;
- border: none;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .t-icon {
- width: 8vw;
- height: 8vw;
- }
- text {
- margin-top: 10px;
- font-size: var(--font14Size);
- color: #3B4144;
- }
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- </style>
|