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

348 lines
8.3 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
  1. <template>
  2. <view class="main_container">
  3. <view class="screen-swiper-box">
  4. <swiper :hidden="autoplay" class="screen-swiper" indicator-dots="true" circular="true" :autoplay="!autoplay"
  5. indicator-active-color="#71C1F6" indicator-color="#ffffff" interval="3000" duration="500">
  6. <swiper-item>
  7. <image class="swiperImage" :src="pictureUrl" mode="scaleToFill"></image>
  8. </swiper-item>
  9. <swiper-item>
  10. <image class="swiperImage" :src="videoPicture" @click="showVideo" mode="scaleToFill"></image>
  11. </swiper-item>
  12. </swiper>
  13. <view :hidden="!autoplay" class="video">
  14. <video class="MyVideo" id="myVideo" :src="videoUrl" objectFit="cover" @play="BoFang()" @pause="ZanTing()"
  15. controls="true">
  16. <cover-image class="videoClose" @click="colseVideo()"
  17. src="https://i-1-lanrentuku.qqxzb-img.com/2020/11/20/7ab68fc9-e126-47da-bcf2-7dd7a3b9f540.jpg?imageView2/2/w/1024/">
  18. </cover-image>
  19. <!-- 添加一个覆盖在视频上的关闭按钮cover-image -->
  20. </video>
  21. </view>
  22. </view>
  23. <view class="show-audio"></view>
  24. <view style="position:absolute; bottom:55.55rpx; left: 69.44rpx; color: #fff; z-index: 99999;">{{infoTxt}}--{{linkUrl}}--{{ audioName }}</view>
  25. <!-- <view v-if="!deviceInfoShow" class="local-data">
  26. <text class="title">欢迎使用数字新视窗</text>
  27. <view class="data-info">设备ID : 123456789</view>
  28. <view class="data-info">设备账号 : 123456789</view>
  29. <view class="data-info">设备名称 : CVBBN2</view>
  30. <view class="count-down" @click="deviceInfoShow=true">{{ count }}</view>
  31. </view> -->
  32. </view>
  33. </template>
  34. <script>
  35. import utils from '@/utils/common.js';
  36. import one from './show2.js';
  37. let innerAudioContext = uni.createInnerAudioContext();
  38. export default {
  39. components: {},
  40. data() {
  41. return {
  42. // 已登录情况显示6S得设备信息
  43. count: 6,
  44. deviceInfoShow: false,
  45. autoplay: false,
  46. // 素材
  47. materialsCont: [],
  48. show_materials: [],
  49. contentIndex: 0,
  50. itemIndex: 0,
  51. linkUrl: '',
  52. timer: null,
  53. duration: null,
  54. audioSrc: null,
  55. audioName: null,
  56. itemLength: [],
  57. flagIndex: 0,
  58. infoTxt:'',
  59. voicePlayer: null,
  60. videoPicture: 'https://desk-fd.zol-img.com.cn/t_s720x360c5/g6/M00/0B/06/ChMkKmFBixKIYQSCAAJVqqciWmYAATuTwFJgJkAAlXC803.jpg',
  61. pictureUrl: 'https://img-baofun.zhhainiao.com/market/133/2366564fa6b83158208eb3181752a8d6_preview.jpg',
  62. videoUrl: 'https://stream7.iqilu.com/10339/upload_transcode/202002/18/20200218114723HDu3hhxqIT.mp4',
  63. };
  64. },
  65. onReady: function(res) {
  66. // #ifndef MP-ALIPAY
  67. this.videoContext = uni.createVideoContext('myVideo')
  68. // #endif
  69. },
  70. onLoad() {
  71. const _this = this;
  72. let result = one.data.data;
  73. this.materialsCont = result;
  74. this.materialsCont.map(item => {
  75. this.itemLength = this.itemLength.concat(item.show_materials.length);
  76. this.show_materials = this.show_materials.concat(item.show_materials);
  77. });
  78. // 初始化
  79. this.changIndex();
  80. },
  81. created() {
  82. this.atuo();
  83. },
  84. mounted() {
  85. // this.countdown();
  86. this.changeMaterial();
  87. this.voicePlayer.play();
  88. },
  89. methods: {
  90. // 轮播图事件
  91. showVideo() {
  92. this.autoplay = true;
  93. this.videoContext.play();
  94. },
  95. colseVideo() {
  96. this.videoContext.pause();
  97. this.autoplay = false;
  98. },
  99. BoFang() {
  100. this.videoContext.play();
  101. },
  102. ZanTing() {
  103. this.videoContext.pause();
  104. },
  105. swiperChange(current, source){
  106. // 切换如果不是视频位置 暂停视频
  107. console.log(current.target.current)
  108. if(current.target.current == 0){
  109. //this.player.seek(0)
  110. this.player.play()
  111. //this.showFullVideo=true;
  112. }else{
  113. this.player.pause()
  114. //this.player.stop()
  115. //this.showFullVideo=false;
  116. }
  117. },
  118. changeMaterial() {
  119. const _this = this;
  120. clearInterval(_this.timer);
  121. _this.timer = setInterval(() => {
  122. _this.duration -= 1;
  123. if (_this.duration == 0) {
  124. _this.itemIndex++;
  125. _this.flagIndex++;
  126. this.changIndex();
  127. }
  128. }, 1000);
  129. },
  130. changIndex() {
  131. const _this = this;
  132. if (_this.itemIndex == this.show_materials.length) {
  133. // clearInterval(_this.timer);
  134. this.itemIndex = 0;
  135. this.flagIndex = 0;
  136. this.contentIndex = 0;
  137. innerAudioContext.stop();
  138. }
  139. _this.duration = this.show_materials[this.itemIndex].duration;
  140. _this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  141. if (this.show_materials[this.itemIndex].bgm_url) {
  142. _this.audioSrc = '../../static/source/' + this.show_materials[this.itemIndex].bgm_url;
  143. _this.audioName = this.show_materials[this.itemIndex].bgm_name;
  144. } else {
  145. if (this.contentIndex == this.itemLength.length) {
  146. this.flagIndex = 0;
  147. this.contentIndex = 0;
  148. }else{
  149. if (this.flagIndex == this.itemLength[this.contentIndex]) {
  150. this.flagIndex = 0;
  151. this.contentIndex++;
  152. }
  153. }
  154. if (this.materialsCont[this.contentIndex].bgm_main) {
  155. this.audioSrc = '../../static/source/' + this.materialsCont[this.contentIndex].bgm_main;
  156. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  157. }
  158. }
  159. // this.playVoice(this.audioSrc);
  160. if (this.show_materials[this.itemIndex].material_type == 1) {
  161. innerAudioContext.stop();
  162. }
  163. },
  164. videoPlayEnd() {
  165. this.itemIndex++;
  166. this.flagIndex++;
  167. this.changIndex();
  168. },
  169. playVoice(src) {
  170. if (innerAudioContext != undefined) {
  171. innerAudioContext.stop();
  172. }
  173. innerAudioContext = uni.createInnerAudioContext();
  174. innerAudioContext.stop();
  175. innerAudioContext.src = src;
  176. innerAudioContext.autoplay = true;
  177. innerAudioContext.onPlay(() => {
  178. this.infoTxt = ''
  179. this.infoTxt = '开始播放'
  180. console.log('开始播放');
  181. });
  182. innerAudioContext.onError(res => {
  183. console.log(res.errMsg);
  184. console.log(res.errCode);
  185. innerAudioContext.stop();
  186. });
  187. innerAudioContext.onPause(() => {
  188. //暂停监听
  189. this.infoTxt = '暂停'
  190. console.log('暂停');
  191. // innerAudioContext.stop();
  192. });
  193. innerAudioContext.onEnded(() => {
  194. // 自然播放结束监听也需要更改isPause 开关状态
  195. this.infoTxt = '音频自然播放结束事件'
  196. console.log('音频自然播放结束事件');
  197. innerAudioContext.stop();
  198. });
  199. },
  200. atuo() {
  201. this.autoplay = true;
  202. },
  203. countdown() {
  204. this.count = 6;
  205. const timer = setInterval(() => {
  206. this.count -= 1;
  207. if (this.count < 1) {
  208. clearInterval(timer);
  209. this.deviceInfoShow = true;
  210. console.log('倒计时结束');
  211. }
  212. }, 1000);
  213. }
  214. }
  215. };
  216. </script>
  217. <!--
  218. <style scoped>
  219. .main_container {
  220. position: relative;
  221. overflow: hidden;
  222. background: #000;
  223. }
  224. .show-item {
  225. /* width: 100%;
  226. height: 100vh; */
  227. display: flex;
  228. flex-direction: column;
  229. align-items: center;
  230. justify-content: center;
  231. }
  232. .show-item .show-img {
  233. width: 100%;
  234. height: 100vh;
  235. object-fit: cover;
  236. }
  237. .show-item uni-video {
  238. width: 100%;
  239. }
  240. .show-video {
  241. width: 100%;
  242. height: 100vh;
  243. }
  244. .show-audio {
  245. position: fixed;
  246. bottom: 79.16rpx;
  247. right: 46.52rpx;
  248. width: 159.72rpx;
  249. height: 152.08rpx;
  250. background: url(~@/static/images/an-yy.png) no-repeat;
  251. background-size: cover;
  252. }
  253. .show-audio uni-image {
  254. width: 159.72rpx;
  255. height: 152.08rpx;
  256. }
  257. .local-data {
  258. position: absolute;
  259. left: 50%;
  260. top: 50%;
  261. display: flex;
  262. flex-direction: column;
  263. justify-content: center;
  264. width: 625rpx;
  265. height: 555.55rpx;
  266. transform: translate(-50%, -50%);
  267. font-size: 27.77rpx;
  268. color: #333;
  269. border-radius: 27.77rpx;
  270. background: rgba(255, 255, 255, 0.85);
  271. }
  272. .title {
  273. margin-bottom: 32.63rpx;
  274. font-size: 56.94rpx;
  275. text-align: center;
  276. }
  277. .data-info {
  278. padding: 0 83.33rpx;
  279. margin-bottom: 32.63rpx;
  280. }
  281. .count-down {
  282. position: absolute;
  283. right: 34.72rpx;
  284. top: 27.77rpx;
  285. width: 48.61rpx;
  286. height: 48.61rpx;
  287. font-size: 30.55rpx;
  288. text-align: center;
  289. line-height: 48.61rpx;
  290. border: 1px solid #333;
  291. border-radius: 50%;
  292. }
  293. </style> -->
  294. <style lang="scss" scoped>
  295. .screen-swiper-box {
  296. position: absolute;
  297. width: 100%;
  298. height: 350rpx;
  299. .video {
  300. height: 100%;
  301. width: 100%;
  302. position: absolute;
  303. .MyVideo {
  304. width: 100%;
  305. position: absolute;
  306. height: 100%;
  307. .videoClose {
  308. height: 40rpx;
  309. width: 40rpx;
  310. position: absolute;
  311. right: -1rpx;
  312. z-index: 99999;
  313. background-repeat: no-repeat;
  314. background-size: 100% 100%;
  315. }
  316. }
  317. }
  318. .screen-swiper {
  319. width: 100%;
  320. position: absolute;
  321. height: 100%;
  322. .swiperImage {
  323. width: 100%;
  324. position: absolute;
  325. height: 100%;
  326. }
  327. }
  328. }
  329. </style>