提交 7e96d282 编写于 作者: L lumin

完善海报逻辑

上级 84feb68e
......@@ -13,6 +13,7 @@ exports.createQrcode = async (event, context) => {
scene: event.scene,
page: event.page
})
// if (result && result.buffer) {
// var res = await cloud.uploadFile({
// cloudPath: fileName,
......
......@@ -5,7 +5,7 @@ export default class Create {
that.setData({
'posterParams.width': `660rpx`,
'posterParams.height': `1080rpx`,
'posterParams.background': '#eee',
'posterParams.background': '#fff',
});
// console.log(rects);
let views = [
......@@ -51,12 +51,15 @@ export default class Create {
{
id:'qrcode',
type: "image",
url: `${that.data.project.users[0].userInfo.avatarUrl}`,
url: `${that.data.qrcode}`,
css: {
top: "340rpx",
left: "90rpx",
width: "460rpx",
height: "460rpx",
top: "370rpx",
left: "120rpx",
width: "400rpx",
height: "400rpx",
// borderWidth: '2rpx',
// borderColor: 'black',
// borderStyle: 'dashed',
},
},
{
......
......@@ -47,7 +47,6 @@ Page({
enrollUser:[],
posterParams:{}
})
this.createQrcode();
this.loadProject(projectId);
this.loadEnrolls();
},
......@@ -72,10 +71,9 @@ Page({
})
}
// 查询元素
setTimeout(() => {
new posterFactory().setPosterParams(that);
}, 0);
that.createQrcode();
}).catch(err => {
console.log('err:', err)
})
......@@ -92,7 +90,20 @@ Page({
}
}).then(res => {
console.log('cloud res:', res)
// that.setData({
// qrcode:res.result.result.buffer
// })
console.log(res.result.result.buffer);
that.getQRCodeImg(res.result.result.buffer,function(res){
console.log(that.data);
that.setData({
qrcode:res
})
// 查询元素
setTimeout(() => {
new posterFactory().setPosterParams(that);
}, 0);
});
}).catch(err => {
console.log('err:', err)
})
......@@ -140,6 +151,29 @@ Page({
})
},
/** 将小程序码的ArrayBuffer转换成临时图片路径 */
getQRCodeImg(arrayBuffer,callback) {
const fs = wx.getFileSystemManager() // 获取文件管理器实例
const filePath = wx.env.USER_DATA_PATH + "/" + this.data.projectId + ".jpg" // 临时路径
// 将arrayBuffer写入缓存中,并返回文件路径
// return new Promise((resolve, reject) => {
fs.writeFile({
filePath: filePath,
data: arrayBuffer,
encoding: 'base64',
success(res) {
console.log(res);
console.log(filePath);
callback(filePath)
},
fail(err) {
console.log('getQRCodeImgErr --- ', err)
}
})
// })
},
addEnroll:function(){
let that = this;
wx.cloud.callFunction({
......
<view class="cu-modal show {{modalName=='addwx'?'show':''}}">
<view class="cu-modal {{modalName=='addwx'?'show':''}}">
<view class="cu-dialog">
<view class="cu-bar bg-white justify-end">
<view class="content">添加好友</view>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册