detail.vue 17 KB

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