index.js 1.5 KB

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