detail.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <view class="activity-detail" v-if="info">
  3. <view
  4. class="top-wrap"
  5. :style="'background-image:url(' + info.speakerBackgroundPic + ')'"
  6. >
  7. <view class="status status-before" v-if="info.activityState === 1"
  8. >未开始</view
  9. >
  10. <view class="status status-before" v-if="info.activityState === 2"
  11. >进行中</view
  12. >
  13. <view class="status status-before" v-if="info.activityState === 3"
  14. >已结束</view
  15. >
  16. <view class="title">{{ info.activityTypeName }}</view>
  17. <view class="name">主讲人:{{ info.speaker }}</view>
  18. <view class="time"
  19. >活动时间:{{
  20. info.startTime | formatActivityTime(info.endTime)
  21. }}</view
  22. >
  23. <view class="flex city" v-if="info.city">
  24. <image src="./static/position.png" model="aspectFill"></image>
  25. <text>{{ info.city }}</text>
  26. </view>
  27. </view>
  28. <view class="intro-wrap">{{ info.reportName?info.reportName.split('】')[1]:info.activityName }}</view>
  29. <!-- 音频 -->
  30. <view class="audio-wrap" v-if="info.activityState === 3">
  31. <view
  32. class="audio-item"
  33. v-for="(item,index) in audioList"
  34. :key="item.voiceUrl"
  35. >
  36. <image
  37. class="icon"
  38. :src="(activeAudioUrl==item.voiceUrl&&item.playStatus)?'./static/audio-doing.png':'./static/audio-play.png'"
  39. model="aspectFill"
  40. @click="handlePlayAudio(item)">
  41. </image>
  42. <view class="name">{{ item.voiceName }}</view>
  43. <view class="time">{{activeAudioUrl==item.voiceUrl?activeAudioTime:0|formarVoiceTime}} / {{ item.voicePlaySeconds|formarVoiceTime }}</view>
  44. <slider
  45. class="audio-slider"
  46. activeColor="#e3b377"
  47. :max="item.voicePlaySeconds"
  48. :value="activeAudioUrl==item.voiceUrl?activeAudioTime:0"
  49. @change="handleAudioSliderChange($event,item)"
  50. block-size="20"
  51. />
  52. </view>
  53. </view>
  54. <view class="info-wrap">
  55. <view
  56. class="flex item"
  57. v-for="item in infoList"
  58. :key="item.label"
  59. @click="handleClickInfoItem(item)"
  60. >
  61. <view class="label">{{ item.label }}:</view>
  62. <view :class="['content', item.color && 'yellow-color',item.type=='copy'&&'link']">
  63. {{item.text}}
  64. </view>
  65. <view class="copy-btn" v-if="item.type == 'copy'" @click="handleCopyLink(item.text)">复制链接</view>
  66. </view>
  67. </view>
  68. <!-- 报告链接 -->
  69. <view class="info-wrap" v-if="info.reportLink">
  70. <view class="flex item" @click="handleOpenReport">
  71. <view class="label">相关报告:</view>
  72. <view class="yellow-color">查看报告链接</view>
  73. </view>
  74. </view>
  75. <view class="btn-wrap" v-if="info.activityState === 1">
  76. <view
  77. :class="[info.registerState == 1?'global-btn-disable':'global-btn-yellow-change' ,'btn']"
  78. v-if="info.firstActivityTypeId === 3"
  79. @click="handleSetRegister"
  80. >{{
  81. info.registerState == 0
  82. ? "报名线下参会"
  83. : "取消报名线下参会"
  84. }}({{ info.registeredNum>info.limitPeopleNum?info.limitPeopleNum:info.registeredNum }}/{{ info.limitPeopleNum }})</view
  85. >
  86. <view
  87. :class="[
  88. info.hasRemind == 1
  89. ? 'global-btn-disable'
  90. : 'global-btn-yellow-change',
  91. 'btn',
  92. ]"
  93. @click="handleSetRemind"
  94. >{{ info.hasRemind == 1 ? "取消会议提醒" : "会议提醒" }}</view
  95. >
  96. <p class="tips">(会前15分钟推送微信消息提醒)</p>
  97. </view>
  98. <!-- 弹窗 -->
  99. <van-popup :show="pupData.show" @close="pupData.show = false" :close-on-click-overlay="false">
  100. <view class="global-pup">
  101. <view class="content">
  102. <rich-text :nodes="pupData.content"></rich-text>
  103. </view>
  104. <view class="flex bot" v-if="pupData.type == 'contact'">
  105. <view @click="pupData.show = false" style="color: #a9afb8">取消</view>
  106. <view @click="handleCallPhone(pupData.mobile)">拨号</view>
  107. </view>
  108. <view class="flex bot" v-else-if="pupData.type == 'apply'">
  109. <view @click="pupData.show = false" style="color: #a9afb8">取消</view>
  110. <view @click="handleApply">立即申请</view>
  111. </view>
  112. <view class="flex bot" v-else>
  113. <view @click="pupData.show = false">知道了</view>
  114. </view>
  115. </view>
  116. </van-popup>
  117. </view>
  118. </template>
  119. <script>
  120. // 活动详情
  121. import {
  122. apiActivityDetail,
  123. apiActivityAudios,
  124. apiActivityAddRemind,
  125. apiActivityCancelRemind,
  126. apiActivityRegister,
  127. apiActivityCancelRegister
  128. } from "@/api/activity";
  129. import {baseApiUrl} from '@/utils/config.js'
  130. export default {
  131. name: "ActivityDetail",
  132. filters:{
  133. formarVoiceTime(e){
  134. let minus=parseInt(e/60)
  135. let sec=e%60
  136. return `${minus}:${sec>9?sec:'0'+sec}`
  137. }
  138. },
  139. data() {
  140. return {
  141. id: 0, //活动id
  142. infoList: [],
  143. info: null,
  144. audioList: [], //音频数据
  145. activeAudioUrl:'',//正在播放的背景音频地址
  146. activeAudioTime:0,//
  147. pupData: {
  148. show: false,
  149. content: "", //弹窗html字符串
  150. type: "",
  151. mobile: "",
  152. },
  153. };
  154. },
  155. onLoad(options) {
  156. this.id = options.id;
  157. this.getDetail();
  158. this.getAudios()
  159. },
  160. onUnload(){
  161. this.handleSaveAudioMsg()
  162. },
  163. onShareAppMessage() {
  164. let title=''
  165. if(this.info.firstActivityTypeId==1){
  166. title=this.info.reportName.split('】')[1]||this.info.activityName
  167. }else{
  168. title=this.info.activityName
  169. }
  170. const token=uni.getStorageSync('token')
  171. let imgUrl=baseApiUrl+`/activity/getActivityShareImg?activity_id=${this.id}`
  172. return {
  173. title: title,
  174. imageUrl:imgUrl
  175. }
  176. },
  177. methods: {
  178. async getDetail() {
  179. const res = await apiActivityDetail({ activity_id: Number(this.id) });
  180. // 无权限
  181. if (res.code === 403) {
  182. uni.redirectTo({
  183. url: "/pages-activity/noAuthority?data=" + JSON.stringify(res.data),
  184. });
  185. return;
  186. }
  187. if (res.code === 200) {
  188. this.info = res.data;
  189. let arr = [
  190. {
  191. label: "大陆拨号",
  192. text: res.data.mainlandTel,
  193. color: "yellow",
  194. type: "tel",
  195. },
  196. {
  197. label: "香港拨入",
  198. text: res.data.hongKongTel,
  199. color: "yellow",
  200. type: "tel",
  201. },
  202. {
  203. label: "台湾拨入",
  204. text: res.data.taiwanTel,
  205. color: "yellow",
  206. type: "tel",
  207. },
  208. {
  209. label: "新加坡拨入",
  210. text: res.data.singaporeTel,
  211. color: "yellow",
  212. type: "tel",
  213. },
  214. {
  215. label: "美国拨入",
  216. text: res.data.americaTel,
  217. color: "yellow",
  218. type: "tel",
  219. },
  220. {
  221. label: "拨入密码",
  222. text: res.data.participationCode,
  223. },
  224. ];
  225. this.infoList = arr.filter((item) => {
  226. return item.text;
  227. });
  228. // 研究员线下沙龙
  229. if (res.data.firstActivityTypeId === 3) {
  230. // this.infoList.push({label: "活动地址",text: res.data.city + res.data.address})
  231. if(res.data.linkParticipants){
  232. this.infoList.push({label: "网络参会",text: res.data.linkParticipants,color: "yellow",type: "copy"})
  233. }
  234. }
  235. }
  236. },
  237. // 获取活动音频
  238. async getAudios() {
  239. const res = await apiActivityAudios({ activity_id: Number(this.id) });
  240. if (res.code === 200&&res.data) {
  241. const audioPlayPaused=this.globalBgMusic.paused// true 当前没有音频在播放
  242. if(audioPlayPaused===false){// 当前有音频在播放
  243. this.activeAudioUrl=uni.getStorageSync('activityAudioUrl')
  244. }
  245. console.log('是否有音频在播放',audioPlayPaused===false);
  246. this.audioList = res.data.map(item=>{
  247. let obj={...item,playStatus:false}
  248. if(audioPlayPaused===false){
  249. if(item.voiceUrl==this.globalBgMusic.src){
  250. obj.playStatus=true
  251. }
  252. }
  253. return obj
  254. });
  255. if(audioPlayPaused===false){
  256. this.activeAudioTime=this.globalBgMusic.currentTime
  257. this.globalBgMusic.onTimeUpdate(()=>{
  258. this.activeAudioTime=parseInt(this.globalBgMusic.currentTime)
  259. })
  260. }
  261. }
  262. },
  263. // 播放音频
  264. handlePlayAudio(e){
  265. if(this.globalBgMusic.src==e.voiceUrl&&e.playStatus){// 同一个音频 并且是播放状态 则暂停
  266. console.log('同一个音频 并且是播放状态 则暂停');
  267. console.log('音频实例',this.globalBgMusic.src);
  268. this.globalBgMusic.pause()
  269. }else if(this.globalBgMusic.src==e.voiceUrl&&!e.playStatus){//同一个音频 并且是暂停状态 则直接播放
  270. console.log('同一个音频 并且是暂停状态 则直接播放');
  271. console.log('音频实例',this.globalBgMusic.src);
  272. this.globalBgMusic.play()
  273. }else{
  274. this.globalBgMusic.title=e.voiceName
  275. this.globalBgMusic.src=e.voiceUrl
  276. this.activeAudioUrl=e.voiceUrl
  277. this.activeAudioTime=0
  278. }
  279. this.globalBgMusic.onCanplay(()=>{
  280. console.log('onCanplay');
  281. this.globalBgMusic.play()
  282. })
  283. this.globalBgMusic.onPlay(()=>{
  284. console.log('onplay');
  285. e.playStatus=true
  286. })
  287. this.globalBgMusic.onPause(()=>{
  288. console.log('onPause');
  289. e.playStatus=false
  290. })
  291. this.globalBgMusic.onStop(()=>{
  292. console.log('onStop');
  293. e.playStatus=false
  294. this.activeAudioTime=0
  295. })
  296. this.globalBgMusic.onEnded(()=>{
  297. console.log('onEnded');
  298. e.playStatus=false
  299. this.activeAudioTime=0
  300. })
  301. this.globalBgMusic.onError((e)=>{
  302. console.log('onError',e);
  303. })
  304. this.globalBgMusic.onTimeUpdate(()=>{
  305. if(this.globalBgMusic.src==e.voiceUrl){
  306. this.activeAudioTime=parseInt(this.globalBgMusic.currentTime)
  307. }
  308. })
  309. },
  310. //音频进度条拖动
  311. handleAudioSliderChange(e,item){
  312. const value=e.detail.value
  313. item.currentPlayTime=value
  314. // 如果当前activeAudioUrl 不等于拖动的这个音频
  315. if(item.voiceUrl!=this.globalBgMusic.src){
  316. this.handlePlayAudio(item)
  317. }else{
  318. this.globalBgMusic.seek(value)
  319. this.globalBgMusic.play()
  320. }
  321. },
  322. // 存储音频播放的信息
  323. handleSaveAudioMsg(){
  324. // 当音频暂停(不是停止)时 主动调一次停止
  325. const audioPlayPaused=this.globalBgMusic.paused
  326. if(audioPlayPaused===true){
  327. this.globalBgMusic.stop()
  328. }
  329. uni.setStorageSync('activityAudioUrl',this.activeAudioUrl)
  330. },
  331. // 点击信息项
  332. handleClickInfoItem(e) {
  333. if (e.type === "tel" && e.text) {
  334. uni.makePhoneCall({
  335. phoneNumber: e.text,
  336. });
  337. }
  338. },
  339. // 跳转webview 打开报告
  340. handleOpenReport() {
  341. uni.navigateTo({
  342. url: "/pages-activity/reportDetail",
  343. success:(res)=>{
  344. res.eventChannel.emit('webUrl', { url: this.info.reportLink})
  345. }
  346. });
  347. },
  348. // 复制链接
  349. handleCopyLink(text){
  350. uni.setClipboardData({
  351. data: text,
  352. success: function () {
  353. uni.showToast({
  354. title:"复制成功,可在浏览器内打开",
  355. icon:"none"
  356. })
  357. },
  358. fail:function(){
  359. uni.showToast({
  360. title:"复制失败",
  361. icon:"none"
  362. })
  363. }
  364. });
  365. },
  366. // 设置会议提醒
  367. async handleSetRemind() {
  368. if (this.info.hasRemind == 1) {
  369. this.handleCancelRemind();
  370. } else {
  371. this.handleAddRemind();
  372. }
  373. },
  374. // 添加提醒
  375. async handleAddRemind() {
  376. const res = await apiActivityAddRemind({ activity_id: Number(this.info.activityId) });
  377. if (res.code === 200) {
  378. this.pupData.content = `<h4 style="text-align:center;margin-bottom:5px">设置成功</h4>
  379. <p>关注【弘则研究】公众号,接收会前15分钟微信提醒,并及时获取活动信息变更通知</p>`;
  380. this.pupData.show = true;
  381. this.handleUpateRemindStatus();
  382. } else if (res.code === 4001) {
  383. if (res.data.type == "time") {
  384. this.pupData.content = `<p>会议开始前15分钟内无法设置会议提醒</p>`;
  385. this.pupData.type = "time";
  386. }
  387. this.pupData.show = true;
  388. }
  389. },
  390. //取消提醒
  391. async handleCancelRemind() {
  392. const res = await apiActivityCancelRemind({ activity_id: Number(this.info.activityId) });
  393. if (res.code === 200) {
  394. uni.showToast({
  395. title: "取消提醒成功",
  396. icon: "none",
  397. });
  398. this.handleUpateRemindStatus();
  399. }else if(res.code===403){
  400. uni.showToast({
  401. title:res.msg,
  402. icon:"none"
  403. })
  404. }
  405. },
  406. // 更新列表提醒状态
  407. handleUpateRemindStatus() {
  408. if (this.info.hasRemind == 1) {
  409. this.info.hasRemind = 0
  410. } else {
  411. this.info.hasRemind = 1
  412. }
  413. uni.$emit('activityDetailSetRemind', { id: this.info.activityId })
  414. },
  415. // 设置报名
  416. handleSetRegister() {
  417. if (this.info.registerState == 1) {
  418. this.handleCancelRegister();
  419. } else {
  420. this.handleAddRegister();
  421. }
  422. },
  423. // 线下报名
  424. async handleAddRegister() {
  425. const res = await apiActivityRegister({ activity_id: Number(this.info.activityId) })
  426. if (res.code === 200) {
  427. this.pupData.content = `<h4 style="text-align:center;margin-bottom:5px">报名成功</h4>
  428. <p>关注【弘则研究】公众号,接收会前1小时微信提醒,并及时获取活动信息变更通知</p>`
  429. this.pupData.show = true
  430. this.handleUpdateRegister()
  431. } else if (res.code === 4001) {
  432. if (res.data.type == 'time') {
  433. this.pupData.content = `<p>活动开始前15分钟内无法设置会议提醒</p>`
  434. this.pupData.type = 'time'
  435. } else if (res.data.type == 'full') {
  436. this.pupData.content = `<p>此活动报名人数已满,请留意下期活动</p>`
  437. this.pupData.type = 'full'
  438. }
  439. this.pupData.show = true
  440. }
  441. },
  442. //取消线下报名
  443. async handleCancelRegister() {
  444. const res = await apiActivityCancelRegister({ activity_id: Number(this.info.activityId) })
  445. if (res.code === 200) {
  446. uni.showToast({
  447. title: "取消报名成功",
  448. icon: "none"
  449. })
  450. this.handleUpdateRegister()
  451. }else if(res.code===403){
  452. uni.showToast({
  453. title:res.msg,
  454. icon:"none"
  455. })
  456. }
  457. },
  458. //更新列表报名状态
  459. handleUpdateRegister() {
  460. if (this.info.registerState == 1) {
  461. this.info.registerState = 0
  462. } else {
  463. this.info.registerState = 1
  464. }
  465. this.getDetail()
  466. uni.$emit('activityDetailSetRegister', { id: this.info.activityId })
  467. }
  468. },
  469. };
  470. </script>
  471. <style lang="scss">
  472. .activity-detail {
  473. background: #fff;
  474. }
  475. .top-wrap {
  476. width: 100%;
  477. height: 370rpx;
  478. // background: linear-gradient(
  479. // 312deg,
  480. // rgba(0, 0, 0, 0.8) 0%,
  481. // rgba(43, 43, 43, 0.8) 100%
  482. // );
  483. background-color: #666666;
  484. color: $global-text-color-white;
  485. padding-top: 144rpx;
  486. padding-left: 40rpx;
  487. padding-right: 40rpx;
  488. background-size: cover;
  489. background-repeat: no-repeat;
  490. position: relative;
  491. .status {
  492. position: absolute;
  493. top: 0;
  494. left: 0;
  495. width: 116rpx;
  496. line-height: 44rpx;
  497. border-radius: 0px 0px 16rpx 0px;
  498. color: $global-text-color-white;
  499. text-align: center;
  500. font-size: $global-font-size-sm;
  501. }
  502. .status-before {
  503. background-color: #e3b377;
  504. }
  505. .status-progress {
  506. background-color: #3385ff;
  507. }
  508. .status-end {
  509. background-color: #a2a2a2;
  510. }
  511. .title {
  512. font-size: 19px;
  513. font-weight: bold;
  514. }
  515. .name {
  516. margin-top: 15rpx;
  517. margin-bottom: 40rpx;
  518. }
  519. .time {
  520. opacity: 0.8;
  521. font-size: $global-font-size-sm;
  522. }
  523. .city {
  524. font-size: $global-font-size-sm;
  525. align-items: center;
  526. position: absolute;
  527. right: 40rpx;
  528. bottom: 59rpx;
  529. image {
  530. width: 32rpx;
  531. height: 32rpx;
  532. }
  533. }
  534. }
  535. .intro-wrap {
  536. background-color: #fff;
  537. box-shadow: 0px 3px 12px rgba(196, 196, 196, 0.16);
  538. font-size: $global-font-size-lg;
  539. font-weight: bold;
  540. padding: 28rpx 34rpx;
  541. }
  542. .info-wrap {
  543. padding: 30rpx 34rpx;
  544. .item {
  545. margin-bottom: 30rpx;
  546. .label {
  547. flex-shrink: 0;
  548. }
  549. .copy-btn {
  550. background-color: #e3b377;
  551. color: #fff;
  552. padding: 4rpx 8rpx;
  553. font-size: 12px;
  554. margin-left: 4rpx;
  555. }
  556. .link{
  557. width: 300rpx;
  558. white-space:nowrap;
  559. overflow:hidden;
  560. text-overflow:ellipsis;
  561. }
  562. }
  563. .yellow-color {
  564. color: $global-text-color-main;
  565. }
  566. }
  567. .audio-wrap {
  568. padding: 0 94rpx 0 34rpx;
  569. .audio-item {
  570. padding-top: 36rpx;
  571. // border-bottom: 1px solid #E8DED2;
  572. position: relative;
  573. .icon {
  574. position: absolute;
  575. top: 50rpx;
  576. right: 0;
  577. width: 48rpx;
  578. height: 48rpx;
  579. }
  580. .name {
  581. margin-bottom: 10rpx;
  582. }
  583. .time {
  584. font-size: $global-font-size-mini;
  585. }
  586. .audio-slider{
  587. margin: 20rpx 0 20rpx 20rpx;
  588. }
  589. }
  590. }
  591. .btn-wrap {
  592. .btn {
  593. width: 380rpx;
  594. line-height: 70rpx;
  595. margin-left: auto;
  596. margin-right: auto;
  597. margin-top: 40rpx;
  598. }
  599. .tips {
  600. font-size: $global-font-size-sm;
  601. color: $global-text-color-999;
  602. text-align: center;
  603. }
  604. }
  605. </style>