jssdk.js 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // jwx.js
  2. //#ifdef H5
  3. const jweixin = require('jweixin-module')
  4. //#endif
  5. export function configWeiXin(callback) {
  6. const url = window.location.href.split('#')[0];
  7. // start
  8. uni.request({
  9. url:"https://qhome.usky.cn/sign.php",
  10. header: {
  11. 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
  12. },
  13. data:{"url":url},
  14. method: 'GET',
  15. success: (res) => {
  16. console.log('请求的签名的参数')
  17. console.log(res)
  18. let apiList = [ // 可能需要用到的能力 需要啥就写啥。多写也没有坏处
  19. 'openLocation'
  20. ];
  21. let info = {
  22. debug: false, // 调试,发布的时候改为false
  23. appId: res.data.appid,
  24. nonceStr: res.data.nonceStr,
  25. timestamp: parseInt(res.data.timestamp),
  26. signature: res.data.sha_str,
  27. jsApiList: apiList
  28. };
  29. jweixin.config(info);
  30. jweixin.error(err => {
  31. console.log('config fail:', err);
  32. return
  33. });
  34. jweixin.ready(res => {
  35. if (callback) callback(jweixin);
  36. });
  37. }
  38. });
  39. // end
  40. }