微信官方文档地址:https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/url-scheme.html
小程序(已上线的版本)需要配置明文scheme拉起,步骤如下:
微信公众平台配置
登陆微信公众平台 (https://mp.weixin.qq.com/)设置->隐私与安全->明文scheme拉起->配置->填写path项目中调用该方法
jumpToMiniProgram () {
console.log('测试跳转小程序');
let query ={
contractCode: "A20220802002",
scanCode: "测试跳转小程序",
ingoUrl: "",
brandId: "",
userId: "",
userName: ""
}
// 把对象转换成 a=1&b=2&c=3&d=4 的字符串格式
let queryString = Object.keys(query).map(key => `${encodeURIComponent(key)}=${encodeURIComponent(query[key])}`).join('&')
// 对其进行转码
let res = encodeURIComponent(queryString)
console.log('queryString', queryString)
window.location.href = `weixin://dl/business/?appid=xxxxxxx&path=page/index/index&query=${res}`;
}