activity.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <view class="activity-page">
  3. <van-sticky style="background: #fff">
  4. <!-- <view class="search-wrap">
  5. <van-search
  6. shape="round"
  7. :value="searchVal"
  8. placeholder="搜索您想要的商品名"
  9. @change="searchValChange"
  10. @search="onSearch"
  11. @clear="onClearSearch"
  12. />
  13. </view> -->
  14. <view class="flex tabs-wrap" @click="tabChange">
  15. <view
  16. :class="['tab-item', tabActive === '1' && 'tab-active']"
  17. data-type="1"
  18. >线上会议</view>
  19. <view
  20. :class="['tab-item', tabActive === '3' && 'tab-active']"
  21. data-type="3"
  22. >线下沙龙</view>
  23. </view>
  24. <view class="flex status-wrap" @click="statusChange">
  25. <view
  26. :class="[
  27. 'status-item',
  28. statusActive === '1' && 'status-active',
  29. ]"
  30. data-status="1">本周预告
  31. </view>
  32. <view
  33. :class="[
  34. 'status-item',
  35. statusActive === '2' && 'status-active',
  36. ]"
  37. data-status="2">进行中
  38. </view>
  39. <view
  40. :class="[
  41. 'status-item',
  42. statusActive === '3' && 'status-active',
  43. ]"
  44. data-status="3">已结束
  45. </view>
  46. </view>
  47. </van-sticky>
  48. <view class="list" v-if="list.length > 0">
  49. <view
  50. class="global-list-card item"
  51. v-for="(item,index) in list"
  52. :key="item.activityId"
  53. @click="handleGoDetail(item.activityId)"
  54. >
  55. <view class="status-box status-before" v-if="item.activityState===1">未开始</view>
  56. <view class="status-box status-progress" v-if="item.activityState===2">进行中</view>
  57. <view class="status-box status-end" v-if="item.activityState===3">已结束</view>
  58. <view class="flex top">
  59. <image class="avatar" :src="item.speakerHeadPic" mode="aspectFill"></image>
  60. <view class="content">
  61. <view class="flex icon-box">
  62. <template v-if="item.activityTypeId===3&&item.city">
  63. <image src='../../static/position.png'></image>
  64. <text>{{item.city}}</text>
  65. </template>
  66. <template v-if="item.activityTypeId===1&&item.hasPlayBack">
  67. <image src='../../static/hf.png'></image>
  68. <text>回放</text>
  69. </template>
  70. </view>
  71. <view class="van-ellipsis title">{{item.activityTypeName}}</view>
  72. <view class="name">主讲:{{item.speaker}}</view>
  73. <view class="time">时间:{{ item.startTime | formatActivityTime(item.endTime) }}</view>
  74. </view>
  75. </view>
  76. <view class="flex bot" v-if="item.activityState===1">
  77. <view
  78. :class="!item.hasRemind&&'active'"
  79. @click.stop="handleRemind(item,index)"
  80. >
  81. {{item.hasRemind?'取消提醒':'会议提醒'}}
  82. </view>
  83. <view
  84. :class="!item.registerState&&'active'"
  85. v-if="item.firstActivityTypeId===3"
  86. @click.stop="handleRegister(item,index)"
  87. >
  88. {{item.registerState?'取消线下报名':'报名线下参会'}}
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <van-empty description="暂无数据" v-else />
  94. <!-- 弹窗 -->
  95. <van-popup :show="pupData.show" @close="pupData.show=false">
  96. <view class="global-pup">
  97. <view class="content">
  98. <rich-text :nodes="pupData.content"></rich-text>
  99. </view>
  100. <view class="flex bot" v-if="pupData.type=='contact'">
  101. <view @click="pupData.show=false" style="color:#A9AFB8">取消</view>
  102. <view @click="handleCallPhone(pupData.mobile)">拨号</view>
  103. </view>
  104. <view class="flex bot" v-if="pupData.type=='apply'">
  105. <view @click="pupData.show=false" style="color:#A9AFB8">取消</view>
  106. <view @click="handleApply">立即申请</view>
  107. </view>
  108. <view class="flex bot" v-else>
  109. <view @click="pupData.show=false">知道了</view>
  110. </view>
  111. </view>
  112. </van-popup>
  113. </view>
  114. </template>
  115. <script>
  116. import {
  117. apiActivityList,
  118. apiActivityAddRemind,
  119. apiActivityCancelRemind,
  120. apiActivityRegister,
  121. apiActivityCancelRegister
  122. } from '@/api/activity'
  123. import {apiApplyPermission} from '@/api/user'
  124. export default {
  125. watch: {
  126. 'pupData.show':{
  127. handler(nval){
  128. if(!nval){
  129. this.pupData={
  130. show:false,
  131. content:'',//弹窗html字符串
  132. type:'',
  133. mobile:"",
  134. }
  135. }
  136. }
  137. }
  138. },
  139. data() {
  140. return {
  141. searchVal: '',
  142. tabActive: '1',
  143. statusActive: '1',
  144. page: 1,
  145. pageSize: 20,
  146. list: [],
  147. finished: false,
  148. pupData:{
  149. show:false,
  150. content:'',//弹窗html字符串
  151. type:'',
  152. mobile:"",
  153. }
  154. }
  155. },
  156. onLoad() {
  157. this.getList()
  158. this.addEventListenerRemind()
  159. this.addEventListenerRegister()
  160. },
  161. onShow() {
  162. if(this.$store.state.activity.activityListPageRefresh){
  163. this.allRefresh()
  164. }
  165. },
  166. onUnload(){
  167. uni.$off('activityDetailSetRemind')
  168. uni.$off('activityDetailSetRegister')
  169. },
  170. onShareAppMessage(res) {
  171. return {
  172. title: '弘则研报',
  173. path: ''
  174. }
  175. },
  176. onPullDownRefresh() {
  177. this.refreshPage()
  178. setTimeout(() => {
  179. uni.stopPullDownRefresh()
  180. }, 1500)
  181. },
  182. onReachBottom() {
  183. if (this.finished) return
  184. this.page++
  185. this.getList()
  186. },
  187. methods: {
  188. // 切换tabbar页面时 整个刷新
  189. allRefresh(){
  190. this.tabActive= '1'
  191. this.statusActive='1'
  192. this.pupData={
  193. show:false,
  194. content:'',//弹窗html字符串
  195. type:'',
  196. mobile:"",
  197. }
  198. this.page = 1
  199. this.list = []
  200. this.finished = false
  201. this.getList()
  202. },
  203. // 监听详情中设置提醒
  204. addEventListenerRemind(){
  205. uni.$on('activityDetailSetRemind',e=>{
  206. this.list.forEach((item,index) => {
  207. if(item.activityId==e.id){
  208. this.handleUpateRemindStatus(index)
  209. }
  210. });
  211. })
  212. },
  213. // 监听详情中报名
  214. addEventListenerRegister(){
  215. uni.$on('activityDetailSetRegister',e=>{
  216. this.list.forEach((item,index) => {
  217. if(item.activityId==e.id){
  218. this.handleUpdateRegister(index)
  219. }
  220. });
  221. })
  222. },
  223. //搜索
  224. onSearch(){
  225. this.refreshPage()
  226. this.getList()
  227. },
  228. //清除搜索内容
  229. onClearSearch(){
  230. this.searchVal=''
  231. this.refreshPage()
  232. this.getList()
  233. },
  234. // 同步搜索关键词
  235. searchValChange(e){
  236. this.searchVal=e.detail
  237. },
  238. // 类型切换
  239. tabChange(e) {
  240. const type = e.target.dataset.type
  241. if (!type||type === this.tabActive) return
  242. this.tabActive = type
  243. this.statusActive = '1'
  244. this.refreshPage()
  245. },
  246. // 状态切换
  247. statusChange(e) {
  248. const status = e.target.dataset.status
  249. if (!status||status === this.statusActive) return
  250. this.statusActive = status
  251. this.refreshPage()
  252. },
  253. // 刷新页面
  254. refreshPage() {
  255. this.page = 1
  256. this.list = []
  257. this.finished = false
  258. this.getList()
  259. },
  260. handleGoDetail(id) {
  261. uni.navigateTo({
  262. url: '/pages-activity/detail?id=' + id
  263. });
  264. },
  265. async getList() {
  266. const res = await apiActivityList({
  267. title:this.searchVal,
  268. active_state: Number(this.statusActive),
  269. activity_type: Number(this.tabActive),
  270. page: this.page,
  271. limit: this.pageSize
  272. })
  273. if (res.code === 200) {
  274. if(res.data){
  275. this.list = [...this.list, ...res.data]
  276. }else{
  277. this.finished=true
  278. }
  279. }
  280. },
  281. handleRemind(e,index){
  282. if(e.hasRemind===0){
  283. this.handleAddRemind(e,index)
  284. }else{
  285. this.handleCancelRemind(e,index)
  286. }
  287. },
  288. // 添加提醒
  289. async handleAddRemind(e,index){
  290. const res=await apiActivityAddRemind({activity_id:Number(e.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(index)
  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. }else if(res.code===403){
  303. if(res.data.type=='contact'){
  304. this.pupData.content=`<p>您暂无权限参加此会议,若想参加请联系对口销售--${res.data.name}:</p>
  305. <p>${res.data.mobile}</p>`
  306. this.pupData.mobile=res.data.mobile
  307. }else if(res.data.type=='apply'){
  308. this.pupData.content=`<p style="margin-top:20px">您暂无权限参加此会议,若想参加可以申请开通哦</p>`
  309. }
  310. this.pupData.show=true
  311. this.pupData={...this.pupData,...res.data}
  312. }
  313. },
  314. //取消提醒
  315. async handleCancelRemind(e,index){
  316. const res=await apiActivityCancelRemind({activity_id:Number(e.activityId)})
  317. if(res.code===200){
  318. uni.showToast({
  319. title:"取消提醒成功",
  320. icon:"none"
  321. })
  322. this.handleUpateRemindStatus(index)
  323. }
  324. },
  325. //更新列表中某项的设置提醒状态
  326. handleUpateRemindStatus(index){
  327. if(this.list[index].hasRemind===0){
  328. this.list[index].hasRemind=1
  329. }else{
  330. this.list[index].hasRemind=0
  331. }
  332. },
  333. handleRegister(e,index){
  334. if(e.registerState===0){
  335. this.handleAddRegister(e,index)
  336. }else{
  337. this.handleCancelRegister(e,index)
  338. }
  339. },
  340. // 线下报名
  341. async handleAddRegister(e,index){
  342. const res=await apiActivityRegister({activity_id:Number(e.activityId)})
  343. if(res.code===200){
  344. this.pupData.content=`<h4 style="text-align:center;margin-bottom:5px">报名成功</h4>
  345. <p>请关注【弘则研究】公众号,接收会前1小时微信提醒,并及时获取活动信息变更通知</p>`
  346. this.pupData.show=true
  347. this.handleUpdateRegister(index)
  348. }else if(res.code===4001){
  349. if(res.data.type=='time'){
  350. this.pupData.content=`<p style="margin-top:20px">活动开始前15分钟内无法设置会议提醒</p>`
  351. this.pupData.type='time'
  352. }else if(res.data.type=='full'){
  353. this.pupData.content=`<p style="margin-top:20px">此活动报名人数已满,请留意下期活动</p>`
  354. this.pupData.type='full'
  355. }
  356. this.pupData.show=true
  357. }else if(res.code===403){
  358. if(res.data.type=='contact'){
  359. this.pupData.content=`<p>您暂无权限参加此活动,若想参加请联系对口销售--${res.data.name}:</p>
  360. <p>${res.data.mobile}</p>`
  361. this.pupData.mobile=res.data.mobile
  362. }else if(res.data.type=='apply'){
  363. this.pupData.content=`<p style="margin-top:20px">您暂无权限参加此活动,若想参加可以申请开通哦</p>`
  364. }
  365. this.pupData.show=true
  366. this.pupData={...this.pupData,...res.data}
  367. }
  368. },
  369. //取消线下报名
  370. async handleCancelRegister(e,index){
  371. const res=await apiActivityCancelRegister({activity_id:Number(e.activityId)})
  372. if(res.code===200){
  373. uni.showToast({
  374. title:"取消报名成功",
  375. icon:"none"
  376. })
  377. this.handleUpdateRegister(index)
  378. }
  379. },
  380. // 更新报名状态
  381. handleUpdateRegister(index){
  382. if(this.list[index].registerState===0){
  383. this.list[index].registerState=1
  384. }else{
  385. this.list[index].registerState=0
  386. }
  387. },
  388. // 点击立即申请
  389. async handleApply(){
  390. if(this.pupData.customer_info.has_apply){//已经申请过
  391. this.pupData.content=`<p>申请已提交</p><p>请等待销售人员与您联系</p>`
  392. this.pupData.type=''
  393. }else{
  394. if(!this.pupData.customer_info.status||this.pupData.customer_info.status!='流失'){
  395. uni.navigateTo({
  396. url:"/pages-applyPermission/applyPermission"
  397. })
  398. }else{//主动调一次申请权限接口
  399. const res=await apiApplyPermission({
  400. company_name:this.pupData.customer_info.company_name,
  401. real_name:this.pupData.customer_info.name,
  402. })
  403. if(res.code===200){
  404. this.pupData.content=`<p>申请已提交</p><p>请等待销售人员与您联系</p>`
  405. this.pupData.type=''
  406. }
  407. }
  408. }
  409. },
  410. // 拨打电话
  411. handleCallPhone(tel){
  412. uni.makePhoneCall({
  413. phoneNumber: tel
  414. });
  415. }
  416. }
  417. }
  418. </script>
  419. <style lang="scss">
  420. .search-wrap {
  421. padding: 0 8rpx;
  422. background-color: $global-bg-color;
  423. }
  424. .tabs-wrap {
  425. background-color: $global-bg-color;
  426. box-shadow: $global-tab-shadow-color;
  427. align-items: center;
  428. text-align: center;
  429. font-size: $global-font-size-lg;
  430. color: $global-text-color-grey;
  431. position: relative;
  432. z-index: 10;
  433. .tab-item {
  434. flex: 1;
  435. height: 94rpx;
  436. line-height: 94rpx;
  437. }
  438. .tab-active {
  439. font-weight: bold;
  440. color: $global-text-color-main;
  441. border-bottom: 6rpx solid $global-text-color-main;
  442. }
  443. }
  444. .status-wrap {
  445. background-color: $global-bg-color;
  446. padding: 40rpx 34rpx 20rpx 34rpx;
  447. .status-item {
  448. font-size: $global-font-size-sm;
  449. color: #444;
  450. min-width: 167rpx;
  451. text-align: center;
  452. padding: 14rpx;
  453. border-radius: 40rpx;
  454. background-color: #f6f6f6;
  455. margin-right: 40rpx;
  456. }
  457. .status-active {
  458. background: linear-gradient(270deg, #efc896 0%, #d9a35f 100%);
  459. color: $global-bg-color;
  460. }
  461. }
  462. .list {
  463. padding: 34rpx;
  464. .item {
  465. position: relative;
  466. margin-bottom: 30rpx;
  467. .status-box {
  468. top: 0;
  469. right: 0;
  470. position: absolute;
  471. width: 132rpx;
  472. line-height: 44rpx;
  473. text-align: center;
  474. font-size: $global-font-size-sm;
  475. color: $global-text-color-white;
  476. }
  477. .status-before {
  478. background-color: #e3b377;
  479. }
  480. .status-progress {
  481. background-color: #3385ff;
  482. }
  483. .status-end {
  484. background-color: #a2a2a2;
  485. }
  486. .top {
  487. padding-top: 64rpx;
  488. padding-left: 30rpx;
  489. padding-right: 30rpx;
  490. padding-bottom: 42rpx;
  491. .avatar {
  492. width: 168rpx;
  493. height: 168rpx;
  494. border-radius: 50%;
  495. margin-right: 30rpx;
  496. flex-shrink: 0;
  497. }
  498. .title {
  499. font-size: $global-font-size-lg;
  500. font-weight: bold;
  501. width: 420rpx;
  502. padding-right: 80rpx;
  503. padding-bottom: 10rpx;
  504. border-bottom: 1px solid $global-border-color;
  505. }
  506. .name {
  507. color: $global-text-color-grey;
  508. margin: 20rpx 0;
  509. }
  510. .time {
  511. font-size: $global-font-size-mini;
  512. color: $global-text-color-999;
  513. }
  514. }
  515. .bot {
  516. border-top: 1px solid $global-border-color;
  517. color: $global-text-color-999;
  518. view {
  519. line-height: 72rpx;
  520. flex: 1;
  521. text-align: center;
  522. border-right: 1px solid $global-border-color;
  523. }
  524. view:last-child {
  525. border: none;
  526. }
  527. .active{
  528. color: #E3B377;
  529. }
  530. }
  531. .content{
  532. width: 420rpx;
  533. position: relative;
  534. .icon-box{
  535. align-items: center;
  536. position: absolute;
  537. right: 0;
  538. top: 8rpx;
  539. font-size: $global-font-size-sm;
  540. color:$global-text-color-main;
  541. image{
  542. width: 26rpx;
  543. height: 26rpx;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. </style>