| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- Page({
- onShareAppMessage() {
- return {
- title: 'camera',
- path: 'page/component/pages/camera/camera'
- }
- },
- data: {
- src: '',
- videoSrc: '',
- position: 'back',
- mode: 'scanCode',
- result: {}
- },
- onLoad() {
- this.ctx = wx.createCameraContext()
- },
- takePhoto() {
- this.ctx.takePhoto({
- quality: 'high',
- success: (res) => {
- this.setData({
- src: res.tempImagePath
- })
- }
- })
- },
- startRecord() {
- this.ctx.startRecord({
- success: () => {
- console.log('startRecord')
- }
- })
- },
- stopRecord() {
- this.ctx.stopRecord({
- success: (res) => {
- this.setData({
- src: res.tempThumbPath,
- videoSrc: res.tempVideoPath
- })
- }
- })
- },
- togglePosition() {
- this.setData({
- position: this.data.position === 'front'
- ? 'back' : 'front'
- })
- },
- error(e) {
- console.log(e.detail)
- }
- })
|