activity.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  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. onUnload(){
  162. uni.$off('activityDetailSetRemind')
  163. uni.$off('activityDetailSetRegister')
  164. },
  165. onShareAppMessage(res) {
  166. return {
  167. title: '弘则研报',
  168. path: ''
  169. }
  170. },
  171. onPullDownRefresh() {
  172. this.refreshPage()
  173. setTimeout(() => {
  174. uni.stopPullDownRefresh()
  175. }, 1500)
  176. },
  177. onReachBottom() {
  178. if (this.finished) return
  179. this.page++
  180. this.getList()
  181. },
  182. methods: {
  183. // 监听详情中设置提醒
  184. addEventListenerRemind(){
  185. uni.$on('activityDetailSetRemind',e=>{
  186. this.list.forEach((item,index) => {
  187. if(item.activityId==e.id){
  188. this.handleUpateRemindStatus(index)
  189. }
  190. });
  191. })
  192. },
  193. // 监听详情中报名
  194. addEventListenerRegister(){
  195. uni.$on('activityDetailSetRegister',e=>{
  196. this.list.forEach((item,index) => {
  197. if(item.activityId==e.id){
  198. this.handleUpdateRegister(index)
  199. }
  200. });
  201. })
  202. },
  203. //搜索
  204. onSearch(){
  205. this.refreshPage()
  206. this.getList()
  207. },
  208. //清除搜索内容
  209. onClearSearch(){
  210. this.searchVal=''
  211. this.refreshPage()
  212. this.getList()
  213. },
  214. // 同步搜索关键词
  215. searchValChange(e){
  216. this.searchVal=e.detail
  217. },
  218. // 类型切换
  219. tabChange(e) {
  220. const type = e.target.dataset.type
  221. if (!type||type === this.tabActive) return
  222. this.tabActive = type
  223. this.statusActive = '1'
  224. this.refreshPage()
  225. },
  226. // 状态切换
  227. statusChange(e) {
  228. const status = e.target.dataset.status
  229. if (!status||status === this.statusActive) return
  230. this.statusActive = status
  231. this.refreshPage()
  232. },
  233. // 刷新页面
  234. refreshPage() {
  235. this.page = 1
  236. this.list = []
  237. this.finished = false
  238. this.getList()
  239. },
  240. handleGoDetail(id) {
  241. uni.navigateTo({
  242. url: '/pages-activity/detail?id=' + id
  243. });
  244. },
  245. async getList() {
  246. const res = await apiActivityList({
  247. title:this.searchVal,
  248. active_state: Number(this.statusActive),
  249. activity_type: Number(this.tabActive),
  250. page: this.page,
  251. limit: this.pageSize
  252. })
  253. if (res.code === 200) {
  254. if(res.data){
  255. this.list = [...this.list, ...res.data]
  256. }else{
  257. this.finished=true
  258. }
  259. }
  260. },
  261. handleRemind(e,index){
  262. if(e.hasRemind===0){
  263. this.handleAddRemind(e,index)
  264. }else{
  265. this.handleCancelRemind(e,index)
  266. }
  267. },
  268. // 添加提醒
  269. async handleAddRemind(e,index){
  270. const res=await apiActivityAddRemind({activity_id:Number(e.activityId)})
  271. if(res.code===200){
  272. this.pupData.content=`<p>请关注【弘则研究】公众号,接收会前15分钟微信提醒,并及时获取活动信息变更通知</p>`
  273. this.pupData.show=true
  274. this.handleUpateRemindStatus(index)
  275. }else if(res.code===4001){
  276. if(res.data.type=='time'){
  277. this.pupData.content=`<p>会议开始前15分钟内无法设置会议提醒</p>`
  278. this.pupData.type='time'
  279. }
  280. this.pupData.show=true
  281. }else if(res.code===403){
  282. if(res.data.type=='contact'){
  283. this.pupData.content=`<p>您暂无权限参加此会议,若想参加请联系对口销售--${res.data.name}:</p>
  284. <p>${res.data.mobile}</p>`
  285. this.pupData.mobile=res.data.mobile
  286. }else if(res.data.type=='apply'){
  287. this.pupData.content=`<p>您暂无权限参加此会议,若想参加可以申请开通哦</p>`
  288. }
  289. this.pupData.show=true
  290. this.pupData={...this.pupData,...res.data}
  291. }
  292. },
  293. //取消提醒
  294. async handleCancelRemind(e,index){
  295. const res=await apiActivityCancelRemind({activity_id:Number(e.activityId)})
  296. if(res.code===200){
  297. uni.showToast({
  298. title:"取消提醒成功",
  299. icon:"none"
  300. })
  301. this.handleUpateRemindStatus(index)
  302. }
  303. },
  304. //更新列表中某项的设置提醒状态
  305. handleUpateRemindStatus(index){
  306. if(this.list[index].hasRemind===0){
  307. this.list[index].hasRemind=1
  308. }else{
  309. this.list[index].hasRemind=0
  310. }
  311. },
  312. handleRegister(e,index){
  313. if(e.registerState===0){
  314. this.handleAddRegister(e,index)
  315. }else{
  316. this.handleCancelRegister(e,index)
  317. }
  318. },
  319. // 线下报名
  320. async handleAddRegister(e,index){
  321. const res=await apiActivityRegister({activity_id:Number(e.activityId)})
  322. if(res.code===200){
  323. this.pupData.content=`<p>请关注【弘则研究】公众号,接收会前1小时微信提醒,并及时获取活动信息变更通知</p>`
  324. this.pupData.show=true
  325. this.handleUpdateRegister(index)
  326. }else if(res.code===4001){
  327. if(res.data.type=='time'){
  328. this.pupData.content=`<p>活动开始前15分钟内无法设置会议提醒</p>`
  329. this.pupData.type='time'
  330. }else if(res.data.type=='full'){
  331. this.pupData.content=`<p>此活动报名人数已满,请留意下期活动</p>`
  332. this.pupData.type='full'
  333. }
  334. this.pupData.show=true
  335. }else if(res.code===403){
  336. if(res.data.type=='contact'){
  337. this.pupData.content=`<p>您暂无权限参加此活动,若想参加请联系对口销售--${res.data.name}:</p>
  338. <p>${res.data.mobile}</p>`
  339. this.pupData.mobile=res.data.mobile
  340. }else if(res.data.type=='apply'){
  341. this.pupData.content=`<p>您暂无权限参加此活动,若想参加可以申请开通哦</p>`
  342. }
  343. this.pupData.show=true
  344. this.pupData={...this.pupData,...res.data}
  345. }
  346. },
  347. //取消线下报名
  348. async handleCancelRegister(e,index){
  349. const res=await apiActivityCancelRegister({activity_id:Number(e.activityId)})
  350. if(res.code===200){
  351. uni.showToast({
  352. title:"取消报名成功",
  353. icon:"none"
  354. })
  355. this.handleUpdateRegister(index)
  356. }
  357. },
  358. // 更新报名状态
  359. handleUpdateRegister(index){
  360. if(this.list[index].registerState===0){
  361. this.list[index].registerState=1
  362. }else{
  363. this.list[index].registerState=0
  364. }
  365. },
  366. // 点击立即申请
  367. async handleApply(){
  368. if(this.pupData.customer_info.has_apply){//已经申请过
  369. this.pupData.content=`<p>申请已提交</p><p>请等待销售人员与您联系</p>`
  370. this.pupData.type=''
  371. }else{
  372. if(!this.pupData.customer_info.status||this.pupData.customer_info.status!='流失'){
  373. uni.navigateTo({
  374. url:"/pages-applyPermission/applyPermission"
  375. })
  376. }else{//主动调一次申请权限接口
  377. const res=await apiApplyPermission({
  378. company_name:this.pupData.customer_info.company_name,
  379. real_name:this.pupData.customer_info.name,
  380. })
  381. if(res.code===200){
  382. this.pupData.content=`<p>申请已提交</p><p>请等待销售人员与您联系</p>`
  383. this.pupData.type=''
  384. }
  385. }
  386. }
  387. },
  388. // 拨打电话
  389. handleCallPhone(tel){
  390. uni.makePhoneCall({
  391. phoneNumber: tel
  392. });
  393. }
  394. }
  395. }
  396. </script>
  397. <style lang="scss">
  398. .search-wrap {
  399. padding: 0 8rpx;
  400. background-color: $global-bg-color;
  401. }
  402. .tabs-wrap {
  403. background-color: $global-bg-color;
  404. box-shadow: $global-tab-shadow-color;
  405. align-items: center;
  406. text-align: center;
  407. font-size: $global-font-size-lg;
  408. color: $global-text-color-grey;
  409. position: relative;
  410. z-index: 10;
  411. .tab-item {
  412. flex: 1;
  413. height: 94rpx;
  414. line-height: 94rpx;
  415. }
  416. .tab-active {
  417. font-weight: bold;
  418. color: $global-text-color-main;
  419. border-bottom: 6rpx solid $global-text-color-main;
  420. }
  421. }
  422. .status-wrap {
  423. background-color: $global-bg-color;
  424. padding: 40rpx 34rpx 20rpx 34rpx;
  425. .status-item {
  426. font-size: $global-font-size-sm;
  427. color: #444;
  428. min-width: 167rpx;
  429. text-align: center;
  430. padding: 14rpx;
  431. border-radius: 40rpx;
  432. background-color: #f6f6f6;
  433. margin-right: 40rpx;
  434. }
  435. .status-active {
  436. background: linear-gradient(270deg, #efc896 0%, #d9a35f 100%);
  437. color: $global-bg-color;
  438. }
  439. }
  440. .list {
  441. padding: 34rpx;
  442. .item {
  443. position: relative;
  444. margin-bottom: 30rpx;
  445. .status-box {
  446. top: 0;
  447. right: 0;
  448. position: absolute;
  449. width: 132rpx;
  450. line-height: 44rpx;
  451. text-align: center;
  452. font-size: $global-font-size-sm;
  453. color: $global-text-color-white;
  454. }
  455. .status-before {
  456. background-color: #e3b377;
  457. }
  458. .status-progress {
  459. background-color: #3385ff;
  460. }
  461. .status-end {
  462. background-color: #a2a2a2;
  463. }
  464. .top {
  465. padding-top: 64rpx;
  466. padding-left: 30rpx;
  467. padding-right: 30rpx;
  468. padding-bottom: 42rpx;
  469. .avatar {
  470. width: 168rpx;
  471. height: 168rpx;
  472. border-radius: 50%;
  473. margin-right: 30rpx;
  474. flex-shrink: 0;
  475. }
  476. .title {
  477. font-size: $global-font-size-lg;
  478. font-weight: bold;
  479. width: 420rpx;
  480. padding-right: 80rpx;
  481. padding-bottom: 10rpx;
  482. border-bottom: 1px solid $global-border-color;
  483. }
  484. .name {
  485. color: $global-text-color-grey;
  486. margin: 20rpx 0;
  487. }
  488. .time {
  489. font-size: $global-font-size-mini;
  490. color: $global-text-color-999;
  491. }
  492. }
  493. .bot {
  494. border-top: 1px solid $global-border-color;
  495. color: $global-text-color-999;
  496. view {
  497. line-height: 72rpx;
  498. flex: 1;
  499. text-align: center;
  500. border-right: 1px solid $global-border-color;
  501. }
  502. view:last-child {
  503. border: none;
  504. }
  505. .active{
  506. color: #E3B377;
  507. }
  508. }
  509. .content{
  510. width: 420rpx;
  511. position: relative;
  512. .icon-box{
  513. align-items: center;
  514. position: absolute;
  515. right: 0;
  516. top: 8rpx;
  517. font-size: $global-font-size-sm;
  518. color:$global-text-color-main;
  519. image{
  520. width: 26rpx;
  521. height: 26rpx;
  522. }
  523. }
  524. }
  525. }
  526. }
  527. </style>