智慧画屏客户端
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.

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