audioList.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template name="audioList">
  2. <view>
  3. <swiper class="swiper" autoplay="false" vertical="true" interval="990000" @change="changeAudio">
  4. <swiper-item v-for="(v, k) in item" :key="k">
  5. <dever-audio
  6. :src="v.audio"
  7. :pic="v.pic"
  8. :control="true"
  9. :loop="true"
  10. :load.sync="load"
  11. ref="audio"
  12. >
  13. </dever-audio>
  14. </swiper-item>
  15. </swiper>
  16. </view>
  17. </template>
  18. <script>
  19. import deverAudio from '@/lib/dever/components/audio.nvue';
  20. var play = true;
  21. export default {
  22. name: "audioList",
  23. props: {
  24. control : {
  25. type : Object,
  26. value : null
  27. },
  28. item : {
  29. type : Array,
  30. value : null
  31. },
  32. index : 0
  33. },
  34. data() {
  35. return {
  36. load : false,
  37. current_index: 0,
  38. };
  39. },
  40. created() {
  41. },
  42. mounted() {
  43. this.control[this.index] = this;
  44. },
  45. methods:{
  46. start : function() {
  47. this.$refs.audio[this.current_index].start();
  48. },
  49. stop : function() {
  50. this.$refs.audio[this.current_index].stop(true);
  51. },
  52. changeAudio : function(e) {
  53. var self = this;
  54. self.$nextTick(()=>{
  55. this.$refs.audio[this.current_index].stop(false);
  56. this.current_index = e.detail.current;
  57. self.start();
  58. });
  59. },
  60. },
  61. components:{
  62. deverAudio
  63. }
  64. }
  65. </script>
  66. <style>
  67. .swiper{
  68. width: 100vw;
  69. height: 100vh;
  70. /*position: fixed;*/
  71. position: relative;
  72. top: 0;
  73. left: 0;
  74. }
  75. </style>