main.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import Vue from 'vue'
  2. import store from './store'
  3. import App from './App'
  4. Vue.prototype.$store = store
  5. // import VueClipboard from 'vue-clipboard2'
  6. // Vue.use(VueClipboard);
  7. /**
  8. * 所有测试用数据均存放于根目录json.js
  9. *
  10. * css部分使用了App.vue下的全局样式和iconfont图标,有需要图标库的可以留言。
  11. * 示例使用了uni.scss下的变量, 除变量外已尽量移除特有语法,可直接替换为其他预处理器使用
  12. */
  13. const msg = (title, duration=2500, mask=false, icon='none')=>{
  14. //统一提示方便全局修改
  15. if(Boolean(title) === false){
  16. return;
  17. }
  18. uni.showToast({
  19. title,
  20. duration,
  21. mask,
  22. icon
  23. });
  24. }
  25. const prePage = ()=>{
  26. // 获取当前页面
  27. let pages = getCurrentPages();
  28. let prePage = pages[pages.length - 2];
  29. // #ifdef H5
  30. return prePage;
  31. // #endif
  32. return prePage.$vm;
  33. }
  34. var music = null;
  35. music = uni.createInnerAudioContext(); //创建播放器对象
  36. music.autoplay = false;
  37. music.loop = true;
  38. music.src= "./static/audio/xx.mp3"; //选择播放的音频
  39. Vue.prototype.ScanAudio = function(e){
  40. let player = e;
  41. if (player == true ) {
  42. music.play(); //执行播放
  43. console.log('执行播放1', player)
  44. } else {
  45. music.pause(); //暂停播放
  46. console.log('暂停播放')
  47. }
  48. }
  49. var musict = null
  50. musict = uni.createInnerAudioContext();
  51. musict.autoplay = false;
  52. musict.loop = true;
  53. musict.src= "./static/audio/bg-music.mp3"; //选择播放的音频
  54. function playMusic(e){
  55. let player = e;
  56. if (player == true ) {
  57. musict.play(); //执行播放
  58. console.log('执行播放1', player)
  59. } else {
  60. musict.pause(); //暂停播放
  61. console.log('暂停播放')
  62. }
  63. }
  64. musict.onPlay(() => {
  65. console.log('开始播放');
  66. store.state.isPlay = true
  67. });
  68. Vue.config.productionTip = false
  69. Vue.prototype.$fire = new Vue();
  70. Vue.prototype.$store = store;
  71. Vue.prototype.$api = {msg, prePage,playMusic};
  72. App.mpType = 'app'
  73. const app = new Vue({
  74. ...App
  75. })
  76. app.$mount()