index.vue 11 KB

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