index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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. <view class="live-card"></view>
  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. pageIndex: 1,
  57. isOver: false,
  58. list: [],
  59. manageType: false,
  60. loadingData: false,
  61. }
  62. },
  63. onLoad() {},
  64. onShow() {
  65. this.pageIndex = 1
  66. this.list = []
  67. this.getList()
  68. },
  69. methods: {
  70. // 直播设置
  71. goToSetLive() {
  72. uni.navigateTo({
  73. url: '/pagesMedia/liveOption'
  74. });
  75. },
  76. // 新增短视频
  77. addVideo() {
  78. uni.navigateTo({
  79. url: '/pagesMedia/videoForm?type=add'
  80. });
  81. },
  82. // 懒加载
  83. handleLoadMore() {
  84. if (!this.isOver) {
  85. this.pageIndex++
  86. this.getList()
  87. }
  88. },
  89. // 获取列表数据
  90. getList() {
  91. this.loadingData = true
  92. NET.request(API.getVideoList + this.pageIndex + '/10', {}, 'GET').then(res => {
  93. this.loadingData = false
  94. this.isOver = res.data.list.length != 10
  95. res.data.list.forEach(site => {
  96. site.check = false
  97. })
  98. this.list = this.list.concat(res.data.list)
  99. }).catch(error => {
  100. this.loadingData = false
  101. this.$refs.uTips.show({
  102. title: error.data.msg,
  103. type: 'warning',
  104. })
  105. })
  106. },
  107. // 查看短视频详情
  108. goToVideo(item) {
  109. uni.navigateTo({
  110. url: '/pagesMedia/videoDetail?videoId=' + item.videoId
  111. });
  112. },
  113. // 删除短视频
  114. deleteVideo() {
  115. let postData = ''
  116. this.list.filter(site => site.check).forEach((site, index) => {
  117. postData += (index ? '&' : '?') + 'videoIds=' + site.videoId
  118. })
  119. NET.request(API.deleteVideo + '/' + postData, {}, 'GET').then(res => {
  120. this.$refs.uTips.show({
  121. title: '删除成功',
  122. type: 'success',
  123. })
  124. this.manageType = false
  125. this.pageIndex = 1
  126. this.list = []
  127. this.getList()
  128. }).catch(error => {
  129. this.$refs.uTips.show({
  130. title: error.data.msg,
  131. type: 'warning',
  132. })
  133. })
  134. },
  135. }
  136. }
  137. </script>
  138. <style lang="less" scoped>
  139. page {
  140. width: 100%;
  141. height: 100%;
  142. }
  143. .container {
  144. width: 100%;
  145. height: 100%;
  146. float: left;
  147. background-color: #f7f7f7;
  148. overflow-y: auto;
  149. .media-card {
  150. width: 100%;
  151. float: left;
  152. background: #FFFFFF;
  153. border-radius: 0 0 10px 10px;
  154. margin-bottom: 10px;
  155. .media-head {
  156. width: 100%;
  157. height: 45px;
  158. float: left;
  159. box-sizing: border-box;
  160. padding: 6px 0 6px 15px;
  161. border-bottom: 1px solid #EDEDED;
  162. .media-title {
  163. height: 16px;
  164. float: left;
  165. margin: 8px 0;
  166. padding-left: 6px;
  167. border-left: 2px solid #51A539;
  168. font-size: 15px;
  169. font-family: PingFang SC;
  170. color: #333333;
  171. line-height: 16px;
  172. }
  173. .media-handle {
  174. height: 32px;
  175. float: right;
  176. .handle-text {
  177. height: 32px;
  178. float: left;
  179. padding: 0 10px;
  180. margin: 0 5px;
  181. font-size: 15px;
  182. font-family: PingFang SC;
  183. line-height: 32px;
  184. }
  185. .handle-card {
  186. width: 96px;
  187. height: 32px;
  188. float: left;
  189. background: #51A539;
  190. border-radius: 16px 0px 0px 16px;
  191. font-family: PingFang SC;
  192. color: #FFFFFF;
  193. display: flex;
  194. align-items: center;
  195. justify-content: center;
  196. .iconfont {
  197. font-size: 22px;
  198. }
  199. .handle-card-text {
  200. float: left;
  201. line-height: 32px;
  202. font-size: 12px;
  203. }
  204. }
  205. }
  206. }
  207. .media-content {
  208. width: 100%;
  209. float: left;
  210. padding: 10px 15px;
  211. box-sizing: border-box;
  212. .live-card {
  213. width: 100%;
  214. height: 80px;
  215. float: left;
  216. background-size: 100% 80px;
  217. background-position: center top;
  218. background-repeat: no-repeat;
  219. background-image: url(@/static/images/live-card.png);
  220. }
  221. .video-card:nth-child(odd) {
  222. margin: 0 5px 10px 0;
  223. }
  224. .video-card:nth-child(even) {
  225. margin: 0 0 10px 5px;
  226. }
  227. .video-card {
  228. width: calc(50% - 5px);
  229. height: 206px;
  230. float: left;
  231. background: #FFFFFF;
  232. box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.1);
  233. border-radius: 5px;
  234. overflow: hidden;
  235. .video-img {
  236. width: 100%;
  237. height: 170px;
  238. object-fit: cover;
  239. float: left;
  240. }
  241. .video-title-box {
  242. width: 100%;
  243. height: 36px;
  244. float: left;
  245. font-family: PingFang SC;
  246. line-height: 36px;
  247. display: flex;
  248. justify-content: center;
  249. .iconfont {
  250. color: #51A539;
  251. font-size: 36px;
  252. line-height: 36px;
  253. display: flex;
  254. align-items: center;
  255. }
  256. .video-title {
  257. max-width: calc(100% - 36px);
  258. height: 36px;
  259. line-height: 36px;
  260. font-size: 15px;
  261. color: #333333;
  262. overflow: hidden;
  263. text-overflow: ellipsis;
  264. white-space: nowrap;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. }
  271. </style>