index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="container">
  3. <view class="media-card">
  4. <view class="media-head">
  5. <view class="media-title">直播</view>
  6. <view class="media-handle">
  7. <view class="handle-card" @click="goToSetLive">
  8. <view class="iconfont iconshezhi"></view>
  9. <view class="handle-card-text">直播设置</view>
  10. </view>
  11. </view>
  12. </view>
  13. <view class="media-content">
  14. <cover-image class="live-card" src="../../static/images/live-card.png" @click="goToLiveDetail"></cover-image>
  15. </view>
  16. </view>
  17. <view class="media-card">
  18. <view class="media-head">
  19. <view class="media-title">短视频</view>
  20. <view class="media-handle">
  21. <view class="handle-text" style="color: #51A539;" @click="manageType = true" v-if="!manageType">管理</view>
  22. <view class="handle-text" style="color: #333333;" @click="manageType = false" v-if="manageType">取消</view>
  23. <view class="handle-text" style="color: #F95151;" @click="deleteVideo()" v-if="manageType">删除</view>
  24. <view class="handle-card" v-if="!manageType" @click="addVideo">
  25. <view class="iconfont iconshangchuan"></view>
  26. <view class="handle-card-text">上传视频</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="media-content">
  31. <view class="video-card" v-for="(item, index) in list" :key="index" @click="goToVideo(item)">
  32. <cover-image class="video-img" :src="item.coverUrl"></cover-image>
  33. <view class="video-title-box">
  34. <text class="iconfont" :class="item.check ? 'iconqueding' : 'iconfeigouxuan'" @click.stop="item.check = !item.check"
  35. v-if="manageType"></text>
  36. <view class="video-title">
  37. {{item.videoName}}
  38. </view>
  39. </view>
  40. </view>
  41. <u-divider :color="isOver ? '#909399' : '#51A539'" :border-color="isOver ? '#909399' : '#51A539'" @click="handleLoadMore()">
  42. <u-loading mode="circle" v-if="loadingData"></u-loading>{{loadingData ? '加载中' : (isOver ? '没有更多了' : '点击加载更多')}}
  43. </u-divider>
  44. </view>
  45. </view>
  46. <u-top-tips ref="uTips"></u-top-tips>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. const NET = require('@/utils/request')
  52. const API = require('@/config/api')
  53. export default {
  54. data() {
  55. return {
  56. liveId: '',
  57. pageIndex: 1,
  58. isOver: false,
  59. list: [],
  60. manageType: false,
  61. loadingData: false,
  62. }
  63. },
  64. onLoad() {},
  65. onShow() {
  66. this.pageIndex = 1
  67. this.list = []
  68. this.getList()
  69. NET.request(API.getLiveId, {}, 'GET').then(res => {
  70. if (res.data && res.data != 0) {
  71. this.liveId = res.data
  72. }
  73. }).catch(res => {
  74. this.$refs.uTips.show({
  75. title: '获取直播ID失败',
  76. type: 'warning',
  77. })
  78. })
  79. },
  80. methods: {
  81. // 直播设置
  82. goToSetLive() {
  83. uni.navigateTo({
  84. url: '/pagesMedia/liveOption'
  85. });
  86. },
  87. // 查看直播详情
  88. goToLiveDetail() {
  89. if (this.liveId) {
  90. uni.navigateTo({
  91. url: '/pagesMedia/liveDetail?liveId=' + this.liveId
  92. });
  93. } else {
  94. this.$refs.uTips.show({
  95. title: '当前无可进行的直播',
  96. type: 'warning',
  97. })
  98. }
  99. },
  100. // 新增短视频
  101. addVideo() {
  102. uni.navigateTo({
  103. url: '/pagesMedia/videoForm?type=add'
  104. });
  105. },
  106. // 懒加载
  107. handleLoadMore() {
  108. if (!this.isOver) {
  109. this.pageIndex++
  110. this.getList()
  111. }
  112. },
  113. // 获取列表数据
  114. getList() {
  115. this.loadingData = true
  116. NET.request(API.getVideoList + this.pageIndex + '/10', {}, 'GET').then(res => {
  117. this.loadingData = false
  118. this.isOver = res.data.list.length != 10
  119. res.data.list.forEach(site => {
  120. site.check = false
  121. })
  122. this.list = this.list.concat(res.data.list)
  123. }).catch(error => {
  124. this.loadingData = false
  125. this.$refs.uTips.show({
  126. title: error.data.msg,
  127. type: 'warning',
  128. })
  129. })
  130. },
  131. // 查看短视频详情
  132. goToVideo(item) {
  133. uni.setStorage({
  134. key: 'videoUrl',
  135. data: item.mediaUrl
  136. })
  137. uni.navigateTo({
  138. url: '/pagesMedia/videoDetail?videoId=' + item.videoId
  139. });
  140. },
  141. // 删除短视频
  142. deleteVideo() {
  143. let postData = ''
  144. this.list.filter(site => site.check).forEach((site, index) => {
  145. postData += (index ? '&' : '?') + 'videoIds=' + site.videoId
  146. })
  147. NET.request(API.deleteVideo + '/' + postData, {}, 'GET').then(res => {
  148. this.$refs.uTips.show({
  149. title: '删除成功',
  150. type: 'success',
  151. })
  152. this.manageType = false
  153. this.pageIndex = 1
  154. this.list = []
  155. this.getList()
  156. }).catch(error => {
  157. this.$refs.uTips.show({
  158. title: error.data.msg,
  159. type: 'warning',
  160. })
  161. })
  162. },
  163. }
  164. }
  165. </script>
  166. <style lang="less" scoped>
  167. page {
  168. width: 100%;
  169. height: 100%;
  170. }
  171. .container {
  172. width: 100%;
  173. height: 100%;
  174. float: left;
  175. background-color: #f7f7f7;
  176. overflow-y: auto;
  177. .media-card {
  178. width: 100%;
  179. float: left;
  180. background: #FFFFFF;
  181. border-radius: 0 0 10px 10px;
  182. margin-bottom: 10px;
  183. .media-head {
  184. width: 100%;
  185. height: 45px;
  186. float: left;
  187. box-sizing: border-box;
  188. padding: 6px 0 6px 15px;
  189. border-bottom: 1px solid #EDEDED;
  190. .media-title {
  191. height: 16px;
  192. float: left;
  193. margin: 8px 0;
  194. padding-left: 6px;
  195. border-left: 2px solid #51A539;
  196. font-size: 15px;
  197. font-family: PingFang SC;
  198. color: #333333;
  199. line-height: 16px;
  200. }
  201. .media-handle {
  202. height: 32px;
  203. float: right;
  204. .handle-text {
  205. height: 32px;
  206. float: left;
  207. padding: 0 10px;
  208. margin: 0 5px;
  209. font-size: 15px;
  210. font-family: PingFang SC;
  211. line-height: 32px;
  212. }
  213. .handle-card {
  214. width: 96px;
  215. height: 32px;
  216. float: left;
  217. background: #51A539;
  218. border-radius: 16px 0px 0px 16px;
  219. font-family: PingFang SC;
  220. color: #FFFFFF;
  221. display: flex;
  222. align-items: center;
  223. justify-content: center;
  224. .iconfont {
  225. font-size: 22px;
  226. }
  227. .handle-card-text {
  228. float: left;
  229. line-height: 32px;
  230. font-size: 12px;
  231. }
  232. }
  233. }
  234. }
  235. .media-content {
  236. width: 100%;
  237. float: left;
  238. padding: 10px 15px;
  239. box-sizing: border-box;
  240. .live-card {
  241. width: 100%;
  242. height: 80px;
  243. float: left;
  244. }
  245. .video-card:nth-child(odd) {
  246. margin: 0 5px 10px 0;
  247. }
  248. .video-card:nth-child(even) {
  249. margin: 0 0 10px 5px;
  250. }
  251. .video-card {
  252. width: calc(50% - 5px);
  253. height: 206px;
  254. float: left;
  255. background: #FFFFFF;
  256. box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.1);
  257. border-radius: 5px;
  258. overflow: hidden;
  259. .video-img {
  260. width: 100%;
  261. height: 170px;
  262. object-fit: cover;
  263. float: left;
  264. }
  265. .video-title-box {
  266. width: 100%;
  267. height: 36px;
  268. float: left;
  269. font-family: PingFang SC;
  270. line-height: 36px;
  271. display: flex;
  272. justify-content: center;
  273. .iconfont {
  274. color: #51A539;
  275. font-size: 36px;
  276. line-height: 36px;
  277. display: flex;
  278. align-items: center;
  279. }
  280. .video-title {
  281. max-width: calc(100% - 36px);
  282. height: 36px;
  283. line-height: 36px;
  284. font-size: 15px;
  285. color: #333333;
  286. overflow: hidden;
  287. text-overflow: ellipsis;
  288. white-space: nowrap;
  289. }
  290. }
  291. }
  292. }
  293. }
  294. }
  295. </style>