智慧画屏客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

498 lines
13 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. <template>
  2. <view class="main_container">
  3. <view class="show-content" @touchstart="touchStart" @touchmove="touchMove" @touchend="touchEnd">
  4. <view v-for="(item, index) in show_materials" :key="index" :class="['show-item', item.material_type == 1 && itemIndex == index ? 'show-video' : '']">
  5. <!-- <image
  6. :class="['show-img', 'animate__animated', item.material_type == 0 ? item.effect : '']"
  7. v-show="item.material_type == 0 && itemIndex == index"
  8. :src="linkUrl"
  9. mode="aspectFill"
  10. ></image> -->
  11. <image
  12. :class="['show-img', 'animate__animated', item.material_type == 0 ? item.effect : '']"
  13. v-show="item.material_type == 0 && itemIndex == index"
  14. :src="require('@/static/source/'+linkUrl)"
  15. mode="aspectFill"
  16. ></image>
  17. <video
  18. :id="'video' + index"
  19. v-if="item.material_type == 1 && itemIndex == index"
  20. :src="require('@/static/source/'+linkUrl)"
  21. :controls="false"
  22. :autoplay="autoplay"
  23. :enable-progress-gesture="false"
  24. :enable-play-gesture="false"
  25. object-fit="contain"
  26. show-center-play-btn="false"
  27. @play="playEvent"
  28. @ended="videoPlayEnd"
  29. @waiting="waitingVideo"
  30. @loadeddata="loading"
  31. @timeupdate="timeUpdate"
  32. initial-time="initial_time"
  33. >
  34. </video>
  35. </view>
  36. </view>
  37. <view class="show-audio" @click="pauseAudio">
  38. <image :class="['audio_round',!isPauseAudio ? 'animate_round' : '']" src="~@/static/images/audio_01.png"></image>
  39. <image class="audio_zz" src="~@/static/images/audio_02.png"></image>
  40. </view>
  41. <!-- <view style="position:absolute; bottom:55.55rpx; left: 69.44rpx; color: #fff; z-index: 99999;">{{ infoTxt }}--{{ audioName }}</view> -->
  42. <view v-if="!deviceInfoShow" class="local-data">
  43. <text class="title">欢迎使用数字新视窗</text>
  44. <view class="data-info">设备ID : 123456789</view>
  45. <view class="data-info">设备账号 : 123456789</view>
  46. <view class="data-info">设备名称 : CVBBN2</view>
  47. <view class="count-down" @click="deviceInfoShow=true">{{ count }}</view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import one from './show.js';
  53. let innerAudioContext = uni.createInnerAudioContext();
  54. export default {
  55. name:'Show',
  56. components: {},
  57. data() {
  58. return {
  59. // 已登录情况显示6S得设备信息
  60. count: 6,
  61. deviceInfoShow: false,
  62. autoplay: false,
  63. // 素材
  64. materialsCont: [],
  65. show_materials: [],
  66. contentIndex: 0,
  67. itemIndex: 0,
  68. linkUrl: '',
  69. timer: null,
  70. duration: null,
  71. audioSrc: null,
  72. audioName: null,
  73. itemLength: [],
  74. flagIndex: 0,
  75. infoTxt: '',
  76. video_real_time: 0,
  77. nitial_time: '',
  78. startY: 0,
  79. startX: 0,
  80. isAutoSwitch: true,
  81. moveX: 0, //滑动的x轴距离
  82. moveY: 0, //滑动的y轴距离
  83. pageState: 0,//-1:左滑,0:没滑动,1:右滑
  84. isPauseAudio: false
  85. };
  86. },
  87. onLoad() {
  88. const _this = this;
  89. let result = one.data.data;
  90. this.materialsCont = result;
  91. this.materialsCont.map(item => {
  92. this.itemLength = this.itemLength.concat(item.show_materials.length);
  93. this.show_materials = this.show_materials.concat(item.show_materials);
  94. });
  95. // 初始化
  96. this.changIndex();
  97. },
  98. onReady: function(res) {
  99. const videoId = 'video'+this.itemIndex
  100. this.videoCtx = uni.createVideoContext(videoId)
  101. },
  102. created() {
  103. this.auto();
  104. },
  105. mounted() {
  106. this.countdown();
  107. this.changeMaterial();
  108. },
  109. methods: {
  110. // 素材切换
  111. touchStart(event) {
  112. this.startX = event.touches[0].pageX;
  113. this.startY = event.touches[0].pageY;
  114. // console.log('开始触摸:', this.startX, this.startY);
  115. },
  116. touchMove(event) {
  117. let currentX = event.touches[0].pageX;
  118. let currentY = event.touches[0].pageY;
  119. let moveX = currentX - this.startX;
  120. let moveY = currentY - this.startY;
  121. let text = '';
  122. let state = 0; //-1:左滑,0:没滑动,1:右滑
  123. // //左右方向滑动
  124. if (Math.abs(moveX) > Math.abs(moveY)) {
  125. if (moveX < -10) {
  126. text = '左滑';
  127. state = 1;
  128. } else if (moveX > 10) {
  129. text = '右滑';
  130. state = -1;
  131. }
  132. } else {
  133. //上下方向滑动
  134. if (moveY < 0) {
  135. text = '上滑';
  136. state = -2;
  137. } else if (moveY > 0) {
  138. text = '下滑';
  139. state = 2;
  140. }
  141. }
  142. this.pageState = state;
  143. this.moveX = moveX;
  144. this.moveY = moveY;
  145. // console.log('开始滑动:', this.moveX, this.moveY, this.pageState);
  146. },
  147. touchEnd(event) {
  148. // console.log(`移动距离:${Math.abs(this.moveX)}`);
  149. // if (Math.abs(this.moveX) > 60 ) {
  150. // if (this.pageState == 1) {
  151. // this.itemIndex++;
  152. // this.flagIndex++;
  153. // this.isAutoSwitch = true;
  154. // } else if (this.pageState == -1) {
  155. // this.itemIndex--;
  156. // this.flagIndex--;
  157. // this.isAutoSwitch = false;
  158. // }
  159. // this.changIndex();
  160. // }
  161. // 上下滑动
  162. if (Math.abs(this.moveY) > 60) {
  163. if (this.pageState == -2) {
  164. this.itemIndex++;
  165. this.flagIndex++;
  166. this.isAutoSwitch = true;
  167. } else if (this.pageState == 2) {
  168. this.itemIndex--;
  169. this.flagIndex--;
  170. this.isAutoSwitch = false;
  171. }
  172. this.changIndex();
  173. }
  174. },
  175. // 自动切换
  176. changeMaterial() {
  177. const _this = this;
  178. clearInterval(_this.timer);
  179. _this.timer = setInterval(() => {
  180. _this.duration -= 1;
  181. if (_this.duration == 0) {
  182. _this.itemIndex++;
  183. _this.flagIndex++;
  184. this.isAutoSwitch = true;
  185. this.changIndex();
  186. }
  187. }, 1000);
  188. },
  189. changIndex() {
  190. const _this = this;
  191. innerAudioContext.destroy();
  192. _this.linkUrl = '';
  193. console.log(this.itemLength)
  194. // 资源素材加载到最后一张时 - 下一页
  195. if (_this.itemIndex == this.show_materials.length) {
  196. // clearInterval(_this.timer);
  197. console.log('最后一页啦')
  198. this.itemIndex = 0;
  199. this.flagIndex = 0;
  200. this.contentIndex = 0;
  201. }
  202. // 资源加载到第一张时 - 上一页
  203. if (this.itemIndex == -1) {
  204. this.itemIndex = this.show_materials.length - 1;
  205. this.contentIndex = this.itemLength.length - 1;
  206. this.flagIndex = this.itemLength[this.contentIndex];
  207. }
  208. if (this.flagIndex == -1) {
  209. this.contentIndex--;
  210. this.flagIndex = this.itemLength[this.contentIndex];
  211. }
  212. // 图片播放时间
  213. _this.duration = this.show_materials[this.itemIndex].duration;
  214. // 资源地址-图片/视频
  215. _this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  216. // 优先判断图片自带音频
  217. if (this.show_materials[this.itemIndex].bgm_url) {
  218. _this.audioSrc = this.show_materials[this.itemIndex].bgm_url;
  219. _this.audioName = this.show_materials[this.itemIndex].bgm_name;
  220. } else {
  221. // 不同发布节点
  222. if (this.contentIndex == this.itemLength.length) {
  223. this.flagIndex = 0;
  224. this.contentIndex = 0;
  225. } else {
  226. if (this.isAutoSwitch) {
  227. if (this.flagIndex == this.itemLength[this.contentIndex]) {
  228. this.flagIndex = 0;
  229. this.contentIndex++;
  230. if (this.contentIndex == this.itemLength.length || _this.itemIndex == this.show_materials.length) {
  231. this.contentIndex = this.itemLength.length-1;
  232. this.flagIndex = this.itemLength[this.contentIndex];
  233. }
  234. }
  235. }
  236. }
  237. // 图片无自带 - 再判断是否有BGM - main
  238. if (this.materialsCont[this.contentIndex].bgm_main) {
  239. this.audioSrc = this.materialsCont[this.contentIndex].bgm_main;
  240. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  241. }
  242. }
  243. // 当前资源是 - 视频 - 时,即销毁音频(防止干扰)
  244. if (this.show_materials[this.itemIndex].material_type == 1) {
  245. innerAudioContext.destroy();
  246. innerAudioContext.src = '';
  247. }
  248. // 销毁-创建音频-播放音频
  249. innerAudioContext = uni.createInnerAudioContext();
  250. this.playVoice(this.audioSrc);
  251. },
  252. // 视频
  253. videoPlayEnd() {
  254. console.log('end-video');
  255. this.itemIndex++;
  256. this.flagIndex++;
  257. this.changIndex();
  258. },
  259. auto() {
  260. setTimeout(()=>{
  261. this.autoplay = true;
  262. },500)
  263. },
  264. playEvent(e) {
  265. console.log("play_video")
  266. let currentId = e.target.id; // 获取当前视频id
  267. this.videoCtx = uni.createVideoContext(currentId);
  268. innerAudioContext.destroy();
  269. },
  270. loading(){
  271. console.log('play_loading');
  272. },
  273. waitingVideo(){
  274. console.log('waiting-video');
  275. this.videoCtx.pause();
  276. },
  277. timeupdateEvent(event) {
  278. console.log('timeupdateEvent');
  279. },
  280. // 禁止拖动进度条快进
  281. timeUpdate(e) {
  282. var isReady = 1; // 是否开启可以视频快进 1 禁止开启
  283. //跳转到指定播放位置 initial-time 时间为秒
  284. let that = this;
  285. //播放的总时长
  286. var duration = e.detail.duration;
  287. //实时播放进度 秒数
  288. var currentTime = parseInt(e.detail.currentTime);
  289. //当前视频进度
  290. // console.log("视频播放到第" + currentTime + "秒")//查看正在播放时间,以秒为单位
  291. if (that.video_real_time == 0) {
  292. var jump_time = parseInt(that.initial_time) + parseInt(that.video_real_time);
  293. } else {
  294. var jump_time = parseInt(that.video_real_time);
  295. }
  296. if (isReady == 1) {
  297. if (currentTime > jump_time && currentTime - jump_time > 3) {
  298. let videoContext = uni.createVideoContext(e.target.id);
  299. uni.showToast({
  300. title: '未完整看完该视频,不能快进',
  301. icon: 'none',
  302. duration: 2000
  303. });
  304. videoContext.stop();
  305. videoContext.seek(0);
  306. }
  307. }
  308. that.video_real_time = currentTime; //实时播放进度
  309. },
  310. pauseAudio(){
  311. this.isPauseAudio = !this.isPauseAudio;
  312. if(this.isPauseAudio){
  313. innerAudioContext.pause();
  314. }else{
  315. this.playVoice(this.audioSrc);
  316. }
  317. },
  318. // 音频
  319. playVoice(src) {
  320. const _this = this;
  321. if (innerAudioContext != undefined) {
  322. innerAudioContext.stop();
  323. }
  324. innerAudioContext = uni.createInnerAudioContext();
  325. innerAudioContext.stop();
  326. innerAudioContext.src = src;
  327. if(_this.isPauseAudio){
  328. if(innerAudioContext.paused){
  329. innerAudioContext.destroy();
  330. innerAudioContext = uni.createInnerAudioContext();
  331. }else{
  332. innerAudioContext.autoplay = true;
  333. }
  334. }else{
  335. innerAudioContext.autoplay = true;
  336. }
  337. innerAudioContext.onPlay(() => {
  338. this.infoTxt = '音频开始播放';
  339. console.log('开始播放');
  340. });
  341. innerAudioContext.onStop(() => {
  342. this.infoTxt = '音频停止';
  343. // console.log('停止');
  344. });
  345. innerAudioContext.onError(res => {
  346. if(this.show_materials[this.itemIndex].material_type != 1){
  347. console.log(res.errMsg);
  348. console.log(res.errCode);
  349. innerAudioContext.destroy();
  350. }
  351. });
  352. innerAudioContext.onEnded(() => {
  353. this.infoTxt = '音频自然播放结束事件';
  354. // console.log('音频自然播放结束事件');
  355. });
  356. },
  357. countdown() {
  358. this.count = 6;
  359. const timer = setInterval(() => {
  360. this.count -= 1;
  361. if (this.count < 1) {
  362. clearInterval(timer);
  363. this.deviceInfoShow = true;
  364. console.log('倒计时结束');
  365. }
  366. }, 1000);
  367. }
  368. }
  369. };
  370. </script>
  371. <style scoped>
  372. .main_container {
  373. position: relative;
  374. overflow: hidden;
  375. background: #000;
  376. }
  377. .show-item {
  378. display: flex;
  379. flex-direction: column;
  380. align-items: center;
  381. justify-content: center;
  382. }
  383. .show-item .show-img {
  384. width: 100%;
  385. height: 100vh;
  386. object-fit: cover;
  387. }
  388. .show-item uni-video {
  389. width: 100%;
  390. height: 100%;
  391. }
  392. .show-video {
  393. width: 100%;
  394. height: 100vh;
  395. }
  396. .show-audio {
  397. position: fixed;
  398. bottom: 79.16rpx;
  399. right: 46.52rpx;
  400. width: 122.91rpx;
  401. height: 113.88rpx;
  402. }
  403. .show-audio .audio_round{
  404. width: 113.19rpx;
  405. height: 113.19rpx;
  406. }
  407. .show-audio .audio_zz{
  408. position: absolute;
  409. right: 0;
  410. top: 0;
  411. width: 40.27rpx;
  412. height: 84.02rpx;
  413. z-index: 999;
  414. }
  415. .animate_round{
  416. animation: circle 2s linear infinite;
  417. }
  418. @keyframes circle {
  419. 100% {
  420. transform: rotate(360deg);
  421. }
  422. }
  423. .show-audio uni-image {
  424. width: 159.72rpx;
  425. height: 152.08rpx;
  426. }
  427. .local-data {
  428. position: absolute;
  429. left: 50%;
  430. top: 50%;
  431. display: flex;
  432. flex-direction: column;
  433. justify-content: center;
  434. width: 625rpx;
  435. height: 555.55rpx;
  436. transform: translate(-50%, -50%);
  437. font-size: 27.77rpx;
  438. color: #333;
  439. border-radius: 27.77rpx;
  440. background: rgba(255, 255, 255, 0.85);
  441. }
  442. .title {
  443. margin-bottom: 32.63rpx;
  444. font-size: 56.94rpx;
  445. text-align: center;
  446. }
  447. .data-info {
  448. padding: 0 83.33rpx;
  449. margin-bottom: 32.63rpx;
  450. }
  451. .count-down {
  452. position: absolute;
  453. right: 34.72rpx;
  454. top: 27.77rpx;
  455. width: 48.61rpx;
  456. height: 48.61rpx;
  457. font-size: 30.55rpx;
  458. text-align: center;
  459. line-height: 48.61rpx;
  460. border: 1px solid #333;
  461. border-radius: 50%;
  462. }
  463. .swiper {
  464. height: 100vh;
  465. }
  466. .item {
  467. width: 100%;
  468. height: 100%;
  469. }
  470. .mask {
  471. position: absolute;
  472. top: 0;
  473. left: 0;
  474. bottom: 0;
  475. right: 0;
  476. width: 100%;
  477. height: 100%;
  478. background: rgba(0, 0, 0, 0.3);
  479. z-index: 999;
  480. }
  481. .controls-title {
  482. position: absolute;
  483. top: 0;
  484. left: 0;
  485. bottom: 0;
  486. right: 0;
  487. width: 100%;
  488. height: 100%;
  489. background: rgba(0, 0, 0, 0.3);
  490. text-align: center;
  491. color: #ffffff;
  492. border: 10px solid #fff;
  493. z-index: 9999;
  494. }
  495. </style>