请先看第一篇:node获取存储token和ticket / 生成签名

一:后端

使用:

1. app.js里引入

const setSdk = require('./config/setSdk')
 
2. 前台会post一个url给后台,只需要给setSdk传入前台post的url,并返回给前台就行
ctx.body = await setSdk(ctx.request.body.url)

二:前端

前端需要post给后端一个当前页面的url

 let url = location.href.split('#')[0]
  $.ajax({
    type: 'post',
    url: '接口地址',
    dataType: 'json',
    data: {
      url
    },
    success: (res) => {
      // res是后台返回给前端的签名信息,
      // 用来匹配 wx.config 
       //包括:
        // appId: res.appId,
        // timestamp: res.timestamp,
        // nonceStr: res.nonceStr,
        // signature: res.signature,
    }
  })        

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-20
  • 2021-09-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
猜你喜欢
  • 2021-08-09
  • 2021-08-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-11-25
相关资源
相似解决方案