index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // 挂载变量
  2. // import {
  3. // API_URL,
  4. // API_ROOT
  5. // } from '@/common/request/request';
  6. import store from '@/common/store';
  7. import http from '@/common/request';
  8. import platform from '@/common/platform';
  9. import tools from '@/common/utils/tools'
  10. // mixin混入
  11. import mixin from '@/common/mixins';
  12. // #ifdef H5
  13. // uni方法重写, h5的粘贴板的设置,获取。图片视频的保存
  14. import wxsdk from '@/common/wechat/sdk'
  15. import VConsole from 'vconsole'
  16. import '@/common/utils/sdk-h5.js'
  17. // #endif
  18. import wechat from '@/common/wechat/wechat';
  19. const install = Vue => {
  20. // Vue.prototype.$API_URL = API_URL;
  21. // Vue.prototype.$API_ROOT = API_ROOT;
  22. // 挂载请求
  23. Vue.prototype.$http = http;
  24. // 平台判断
  25. Vue.prototype.$platform = platform;
  26. // 挂载工具函数
  27. Vue.prototype.$tools = tools;
  28. Vue.mixin(mixin);
  29. // #ifdef H5
  30. // 微信H5,sdk挂载
  31. Vue.prototype.$wxsdk = wxsdk;
  32. // 调试微信jssdk
  33. // new VConsole()
  34. // #endif
  35. }
  36. export async function init(options) {
  37. // #ifdef H5
  38. platform.entry();
  39. // #endif
  40. // #ifdef MP-WEIXIN
  41. // 检测小程序更新(如果从朋友圈场景进入则无此API)
  42. options.scene !== 1154 && wechat.checkMiniProgramUpdate();
  43. // #endif
  44. await store.dispatch("appInit", options); // 加载基本信息
  45. //获取模板消息
  46. await store.dispatch("getTemplate", options);
  47. // #ifdef MP-WEIXIN
  48. await store.dispatch('getMessageIds'); //订阅消息
  49. // #endif
  50. }
  51. export default {
  52. install
  53. }