activity.vue 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. <template>
  2. <page-meta :page-style="currentAudioMsg.show? 'overflow: hidden;' : ''" />
  3. <view class="activity-page">
  4. <van-sticky style="background: #fff">
  5. <!-- <view class="search-wrap">
  6. <van-search
  7. shape="round"
  8. :value="searchVal"
  9. placeholder="搜索您想要的商品名"
  10. @change="searchValChange"
  11. @search="onSearch"
  12. @clear="onClearSearch"
  13. />
  14. </view> -->
  15. <!-- <view class="flex tabs-wrap" @click="tabChange">
  16. <view
  17. :class="['tab-item', tabActive === '1' && 'tab-active']"
  18. data-type="1"
  19. >线上会议</view>
  20. <view
  21. :class="['tab-item', tabActive === '3' && 'tab-active']"
  22. data-type="3"
  23. >线下沙龙</view>
  24. </view> -->
  25. <view class="flex status-wrap" @click="statusChange">
  26. <view
  27. :class="[
  28. 'status-item',
  29. statusActive === '1' && 'status-active',
  30. ]"
  31. data-status="1">本周预告
  32. </view>
  33. <view
  34. :class="[
  35. 'status-item',
  36. statusActive === '2' && 'status-active',
  37. ]"
  38. data-status="2">进行中
  39. </view>
  40. <view
  41. :class="[
  42. 'status-item',
  43. statusActive === '3' && 'status-active',
  44. ]"
  45. data-status="3">已结束
  46. </view>
  47. <van-checkbox
  48. class="auth-box"
  49. shape="square"
  50. :value="onlySeeAuth"
  51. @change="handleAuthChange"
  52. checked-color="#D5AD79"
  53. icon-size="16px"
  54. >
  55. <view class="text">只看有权限</view>
  56. </van-checkbox>
  57. </view>
  58. </van-sticky>
  59. <view class="list" v-if="list.length > 0">
  60. <view
  61. class="global-list-card item"
  62. v-for="(item,index) in list"
  63. :key="item.activityId"
  64. @click="handleGoDetail(item.activityId)"
  65. >
  66. <view class="status-box status-before" v-if="item.activityState===1">未开始</view>
  67. <view class="status-box status-progress" v-if="item.activityState===2">进行中</view>
  68. <view class="status-box status-end" v-if="item.activityState===3">已结束</view>
  69. <view class="flex top">
  70. <image class="avatar" :src="item.speakerHeadPic" mode="aspectFill"></image>
  71. <view class="content">
  72. <view class="flex icon-box" @click.stop="handleGetAudio(item)">
  73. <template v-if="item.firstActivityTypeId===3&&item.city">
  74. <image src='../../static/position.png'></image>
  75. <text>{{item.city}}</text>
  76. </template>
  77. <template v-if="item.firstActivityTypeId===1&&item.activityState===3&&item.hasPlayBack">
  78. <image :src="currentAudioMsg.activityId==item.activityId&&currentAudioMsg.play?'../../static/audio-doing.png':'../../static/audio-pause-3.png'"></image>
  79. <text>{{currentAudioMsg.activityId==item.activityId?currentAudioMsg.play?'暂停':'回放':'回放'}}</text>
  80. </template>
  81. </view>
  82. <view class="van-ellipsis title">{{item.activityTypeName}}</view>
  83. <view class="name">主讲:{{item.speaker}}</view>
  84. <view class="time">{{ item.startTime | formatActivityTime(item.endTime) }}</view>
  85. </view>
  86. </view>
  87. <view class="flex bot" v-if="item.activityState===1">
  88. <view
  89. :class="!item.hasRemind&&'active'"
  90. @click.stop="handleRemind(item,index)"
  91. >
  92. {{item.hasRemind?'取消提醒':'会议提醒'}}
  93. </view>
  94. <view
  95. :class="!item.registerState&&'active'"
  96. v-if="item.firstActivityTypeId===3"
  97. @click.stop="handleRegister(item,index)"
  98. >
  99. {{item.registerState?'取消线下报名':'报名线下参会'}}
  100. </view>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="report-empty-box" v-if="list.length===0&&finished">
  105. <image :src="globalImgUrls.chartEmpty" mode="widthFix" />
  106. <view>暂无活动</view>
  107. </view>
  108. <!-- <van-empty description="暂无数据" v-if="list.length===0&&finished" /> -->
  109. <!-- 弹窗 -->
  110. <van-popup :show="pupData.show" @close="pupData.show=false" :close-on-click-overlay="false">
  111. <view class="global-pup">
  112. <view class="content">
  113. <rich-text :nodes="pupData.content"></rich-text>
  114. </view>
  115. <view class="flex bot" v-if="pupData.type=='contact'">
  116. <view @click="pupData.show=false" style="color:#A9AFB8">取消</view>
  117. <view @click="handleCallPhone(pupData.mobile)">拨号</view>
  118. </view>
  119. <view class="flex bot" v-else-if="pupData.type=='apply'">
  120. <view @click="pupData.show=false" style="color:#A9AFB8">取消</view>
  121. <view @click="handleApply">立即申请</view>
  122. </view>
  123. <view class="flex bot" v-else>
  124. <view @click="pupData.show=false">知道了</view>
  125. </view>
  126. </view>
  127. </van-popup>
  128. <!-- 音频弹窗 -->
  129. <van-popup
  130. :show="currentAudioMsg.show"
  131. @close="currentAudioMsg.show=false"
  132. position="bottom"
  133. closeable
  134. round
  135. z-index="99999"
  136. >
  137. <view class="audio-popup-box">
  138. <view class="title">{{currentAudioMsg.title}}</view>
  139. <view class="list">
  140. <view class="flex item" v-for="item in currentAudioMsg.list" :key="item.voiceUrl" @click="handleAudioChange(item)">
  141. <view>
  142. <view :style="{color:item.voiceUrl==currentAudioMsg.audioCurrentUrl?'#D5AD79':''}">{{item.voiceName}}</view>
  143. <view style="font-size:12px;color:#999">{{item.voicePlaySeconds|formatVoiceTime}}</view>
  144. </view>
  145. <!-- <image v-if="item.voiceUrl==currentAudioMsg.audioCurrentUrl&&currentAudioMsg.play" src="../../static/audio-doing.png" mode="scaleToFill"/>
  146. <image v-else-if="item.voiceUrl==currentAudioMsg.audioCurrentUrl&&!currentAudioMsg.play" src="../../static/audio-pause-3.png" mode="scaleToFill"/>
  147. <image v-else src="../../static/audio-pause-2.png" mode="scaleToFill"/> -->
  148. </view>
  149. </view>
  150. <view class="flex box">
  151. <text>{{currentAudioMsg.audioCurrentTime|formatVoiceTime}}</text>
  152. <slider
  153. activeColor="#e3b377"
  154. :max="currentAudioMsg.audioTime"
  155. :value="currentAudioMsg.audioCurrentTime"
  156. @change="handleAudioSliderChange($event)"
  157. block-size="20"
  158. />
  159. <text>{{currentAudioMsg.audioTime|formatVoiceTime}}</text>
  160. </view>
  161. <view class="flex btns">
  162. <image
  163. class="before"
  164. :src="isFirstAudio?'../../static/audio-before-grey.png':'../../static/audio-before.png'"
  165. mode="aspectFit"
  166. @click="handleAudioBtn('before')"
  167. />
  168. <image
  169. class="center"
  170. :src="currentAudioMsg.play?'../../static/audio-doing.png':'../../static/audio-pause-3.png'"
  171. mode="aspectFit"
  172. @click="handleAudioBtn('center')"
  173. />
  174. <image
  175. class="next"
  176. :src="isLastAudio?'../../static/audio-before-grey.png':'../../static/audio-before.png'"
  177. mode="aspectFit"
  178. @click="handleAudioBtn('next')"
  179. />
  180. </view>
  181. </view>
  182. </van-popup>
  183. <!-- 分享海报 -->
  184. <sharePoster
  185. :style="{bottom:'250rpx'}"
  186. :shareData="{
  187. type:'activity_list',
  188. code_page:'pages/activity/activity',
  189. code_scene:'',
  190. data:shareParams
  191. }"
  192. v-if="showPoster"
  193. ></sharePoster>
  194. </view>
  195. </template>
  196. <script>
  197. import {
  198. apiActivityList,
  199. apiActivityAddRemind,
  200. apiActivityCancelRemind,
  201. apiActivityRegister,
  202. apiActivityCancelRegister,
  203. apiActivityAudios,
  204. apiActivityAudioPlayRecordAdd,
  205. apiActivityAudioPlayRecordUpate
  206. } from '@/api/activity'
  207. import {apiApplyPermission,apiUserInfo} from '@/api/user'
  208. import sharePoster from '../../components/sharePoster/sharePoster.vue'
  209. const dayjs=require('@/utils/dayjs.min')
  210. dayjs.locale('zh-cn')
  211. export default {
  212. components: {
  213. sharePoster
  214. },
  215. computed: {
  216. isFirstAudio(){
  217. if(!this.currentAudioMsg.audioCurrentUrl){
  218. return true
  219. }
  220. if(this.currentAudioMsg.list.length>0){
  221. return this.currentAudioMsg.audioCurrentUrl==this.currentAudioMsg.list[0].voiceUrl
  222. }
  223. },
  224. isLastAudio(){
  225. if(!this.currentAudioMsg.audioCurrentUrl){
  226. return true
  227. }
  228. if(this.currentAudioMsg.list.length>0){
  229. return this.currentAudioMsg.audioCurrentUrl==this.currentAudioMsg.list[this.currentAudioMsg.list.length-1].voiceUrl
  230. }
  231. },
  232. shareParams(){ //生成海报数据
  233. let obj={
  234. list_title:this.tabActive === '1'?'线上会议':'线下沙龙',
  235. status_1:'',
  236. avatar_1:'',
  237. title_1:'',
  238. speaker_1:'',
  239. time_1:'',
  240. status_2:'',
  241. avatar_2:'',
  242. title_2:'',
  243. speaker_2:'',
  244. time_2:'',
  245. }
  246. if(this.list[0]){
  247. obj.status_1=this.list[0].activityState==1?'未开始':this.list[0].activityState==2?'进行中':'已结束'
  248. obj.avatar_1=this.list[0].speakerHeadPic
  249. obj.title_1=this.list[0].activityTypeName
  250. obj.speaker_1=this.list[0].speaker
  251. obj.time_1=this.formatActivityTime(this.list[0].startTime,this.list[0].endTime)
  252. }
  253. if(this.list[1]){
  254. obj.status_2=this.list[1].activityState==1?'未开始':this.list[1].activityState==2?'进行中':'已结束'
  255. obj.avatar_2=this.list[1].speakerHeadPic
  256. obj.title_2=this.list[1].activityTypeName
  257. obj.speaker_2=this.list[1].speaker
  258. obj.time_2=this.formatActivityTime(this.list[1].startTime,this.list[1].endTime)
  259. }
  260. return obj
  261. }
  262. },
  263. watch: {
  264. 'pupData.show':{
  265. handler(nval){
  266. if(!nval){
  267. this.pupData={
  268. show:false,
  269. content:'',//弹窗html字符串
  270. type:'',
  271. mobile:"",
  272. }
  273. }
  274. }
  275. }
  276. },
  277. data() {
  278. return {
  279. searchVal: '',
  280. tabActive: '3',
  281. statusActive: '1',
  282. page: 1,
  283. pageSize: 20,
  284. list: [],
  285. finished: false,
  286. isInit:false,//是否是初始化获取数据
  287. pupData:{
  288. show:false,
  289. content:'',//弹窗html字符串
  290. type:'',
  291. mobile:"",
  292. },
  293. onlySeeAuth:false,// 是否只看有权限的
  294. currentAudioMsg:{
  295. activityId:'',//活动id
  296. play:false,//是否正在播放
  297. list:[],//音频列表数据
  298. show:false,//是否显示弹窗
  299. title:'',//音频弹窗标题
  300. audioCurrentTime:0,//音频播放实时时间
  301. audioTime:0,//当前音频时间
  302. audioCurrentUrl:'',//当前音频地址
  303. recordId:0,//新增音频播放记录成功的id
  304. },
  305. showPoster:true
  306. }
  307. },
  308. onLoad() {
  309. this.isInit=true
  310. this.init()
  311. this.addEventListenerRemind()
  312. this.addEventListenerRegister()
  313. },
  314. onShow() {
  315. this.showPoster=true
  316. if(this.$store.state.activity.activityListPageRefresh){
  317. if(this.isInit) return
  318. this.allRefresh()
  319. }
  320. this.initAudio()
  321. // uni.getSystemInfo({
  322. // success: function (res) {
  323. // if (res.windowWidth > 600||['windows','mac'].includes(res.platform)) {
  324. // console.log('跳转启动页判断进入pc');
  325. // uni.reLaunch({
  326. // url: "/pages/pc",
  327. // });
  328. // }
  329. // },
  330. // })
  331. },
  332. onHide(){
  333. this.showPoster=false
  334. this.pupData.show=false
  335. this.currentAudioMsg.show=false
  336. // 存一次音频信息
  337. uni.setStorageSync('audioMsg', JSON.stringify(this.currentAudioMsg))
  338. },
  339. onUnload(){
  340. uni.$off('activityDetailSetRemind')
  341. uni.$off('activityDetailSetRegister')
  342. },
  343. onShareAppMessage(res) {
  344. return {
  345. title: '弘则FICC线下沙龙',
  346. path: ''
  347. }
  348. },
  349. onPullDownRefresh() {
  350. this.refreshPage()
  351. setTimeout(() => {
  352. uni.stopPullDownRefresh()
  353. }, 1500)
  354. },
  355. onReachBottom() {
  356. if (this.finished) return
  357. this.page++
  358. this.getList()
  359. },
  360. methods: {
  361. formatActivityTime(start,end){
  362. const week=dayjs(start).format('dddd');
  363. const day=dayjs(start).format('YYYY-MM-DD');
  364. const startTime=dayjs(start).format('HH:mm');
  365. const endTime=dayjs(end).format('HH:mm');
  366. return `${day} ${startTime}-${endTime} ${week}`
  367. },
  368. //新增音频播放统计
  369. async handleAudioPlayRecordAdd(primary_id,extend_id){
  370. const res=await apiActivityAudioPlayRecordAdd({
  371. primary_id:Number(primary_id),
  372. extend_id:Number(extend_id),
  373. from_page:'活动列表'
  374. })
  375. if(res.code===200){
  376. console.log('新增音频播放记录成功');
  377. this.currentAudioMsg.recordId=res.data.id
  378. }
  379. },
  380. //更新音频播放记录
  381. async handleAudioPlayRecordUpdate(){
  382. const res=await apiActivityAudioPlayRecordUpate({
  383. id:Number(this.currentAudioMsg.recordId),
  384. stop_seconds:Number(this.currentAudioMsg.audioCurrentTime)
  385. })
  386. if(res.code===200){
  387. console.log('更新音频播放记录成功');
  388. }
  389. },
  390. // 初始化音频状态
  391. initAudio(){
  392. console.log('音频src',this.globalBgMusic.src);
  393. if(this.globalBgMusic.src){
  394. const obj=uni.getStorageSync('audioMsg')
  395. if(obj){
  396. this.currentAudioMsg=JSON.parse(obj)
  397. }
  398. this.handleAudioFun()
  399. }else{
  400. this.currentAudioMsg={
  401. activityId:'',//活动id
  402. play:false,//是否正在播放
  403. list:[],//音频列表数据
  404. show:false,//是否显示弹窗
  405. title:'',//音频弹窗标题
  406. audioCurrentTime:0,//音频播放实时时间
  407. audioTime:0,//当前音频时间
  408. audioCurrentUrl:'',//当前音频地址
  409. recordId:0
  410. }
  411. }
  412. },
  413. // 点击列表中播放音频
  414. async handleGetAudio(item){
  415. await this.checkUserIsBind()
  416. if(!(item.firstActivityTypeId===1&&item.activityState===3&&item.hasPlayBack)) return
  417. // 获取音频
  418. if(this.currentAudioMsg.activityId!=item.activityId){
  419. const res=await apiActivityAudios({activity_id: Number(item.activityId)})
  420. if(res.code===200){
  421. // 如果当前有其他的在播放则要掉一次更新
  422. if(this.currentAudioMsg.activityId){
  423. this.handleAudioPlayRecordUpdate()
  424. }
  425. if(res.data){
  426. this.currentAudioMsg.activityId=item.activityId
  427. this.currentAudioMsg.list=res.data
  428. this.currentAudioMsg.title=item.activityTypeName
  429. this.handlePlayAudio(res.data[0])
  430. this.currentAudioMsg.show=!this.currentAudioMsg.show
  431. }else{
  432. uni.showToast({
  433. title:"无音频数据",
  434. icon:"none"
  435. })
  436. }
  437. }else if(res.code===403){
  438. if(res.data.type=='contact'){
  439. if(!res.data.customer_info.has_apply){
  440. if(res.data.customer_info.status=='冻结'||(res.data.customer_info.status=='试用'&&res.data.customer_info.is_suspend==1)){
  441. apiApplyPermission({
  442. company_name:res.data.customer_info.company_name,
  443. real_name:res.data.customer_info.name,
  444. source:2,
  445. from_page:'活动列表'
  446. }).then(res=>{
  447. if(res.code===200){
  448. console.log('主动申请成功');
  449. }
  450. })
  451. }
  452. }
  453. this.pupData.content=`<p>您暂无权限参加此活动,若想参加请联系</p>
  454. <p>对口销售${res.data.name}:${res.data.mobile}</p>`
  455. this.pupData.mobile=res.data.mobile
  456. }else if(res.data.type=='apply'){
  457. this.pupData.content=`<p>您暂无权限参加此活动,若想参加可以申请开通哦</p>`
  458. }
  459. this.pupData.show=true
  460. this.pupData={...this.pupData,...res.data}
  461. }
  462. }else{
  463. if(this.currentAudioMsg.play){
  464. this.globalBgMusic.pause()
  465. }else{
  466. this.globalBgMusic.play()
  467. }
  468. this.currentAudioMsg.show=!this.currentAudioMsg.show
  469. }
  470. },
  471. // 播放音频
  472. handlePlayAudio(item){
  473. this.handleAudioPlayRecordAdd(item.activity_voice_id,item.activityId)
  474. this.globalBgMusic.src=item.voiceUrl
  475. this.globalBgMusic.title=item.voiceName
  476. this.globalBgMusic.onCanplay(()=>{
  477. this.globalBgMusic.play()
  478. this.currentAudioMsg.audioTime=item.voicePlaySeconds
  479. })
  480. this.handleAudioFun()
  481. },
  482. // 音频事件
  483. handleAudioFun(){
  484. this.globalBgMusic.onPlay(()=>{
  485. this.currentAudioMsg.play=true
  486. this.currentAudioMsg.audioCurrentUrl=this.globalBgMusic.src
  487. })
  488. this.globalBgMusic.onPause(()=>{
  489. this.currentAudioMsg.play=false
  490. })
  491. this.globalBgMusic.onStop(()=>{
  492. console.log('stop',this.currentAudioMsg);
  493. this.handleAudioPlayRecordUpdate()
  494. this.currentAudioMsg.play=false
  495. this.currentAudioMsg.audioCurrentTime=0
  496. this.currentAudioMsg.audioTime=0
  497. this.currentAudioMsg.audioCurrentUrl=0
  498. })
  499. this.globalBgMusic.onEnded(()=>{
  500. console.log('onEnded',this.currentAudioMsg);
  501. this.handleAudioPlayRecordUpdate()
  502. this.currentAudioMsg.play=false
  503. this.handleAudioBtn('next','auto')
  504. })
  505. this.globalBgMusic.onError((e)=>{
  506. console.log('onError',e);
  507. })
  508. this.globalBgMusic.onTimeUpdate(()=>{
  509. console.log('时间更新');
  510. // if(this.globalBgMusic.src==this.currentAudioMsg.audioCurrentUrl){
  511. this.currentAudioMsg.audioCurrentTime=parseInt(this.globalBgMusic.currentTime)
  512. // }
  513. })
  514. },
  515. // 点击弹窗中的按钮
  516. handleAudioBtn(type,e){
  517. if(type==='center'){
  518. if(this.globalBgMusic.src){
  519. if(this.currentAudioMsg.play){
  520. this.globalBgMusic.pause()
  521. }else{
  522. this.globalBgMusic.play()
  523. }
  524. }else{
  525. this.handlePlayAudio(this.currentAudioMsg.list[0])
  526. }
  527. }
  528. if(type==='before'){
  529. if(!this.isFirstAudio){
  530. this.handleAudioPlayRecordUpdate()
  531. this.currentAudioMsg.list.forEach((_item,index)=>{
  532. if(_item.voiceUrl==this.currentAudioMsg.audioCurrentUrl){
  533. this.handlePlayAudio(this.currentAudioMsg.list[index-1])
  534. }
  535. })
  536. }
  537. }
  538. if(type==='next'){
  539. if(!this.isLastAudio){
  540. this.handleAudioPlayRecordUpdate()
  541. this.currentAudioMsg.list.forEach((_item,index)=>{
  542. if(_item.voiceUrl==this.currentAudioMsg.audioCurrentUrl){
  543. this.handlePlayAudio(this.currentAudioMsg.list[index+1])
  544. }
  545. })
  546. }else{
  547. if(e==='auto'){
  548. this.currentAudioMsg.play=false
  549. this.currentAudioMsg.audioCurrentTime=0
  550. this.currentAudioMsg.audioTime=0
  551. this.currentAudioMsg.audioCurrentUrl=''
  552. }
  553. }
  554. }
  555. },
  556. //点击弹窗中的音频项
  557. handleAudioChange(item){
  558. // 点击的同一个
  559. if(item.voiceUrl==this.currentAudioMsg.audioCurrentUrl){
  560. // if(this.currentAudioMsg.play){
  561. // this.globalBgMusic.pause()
  562. // }else{
  563. // this.globalBgMusic.play()
  564. // }
  565. }else{
  566. this.handlePlayAudio(item)
  567. }
  568. },
  569. //拖动进度条
  570. handleAudioSliderChange(e){
  571. const value=e.detail.value
  572. this.globalBgMusic.seek(value)
  573. },
  574. async init(){
  575. let userInfoRes=this.userInfo
  576. if(!this.userInfo.status){
  577. const res=await apiUserInfo()
  578. if(res.code===200){
  579. userInfoRes=res.data
  580. }
  581. }
  582. if(['正式','永续'].includes(userInfoRes.status)){
  583. this.onlySeeAuth=true
  584. }
  585. if(userInfoRes.status=='试用'&&userInfoRes.is_suspend==0){
  586. this.onlySeeAuth=true
  587. }
  588. this.getList('init')
  589. },
  590. handleAuthChange(e){
  591. this.onlySeeAuth=e.detail
  592. this.refreshPage()
  593. },
  594. // 切换tabbar页面时 整个刷新
  595. allRefresh(){
  596. this.tabActive= '3'
  597. this.statusActive='1'
  598. this.pupData={
  599. show:false,
  600. content:'',//弹窗html字符串
  601. type:'',
  602. mobile:"",
  603. }
  604. this.page = 1
  605. this.list = []
  606. this.finished = false
  607. this.getList()
  608. },
  609. // 监听详情中设置提醒
  610. addEventListenerRemind(){
  611. uni.$on('activityDetailSetRemind',e=>{
  612. this.list.forEach((item,index) => {
  613. if(item.activityId==e.id){
  614. this.handleUpateRemindStatus(index)
  615. }
  616. });
  617. })
  618. },
  619. // 监听详情中报名
  620. addEventListenerRegister(){
  621. uni.$on('activityDetailSetRegister',e=>{
  622. this.list.forEach((item,index) => {
  623. if(item.activityId==e.id){
  624. this.handleUpdateRegister(index)
  625. }
  626. });
  627. })
  628. },
  629. //搜索
  630. onSearch(){
  631. this.refreshPage()
  632. this.getList()
  633. },
  634. //清除搜索内容
  635. onClearSearch(){
  636. this.searchVal=''
  637. this.refreshPage()
  638. this.getList()
  639. },
  640. // 同步搜索关键词
  641. searchValChange(e){
  642. this.searchVal=e.detail
  643. },
  644. // 类型切换
  645. tabChange(e) {
  646. const type = e.target.dataset.type
  647. if (!type||type === this.tabActive) return
  648. this.tabActive = type
  649. this.statusActive = '1'
  650. this.refreshPage()
  651. },
  652. // 状态切换
  653. statusChange(e) {
  654. const status = e.target.dataset.status
  655. if (!status||status === this.statusActive) return
  656. this.statusActive = status
  657. this.refreshPage()
  658. },
  659. // 刷新页面
  660. refreshPage() {
  661. this.page = 1
  662. this.list = []
  663. this.finished = false
  664. this.getList()
  665. },
  666. async handleGoDetail(id) {
  667. await this.checkUserIsBind()
  668. uni.navigateTo({
  669. url: '/pages-activity/detail?id=' + id
  670. });
  671. },
  672. async getList(e) {
  673. const res = await apiActivityList({
  674. title:this.searchVal,
  675. active_state: Number(this.statusActive),
  676. activity_type: Number(this.tabActive),
  677. has_permission:this.onlySeeAuth?1:0,
  678. page: this.page,
  679. limit: this.pageSize
  680. })
  681. if(e=='init'){
  682. this.isInit=false
  683. }
  684. if (res.code === 200) {
  685. if(res.data){
  686. this.list = [...this.list, ...res.data]
  687. }else{
  688. this.finished=true
  689. }
  690. }
  691. },
  692. async handleRemind(e,index){
  693. await this.checkUserIsBind()
  694. if(e.hasRemind===0){
  695. this.handleAddRemind(e,index)
  696. }else{
  697. this.handleCancelRemind(e,index)
  698. }
  699. },
  700. // 添加提醒
  701. async handleAddRemind(e,index){
  702. const res=await apiActivityAddRemind({activity_id:Number(e.activityId)})
  703. if(res.code===200){
  704. this.pupData.content=`<h4 style="text-align:center;margin-bottom:5px">设置成功</h4>
  705. <p>关注【弘则研究】公众号,接收会前15分钟微信提醒,并及时获取活动信息变更通知</p>`
  706. this.pupData.show=true
  707. this.handleUpateRemindStatus(index)
  708. }else if(res.code===4001){
  709. if(res.data.type=='time'){
  710. this.pupData.content=`<p>会议开始前15分钟内无法设置会议提醒</p>`
  711. this.pupData.type='time'
  712. }
  713. this.pupData.show=true
  714. }else if(res.code===403){
  715. if(res.data.type=='contact'){
  716. if(!res.data.customer_info.has_apply){
  717. if(res.data.customer_info.status=='冻结'||(res.data.customer_info.status=='试用'&&res.data.customer_info.is_suspend==1)){
  718. apiApplyPermission({
  719. company_name:res.data.customer_info.company_name,
  720. real_name:res.data.customer_info.name,
  721. source:2,
  722. from_page:'活动列表'
  723. }).then(res=>{
  724. if(res.code===200){
  725. console.log('主动申请成功');
  726. }
  727. })
  728. }
  729. }
  730. this.pupData.content=`<p>您暂无权限参加此会议,若想参加请联系</p>
  731. <p>对口销售${res.data.name}:${res.data.mobile}</p>`
  732. this.pupData.mobile=res.data.mobile
  733. }else if(res.data.type=='apply'){
  734. this.pupData.content=`<p>您暂无权限参加此会议,若想参加可以申请开通哦</p>`
  735. }
  736. this.pupData.show=true
  737. this.pupData={...this.pupData,...res.data}
  738. }
  739. },
  740. //取消提醒
  741. async handleCancelRemind(e,index){
  742. const res=await apiActivityCancelRemind({activity_id:Number(e.activityId)})
  743. if(res.code===200){
  744. uni.showToast({
  745. title:"取消提醒成功",
  746. icon:"none"
  747. })
  748. this.handleUpateRemindStatus(index)
  749. }else if(res.code===403){
  750. uni.showToast({
  751. title:res.msg,
  752. icon:"none"
  753. })
  754. }
  755. },
  756. //更新列表中某项的设置提醒状态
  757. handleUpateRemindStatus(index){
  758. if(this.list[index].hasRemind===0){
  759. this.list[index].hasRemind=1
  760. }else{
  761. this.list[index].hasRemind=0
  762. }
  763. },
  764. async handleRegister(e,index){
  765. await this.checkUserIsBind()
  766. if(e.registerState===0){
  767. this.handleAddRegister(e,index)
  768. }else{
  769. this.handleCancelRegister(e,index)
  770. }
  771. },
  772. // 线下报名
  773. async handleAddRegister(e,index){
  774. const res=await apiActivityRegister({activity_id:Number(e.activityId)})
  775. if(res.code===200){
  776. this.pupData.content=`<h4 style="text-align:center;margin-bottom:5px">报名成功</h4>
  777. <p>关注【弘则研究】公众号,接收会前1小时微信提醒,并及时获取活动信息变更通知</p>`
  778. this.pupData.show=true
  779. this.handleUpdateRegister(index)
  780. }else if(res.code===4001){
  781. if(res.data.type=='time'){
  782. this.pupData.content=`<p>活动开始前15分钟内无法设置会议提醒</p>`
  783. this.pupData.type='time'
  784. }else if(res.data.type=='full'){
  785. this.pupData.content=`<p>此活动报名人数已满,请留意下期活动</p>`
  786. this.pupData.type='full'
  787. }
  788. this.pupData.show=true
  789. }else if(res.code===403){
  790. if(res.data.type=='contact'){
  791. if(!res.data.customer_info.has_apply){
  792. if(res.data.customer_info.status=='冻结'||(res.data.customer_info.status=='试用'&&res.data.customer_info.is_suspend==1)){
  793. apiApplyPermission({
  794. company_name:res.data.customer_info.company_name,
  795. real_name:res.data.customer_info.name,
  796. source:2,
  797. from_page:'活动列表'
  798. }).then(res=>{
  799. if(res.code===200){
  800. console.log('主动申请成功');
  801. }
  802. })
  803. }
  804. }
  805. this.pupData.content=`<p>您暂无权限参加此活动,若想参加请联系</p>
  806. <p>对口销售${res.data.name}:${res.data.mobile}</p>`
  807. this.pupData.mobile=res.data.mobile
  808. }else if(res.data.type=='apply'){
  809. this.pupData.content=`<p>您暂无权限参加此活动,若想参加可以申请开通哦</p>`
  810. }
  811. this.pupData.show=true
  812. this.pupData={...this.pupData,...res.data}
  813. }
  814. },
  815. //取消线下报名
  816. async handleCancelRegister(e,index){
  817. const res=await apiActivityCancelRegister({activity_id:Number(e.activityId)})
  818. if(res.code===200){
  819. uni.showToast({
  820. title:"取消报名成功",
  821. icon:"none"
  822. })
  823. this.handleUpdateRegister(index)
  824. }else if(res.code===403){
  825. uni.showToast({
  826. title:res.msg,
  827. icon:"none"
  828. })
  829. }
  830. },
  831. // 更新报名状态
  832. handleUpdateRegister(index){
  833. if(this.list[index].registerState===0){
  834. this.list[index].registerState=1
  835. }else{
  836. this.list[index].registerState=0
  837. }
  838. },
  839. // 点击立即申请
  840. async handleApply(){
  841. await this.checkUserIsBind()
  842. if(this.pupData.customer_info.has_apply){//已经申请过
  843. this.pupData.content=`<p>您已提交过申请,请耐心等待</p>`
  844. this.pupData.type=''
  845. }else{
  846. if(!this.pupData.customer_info.status||this.pupData.customer_info.status!='流失'||this.pupData.customer_info.status!='关闭'){
  847. uni.navigateTo({
  848. url:"/pages-applyPermission/applyPermission?source=2"
  849. })
  850. }else{//主动调一次申请权限接口
  851. const res=await apiApplyPermission({
  852. company_name:this.pupData.customer_info.company_name,
  853. real_name:this.pupData.customer_info.name,
  854. source:2,
  855. from_page:'活动列表'
  856. })
  857. if(res.code===200){
  858. this.pupData.content=`<p>申请已提交</p><p>请等待销售人员与您联系</p>`
  859. this.pupData.type=''
  860. }
  861. }
  862. }
  863. },
  864. // 拨打电话
  865. handleCallPhone(tel){
  866. uni.makePhoneCall({
  867. phoneNumber: tel
  868. });
  869. }
  870. }
  871. }
  872. </script>
  873. <style lang="scss">
  874. .audio-popup-box{
  875. .title{
  876. font-size: 16px;
  877. font-weight: bold;
  878. padding: 40rpx 34rpx 0 34rpx;
  879. }
  880. .list{
  881. max-height: 50vh;
  882. overflow-y: auto;
  883. }
  884. .item{
  885. padding: 34rpx 52rpx 34rpx 34rpx;
  886. border-bottom: 1px solid $global-border-color;
  887. justify-content: space-between;
  888. image{
  889. width: 48rpx;
  890. height: 48rpx;
  891. flex-shrink: 0;
  892. }
  893. }
  894. .box{
  895. align-items: center;
  896. padding: 0rpx 54rpx 30rpx 54rpx;
  897. text{
  898. width: 110rpx;
  899. display: inline-block;
  900. font-size: 12px;
  901. }
  902. slider{
  903. flex: 1;
  904. }
  905. }
  906. .btns{
  907. width: 45%;
  908. margin-left: auto;
  909. margin-right: auto;
  910. margin-bottom: 20rpx;
  911. justify-content: space-between;
  912. image{
  913. width: 58rpx;
  914. height: 58rpx;
  915. }
  916. .next{
  917. transform: rotate(180deg);
  918. }
  919. }
  920. }
  921. .search-wrap {
  922. padding: 0 8rpx;
  923. background-color: $global-bg-color;
  924. }
  925. .tabs-wrap {
  926. background-color: $global-bg-color;
  927. box-shadow: $global-tab-shadow-color;
  928. align-items: center;
  929. text-align: center;
  930. font-size: $global-font-size-lg;
  931. color: $global-text-color-grey;
  932. position: relative;
  933. z-index: 10;
  934. .tab-item {
  935. flex: 1;
  936. height: 94rpx;
  937. line-height: 94rpx;
  938. }
  939. .tab-active {
  940. font-weight: bold;
  941. color: $global-text-color-main;
  942. border-bottom: 6rpx solid $global-text-color-main;
  943. }
  944. }
  945. .status-wrap {
  946. background-color: $global-bg-color;
  947. padding: 40rpx 34rpx 20rpx 34rpx;
  948. overflow-x: scroll;
  949. width: 100%;
  950. margin-right: 34rpx;
  951. align-items: center;
  952. &::-webkit-scrollbar{
  953. width: 0;
  954. display: none;
  955. }
  956. .status-item {
  957. font-size: $global-font-size-sm;
  958. color: #444;
  959. min-width: 167rpx;
  960. text-align: center;
  961. padding: 14rpx;
  962. border-radius: 40rpx;
  963. background-color: #f6f6f6;
  964. margin-right: 40rpx;
  965. // height: 60rpx;
  966. }
  967. .status-active {
  968. background: linear-gradient(270deg, #efc896 0%, #d9a35f 100%);
  969. color: $global-bg-color;
  970. }
  971. .auth-box{
  972. margin-right: 40rpx;
  973. .text{
  974. color: $global-text-color-main;
  975. font-size: $global-font-size-sm;
  976. min-width: 120rpx;
  977. white-space: nowrap;
  978. }
  979. }
  980. }
  981. .list {
  982. padding: 34rpx;
  983. .item {
  984. position: relative;
  985. margin-bottom: 30rpx;
  986. .status-box {
  987. top: 0;
  988. right: 0;
  989. position: absolute;
  990. width: 132rpx;
  991. line-height: 44rpx;
  992. text-align: center;
  993. font-size: $global-font-size-sm;
  994. color: $global-text-color-white;
  995. }
  996. .status-before {
  997. background-color: #e3b377;
  998. }
  999. .status-progress {
  1000. background-color: #3385ff;
  1001. }
  1002. .status-end {
  1003. background-color: #a2a2a2;
  1004. }
  1005. .top {
  1006. padding-top: 64rpx;
  1007. padding-left: 30rpx;
  1008. padding-right: 30rpx;
  1009. padding-bottom: 42rpx;
  1010. .avatar {
  1011. width: 168rpx;
  1012. height: 168rpx;
  1013. border-radius: 50%;
  1014. margin-right: 30rpx;
  1015. flex-shrink: 0;
  1016. border: 1px solid $global-border-color;
  1017. }
  1018. .title {
  1019. font-size: $global-font-size-lg;
  1020. font-weight: bold;
  1021. width: 400rpx;
  1022. padding-right: 80rpx;
  1023. padding-bottom: 10rpx;
  1024. border-bottom: 1px solid $global-border-color;
  1025. }
  1026. .name {
  1027. color: $global-text-color-grey;
  1028. margin: 20rpx 0;
  1029. }
  1030. .time {
  1031. font-size: $global-font-size-sm;
  1032. color: $global-text-color-999;
  1033. }
  1034. }
  1035. .bot {
  1036. border-top: 1px solid $global-border-color;
  1037. color: $global-text-color-999;
  1038. view {
  1039. line-height: 72rpx;
  1040. flex: 1;
  1041. text-align: center;
  1042. border-right: 1px solid $global-border-color;
  1043. }
  1044. view:last-child {
  1045. border: none;
  1046. }
  1047. .active{
  1048. color: #E3B377;
  1049. }
  1050. }
  1051. .content{
  1052. width: 420rpx;
  1053. position: relative;
  1054. .icon-box{
  1055. align-items: center;
  1056. position: absolute;
  1057. right: 0;
  1058. top: -10rpx;
  1059. font-size: $global-font-size-sm;
  1060. color:$global-text-color-main;
  1061. width: 100rpx;
  1062. height: 70rpx;
  1063. justify-content: center;
  1064. image{
  1065. width: 26rpx;
  1066. height: 26rpx;
  1067. margin-right: 4rpx;
  1068. }
  1069. }
  1070. }
  1071. }
  1072. }
  1073. </style>