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

386 lines
10 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
  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 v-if="item.material_type == 1 && itemIndex == index" :src="linkUrl" :autoplay="autoplay" :controls="false" :enable-progress-gesture="false" object-fit="contain" @ended="videoPlayEnd">
  12. </video>
  13. </view>
  14. </view>
  15. <!-- <swiper @change="changeMaterial()" style="height: 100%;">
  16. <swiper-item v-for="(item, index) in show_materials" :key="index" :class="['show-item', item.material_type == 1 && itemIndex == index ? 'show-video' : '']">
  17. <view class="item" v-if="item.material_type == 1 && itemIndex == index">
  18. <video id="myVideo" ref="myVideo"
  19. :src="linkUrl" :autoplay="autoplay" :controls="false" :enable-progress-gesture="false" object-fit="contain" @ended="videoPlayEnd"></video>
  20. <cover-view
  21. style="z-index:99;position: fixed;width:100%;height:100%;top:0;left:0;display:flex; justify-content:center; align-items:center;">
  22. <image style="width: 40px;height: 40px;"></image>
  23. </cover-view>
  24. </view>
  25. <view class="item" v-if="item.material_type == 0 && itemIndex == index">
  26. <image :src="linkUrl" :class="['show-img', 'animate__animated', item.material_type == 0 ? item.effect:'']"></image>
  27. </view>
  28. </swiper-item>
  29. </swiper> -->
  30. <view class="show-audio"></view>
  31. <view style="position:absolute; bottom:55.55rpx; left: 69.44rpx; color: #fff; z-index: 99999;">{{ infoTxt }}--{{ audioName }}</view>
  32. <!-- <view v-if="!deviceInfoShow" class="local-data">
  33. <text class="title">欢迎使用数字新视窗</text>
  34. <view class="data-info">设备ID : 123456789</view>
  35. <view class="data-info">设备账号 : 123456789</view>
  36. <view class="data-info">设备名称 : CVBBN2</view>
  37. <view class="count-down" @click="deviceInfoShow=true">{{ count }}</view>
  38. </view> -->
  39. </view>
  40. </template>
  41. <script>
  42. import one from './show2.js';
  43. let innerAudioContext = uni.createInnerAudioContext();
  44. export default {
  45. components: {},
  46. data() {
  47. return {
  48. // 已登录情况显示6S得设备信息
  49. count: 6,
  50. deviceInfoShow: false,
  51. autoplay: false,
  52. // 素材
  53. materialsCont: [],
  54. show_materials: [],
  55. contentIndex: 0,
  56. itemIndex: 0,
  57. linkUrl: '',
  58. timer: null,
  59. duration: null,
  60. audioSrc: null,
  61. audioName: null,
  62. itemLength: [],
  63. flagIndex: 0,
  64. infoTxt: '',
  65. // 刚触碰的时间
  66. startTime: 0,
  67. // 刚触碰的位置
  68. startPosition: 0,
  69. // 结束的位置
  70. endPosition: 0,
  71. startY: 0,
  72. startX: 0,
  73. elePosition: null,
  74. isAutoSwitch: true,
  75. moveX: 0, //滑动的x轴距离
  76. moveY: 0, //滑动的y轴距离
  77. like_state: 0, //-1:左滑,0:没滑动,1:右滑
  78. };
  79. },
  80. onLoad() {
  81. const _this = this;
  82. let result = one.data.data;
  83. this.materialsCont = result;
  84. this.materialsCont.map(item => {
  85. this.itemLength = this.itemLength.concat(item.show_materials.length);
  86. this.show_materials = this.show_materials.concat(item.show_materials);
  87. });
  88. // 初始化
  89. this.changIndex();
  90. },
  91. created() {
  92. this.atuo();
  93. },
  94. mounted() {
  95. // this.countdown();
  96. this.changeMaterial();
  97. },
  98. methods: {
  99. touchStart(event) {
  100. this.startX = event.touches[0].pageX;
  101. this.startY = event.touches[0].pageY;
  102. console.log('开始触摸:', this.startX, this.startY);
  103. },
  104. touchMove(event) {
  105. var currentX = event.touches[0].pageX;
  106. var currentY = event.touches[0].pageY;
  107. var moveX = currentX - this.startX;
  108. var moveY = currentY - this.startY;
  109. var text = '';
  110. var state = 0; //-1:左滑,0:没滑动,1:右滑
  111. // //左右方向滑动
  112. if (Math.abs(moveX) > Math.abs(moveY)) {
  113. if (moveX < -10) {
  114. text = '左滑';
  115. state = 1;
  116. } else if (moveX > 10) {
  117. text = '右滑';
  118. state = -1;
  119. }
  120. } else { //上下方向滑动
  121. if (moveY < 0) {
  122. text = '上滑';
  123. state = -2;
  124. } else if (moveY > 0){
  125. text = '下滑';
  126. state = 2;
  127. }
  128. }
  129. this.like_state = state;
  130. this.moveX = moveX;
  131. this.moveY = moveY;
  132. console.log('开始滑动:', this.moveX, this.moveY, this.like_state);
  133. },
  134. touchEnd(event) {
  135. console.log(`移动距离:${Math.abs(this.moveX)}`)
  136. // if (Math.abs(this.moveX) > 60 ) {
  137. // console.log(this.like_state)
  138. // if(this.like_state == -1){
  139. // this.isAutoSwitch = false;
  140. // this.itemIndex--;
  141. // this.flagIndex--;
  142. // this.changIndex()
  143. // }else if(this.like_state == 1){
  144. // this.itemIndex++;
  145. // this.flagIndex++;
  146. // this.isAutoSwitch = true;
  147. // this.changIndex()
  148. // }
  149. // }
  150. if(Math.abs(this.moveY) > 60){
  151. innerAudioContext.stop();
  152. if(this.like_state == -2){
  153. this.itemIndex++;
  154. this.flagIndex++;
  155. this.isAutoSwitch = true;
  156. }else if(this.like_state == 2){
  157. this.itemIndex--;
  158. this.flagIndex--;
  159. this.isAutoSwitch = false;
  160. }
  161. this.changIndex()
  162. }
  163. },
  164. changeMaterial() {
  165. const _this = this;
  166. clearInterval(_this.timer);
  167. _this.timer = setInterval(() => {
  168. _this.duration -= 1;
  169. if (_this.duration == 0) {
  170. _this.itemIndex++;
  171. _this.flagIndex++;
  172. this.changIndex();
  173. }
  174. }, 1000);
  175. },
  176. changIndex() {
  177. const _this = this;
  178. if (_this.itemIndex == this.show_materials.length) {
  179. // clearInterval(_this.timer);
  180. this.itemIndex = 0;
  181. this.flagIndex = 0;
  182. this.contentIndex = 0;
  183. innerAudioContext.stop();
  184. }
  185. if(this.itemIndex == -1){
  186. this.itemIndex = this.show_materials.length-1
  187. this.contentIndex = this.itemLength.length-1
  188. this.flagIndex = this.itemLength[this.contentIndex]
  189. }
  190. if (this.flagIndex == 0) {
  191. this.contentIndex--;
  192. this.flagIndex = this.itemLength[this.contentIndex];
  193. }
  194. _this.duration = this.show_materials[this.itemIndex].duration;
  195. _this.linkUrl = this.show_materials[this.itemIndex].deposit_url;
  196. if (this.show_materials[this.itemIndex].bgm_url) {
  197. _this.audioSrc = this.show_materials[this.itemIndex].bgm_url;
  198. _this.audioName = this.show_materials[this.itemIndex].bgm_name;
  199. } else {
  200. if (this.contentIndex == this.itemLength.length) {
  201. this.flagIndex = 0;
  202. this.contentIndex = 0;
  203. } else {
  204. if(this.isAutoSwitch){
  205. if (this.flagIndex == this.itemLength[this.contentIndex]) {
  206. this.flagIndex = 0;
  207. this.contentIndex++;
  208. }
  209. }
  210. }
  211. if (this.materialsCont[this.contentIndex].bgm_main) {
  212. this.audioSrc = this.materialsCont[this.contentIndex].bgm_main;
  213. this.audioName = this.materialsCont[this.contentIndex].bgm_name;
  214. }
  215. }
  216. this.playVoice(this.audioSrc);
  217. if (this.show_materials[this.itemIndex].material_type == 1) {
  218. innerAudioContext.stop();
  219. }
  220. },
  221. videoPlayEnd() {
  222. this.itemIndex++;
  223. this.flagIndex++;
  224. this.changIndex();
  225. },
  226. playVoice(src) {
  227. if (innerAudioContext != undefined) {
  228. innerAudioContext.stop();
  229. }
  230. innerAudioContext = uni.createInnerAudioContext();
  231. innerAudioContext.stop();
  232. innerAudioContext.src = src;
  233. innerAudioContext.autoplay = true;
  234. innerAudioContext.onPlay(() => {
  235. this.infoTxt = '';
  236. this.infoTxt = '开始播放';
  237. console.log('开始播放');
  238. });
  239. innerAudioContext.onError(res => {
  240. console.log(res.errMsg);
  241. console.log(res.errCode);
  242. innerAudioContext.stop();
  243. });
  244. innerAudioContext.onPause(() => {
  245. //暂停监听
  246. this.infoTxt = '暂停';
  247. console.log('暂停');
  248. // innerAudioContext.stop();
  249. });
  250. innerAudioContext.onEnded(() => {
  251. // 自然播放结束监听也需要更改isPause 开关状态
  252. this.infoTxt = '音频自然播放结束事件';
  253. console.log('音频自然播放结束事件');
  254. innerAudioContext.stop();
  255. });
  256. },
  257. atuo() {
  258. this.autoplay = true;
  259. },
  260. countdown() {
  261. this.count = 6;
  262. const timer = setInterval(() => {
  263. this.count -= 1;
  264. if (this.count < 1) {
  265. clearInterval(timer);
  266. this.deviceInfoShow = true;
  267. console.log('倒计时结束');
  268. }
  269. }, 1000);
  270. }
  271. }
  272. };
  273. </script>
  274. <style scoped>
  275. .main_container {
  276. position: relative;
  277. overflow: hidden;
  278. background: #000;
  279. }
  280. .show-item {
  281. /* width: 100%;
  282. height: 100vh; */
  283. display: flex;
  284. flex-direction: column;
  285. align-items: center;
  286. justify-content: center;
  287. }
  288. .show-item .show-img {
  289. width: 100%;
  290. height: 100vh;
  291. object-fit: cover;
  292. }
  293. .show-item uni-video {
  294. width: 100%;
  295. height: 100%;
  296. }
  297. .show-video {
  298. width: 100%;
  299. height: 100vh;
  300. }
  301. .show-audio {
  302. position: fixed;
  303. bottom: 79.16rpx;
  304. right: 46.52rpx;
  305. width: 159.72rpx;
  306. height: 152.08rpx;
  307. background: url(~@/static/images/an-yy.png) no-repeat;
  308. background-size: cover;
  309. }
  310. .show-audio uni-image {
  311. width: 159.72rpx;
  312. height: 152.08rpx;
  313. }
  314. .local-data {
  315. position: absolute;
  316. left: 50%;
  317. top: 50%;
  318. display: flex;
  319. flex-direction: column;
  320. justify-content: center;
  321. width: 625rpx;
  322. height: 555.55rpx;
  323. transform: translate(-50%, -50%);
  324. font-size: 27.77rpx;
  325. color: #333;
  326. border-radius: 27.77rpx;
  327. background: rgba(255, 255, 255, 0.85);
  328. }
  329. .title {
  330. margin-bottom: 32.63rpx;
  331. font-size: 56.94rpx;
  332. text-align: center;
  333. }
  334. .data-info {
  335. padding: 0 83.33rpx;
  336. margin-bottom: 32.63rpx;
  337. }
  338. .count-down {
  339. position: absolute;
  340. right: 34.72rpx;
  341. top: 27.77rpx;
  342. width: 48.61rpx;
  343. height: 48.61rpx;
  344. font-size: 30.55rpx;
  345. text-align: center;
  346. line-height: 48.61rpx;
  347. border: 1px solid #333;
  348. border-radius: 50%;
  349. }
  350. .swiper{
  351. height: 100vh;
  352. }
  353. .item{
  354. width: 100%;
  355. height: 100%;
  356. }
  357. .mask{
  358. position: absolute;
  359. top: 0;
  360. left: 0;
  361. bottom: 0;
  362. right: 0;
  363. width: 100%;
  364. height: 100%;
  365. background: rgba(0,0,0,.3);
  366. z-index: 999;
  367. }
  368. .controls-title {
  369. position: absolute;
  370. top: 0;
  371. left: 0;
  372. bottom: 0;
  373. right: 0;
  374. width: 100%;
  375. height: 100%;
  376. background: rgba(0,0,0,.3);
  377. text-align: center;
  378. color: #FFFFFF;
  379. border: 10px solid #fff;
  380. z-index: 9999;
  381. }
  382. </style>