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

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