提交 276aa44d authored 作者: 羊富学's avatar 羊富学

贝因美

上级 8e6d14dc
...@@ -10,7 +10,8 @@ ...@@ -10,7 +10,8 @@
"pages/fenggu/success/success", "pages/fenggu/success/success",
"pages/fenggu/example/example", "pages/fenggu/example/example",
"pages/result/result", "pages/result/result",
"pages/video/video" "pages/video/video",
"pages/beiyinmei/beiyinmei"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
......
// pages/beiyinmei/beiyinmei.js
import qrcode, {
height
} from '../../utils/llqrcodefrankyin.js'
Page({
/**
* 页面的初始数据
*/
data: {
img: 'https://res.wx.qq.com/wxdoc/dist/assets/img/0.4cb08bb4.jpg',
setHeight: '',
setWidth: '',
canvas: {
height: 100,
width: 100
},
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
const that = this
this.cameraContext = wx.createCameraContext()
//系统基本信息
const systemInfo = wx.getSystemInfoSync();
this.setData({
setHeight: systemInfo.windowWidth,
setWidth: systemInfo.windowHeight
})
let n = 1,
flag = true
// const ctx = wx.createCanvasContext('myCanvas');
// wx.chooseImage({
// success: function(res){
// console.log(res);
// ctx.drawImage(res.tempFilePaths[0], (400-50)/2, (300-50)/2, 50,50,0,0,200,200)
// // ctx.drawImage(res.tempFilePaths[0], 0, 0, 150, 150)
// ctx.draw()
// }
// })
// setInterval(() => {
// this.cameraContext.takePhoto({
// success: (res) => {
// console.log(888,res);
// this.checkPictureCode(res.tempImagePath)
// },
// fail(e){
// console.log(e,555);
// }
// })
// },0)
// return
const listener = this.cameraContext.onCameraFrame((frame) => {
if (n % 25 == 0 && flag) {
flag = false
this.setData({
canvas: {
height: 500,
width: 500,
flag: false
}
})
console.log(frame)
const base64 = wx.arrayBufferToBase64(frame.data)
// console.log(base64);
that.setData({
src: 'data:image/jpg;base64,' + base64
});
const data = new Uint8ClampedArray(frame.data);
// wx.canvasPutImageData({
// canvasId: 'myCanvas',
// x: 0,
// y: 0,
// width: frame.width,
// height: frame.width,
// data: data,
// success (res) {},
// fail(err){
// console.log(err);
// }
// })
// return
const query = wx.createSelectorQuery()
query.select('#myCanvas')
.fields({
node: true,
size: true
})
.exec((res) => {
const canvas = res[0].node
const ctx = canvas.getContext('2d')
// const imgData= ctx.getImageData(0,0,200,200)
// console.log(new ImageData(data,100,100));
// const d= ctx.putImageData(new ImageData(data,frame.width,frame.height),0,0)
const imgData = canvas.createImageData(data, 400, 400)
const d = ctx.putImageData(imgData, 0, 0)
flag = true
console.log(imgData, 4444, d);
})
}
n++
})
listener.start()
},
checkPictureCode(imagePath) {
const that = this
wx.getImageInfo({
src: imagePath,
success(result) {
console.log(result, 222);
const w = result.width;
const h = result.height;
const canvasContent = wx.createCanvasContext('myCanvas');
canvasContent.drawImage(imagePath, (w - 200) / 2, (h - 200) / 2 - 50, 200, 200, 0, 0, 200, 200)
canvasContent.draw()
console.log();
wx.canvasGetImageData({
canvasId: 'myCanvas',
x: parseInt(0),
y: parseInt(0),
width: 200,
height: 200,
success(data) {
let d = qrcode.decodefrank(200, 200, data.data)
console.log('d', d, 55555);
}
})
that.setData({
img: result.path
})
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {}
}
\ No newline at end of file
<!--pages/beiyinmei/beiyinmei.wxml-->
<view style="height: 100vh;width: 100vw;position: relative;z-index: 99;">
<camera device-position="back" frame-size="large" flash="off" binderror="error" style="width: 100%; height: 300px;" mode="normal">
<view class="prompt">
<image src="/assets/imgs/拍照框.png" style="width: 40%;" mode="widthFix"/>
<text >请把二维码放置拍照框内</text>
</view>
</camera>
<view style="visibility: hidden;">
<canvas type="2d" id="myCanvas" canvas-id="myCanvas" style="height:{{canvas.height}}px;width: {{canvas.width}}px;"></canvas>
<image src="{{img}}" mode="widthFix"/>
</view>
</view>
/* pages/beiyinmei/beiyinmei.wxss */
.prompt {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #fff;
}
.prompt text {
margin-top: 50px;
}
\ No newline at end of file
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"minifyWXML": true, "minifyWXML": true,
"showES6CompileOption": false, "showES6CompileOption": false,
"useCompilerPlugins": false, "useCompilerPlugins": false,
"condition": false "condition": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.25.3", "libVersion": "2.25.3",
......
...@@ -9,6 +9,13 @@ ...@@ -9,6 +9,13 @@
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
{
"name": "pages/beiyinmei/beiyinmei",
"pathName": "pages/beiyinmei/beiyinmei",
"query": "",
"launchMode": "default",
"scene": null
},
{ {
"name": "pages/video/video", "name": "pages/video/video",
"pathName": "pages/video/video", "pathName": "pages/video/video",
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论