Browse Source

直接翻包打印 优化 未完善

hella_online_20240829
陈薪名 4 months ago
parent
commit
d4a2cc2d8b
  1. 138
      src/pages/point/index.vue

138
src/pages/point/index.vue

@ -91,6 +91,76 @@
methods: {
// qrcodeRef
forEachQrcodeRef(el,index,elLength,wait) {
let _this = this
console.log('11111111111111');
console.log(index);
if (index == elLength) {
console.log('99999999');
return;
}
const item = el[index];
setTimeout(() => {
console.log(el[index]);
console.log(item.canvasToTempFilePath);
// try{
item.canvasToTempFilePath({
success: (res) => {
console.log(res);
// base64
pathToBase64(res.tempFilePath).then(base64 => {
console.log(res.tempFilePath);
_this.data[index].barcodeBase64 = base64
if (index == elLength - 1) {
_this.isLoadFinish = true
uni.hideLoading();
}else {
console.log(index);
}
this.forEachQrcodeRef(el,index+1,el.length,100)
}).catch(err => {
console.log(err);
this.forEachQrcodeRef(el,index+1,el.length,100)
})
},
fail(err) {
console.log(err)
}
})
// }catch(e){
// console.log(e)
// //TODO handle the exception
// // this.forEachQrcodeRef(el,index,el.length)
// }
},wait);
},
// stringToBase64(str) {
// console.log('999999999999999');
// console.log(str);
// //
// // var encodeUTF8 = uni.getSystemInfoSync().platform === 'android' ? 'utf-8' : 'utf8';
// // console.log('8888888888888');
// // var utf8Str = uni.encode(str, encodeUTF8);
// // console.log(utf8Str); data
// // utf8base64
// var base64Str = btoa(str);
// console.log(base64Str);
// return base64Str;
// },
// getQrCodeBase64(index) {
// let _this = this
// // 使setTimeoutDOMcanvas
// setTimeout(() => {
// const qrcodeCanvas = this.$refs.qrcodeRef.$el.querySelector('canvas');
// if (qrcodeCanvas) {
// // canvasBase64URL
// _this.data[index].barcodeBase64 = qrcodeCanvas.toDataURL('image/png');
// } else {
// console.log('xxxxxxxxxxxxxxxxx')
// }
// }, 0);
// },
getListData(){
//
// 线 线
@ -112,36 +182,45 @@
// }]
let _this = this
this.$nextTick(async () => {
// this.$nextTick(async () => {
//
const el = _this.$refs['qrcodeRef']
let str = ''
el.forEach(async (item, index) => {
await item.canvasToTempFilePath({
success: async (res) => {
// base64
await pathToBase64(res.tempFilePath).then(base64 => {
_this.data[index].barcodeBase64 = base64
if (index == el.length - 1) {
_this.isLoadFinish = true
uni.hideLoading();
}else {
console.log(index);
}
}).catch(err => {
console.log(err);
})
},
fail(err) {
console.log('err:::', err)
}
})
_this.forEachQrcodeRef(el,0,el.length,5000);
// // })
})
})
// let _this = this
// this.$nextTick(async () => {
// //
// const el = _this.$refs['qrcodeRef']
// let str = ''
// el.forEach(async (item, index) => {
// await item.canvasToTempFilePath({
// success: async (res) => {
// // base64
// await pathToBase64(res.tempFilePath).then(base64 => {
// _this.data[index].barcodeBase64 = base64
// if (index == el.length - 1) {
// _this.isLoadFinish = true
// uni.hideLoading();
// }else {
// console.log(index);
// }
// }).catch(err => {
// console.log(err);
// })
// },
// fail(err) {
// console.log('err:::', err)
// }
// })
// })
// })
// })
},
// #ifdef APP
@ -250,7 +329,7 @@
})
this.newHtmlContent = this.newHtmlContent.replace(
"mainBody", str); //
console.log(this.newHtmlContent)
// console.log(this.newHtmlContent)
});
// #endif
}
@ -278,7 +357,10 @@
this.timer = null
}
this.data = this.originData
this.getListData()
console.log(287,'11111111')
this.$nextTick(()=> {
this.getListData()
})
},1000)
},
}

Loading…
Cancel
Save