wxConfig.js 777 B

1234567891011121314151617181920212223242526272829303132333435
  1. import request from '../api/request'
  2. import wx from 'weixin-js-sdk'
  3. const wxJs = () => request({
  4. method: 'GET',
  5. url: '/api/wechat/account/config',
  6. params: {
  7. url: location.href,
  8. official_account_code: 'tingbang' // 写死
  9. }
  10. })
  11. export const WxConfig = async () => {
  12. const { data } = await wxJs()
  13. console.log(data)
  14. let wxParam = {
  15. debug: false,
  16. appId: data.app_id,
  17. timestamp: data.timestamp,
  18. nonceStr: data.nonce_str,
  19. signature: data.signature,
  20. jsApiList: [
  21. 'checkJsApi',
  22. 'openLocation',
  23. 'getLocation',
  24. 'updateAppMessageShareData',
  25. 'updateTimelineShareData',
  26. 'onMenuShareAppMessage',
  27. 'onMenuShareTimeline',
  28. 'hideMenuItems',
  29. 'scanQRCode']
  30. }
  31. wx.config(wxParam)
  32. return wx
  33. }