|
|
|
@ -75,8 +75,12 @@ |
|
|
|
|
this.dataInfo = JSON.parse(decodeURIComponent(e.obj)); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
mounted() { |
|
|
|
|
this.couponQrCode() |
|
|
|
|
onReady() { |
|
|
|
|
|
|
|
|
|
this.$nextTick(()=>{ |
|
|
|
|
this.couponQrCode() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
//方法 |
|
|
|
|
methods: { |
|
|
|
@ -85,7 +89,6 @@ |
|
|
|
|
this.swiperIndex = e.detail.current; |
|
|
|
|
}, |
|
|
|
|
async couponQrCode() { |
|
|
|
|
|
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '加载中...' |
|
|
|
|
}); |
|
|
|
@ -101,8 +104,9 @@ |
|
|
|
|
} else { |
|
|
|
|
this.level = qrCode.CorrectLevel.L |
|
|
|
|
} */ |
|
|
|
|
let level = qrCode.CorrectLevel.L; |
|
|
|
|
console.log(that.dataInfo, " that.dataInfo") |
|
|
|
|
let qrcode = await new qrCode('qrImg', { |
|
|
|
|
let qrde = await new qrCode('qrImg', { |
|
|
|
|
text: that.dataInfo.goLink, |
|
|
|
|
width: 100, |
|
|
|
|
height: 100, |
|
|
|
@ -110,9 +114,11 @@ |
|
|
|
|
loadingText: '二维码生成中', // loading文字 |
|
|
|
|
colorDark: '#000000', //二维码暗部颜色 |
|
|
|
|
colorLight: '#ffffff', //二维码亮部颜色 |
|
|
|
|
correctLevel: qrCode.CorrectLevel.L, //二维码质量L/M/Q/H |
|
|
|
|
correctLevel: level, //二维码质量L/M/Q/H |
|
|
|
|
// usingIn: this //在自定义组件下,第二个参数传入组件实例this |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
console.log(qrde, " qrde") |
|
|
|
|
// 把当前画布指定区域的内容导出生成图片,并返回文件路径。 |
|
|
|
|
uni.canvasToTempFilePath({ |
|
|
|
|
canvasId: 'qrImg', |
|
|
|
@ -121,7 +127,7 @@ |
|
|
|
|
// 在H5平台下,tempFilePath 为 base64 |
|
|
|
|
// console.log('yz-qr图片路径:', res) |
|
|
|
|
this.dataInfo.recommendCodeGoods = res.tempFilePath; |
|
|
|
|
qrcode = null; |
|
|
|
|
/* qrcode = null; */ |
|
|
|
|
/* uni.getFileSystemManager().readFile({ |
|
|
|
|
filePath: res.tempFilePath, //选择图片返回的相对路径 |
|
|
|
|
encoding: 'base64', //编码格式 |
|
|
|
@ -135,7 +141,7 @@ |
|
|
|
|
}, |
|
|
|
|
fail: (err) => { |
|
|
|
|
uni.hideLoading(); |
|
|
|
|
qrcode = null; |
|
|
|
|
/* qrcode = null; */ |
|
|
|
|
console.log(err) |
|
|
|
|
} |
|
|
|
|
}, this); |
|
|
|
@ -443,38 +449,7 @@ |
|
|
|
|
return rowText; |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
savePic(Url) { |
|
|
|
|
Url = this.dialogImgUrl //图片路径,也可以传值进来 |
|
|
|
|
var triggerEvent = "touchstart"; //指定下载方式 |
|
|
|
|
var blob = new Blob([''], { |
|
|
|
|
type: 'application/octet-stream' |
|
|
|
|
}); //二进制大型对象blob |
|
|
|
|
var url = URL.createObjectURL(blob); //创建一个字符串路径空位 |
|
|
|
|
var a = document.createElement('a'); //创建一个 a 标签 |
|
|
|
|
a.href = Url; //把路径赋到a标签的href上 |
|
|
|
|
//正则表达式,这里是把图片文件名分离出来。拿到文件名赋到a.download,作为文件名来使用文本 |
|
|
|
|
a.download = Url.replace(/(.*\/)*([^.]+.*)/ig, "$2").split("?")[0]; |
|
|
|
|
/* var e = document.createEvent('MouseEvents'); //创建事件(MouseEvents鼠标事件) |
|
|
|
|
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); //初始化鼠标事件(initMouseEvent已弃用)*/ |
|
|
|
|
|
|
|
|
|
//代替方法。创建鼠标事件并初始化(后面这些参数我也不清楚,参考文档吧 https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/MouseEvent) |
|
|
|
|
var e = new MouseEvent('click', (true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null)); |
|
|
|
|
//派遣后,它将不再执行任何操作。执行保存到本地 |
|
|
|
|
a.dispatchEvent(e); |
|
|
|
|
//释放一个已经存在的路径(有创建createObjectURL就要释放revokeObjectURL) |
|
|
|
|
URL.revokeObjectURL(url); |
|
|
|
|
/* |
|
|
|
|
//这段好像并不影响,所以我不用,注释掉 |
|
|
|
|
var imgs = document.getElementsByTagName("img"); |
|
|
|
|
for(var i = 0,o;o = imgs[i];i++){ |
|
|
|
|
|
|
|
|
|
o.addEventListener(triggerEvent,function(){ |
|
|
|
|
var newurl = this.getAttribute("src"); |
|
|
|
|
saveAs(newurl); |
|
|
|
|
},false); |
|
|
|
|
} */ |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
//用户点击分享 |
|
|
|
|