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

292 lines
8.4 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
  1. <template>
  2. <view class="main_container">
  3. <view class="show-content">
  4. <view v-for="(item, index) in show_materials" :key="index" :class="['show-item', item.material_type == 1 && itemIndex == index ? 'show-video' : '']">
  5. <image :class="['show-img','animate__animated', item.material_type == 0 ? item.effect : '']" v-show="item.material_type == 0 && itemIndex == index" :src="linkUrl"></image>
  6. <video v-if="item.material_type == 1 && itemIndex == index" :src="linkUrl" :autoplay="autoplay" controls object-fit="fill" @ended="videoPlayEnd"></video>
  7. </view>
  8. </view>
  9. <view class="show-audio"></view>
  10. <view style="position:absolute; bottom: 6.94rpx; color: #fff; z-index: 99999;">{{ audioName }}</view>
  11. <!-- <view v-if="!deviceInfoShow" class="local-data">
  12. <text class="title">欢迎使用数字新视窗</text>
  13. <view class="data-info">设备ID : 123456789</view>
  14. <view class="data-info">设备账号 : 123456789</view>
  15. <view class="data-info">设备名称 : CVBBN2</view>
  16. <view class="count-down" @click="deviceInfoShow=true">{{ count }}</view>
  17. </view> -->
  18. </view>
  19. </template>
  20. <script>
  21. // https://qiniu.aiyxlib.com/1608277325000.mp4
  22. // https://qiniu.aiyxlib.com/1634285181000.mp4
  23. // https://qiniu.aiyxlib.com/yuekan-BGM19.mp3
  24. // https://qiniu.aiyxlib.com/yuekan-BGM31.mp3
  25. // https://qiniu.aiyxlib.com/yuekan-BGM27.mp3
  26. // https://qiniu.aiyxlib.com/yuekan-BGM41-f.mp3
  27. import utils from '@/utils/common.js';
  28. import one from './show.js';
  29. let innerAudioContext = uni.createInnerAudioContext();
  30. export default {
  31. components: {},
  32. data() {
  33. return {
  34. // 已登录情况显示6S得设备信息
  35. count: 6,
  36. deviceInfoShow: false,
  37. autoplay: false,
  38. // 素材
  39. materialsCont: [],
  40. show_materials: [],
  41. contentIndex: 0,
  42. itemIndex: 0,
  43. linkUrl: '',
  44. timer: null,
  45. duration: null,
  46. audioSrc: null,
  47. audioName: null,
  48. itemLength: []
  49. };
  50. },
  51. onLoad() {
  52. let result = one.data.data;
  53. this.materialsCont = result;
  54. console.log(this.materialsCont.length);
  55. this.materialsCont.map(item => {
  56. this.itemLength = this.itemLength.concat(item.show_materials.length);
  57. this.show_materials = this.show_materials.concat(item.show_materials);
  58. });
  59. console.log(this.itemLength);
  60. // 初始化
  61. this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  62. this.duration = this.show_materials[this.itemIndex].duration;
  63. if (this.show_materials[this.itemIndex].material_type != 1) {
  64. if (this.show_materials[this.itemIndex].bgm_url) {
  65. this.audioSrc = this.show_materials[this.itemIndex].bgm_url;
  66. this.audioName = this.show_materials[this.itemIndex].bgm_name;
  67. } else {
  68. if (this.materialsCont[this.contentIndex].bgm_main) {
  69. this.audioSrc = this.materialsCont[this.contentIndex].bgm_main;
  70. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  71. }
  72. }
  73. this.playVoice(this.audioSrc)
  74. }else{
  75. innerAudioContext.stop()
  76. }
  77. },
  78. created() {
  79. this.atuo();
  80. },
  81. mounted() {
  82. // this.countdown();
  83. this.changeImg();
  84. },
  85. methods: {
  86. playVoice(src) {
  87. if(innerAudioContext != undefined){
  88. innerAudioContext.stop()
  89. }
  90. innerAudioContext = uni.createInnerAudioContext()
  91. innerAudioContext.stop();
  92. innerAudioContext.src = src;
  93. innerAudioContext.autoplay = true;
  94. innerAudioContext.onPlay(() => {
  95. console.log('开始播放');
  96. });
  97. innerAudioContext.onError(res => {
  98. console.log(res.errMsg);
  99. console.log(res.errCode);
  100. innerAudioContext.stop()
  101. });
  102. innerAudioContext.onPause(() => {//暂停监听
  103. console.log('暂停');
  104. innerAudioContext.stop()
  105. });
  106. innerAudioContext.onEnded(() => {// 自然播放结束监听也需要更改isPause 开关状态
  107. console.log('音频自然播放结束事件');
  108. innerAudioContext.stop()
  109. });
  110. },
  111. changeImg() {
  112. const _this = this;
  113. clearInterval(_this.timer);
  114. _this.timer = setInterval(() => {
  115. _this.duration -= 1;
  116. if (_this.duration == 0) {
  117. _this.itemIndex++;
  118. if (_this.itemIndex == this.show_materials.length) {
  119. // clearInterval(_this.timer);
  120. this.itemIndex = 0
  121. this.contentIndex = 0
  122. _this.duration = this.show_materials[this.itemIndex].duration;
  123. _this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  124. if (this.show_materials[this.itemIndex].material_type != 1) {
  125. if (this.show_materials[this.itemIndex].bgm_url) {
  126. _this.audioSrc = this.show_materials[this.itemIndex].bgm_url;
  127. _this.audioName = this.show_materials[this.itemIndex].bgm_name;
  128. } else {
  129. if (this.materialsCont[this.contentIndex].bgm_main) {
  130. this.audioSrc = this.materialsCont[this.contentIndex].bgm_main;
  131. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  132. }
  133. }
  134. this.playVoice(this.audioSrc)
  135. }else{
  136. innerAudioContext.stop()
  137. }
  138. } else {
  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].material_type != 1) {
  142. if (this.show_materials[this.itemIndex].bgm_url) {
  143. _this.audioSrc = this.show_materials[this.itemIndex].bgm_url;
  144. _this.audioName = this.show_materials[this.itemIndex].bgm_name;
  145. } else {
  146. const result = this.itemLength.some(item => {
  147. return this.itemIndex == item;
  148. });
  149. console.log('result',result)
  150. if (result) {
  151. this.contentIndex++;
  152. }
  153. if (this.materialsCont[this.contentIndex].bgm_main) {
  154. this.audioSrc = this.materialsCont[this.contentIndex].bgm_main;
  155. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  156. }
  157. }
  158. this.playVoice(this.audioSrc)
  159. }else{
  160. innerAudioContext.stop()
  161. }
  162. }
  163. }
  164. }, 1000);
  165. },
  166. videoPlayEnd() {
  167. this.itemIndex = this.itemIndex + 1;
  168. if (this.itemIndex == this.show_materials.length) {
  169. // clearInterval(this.timer);
  170. this.itemIndex = -1
  171. innerAudioContext.stop()
  172. } else {
  173. this.duration = this.show_materials[this.itemIndex].duration;
  174. this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  175. if (this.show_materials[this.itemIndex].material_type != 1) {
  176. if (this.show_materials[this.itemIndex].bgm_url) {
  177. this.audioSrc = this.show_materials[this.itemIndex].bgm_url;
  178. this.audioName = this.show_materials[this.itemIndex].bgm_name;
  179. } else {
  180. const result = this.itemLength.some(item => {
  181. return this.itemIndex == item;
  182. });
  183. if (result) {
  184. this.contentIndex++;
  185. }
  186. if (this.materialsCont[this.contentIndex].bgm_main) {
  187. this.audioSrc = this.materialsCont[this.contentIndex].bgm_main;
  188. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  189. }
  190. }
  191. this.playVoice(this.audioSrc)
  192. }else{
  193. innerAudioContext.stop()
  194. }
  195. }
  196. },
  197. atuo() {
  198. this.autoplay = true;
  199. },
  200. countdown() {
  201. this.count = 6;
  202. const timer = setInterval(() => {
  203. this.count -= 1;
  204. if (this.count < 1) {
  205. clearInterval(timer);
  206. this.deviceInfoShow = true;
  207. console.log('倒计时结束');
  208. }
  209. }, 1000);
  210. }
  211. }
  212. };
  213. </script>
  214. <style scoped>
  215. .main_container {
  216. position: relative;
  217. overflow: hidden;
  218. background: #000;
  219. }
  220. .show-item {
  221. /* width: 100%;
  222. height: 100vh; */
  223. display: flex;
  224. flex-direction: column;
  225. align-items: center;
  226. justify-content: center;
  227. }
  228. .show-item .show-img {
  229. width: 100%;
  230. height: 100vh;
  231. object-fit: cover;
  232. }
  233. .show-item uni-video {
  234. width: 100%;
  235. }
  236. .show-video {
  237. width: 100%;
  238. height: 100vh;
  239. }
  240. .show-audio {
  241. position: fixed;
  242. bottom: 79.16rpx;
  243. right: 46.52rpx;
  244. width: 159.72rpx;
  245. height: 152.08rpx;
  246. background: url(../../static/images/an-yy.png) no-repeat;
  247. background-size: cover;
  248. }
  249. .show-audio uni-image {
  250. width: 159.72rpx;
  251. height: 152.08rpx;
  252. }
  253. .local-data {
  254. position: absolute;
  255. left: 50%;
  256. top: 50%;
  257. display: flex;
  258. flex-direction: column;
  259. justify-content: center;
  260. width: 625rpx;
  261. height: 555.55rpx;
  262. transform: translate(-50%, -50%);
  263. font-size: 27.77rpx;
  264. color: #333;
  265. border-radius: 27.77rpx;
  266. background: rgba(255, 255, 255, 0.85);
  267. }
  268. .title {
  269. margin-bottom: 32.63rpx;
  270. font-size: 56.94rpx;
  271. text-align: center;
  272. }
  273. .data-info {
  274. padding: 0 83.33rpx;
  275. margin-bottom: 32.63rpx;
  276. }
  277. .count-down {
  278. position: absolute;
  279. right: 34.72rpx;
  280. top: 27.77rpx;
  281. width: 48.61rpx;
  282. height: 48.61rpx;
  283. font-size: 30.55rpx;
  284. text-align: center;
  285. line-height: 48.61rpx;
  286. border: 1px solid #333;
  287. border-radius: 50%;
  288. }
  289. </style>