index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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 class="uni-popup-dialog" :hidden="show_qx">
  48. <view class="uni-dialog-title">
  49. <text class="uni-dialog-title-text">提示</text>
  50. </view>
  51. <view class="uni-dialog-content">
  52. <text class="uni-dialog-content-text">请在设置中开启摄像头权限和麦克风权限</text>
  53. </view>
  54. <view class="uni-dialog-button-group">
  55. <button class="uni-dialog-button uni-border-left" open-type="openSetting" @click="closeSetting">
  56. 设置权限
  57. </button>
  58. </view>
  59. </view>
  60. <view class="qx_bg" :hidden="show_qx">
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. const NET = require('@/utils/request')
  67. const API = require('@/config/api')
  68. export default {
  69. data() {
  70. return {
  71. show_qx:true,
  72. liveId: '',
  73. pageIndex: 1,
  74. isOver: false,
  75. list: [],
  76. manageType: false,
  77. loadingData: false,
  78. userData: {},
  79. }
  80. },
  81. onShow() {
  82. this.userData = uni.getStorageSync("userData")||{}
  83. this.getBaseData()
  84. },
  85. onPullDownRefresh() {
  86. this.getBaseData('refresh')
  87. },
  88. methods: {
  89. closeSetting:function(){
  90. this.show_qx=true;
  91. },
  92. goManage() {
  93. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '短视频'))){
  94. this.$refs.uTips.show({
  95. title: '没有授权使用,请联系商户负责人',
  96. type: 'warning',
  97. })
  98. return;
  99. }
  100. this.manageType = true
  101. },
  102. // 取消选中
  103. setVideoStatue(item){
  104. item.check = !item.check
  105. },
  106. // 获取全部数据
  107. getBaseData(refresh) {
  108. this.pageIndex = 1
  109. this.list = []
  110. this.getList()
  111. NET.request(API.getLiveId, {}, 'GET').then(res => {
  112. if (refresh == 'refresh') {
  113. uni.stopPullDownRefresh();
  114. }
  115. if (res.data && res.data != 0) {
  116. this.liveId = res.data
  117. }
  118. }).catch(res => {
  119. this.$refs.uTips.show({
  120. title: '获取直播ID失败',
  121. type: 'warning',
  122. })
  123. })
  124. },
  125. // 直播设置
  126. goToSetLive() {
  127. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '直播信息查改'))){
  128. this.$refs.uTips.show({
  129. title: '没有授权使用,请联系商户负责人',
  130. type: 'warning',
  131. })
  132. return;
  133. }
  134. uni.navigateTo({
  135. url: '/pagesMedia/liveOption'
  136. });
  137. },
  138. // 查看直播详情
  139. goToLiveDetail() {
  140. // uni.navigateTo({
  141. // url: '/pagesMedia/liveDetail?liveId=' + 1
  142. // });
  143. // return;
  144. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '开始直播并可选择商品'))){
  145. this.$refs.uTips.show({
  146. title: '没有授权使用,请联系商户负责人',
  147. type: 'warning',
  148. })
  149. return;
  150. }
  151. if (this.liveId) {
  152. var that=this;
  153. if(uni.getStorageSync("firstTimeLive")==""){
  154. uni.setStorage({
  155. key: 'firstTimeLive',
  156. data: 1
  157. })
  158. uni.navigateTo({
  159. url: '/pagesMedia/liveDetail?liveId=' + that.liveId
  160. });
  161. }else{
  162. // wx.getSetting({
  163. // success(res) {
  164. // if (!res.authSetting['scope.camera']){
  165. // that.show_qx=false;
  166. // }else if (!res.authSetting['scope.record']){
  167. // that.show_qx=false;
  168. // }else{
  169. uni.navigateTo({
  170. url: '/pagesMedia/liveDetail?liveId=' + that.liveId
  171. });
  172. // }
  173. // }
  174. // })
  175. }
  176. } else {
  177. this.$refs.uTips.show({
  178. title: '当前无可进行的直播',
  179. type: 'warning',
  180. })
  181. }
  182. },
  183. // 新增短视频
  184. addVideo() {
  185. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '短视频'))){
  186. this.$refs.uTips.show({
  187. title: '没有授权使用,请联系商户负责人',
  188. type: 'warning',
  189. })
  190. return;
  191. }
  192. uni.navigateTo({
  193. url: '/pagesMedia/videoForm?type=add'
  194. });
  195. },
  196. // 懒加载
  197. handleLoadMore() {
  198. if (!this.isOver) {
  199. this.pageIndex++
  200. this.getList()
  201. }
  202. },
  203. // 获取列表数据
  204. getList() {
  205. this.loadingData = true
  206. NET.request(API.getVideoList + this.pageIndex + '/10', {}, 'GET').then(res => {
  207. this.loadingData = false
  208. this.isOver = res.data.list.length != 10
  209. res.data.list.forEach(site => {
  210. site.check = false
  211. })
  212. this.list = this.list.concat(res.data.list)
  213. }).catch(error => {
  214. this.loadingData = false
  215. this.$refs.uTips.show({
  216. title: error.data.msg,
  217. type: 'warning',
  218. })
  219. })
  220. },
  221. // 查看短视频详情
  222. goToVideo(item) {
  223. if(!this.userData.roleInfos.some(v=>v.menuInfos.some(vv=>vv.label == '短视频'))){
  224. this.$refs.uTips.show({
  225. title: '没有授权使用,请联系商户负责人',
  226. type: 'warning',
  227. })
  228. return;
  229. }
  230. uni.setStorage({
  231. key: 'videoUrl',
  232. data: item.mediaUrl
  233. })
  234. // uni.navigateTo({
  235. // url: '/pagesMedia/videoDetail?videoId=' + item.videoId
  236. // });
  237. uni.navigateTo({
  238. url: '/pagesMedia/videoForm?type=edit&videoId=' + item.videoId
  239. });
  240. },
  241. // 删除短视频
  242. deleteVideo() {
  243. let postData = ''
  244. this.list.filter(site => site.check).forEach((site, index) => {
  245. postData += (index ? '&' : '?') + 'videoIds=' + site.videoId
  246. })
  247. NET.request(API.deleteVideo + '/' + postData, {}, 'GET').then(res => {
  248. this.$refs.uTips.show({
  249. title: '删除成功',
  250. type: 'success',
  251. })
  252. this.manageType = false
  253. this.pageIndex = 1
  254. this.list = []
  255. this.getList()
  256. }).catch(error => {
  257. this.$refs.uTips.show({
  258. title: error.data.msg,
  259. type: 'warning',
  260. })
  261. })
  262. },
  263. }
  264. }
  265. </script>
  266. <style lang="less" scoped>
  267. page {
  268. width: 100%;
  269. height: 100%;
  270. }
  271. .container {
  272. width: 100%;
  273. height: 100%;
  274. float: left;
  275. background-color: #f7f7f7;
  276. overflow-y: auto;
  277. .media-card {
  278. width: 100%;
  279. float: left;
  280. background: #FFFFFF;
  281. border-radius: 0 0 10px 10px;
  282. margin-bottom: 10px;
  283. .media-head {
  284. width: 100%;
  285. height: 45px;
  286. float: left;
  287. box-sizing: border-box;
  288. padding: 6px 0 6px 15px;
  289. border-bottom: 1px solid #EDEDED;
  290. .media-title {
  291. height: 16px;
  292. float: left;
  293. margin: 8px 0;
  294. padding-left: 6px;
  295. border-left: 2px solid #51A539;
  296. font-size: 15px;
  297. font-family: PingFang SC;
  298. color: #333333;
  299. line-height: 16px;
  300. }
  301. .media-handle {
  302. height: 32px;
  303. float: right;
  304. .handle-text {
  305. height: 32px;
  306. float: left;
  307. padding: 0 10px;
  308. margin: 0 5px;
  309. font-size: 15px;
  310. font-family: PingFang SC;
  311. line-height: 32px;
  312. }
  313. .handle-card {
  314. width: 96px;
  315. height: 32px;
  316. float: left;
  317. background: #51A539;
  318. border-radius: 16px 0px 0px 16px;
  319. font-family: PingFang SC;
  320. color: #FFFFFF;
  321. display: flex;
  322. align-items: center;
  323. justify-content: center;
  324. .iconfont {
  325. font-size: 22px;
  326. }
  327. .handle-card-text {
  328. float: left;
  329. line-height: 32px;
  330. font-size: 12px;
  331. }
  332. }
  333. }
  334. }
  335. .media-content {
  336. width: 100%;
  337. float: left;
  338. padding: 10px 15px;
  339. box-sizing: border-box;
  340. .live-card {
  341. width: 100%;
  342. height: 80px;
  343. float: left;
  344. }
  345. .video-card:nth-child(odd) {
  346. margin: 0 5px 10px 0;
  347. }
  348. .video-card:nth-child(even) {
  349. margin: 0 0 10px 5px;
  350. }
  351. .video-card {
  352. width: calc(50% - 5px);
  353. height: 206px;
  354. float: left;
  355. background: #FFFFFF;
  356. box-shadow: 0px 1px 10px 0px rgba(0, 0, 0, 0.1);
  357. border-radius: 5px;
  358. overflow: hidden;
  359. .video-img {
  360. width: 100%;
  361. height: 170px;
  362. object-fit: cover;
  363. float: left;
  364. }
  365. .video-title-box {
  366. width: 100%;
  367. height: 36px;
  368. float: left;
  369. font-family: PingFang SC;
  370. line-height: 36px;
  371. display: flex;
  372. justify-content: center;
  373. .iconfont {
  374. color: #51A539;
  375. font-size: 36px;
  376. line-height: 36px;
  377. display: flex;
  378. align-items: center;
  379. }
  380. .video-title {
  381. max-width: calc(100% - 36px);
  382. height: 36px;
  383. line-height: 36px;
  384. font-size: 15px;
  385. color: #333333;
  386. overflow: hidden;
  387. text-overflow: ellipsis;
  388. white-space: nowrap;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. }
  395. .uni-popup-dialog {
  396. width: 80vw;
  397. border-radius: 15px;
  398. background-color: #fff;
  399. position: fixed;
  400. margin-left: 10vw;
  401. top: 34vh;
  402. z-index: 11;
  403. }
  404. .uni-dialog-title {
  405. /* #ifndef APP-NVUE */
  406. display: flex;
  407. /* #endif */
  408. flex-direction: row;
  409. justify-content: center;
  410. padding-top: 15px;
  411. padding-bottom: 5px;
  412. }
  413. .uni-dialog-title-text {
  414. font-size: 16px;
  415. font-weight: 500;
  416. }
  417. .uni-dialog-content {
  418. /* #ifndef APP-NVUE */
  419. display: flex;
  420. /* #endif */
  421. flex-direction: row;
  422. justify-content: center;
  423. align-items: center;
  424. padding: 5px 15px 15px 15px;
  425. text-align: center;
  426. }
  427. .uni-dialog-content-text {
  428. font-size: 14px;
  429. color: #6e6e6e;
  430. }
  431. .uni-dialog-button-group {
  432. /* #ifndef APP-NVUE */
  433. display: flex;
  434. /* #endif */
  435. flex-direction: row;
  436. border-top-color: #f5f5f5;
  437. border-top-style: solid;
  438. border-top-width: 1px;
  439. }
  440. .uni-dialog-button {
  441. /* #ifndef APP-NVUE */
  442. display: flex;
  443. /* #endif */
  444. background: rgba(0, 0, 0, 0);
  445. border: none;
  446. flex: 1;
  447. flex-direction: row;
  448. justify-content: center;
  449. align-items: center;
  450. height: 45px;
  451. }
  452. .uni-border-left {
  453. border-left-color: #f0f0f0;
  454. border-left-style: solid;
  455. border-left-width: 0px;
  456. }
  457. .uni-dialog-button-text {
  458. font-size: 14px;
  459. }
  460. .uni-button-color {
  461. color: #007aff;
  462. }
  463. .uni-dialog-input {
  464. flex: 1;
  465. font-size: 14px;
  466. }
  467. .uni-popup__success {
  468. color: #4cd964;
  469. }
  470. .uni-popup__warn {
  471. color: #f0ad4e;
  472. }
  473. .uni-popup__error {
  474. color: #dd524d;
  475. }
  476. .uni-popup__info {
  477. color: #909399;
  478. }
  479. .qx_bg{
  480. width: 100vw;
  481. height: 100vh;
  482. background: rgba(0, 0, 0, 0.25);
  483. position: fixed;
  484. top: 0px;
  485. left: 0px;
  486. z-index: 10;
  487. }
  488. </style>