1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import Router from '../../../utils/routes'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- show: 'scan'
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.camera = wx.createCameraContext()
- },
- takePhoto () {
- this.camera.takePhoto({
- success: (res) => {
- const tempImagePath = res.tempImagePath
- this.setData({
- filePath: tempImagePath,
- show: 'confirm'
- })
- }
- })
- },
- selectPhoto () {
- wx.chooseImage({
- count: 1,
- success: (res) => {
- const tempImagePath = res.tempFilePaths[0]
- this.setData({
- filePath: tempImagePath,
- })
- this.recongnize()
- }
- })
- },
- recongnize () {
- Router.push({
- url: 'scanResult',
- query: {
- filePath: this.data.filePath
- }
- })
- },
- reTake () {
- this.setData({
- show: 'scan'
- })
- }
- })
|