引入的方式有两种,可用npm也可直接下载js文件引入
npm install jweixin-module --save
依赖下载了之后可直接在需要掉起分享功能的页面直接配置参数:
let wx= require('jweixin-module');
分享功能是要前端传当前页面的地址给后端处理获取相关信息返回,全代码:
//有两种写法,一种是需要用encodeURIComponent编码传给后端,后端再获取解码,我用的是未编码的
let windowurl = window.location.href.split('#')[0];
uni.request({
url: '/wx/redirect/wx36b6d5f7fd683e55/getJSSDK',//后端提供的接口
method: 'POST',
header: {
'content-type': 'application/x-www-form-urlencoded'
},
data