123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- // jwx.js
- //#ifdef H5
- const jweixin = require('jweixin-module')
- //#endif
- export function configWeiXin(callback) {
- const url = window.location.href.split('#')[0];
- uni.request({
- url: 'https://s.yxin.tech/sign.php', //仅为示例,并非真实接口地址。
- header: {
- 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
- },
- data:{"url":url},
- method: 'GET',
- success: (res) => {
- console.log('请求的签名的参数')
- console.log(res)
-
- let apiList = [ // 可能需要用到的能力 需要啥就写啥。多写也没有坏处
- // 'scanQRCode',
- 'openLocation'
- ];
- let info = {
- debug: true, // 调试,发布的时候改为false
- appId: res.data.appid,
- nonceStr: res.data.nonceStr,
- timestamp: parseInt(res.data.timestamp),
- signature: res.data.sha_str,
- jsApiList: apiList
- };
-
- jweixin.config(info);
- jweixin.error(err => {
- console.log('config fail:', err);
- return
- });
-
- jweixin.ready(res => {
- if (callback) callback(jweixin);
- });
-
-
- //end
-
-
- }
- });
-
-
-
-
-
-
-
- }
|