index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. <image class="live-card" src="../../static/images/live-card.png" @click="goToLiveDetail"></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="goManage" 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="!manageType&&goToVideo(item)">
  32. <image class="video-img" :src="item.coverUrl"></image>
  33. <view class="video-title-box" @click.stop="setVideoStatue(item)">
  34. <text class="iconfont" :class="item.check ? 'iconqueding' : 'iconfeigouxuan'"
  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. userData: {},
  63. }
  64. },
  65. onShow() {
  66. this.userData = uni.getStorageSync("userData")||{}
  67. this.getBaseData()
  68. },
  69. onPullDownRefresh() {
  70. this.getBaseData('refresh')
  71. },
  72. methods: {
  73. goManage() {
  74. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '短视频'))){
  75. this.$refs.uTips.show({
  76. title: '没有授权使用,请联系商户负责人',
  77. type: 'warning',
  78. })
  79. return;
  80. }
  81. this.manageType = true
  82. },
  83. // 取消选中
  84. setVideoStatue(item){
  85. item.check = !item.check
  86. },
  87. // 获取全部数据
  88. getBaseData(refresh) {
  89. this.pageIndex = 1
  90. this.list = []
  91. this.getList()
  92. NET.request(API.getLiveId, {}, 'GET').then(res => {
  93. if (refresh == 'refresh') {
  94. uni.stopPullDownRefresh();
  95. }
  96. if (res.data && res.data != 0) {
  97. this.liveId = res.data
  98. }
  99. }).catch(res => {
  100. this.$refs.uTips.show({
  101. title: '获取直播ID失败',
  102. type: 'warning',
  103. })
  104. })
  105. },
  106. // 直播设置
  107. goToSetLive() {
  108. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '直播信息查改'))){
  109. this.$refs.uTips.show({
  110. title: '没有授权使用,请联系商户负责人',
  111. type: 'warning',
  112. })
  113. return;
  114. }
  115. uni.navigateTo({
  116. url: '/pagesMedia/liveOption'
  117. });
  118. },
  119. // 查看直播详情
  120. goToLiveDetail() {
  121. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '开始直播并可选择商品'))){
  122. this.$refs.uTips.show({
  123. title: '没有授权使用,请联系商户负责人',
  124. type: 'warning',
  125. })
  126. return;
  127. }
  128. if (this.liveId) {
  129. uni.navigateTo({
  130. url: '/pagesMedia/liveDetail?liveId=' + this.liveId
  131. });
  132. } else {
  133. this.$refs.uTips.show({
  134. title: '当前无可进行的直播',
  135. type: 'warning',
  136. })
  137. }
  138. },
  139. // 新增短视频
  140. addVideo() {
  141. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '短视频'))){
  142. this.$refs.uTips.show({
  143. title: '没有授权使用,请联系商户负责人',
  144. type: 'warning',
  145. })
  146. return;
  147. }
  148. uni.navigateTo({
  149. url: '/pagesMedia/videoForm?type=add'
  150. });
  151. },
  152. // 懒加载
  153. handleLoadMore() {
  154. if (!this.isOver) {
  155. this.pageIndex++
  156. this.getList()
  157. }
  158. },
  159. // 获取列表数据
  160. getList() {
  161. this.loadingData = true
  162. NET.request(API.getVideoList + this.pageIndex + '/10', {}, 'GET').then(res => {
  163. this.loadingData = false
  164. this.isOver = res.data.list.length != 10
  165. res.data.list.forEach(site => {
  166. site.check = false
  167. })
  168. this.list = this.list.concat(res.data.list)
  169. }).catch(error => {
  170. this.loadingData = false
  171. this.$refs.uTips.show({
  172. title: error.data.msg,
  173. type: 'warning',
  174. })
  175. })
  176. },
  177. // 查看短视频详情
  178. goToVideo(item) {
  179. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '短视频'))){
  180. this.$refs.uTips.show({
  181. title: '没有授权使用,请联系商户负责人',
  182. type: 'warning',
  183. })
  184. return;
  185. }
  186. uni.setStorage({
  187. key: 'videoUrl',
  188. data: item.mediaUrl
  189. })
  190. uni.navigateTo({
  191. url: '/pagesMedia/videoDetail?videoId=' + item.videoId
  192. });
  193. },
  194. // 删除短视频
  195. deleteVideo() {
  196. let postData = ''
  197. this.list.filter(site => site.check).forEach((site, index) => {
  198. postData += (index ? '&' : '?') + 'videoIds=' + site.videoId
  199. })
  200. NET.request(API.deleteVideo + '/' + postData, {}, 'GET').then(res => {
  201. this.$refs.uTips.show({
  202. title: '删除成功',
  203. type: 'success',
  204. })
  205. this.manageType = false
  206. this.pageIndex = 1
  207. this.list = []
  208. this.getList()
  209. }).catch(error => {
  210. this.$refs.uTips.show({
  211. title: error.data.msg,
  212. type: 'warning',
  213. })
  214. })
  215. },
  216. }
  217. }
  218. </script>
  219. <style lang="less" scoped>
  220. page {
  221. width: 100%;
  222. height: 100%;
  223. }
  224. .container {
  225. width: 100%;
  226. height: 100%;
  227. float: left;
  228. background-color: #f7f7f7;
  229. overflow-y: auto;
  230. .media-card {
  231. width: 100%;
  232. float: left;
  233. background: #FFFFFF;
  234. border-radius: 0 0 10px 10px;
  235. margin-bottom: 10px;
  236. .media-head {
  237. width: 100%;
  238. height: 45px;
  239. float: left;
  240. box-sizing: border-box;
  241. padding: 6px 0 6px 15px;
  242. border-bottom: 1px solid #EDEDED;
  243. .media-title {
  244. height: 16px;
  245. float: left;
  246. margin: 8px 0;
  247. padding-left: 6px;
  248. border-left: 2px solid #51A539;
  249. font-size: 15px;
  250. font-family: PingFang SC;
  251. color: #333333;
  252. line-height: 16px;
  253. }
  254. .media-handle {
  255. height: 32px;
  256. float: right;
  257. .handle-text {
  258. height: 32px;
  259. float: left;
  260. padding: 0 10px;
  261. margin: 0 5px;
  262. font-size: 15px;
  263. font-family: PingFang SC;
  264. line-height: 32px;
  265. }
  266. .handle-card {
  267. width: 96px;
  268. height: 32px;
  269. float: left;
  270. background: #51A539;
  271. border-radius: 16px 0px 0px 16px;
  272. font-family: PingFang SC;
  273. color: #FFFFFF;
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. .iconfont {
  278. font-size: 22px;
  279. }
  280. .handle-card-text {
  281. float: left;
  282. line-height: 32px;
  283. font-size: 12px;
  284. }
  285. }
  286. }
  287. }
  288. .media-content {
  289. width: 100%;
  290. float: left;
  291. padding: 10px 15px;
  292. box-sizing: border-box;
  293. .live-card {
  294. width: 100%;
  295. height: 80px;
  296. float: left;
  297. }
  298. .video-card:nth-child(odd) {
  299. margin: 0 5px 10px 0;
  300. }
  301. .video-card:nth-child(even) {
  302. margin: 0 0 10px 5px;
  303. }
  304. .video-card {
  305. width: calc(50% - 5px);
  306. height: 206px;
  307. float: left;
  308. background: #FFFFFF;
  309. box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.1);
  310. border-radius: 5px;
  311. overflow: hidden;
  312. .video-img {
  313. width: 100%;
  314. height: 170px;
  315. object-fit: cover;
  316. float: left;
  317. }
  318. .video-title-box {
  319. width: 100%;
  320. height: 36px;
  321. float: left;
  322. font-family: PingFang SC;
  323. line-height: 36px;
  324. display: flex;
  325. justify-content: center;
  326. .iconfont {
  327. color: #51A539;
  328. font-size: 36px;
  329. line-height: 36px;
  330. display: flex;
  331. align-items: center;
  332. }
  333. .video-title {
  334. max-width: calc(100% - 36px);
  335. height: 36px;
  336. line-height: 36px;
  337. font-size: 15px;
  338. color: #333333;
  339. overflow: hidden;
  340. text-overflow: ellipsis;
  341. white-space: nowrap;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. </style>