在线生成微信小程序二维码uni.arrayBufferToBase64

37 阅读1分钟

c918df2dacf47655faa2bdfe38cfce0.png

// 生成小程序码
export function createpublicwxaqrcode(query) {
	let params={width:300,appid:'wxaxxa',type:2,...query}
	return http.request({
		url: '/system/wx/wxaapp/createpublicwxaqrcode',//换成自己的接口
		responseType: 'arraybuffer',
		method: 'get',
		params
	})
}

使用方法

createpublicwxaqrcode(param).then((data)=>{
    const arrayBuffer = new Uint8Array(data)
    const base64 = "data:image/png;base64," + uni.arrayBufferToBase64(arrayBuffer) //这里需要添加前缀
    this.wxImg = base64 || '';
})

a5f47dda5f7ba900da15a12e10549d0.png