index.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. var sceneReadyBehavior = require('../../behavior-scene/scene-ready');
  2. Page({
  3. behaviors:[sceneReadyBehavior],
  4. data: {
  5. showBackBtn: true,
  6. resourceData: {
  7. },
  8. onFlags: false,
  9. gltfList: [],
  10. imageList: [],
  11. videoList: [],
  12. },
  13. onLoad() {
  14. // 准备加载数据
  15. },
  16. tapResBtn(event) {
  17. const dataSet = event.target.dataset;
  18. const src = dataSet.src;
  19. const index = dataSet.index;
  20. let onFlags = this.data.onFlags;
  21. onFlags = !onFlags;
  22. let videoListNew;
  23. if(onFlags){
  24. videoListNew = this.data.videoList;
  25. videoListNew.push({
  26. id: index,
  27. src: src
  28. });
  29. } else {
  30. let matchIndex = -1;
  31. for (let i = 0; i < this.data.videoList.length; i++) {
  32. if (this.data.videoList[i] && src === this.data.videoList[i].src) {
  33. matchIndex = i;
  34. break;
  35. }
  36. }
  37. this.data.videoList.splice(matchIndex, 1);
  38. videoListNew = this.data.videoList;
  39. }
  40. this.setData({
  41. videoList: videoListNew,
  42. onFlags: onFlags
  43. });
  44. },
  45. handleInfoListener(cur) {
  46. const detail = cur.detail;
  47. this.setData({
  48. });
  49. }
  50. });