<template> <!-- 教研室详情 --> <view class="activityDetailNew"> <statusBar :item="navbar"></statusBar> <!-- 消息提示 --> <msgPop></msgPop> <view class="top"> <image class="img1" src="https://teacherapi.cocorobo.cn/teaching-file/static/yym/Rectangle25.png" mode="widthFix"> </image> <image class="img2" src="../../static/Dropdown.png" mode="widthFix"></image> </view> <view class="decontent"> <view class="actit"> {{actItemList.acName}} </view> <view class="footer"> <view class=""> {{actItemList.create_at}} </view> <view class=""> 阅读量:{{actItemList.views}} </view> </view> <view class="avaList"> <view class="ava" @click="gotoMorePer"> <u-avatar-group :urls="applyUserlist" maxCount='6' showMore size="35" :extraValue='applyUserlist.length' gap="0.4"></u-avatar-group> <text style="font-size: 24rpx;font-weight: 400;color:rgba(0, 0, 0, 0.6);margin-left: 20rpx;">{{!applyUserlist.length?'暂无报名':'已报名'}}</text> </view> <view class="cost"> ¥<text style="font-size: 48rpx;">{{actItemList.cost}}</text> </view> </view> <view class="acinfo"> <view class="acinfoAddress"> <view class="acinfoTit"> <text>时</text> <text>间</text> </view>: <text class="inf">{{actItemList.begin_at}}</text> </view> <!-- <view class="acinfoAddress"> 地点:<text class="inf">{{actItemList.address}}</text> </view> --> <!-- <view class=""> 主办单位:<text class="inf">暂无字段</text> </view> --> <view class="acinfoAddress"> <view class="acinfoTit"> <text>活</text> <text>动</text> <text>形</text> <text>式</text> </view>: <text style="color:rgba(0, 86, 168, 1) ;">{{actItemList.acshape}}</text> </view> </view> <!-- 活动介绍 --> <view class="acbrief"> <view class="britit"> 活动介绍 </view> <!-- <web-view :src="actItemList.link" webview-styles="{'height': '700rpx';}"></web-view> --> <!-- <br /> --> <view class="bricon"> <!-- <rich-text :nodes="">{{actItemList.brief}}</rich-text> --> <rich-text :nodes="actItemList.brief"></rich-text> <!-- <view style="color: blue;display: inline-block;" :data-link="actItemList.link" @click="gotoLink"> <u-icon name="arrow-right" labelSize='14' size='14' labelColor='blue' space='2' color='blue' labelPos='left' label='查看更多'></u-icon> </view> --> </view> <!-- <image class="briImg" :src="actItemList.pic" mode="widthFix"></image> --> </view> </view> <!-- 按钮 --> <view class="btnBlock"> <view class="icos"> <view class="ico"> <view class="imgBlock" @click="coll"> <image class="icoimg" :src="collArr.includes(actItemList.acId) ? pic_coll2 : '../../static/Starhhh.png'" mode="aspectFill"></image> </view> <text class="icotxt">收藏</text> </view> <!-- <view class="ico" style="position: relative;" @click="share"> --> <view class="ico" style="position: relative;"> <view class="imgBlock"> <image class="icoimg" style="height: 70%;width: 65%;" src="../../static/union.png" mode="aspectFill"></image> </view> <button open-type="share" style="background-color: aquamarine;opacity: 0; position: absolute;left: 0;width: 100%;height: 100%;"></button> <text class="icotxt">分享</text> </view> </view> <view class="rightBtn"> <view class="btnt1" v-if="actItemList.openid==oid">本人创建,暂不支持加入</view> <view class="btnt" v-else-if="!isSign" @click="applyAdd">立即报名</view> <view class="btnt1" v-else-if="isSign">已报名</view> <view class="btnt1" v-else-if="actItemList.bnum>=actItemList.pers">人数已满</view> <!-- <view class="btnt1" v-else-if="isSign && actItemList.openid!=oid">已报名</view> --> </view> </view> <!-- 弹窗 --> <view> <view class="mask" v-show="showPopup" @click="showPopup = false"></view> <view class="popup-container" v-show="showPopup"> <view class="popup"> <view class="header"> <text>确认报名</text> </view> <view class="footer"> <view class="cancel-btn" @click="showPopup=false">取消</view> <view class="confirm-btn" @click="conf">确认</view> </view> </view> </view> </view> <view class="" style="height: 170rpx;width: 750rpx;"> <!-- 占位的 --> </view> </view> </template> <script> export default { data() { return { navbar: { title: '活动详情', btn: 1 }, // 用户openid oid: '', // 活动id acId: '', // 页面数据 actItemList: {}, // 用户收藏列表 collArr: [], // 用户订阅列表 // subArr: [], // 收藏按钮节流 stopTimer: 0, //控制弹窗 showPopup: false, // 是否已加入 isSign: 0, // 报名列表 applyUserlist: [], pic_coll2: 'https://teacherapi.cocorobo.cn/teaching-file/static/mine/Collect_yellow.png', nodes: [{ name: 'div', attrs: { class: 'div-class', style: 'line-height: 60px; color: red; text-align:center;' }, children: [{ type: 'text', text: 'Hello uni-app!' }] }], strings: '<div style="text-align:center;"><img src="https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni@2x.png"/></div>' // pic_sub: 'https://teacherapi.cocorobo.cn/teaching-file/static/yym/Vector (Stroke) (1).png', // pic_sub2: 'https://teacherapi.cocorobo.cn/teaching-file/static/dingyue_blue.png', }; }, // 分享 onShareAppMessage() { uni.share({ provider: "weixin", scene: "WXSceneSession", type: 1, summary: "我正在使用HBuilderX开发uni-app,赶紧跟我一起来体验!", success: function(res) { console.log("success:" + JSON.stringify(res)); }, fail: function(err) { console.log("fail:" + JSON.stringify(err)); } }); }, // onUnload() { // this.$store.dispatch('asyncDelAll') // }, methods: { //跳转到第三方链接 gotoLink(e) { let link = e.currentTarget.dataset.link; uni.navigateTo({ url: "/pages/skipone/skipone?url=" + encodeURIComponent(link), }); }, share() { // onShareAppMessage() { uni.showToast({ title: '暂未开发,还不能分享哦', icon: 'none' }) }, // 获取页面数据 getdata() { let data = { oid: this.$store.state.user.openid, acId: this.acId, } this.$request('/selectActivityID', "POST", data).then(res => { console.log('页面数据', res[0][0]); this.actItemList = res[0][0] }) }, // 申请加入 applyAdd() { // console.log('报名'); this.showPopup = true }, // 确认操作 conf() { // this.showPopup = false; // this.showPopupConfirm = true // 做最后判断防止同一时间进入报名页面都报名成功 this.$request('/selectIntercept', "POST", { oid: this.$store.state.user.openid, acid: this.acId }).then(res => { let c = res[0][0] console.log('报名人数', res[0][0]); console.log(c.bnum >= c.pers * 1); if (c.bnum >= c.pers * 1) { return uni.showToast({ title: '已有人先您一步报名,名额已满', icon: "none" }) } else { let data = { oid: this.$store.state.user.openid, //用户id acid: this.acId, ty: 2, } this.$request('/insertSignup', "POST", data).then(res => { console.log('报名返回', res); // 添加消息页面系统通知提示报名成功 this.addMessage() // 弹窗关闭 this.showPopup = false uni.reLaunch({ url: '/pages/Sign/Sign', }) }) } }) }, // 添加消息页面系统通知提示报名成功 addMessage() { let data = { oid: this.$store.state.user.openid, acid: this.acId, type: 0, } this.$request('/insertMessage', "POST", data).then(res => { console.log('添加消息页面系统通知提示报名成功', res); }) }, // 查看更多报名同学 gotoMorePer() { uni.navigateTo({ url: `/pages/dy/dy?acId=${this.acId}` }) }, //获取是否报名 btnEnroll() { let data = { oid: this.$store.state.user.openid, //用户id aid: this.acId, type: 2 } this.$request('/selectSignup', 'POST', data).then(res => { // console.log('获取报名', res[0][0]); this.isSign = res[0][0].num }) }, // 收藏事件 coll() { // this.stopTimer=0 if (this.stopTimer) return uni.showToast({ icon: 'none', title: '点击过快' }) this.stopTimer = 1 setTimeout(() => { this.stopTimer = 0 }, 500) //判断是否收藏 let iscoll = null // 查询是否收藏过 let data = { acid: this.acId, oid: this.$store.state.user.openid, //用户id ty: 0 } this.$request('/selectOneOperator', 'POST', data).then(res => { // console.log('查询是否收藏过',res); res[0].length ? iscoll = true : iscoll = false; // iscoll为true表示已经收藏过,执行删除 为true则收藏 if (iscoll) { this.$store.dispatch('asyncUpdatemsg', { collAoff: 0 }) console.log('执行删除'); this.$request('/deleteOperator', 'POST', data).then(res => { // console.log(res); this.getColl() setTimeout(() => { this.$store.dispatch('asyncDelMsg') }, 1500) }) } else { this.$store.dispatch('asyncUpdatemsg', { collAoff: 1 }) console.log('执行添加'); this.$request('/insertOperator', 'POST', data).then(res => { // console.log(res); this.getColl() setTimeout(() => { this.$store.dispatch('asyncDelMsg') }, 1500) }) } }) }, //获取是否收藏 getColl() { let data = { oid: this.$store.state.user.openid, //用户id type: 0 } this.$request('/selectOperator', 'POST', data).then(res => { // console.log('获取收藏', res); // 每次调用前清零,防止push叠加错误 this.collArr = [] // 将acid遍历到collArr中 res[0].forEach(i => { this.collArr.push(i.acId) }) }) }, // 获取报名用户 getUsers() { let data = { oid: this.$store.state.user.openid, //用户id aid: this.acId, type: 2, page: 1, //下拉获取更多的备用字段 lim: 6 //一次获取多少数据 } this.$request('/selectApplyUser', 'POST', data).then(res => { console.log('获取报名用户列表', res[0]); res[0].forEach(e => { this.applyUserlist.push(e.avatar) }) // this.applyUserlist = res[0] }) } }, onLoad(e) { // this.stopTimer=0 // console.log('接收参数',e); this.acId = e.acId this.oid = this.$store.state.user.openid // 获取是否报名 this.btnEnroll() // WebviewObject plus.webview.create( url, id, styles, extras ); // this.getActivity() // 获取页面数据 this.getdata() // 获取是否收藏 this.getColl() // 获取是否订阅 // this.getSub() // 获取报名人名单 this.getUsers() } } </script> <style lang="scss"> .activityDetailNew { background-color: #fff; .top { width: 750rpx; position: relative; .img1 { display: block; margin: auto; width: 750rpx; } .img2 { position: absolute; width: 100%; left: 0; bottom: 0; } } .decontent { width: 750rpx; border-top-right-radius: 30rpx; border-top-left-radius: 30rpx; background-color: #fff; padding: 32rpx; display: flex; flex-direction: column; justify-content: flex-start; border-bottom: 1rpx rgba(231, 231, 231, 1) solid; .actit { font-weight: 600; font-size: 40rpx; color: rgba(0, 0, 0, 0.8); line-height: 56rpx; display: -webkit-box; word-break: break-all; text-overflow: ellipsis; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; } .footer { display: flex; justify-content: space-between; color: rgba(0, 0, 0, 0.4); font-size: 24rpx; // height: 32rpx; // line-height: 32rpx; font-weight: 400; padding: 20rpx 0; padding-bottom: 0; } .avaList { display: flex; justify-content: space-between; width: 100%; align-items: center; padding: 30rpx 0; border-bottom: 1rpx rgba(231, 231, 231, 1) solid; margin-bottom: 20rpx; .ava { width: 353rpx; display: flex; align-items: center; } .cost { flex: 1; text-align: right; font-weight: 700; font-size: 40rpx; color: rgba(246, 135, 23, 1); } } .acinfo { width: 100%; display: flex; flex-direction: column; justify-content: space-between; font-size: 28rpx; font-weight: 400; color: rgba(0, 0, 0, 0.6); border-bottom: 1rpx rgba(231, 231, 231, 1) solid; // padding-bottom: 30rpx; .acinfoAddress { // padding: 20rpx 0; display: flex; padding-bottom: 20rpx; .acinfoTit { width: 150rpx; display: flex; justify-content: space-between; // text-align: justify; .justified-text { text-align: justify; text-justify: inter-word; /* 兼容性写法,用于处理中英文混排时的对齐效果 */ } } } .inf { color: rgba(0, 0, 0, 0.8); } } .acbrief { width: 100%; .britit { width: 100%; height: 48rpx; font-weight: 600; line-height: 48rpx; font-size: 32rpx; color: rgba(0, 0, 0, 0.8); margin: 30rpx 0; } .bricon { font-weight: 400; font-size: 28rpx; line-height: 44rpx; color: (0, 0, 0, 0.8); margin-bottom: 30rpx; } .briImg { width: 100%; } } } .btnBlock { position: fixed; bottom: 0; left: 0; width: 750rpx; height: 175rpx; background-color: #fff; display: flex; justify-content: flex-start; align-items: center; padding: 30rpx 30rpx; padding-bottom: 40rpx; border-top: 1rpx rgba(231, 231, 231, 1) solid; // padding-bottom: 78rpx; .icos { width: 200rpx; height: 96rpx; flex-shrink: 0; margin-right: 30rpx; display: flex; justify-content: space-between; .ico { width: 100rpx; display: flex; flex-direction: column; justify-content: space-between; align-items: center; .imgBlock { width: 48rpx; height: 48rpx; display: flex; align-items: center; justify-content: center; .icoimg { width: 42rpx; height: 40rpx; } } .icotxt { font-size: 24rpx; height: 40rpx; line-height: 40rpx; color: rgba(4, 0, 0, 1); } } } .rightBtn { flex: 1; display: flex; justify-content: center; align-items: center; .btnt { width: 454rpx; color: #fff; // font-weight: 600; height: 96rpx; background-color: rgba(0, 86, 168, 1); display: flex; justify-content: center; align-items: center; border-radius: 10rpx; } .btnt1 { width: 454rpx; color: #fff; // font-weight: 600; height: 96rpx; background-color: rgba(139, 190, 255, 1); display: flex; justify-content: center; align-items: center; border-radius: 10rpx; } } } } </style>