list.vue 14 KB

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