list.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <van-list
  3. v-model="loadingMore"
  4. :finished="finished"
  5. :immediate-check="false"
  6. :finished-text="total ? '没有更多了' : ''"
  7. @load="fetchVideoList"
  8. class="vant-list"
  9. >
  10. <div class="page">
  11. <div class="page-content">
  12. <!-- 操作区域 -->
  13. <div class="control">
  14. <div class="search">
  15. <el-input
  16. placeholder="搜索手机号后四位或机构名称"
  17. @keyup.enter.native="getList"
  18. v-model="listQuery.mobileOrAuthpart"
  19. clearable
  20. @clear="getList"
  21. >
  22. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  23. </el-input>
  24. </div>
  25. <div class="publish" @click="onPublish">发布视频</div>
  26. </div>
  27. <!-- 视频列表区域 -->
  28. <div class="video-content">
  29. <div class="title">参赛视频</div>
  30. <SimpleVideoList :list="list" @praise="onPraise" />
  31. <!-- 列表为空 -->
  32. <SimpleEmpty v-if="!total && !isRequest" name="icon-empty-video.png" description="暂无视频~"></SimpleEmpty>
  33. </div>
  34. </div>
  35. <div class="publish" @click="onPublish">发布视频</div>
  36. <!-- 提示框 -->
  37. <GeneralDialog
  38. v-model="promptDialog"
  39. title="提示"
  40. :content="promptContent"
  41. :confirmText="promptConfirmText"
  42. @confirm="onPromptConfirm"
  43. ></GeneralDialog>
  44. </div>
  45. </van-list>
  46. </template>
  47. <script>
  48. import { mapGetters } from 'vuex'
  49. import { debounce } from '~/utils'
  50. export default {
  51. layout: 'app-asbl',
  52. data() {
  53. const promptContentMap = {
  54. 0: '恭喜您,报名成功,请去上传您的抖音视频!',
  55. 1: '抱歉!活动还未开始,暂无法报名!',
  56. 2: '抱歉!活动已结束,暂无法报名!',
  57. 3: '抱歉!您已报名,请勿重复操作!',
  58. 4: '抱歉!请完善您的营业执照!',
  59. 5: '抱歉!您还未报名,请先报名后再来上传视频!',
  60. 6: '抱歉!活动还未开始,暂无法上传视频!',
  61. 7: '抱歉!活动已结束,暂无法上传视频!',
  62. }
  63. return {
  64. isRequest: true,
  65. finished: true, // 列表加载是否完毕(加载完了所有数据)
  66. loadingMore: false, // 是否正在加载
  67. listQuery: {
  68. mobileOrAuthpart: '',
  69. clubUserId: '',
  70. authUserId: '',
  71. pageNum: 1,
  72. pageSize: 20,
  73. status: 1,
  74. },
  75. list: [],
  76. total: 0,
  77. dialog: false,
  78. dialogOption: {
  79. confirmText: '确定',
  80. description: '抱歉,活动已结束,暂无法发布视频!',
  81. cancel: false,
  82. },
  83. publishInfo: {},
  84. // 提示框信息
  85. promptDialog: false,
  86. promptContentMap,
  87. promptStatus: -1,
  88. activityState: 0,
  89. // 用户报名状态
  90. signUpStatus: 0, // 0:未报名 1:已报名
  91. }
  92. },
  93. computed: {
  94. ...mapGetters(['routePrefix', 'accessToken', 'userInfo', 'authUserId']),
  95. promptContent() {
  96. return this.promptContentMap[this.promptStatus]
  97. },
  98. promptConfirmText() {
  99. return this.promptStatus === 2 ? '上传抖音视频' : '确定'
  100. },
  101. },
  102. created() {
  103. this.getList()
  104. this.fetchActivityStatus()
  105. },
  106. beforeDestroy() {
  107. this.$toast.clear()
  108. },
  109. methods: {
  110. // 获取列表
  111. getList() {
  112. this.$toast.loading({
  113. message: '正在获取视频列表...',
  114. duration: 0,
  115. })
  116. this.listQuery.pageNum = 1
  117. this.isRequest = true
  118. this.list = []
  119. this.fetchVideoList()
  120. },
  121. // 获取视频列表
  122. fetchVideoList: debounce(async function () {
  123. try {
  124. this.loadingMore = true
  125. this.isRequest = true
  126. this.listQuery.authUserId = this.authUserId
  127. this.listQuery.clubUserId = this.userInfo.clubUserId
  128. const res = await this.$http.api.fetchClubVideoList(this.listQuery)
  129. this.list = [...this.list, ...res.data.list]
  130. this.total = res.data.total
  131. this.listQuery.pageNum++
  132. this.finished = !res.data.hasNextPage
  133. this.loadingMore = false
  134. this.isRequest = false
  135. } catch (error) {
  136. console.log(error)
  137. } finally {
  138. this.$toast.clear()
  139. }
  140. }, 500),
  141. // 视频点赞
  142. async onPraise(video) {
  143. try {
  144. if (!this.accessToken) {
  145. this.$toast('请先登录')
  146. this.$store.commit('app/SHOW_LOGIN')
  147. return
  148. }
  149. const status = video.diggStatus === 0 ? 1 : 0
  150. const { clubUserId } = this.userInfo
  151. await this.$http.api.diggcountVideo({
  152. id: video.id,
  153. diggStatus: status,
  154. clubUserId,
  155. clubUserIds: video.clubUserIds,
  156. })
  157. video.diggStatus = status
  158. let tip = ''
  159. if (video.diggStatus === 0) {
  160. tip = '已取消点赞'
  161. video.diggCount--
  162. } else {
  163. tip = '点赞成功'
  164. video.diggCount++
  165. }
  166. this.$toast.success(tip)
  167. } catch (error) {
  168. console.log(error)
  169. }
  170. },
  171. // 去发布视频
  172. async onPublish() {
  173. // 活动未开启
  174. if (this.activityState === 0) {
  175. this.promptStatus = 6
  176. this.promptDialog = true
  177. return
  178. }
  179. // 活动已结束
  180. if (this.activityState === 2) {
  181. this.promptStatus = 7
  182. this.promptDialog = true
  183. return
  184. }
  185. // 未登录
  186. if (!this.accessToken) {
  187. this.$store.commit('app/SHOW_LOGIN')
  188. return
  189. }
  190. // 未报名
  191. if (this.signUpStatus === 0) {
  192. this.promptDialog = true
  193. this.promptStatus = 5
  194. return
  195. }
  196. this.$router.push(`${this.routePrefix}/activity/challenge/publish`)
  197. },
  198. // 提示框确定事件
  199. onPromptConfirm() {
  200. this.promptDialog = false
  201. // 上传资质
  202. if (this.promptStatus === 4) {
  203. this.showDialog = true
  204. return
  205. }
  206. // 去上传抖音视频
  207. if (this.promptStatus === 0) {
  208. this.$router.push(`${this.routePrefix}/activity/challenge/publish`)
  209. return
  210. }
  211. },
  212. // 获取用户活动报名状态
  213. async fetchContestInfo() {
  214. try {
  215. const { mobile } = this.userInfo
  216. const res = await this.$http.api.checkContestInfo({ mobile, authUserId: this.authUserId })
  217. this.signUpStatus = res.data.contestStatus
  218. } catch (error) {
  219. console.log(error)
  220. }
  221. },
  222. // 获取活动状态
  223. async fetchActivityStatus() {
  224. try {
  225. const res = await this.$http.api.fetchActivityStatus({
  226. authUserId: this.authUserId,
  227. })
  228. if (!res.data) return
  229. this.activityState = res.data.activityState
  230. if (!this.accessToken) return
  231. this.fetchContestInfo()
  232. } catch (error) {
  233. console.log(error)
  234. }
  235. },
  236. },
  237. }
  238. </script>
  239. <style lang="scss" scoped>
  240. @media screen and (min-width: 768px) {
  241. ::v-deep {
  242. .el-input.is-active .el-input__inner,
  243. .el-input__inner:focus {
  244. border-color: #f3920d;
  245. }
  246. .van-list__finished-text,
  247. .van-list__placeholder {
  248. background: #fff;
  249. }
  250. }
  251. .vant-list {
  252. background: #fff;
  253. }
  254. .page {
  255. background: #fff;
  256. min-height: calc(100vh - 80px - 80px - 50px);
  257. .page-top {
  258. width: 100%;
  259. height: 530px;
  260. background: url(~assets/theme-images/ross/pc-banner-activity.png) no-repeat center;
  261. background-size: auto 530px;
  262. }
  263. .publish {
  264. display: none;
  265. }
  266. .page-content {
  267. width: 1200px;
  268. margin: 0 auto;
  269. .control {
  270. display: flex;
  271. align-items: center;
  272. padding: 32px 0;
  273. .publish {
  274. display: block;
  275. width: 120px;
  276. height: 46px;
  277. text-align: center;
  278. line-height: 46px;
  279. background: #f3920d;
  280. color: #fff;
  281. font-size: 16px;
  282. border-radius: 4px;
  283. cursor: pointer;
  284. transition: all 0.2s;
  285. margin-left: 48px;
  286. &:hover {
  287. background: #e98d0d;
  288. }
  289. }
  290. .search {
  291. flex: 1;
  292. flex-shrink: 0;
  293. .el-input {
  294. height: 46px;
  295. font-size: 16px;
  296. .el-input__icon {
  297. font-size: 24px;
  298. line-height: 46px;
  299. margin-left: 12px;
  300. }
  301. ::v-deep {
  302. & > .el-input__inner {
  303. height: 46px;
  304. padding-left: 55px;
  305. }
  306. }
  307. }
  308. }
  309. }
  310. .video-content {
  311. .title {
  312. font-size: 16px;
  313. color: #282828;
  314. font-weight: bold;
  315. margin: 16px 0;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. @media screen and (max-width: 768px) {
  322. .vant-list {
  323. padding-bottom: 28vw;
  324. }
  325. .page {
  326. background: #fff;
  327. position: relative;
  328. position: relative;
  329. // padding-bottom: 20vw;
  330. .page-top {
  331. width: 100%;
  332. height: 100vw;
  333. background: url(~assets/theme-images/ross/h5-banner-activity.png) no-repeat center;
  334. background-size: auto 100vw;
  335. }
  336. .publish {
  337. position: fixed;
  338. bottom: 16vw;
  339. left: 7.4vw;
  340. width: 85.6vw;
  341. height: 12vw;
  342. background: #f3920d;
  343. color: #fff;
  344. text-align: center;
  345. font-size: 3.6vw;
  346. line-height: 12vw;
  347. z-index: 9;
  348. }
  349. .page-content {
  350. position: relative;
  351. width: 93.6vw;
  352. margin: 0 auto;
  353. .control {
  354. display: flex;
  355. align-items: center;
  356. padding: 6.4vw 0 7.2vw;
  357. .publish {
  358. display: none;
  359. }
  360. .search {
  361. flex: 1;
  362. flex-shrink: 0;
  363. .el-input {
  364. height: 9.6vw;
  365. font-size: 3.4vw;
  366. .el-input__icon {
  367. font-size: 5.6vw;
  368. line-height: 9.6vw;
  369. margin-left: 12px;
  370. }
  371. ::v-deep {
  372. & > .el-input__inner {
  373. height: 9.6vw;
  374. padding-left: 55px;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. .video-content {
  381. .title {
  382. font-size: 3.4vw;
  383. color: #282828;
  384. font-weight: bold;
  385. margin: 0 0 4vw;
  386. }
  387. .video-list {
  388. &::after {
  389. content: '';
  390. display: block;
  391. clear: both;
  392. }
  393. .video {
  394. float: left;
  395. width: 45.6vw;
  396. height: 56.4vw;
  397. background: #fff;
  398. box-sizing: border-box;
  399. border: 0.1vw solid #efefef;
  400. margin: 0 2.4vw 2.4vw 0;
  401. transition: all 0.4s;
  402. &:nth-child(2n) {
  403. margin-right: 0;
  404. }
  405. .cover {
  406. width: 100%;
  407. height: 31.3vw;
  408. position: relative;
  409. img {
  410. display: block;
  411. width: 100%;
  412. height: 31.3vw;
  413. }
  414. &::after {
  415. content: '';
  416. display: block;
  417. position: absolute;
  418. left: 0;
  419. top: 0;
  420. z-index: 1;
  421. width: 100%;
  422. height: 100%;
  423. background: #000;
  424. opacity: 0;
  425. transition: opacity 0.2s;
  426. }
  427. .play {
  428. position: absolute;
  429. z-index: 2;
  430. width: 48px;
  431. height: 48px;
  432. background: url(~assets/theme-images/common/pc-icon-play.png) no-repeat center;
  433. background-size: 48px;
  434. left: 50%;
  435. top: 50%;
  436. transform: translate(-50%, -50%);
  437. opacity: 0;
  438. transition: opacity 0.2s;
  439. cursor: pointer;
  440. }
  441. .name {
  442. color: #fff;
  443. font-size: 3vw;
  444. text-align: center;
  445. width: 100%;
  446. line-height: 6.4vw;
  447. height: 6.4vw;
  448. @include ellipsis(1);
  449. box-sizing: border-box;
  450. padding: 0 1.2vw;
  451. position: absolute;
  452. left: 0;
  453. bottom: 0;
  454. background: rgba(0, 0, 0, 0.5);
  455. }
  456. .rank {
  457. position: absolute;
  458. left: 2.4vw;
  459. top: 0;
  460. width: 7.2vw;
  461. height: 7.5vw;
  462. background: url(~assets/theme-images/ross/h5-rank.png) no-repeat center;
  463. background-size: 7.2vw;
  464. text-align: center;
  465. box-sizing: border-box;
  466. padding-top: 1.9vw;
  467. font-weight: bold;
  468. color: #fff;
  469. font-size: 2.1vw;
  470. &.rank-01 {
  471. background-image: url(~assets/theme-images/ross/h5-rank-01.png);
  472. }
  473. &.rank-02 {
  474. background-image: url(~assets/theme-images/ross/h5-rank-02.png);
  475. }
  476. &.rank-03 {
  477. background-image: url(~assets/theme-images/ross/h5-rank-03.png);
  478. }
  479. }
  480. }
  481. .info {
  482. padding: 2.4vw;
  483. .club-name {
  484. font-size: 3.4vw;
  485. color: #282828;
  486. @include ellipsis(1);
  487. }
  488. .mobile {
  489. font-size: 3vw;
  490. color: #666;
  491. margin-top: 1.6vw;
  492. }
  493. }
  494. .foot {
  495. color: #999999;
  496. font-size: 2.6vw;
  497. display: flex;
  498. justify-content: space-between;
  499. align-items: center;
  500. margin: 0 2.4vw;
  501. border-top: 0.1vw solid #efefef;
  502. padding-top: 2.3vw;
  503. .date,
  504. .praise,
  505. .pv {
  506. flex-shrink: 0;
  507. line-height: 3.6vw;
  508. }
  509. .praise,
  510. .pv {
  511. position: relative;
  512. padding-left: 4.4vw;
  513. &::after {
  514. content: '';
  515. display: block;
  516. width: 3.6vw;
  517. height: 3.6vw;
  518. background: url(~assets/theme-images/common/icon-praise.png) no-repeat center;
  519. background-size: 3.6vw;
  520. position: absolute;
  521. left: 0;
  522. top: 50%;
  523. transform: translateY(-50%);
  524. }
  525. }
  526. .pv {
  527. &::after {
  528. background-image: url(~assets/theme-images/common/icon-pv.png);
  529. }
  530. }
  531. .date {
  532. margin-right: 5.5vw;
  533. }
  534. }
  535. }
  536. }
  537. }
  538. }
  539. }
  540. }
  541. </style>