globalVariable.ts 623 B

1234567891011121314151617181920212223242526
  1. import Vue from 'vue'
  2. import { isWeiXinBrowser } from '@/utils/globalFunctions.ts'
  3. import { getWxSdkSign } from '@/api/pay.ts'
  4. declare module 'vue/types/vue' {
  5. interface Vue {
  6. $env: any;
  7. $getWxSdkSign: any;
  8. }
  9. }
  10. const inWeiXinBrowser = isWeiXinBrowser()
  11. // 全局变量
  12. Vue.prototype.$env = {
  13. isWeiXinBrowser: inWeiXinBrowser,
  14. platform: inWeiXinBrowser ? 'wx' : 'app'
  15. }
  16. // 如果是微信浏览器,全局初始化一个微信SDK
  17. if (inWeiXinBrowser) {
  18. // Vue.prototype.$getWxSdkSign = getWxSdkSign
  19. // getWxSdkSign({ url: location.href.split('#')[0] }).then(res => {
  20. // console.log(res)
  21. // })
  22. }