audioList.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template name="audioList">
  2. <view>
  3. <swiper class="swiper" autoplay="false" vertical="true" interval="990000" @change="changeAudio" :current="current_index" :circular="circular">
  4. <swiper-item v-for="(v, k) in item" :key="k">
  5. <dever-audio
  6. :src="v.audio"
  7. :pic="v.pic"
  8. :lrc="v.lrc ? v.lrc : true"
  9. :title="v.name"
  10. :singer="v.singer"
  11. :lrc_color="v.color"
  12. :lrc_atcolor="v.atcolor"
  13. :control="true"
  14. :loop="true"
  15. :recycle="recycle"
  16. :load.sync="load"
  17. @setRecycle="setRecycle"
  18. @last="last"
  19. @next="next"
  20. ref="audio"
  21. >
  22. </dever-audio>
  23. </swiper-item>
  24. </swiper>
  25. </view>
  26. </template>
  27. <script>
  28. import deverAudio from '@/lib/dever/components/audio.nvue';
  29. var play = true;
  30. export default {
  31. name: "audioList",
  32. props: {
  33. control : {
  34. type : Object,
  35. value : null
  36. },
  37. item : {
  38. type : Array,
  39. value : null
  40. },
  41. index : 0
  42. },
  43. data() {
  44. return {
  45. recycle : true,
  46. circular : true,
  47. load : false,
  48. current_index: 0,
  49. total : 0,
  50. };
  51. },
  52. created() {
  53. },
  54. mounted() {
  55. this.control[this.index] = this;
  56. this.total = this.$refs.audio.length - 1;
  57. },
  58. methods:{
  59. start : function() {
  60. this.$refs.audio[this.current_index].start();
  61. },
  62. stop : function() {
  63. this.$refs.audio[this.current_index].stop(true);
  64. },
  65. changeAudio : function(e) {
  66. this.change(e.detail.current);
  67. },
  68. change : function(index) {
  69. var self = this;
  70. self.$nextTick(()=>{
  71. this.$refs.audio[this.current_index].stop(false);
  72. this.current_index = index;
  73. setTimeout(function() {
  74. self.start();
  75. }, 200);
  76. });
  77. },
  78. next : function() {
  79. var current_index = this.current_index;
  80. if (current_index >= this.total) {
  81. current_index = 0;
  82. } else {
  83. current_index = current_index + 1;
  84. }
  85. this.change(current_index);
  86. },
  87. last : function() {
  88. var current_index = this.current_index;
  89. if (current_index == 0) {
  90. current_index = this.total;
  91. } else {
  92. current_index = current_index - 1;
  93. }
  94. this.change(current_index);
  95. },
  96. setRecycle : function() {
  97. this.recycle = !this.recycle;
  98. return this.recycle;
  99. }
  100. },
  101. components:{
  102. deverAudio
  103. }
  104. }
  105. </script>
  106. <style>
  107. .swiper{
  108. width: 100vw;
  109. height: 100vh;
  110. /*position: fixed;*/
  111. position: relative;
  112. top: 0;
  113. left: 0;
  114. }
  115. </style>