当前位置:网站首页>Uniapp wechat applet obtains page QR code (with parameters)
Uniapp wechat applet obtains page QR code (with parameters)
2022-06-22 16:31:00 【Dumiyue】
1. Generate page QR code ( Backend generation , The front end needs to write the QR code to the file manager )
// Get applet code with parameters
async function getCodeImage() {
let param = {
id: 12345 };
let page = 'pages/index';
//getCodeBase64: Call back-end interface , Give the parameters and page path to the backend
const codeBase64 = await getCodeBase64({
// The required parameters of the page to jump to after scanning the QR code
param,
// The path of the page to which the QR code is scanned
page,
});
// const codeImgPath = `${wx.env.USER_DATA_PATH}/wxacode.png`;
const codeImgPath = `${
wx.env.USER_DATA_PATH}/${
param.id}.png`;
const getUrl = await getImageUrl(codeImgPath, codeBase64);
// QR code path ( It can be used canvas In the poster )
return getUrl;
}
async function getImageUrl(codeImgPath, codeBase64) {
return new Promise((resolve) => {
// Get globally unique file manager
const fs = wx.getFileSystemManager();
// Writing documents
fs.writeFile({
filePath: codeImgPath,
data: codeBase64,
encoding: 'base64',
success: (res) => {
resolve(codeImgPath);
},
})
});
}
2. How to get the QR code parameters for the page that jumps after scanning the QR code
onMounted(() => {
// After scanning the QR code, the applet will assign the page parameters to scene in , So get page parameters scene
// Get page parameter method getLocationParams Please see the notes link below
const scene = getLocationParams('scene');
// The applet code jumps over
if (scene) {
console.log(scene);
// Get the page parameters , Call page interface , Render the page
}
});
remarks : Get page parameter method getLocationParams link :https://blog.csdn.net/honeymoon_/article/details/124130295
边栏推荐
- 实现一个Container全局组件步骤(给还不会使用组件的新手一个思路,大佬绕道)
- IO模型的5中模式
- Runtime -- explore the nature of classes, objects, and classifications
- 2022年中国重卡智能化升级专题研究
- SAP ABAP 中 OpenSQL和Native SQL-05 本教程的目的不是教您 SQL 或数据库概念
- The odoo system sets priorities for the views independently developed by the original model
- 【微信小程序获取自定义tabbar的高度】绝对可用!!!
- 5.文件的读写(学生类)
- SAP ABAP BAPI-016
- 天翼云乘风新基建,构建数字化转型“4+2”能力体系
猜你喜欢
随机推荐
3.抽象类(shape)
SAP ABAP 中的用户出口和客户出口-015
【小程序项目开发-- 京东商城】uni-app开发之分包配置
面试题之 <img>标签 的 title 和 alt 有什么区别
预约打新债到底安不安全呀?是不是靠谱的?
为数字添加千分位符号(金额千分位)
uniapp微信小程序获取页面二维码(带有参数)
使用枚举实现工厂模式
SAP ABAP 内部表:创建、读取、填充、复制和删除-06
Safari兼容性问题总结
Opensql and native sql-05 in SAP ABAP the purpose of this tutorial is not to teach you SQL or database concepts
2022年中国重卡智能化升级专题研究
find命令使用
[Shanda conference] acquisition of user media based on webrtc
超出文本部分用省略号表示
【小程序项目开发-- 京东商城】uni-app开发之配置tabBar & 窗口样式
SAP ABAP dialog programming tutorial: module pool in -09
SAP ABAP 中 OpenSQL和Native SQL-05 本教程的目的不是教您 SQL 或数据库概念
ABAP query tutorial in sap: sq01, sq02, sq03-017
NiO programming service









