Ver Fonte

更新 单据截取功能

wzh há 3 anos atrás
pai
commit
a4916dc94b

+ 2 - 1
miniprogram/app.json

@@ -16,7 +16,8 @@
     "navigationBarBackgroundColor": "#F6F6F6",
     "navigationBarTitleText": "汇很多",
     "navigationBarTextStyle": "black",
-    "navigationStyle": "custom"
+    "navigationStyle": "custom",
+    "pageOrientation": "portrait"
   },
   "permission": {
     "scope.userLocation": {

+ 27 - 4
miniprogram/pages/takeBill/success/success.js

@@ -1,7 +1,30 @@
 Page({
-  go() {
-    wx.navigateTo({
-      url: '/pages/takePhoto/takePhoto',
-    })
+  data: {
+    src: '',
+    path: ''
   },
+  onLoad(options) {
+    let {
+      src,
+      path
+    } = options
+    this.setData({
+      src,
+      path
+    })
+    return
+    wx.getImageInfo({
+      src,
+      success: e => {
+        console.log("src", e)
+      }
+    })
+
+    wx.getImageInfo({
+      src: path,
+      success: e => {
+        console.log('path', e)
+      }
+    })
+  }
 })

+ 2 - 1
miniprogram/pages/takeBill/success/success.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "navigationStyle": "default"
 }

+ 4 - 6
miniprogram/pages/takeBill/success/success.wxml

@@ -1,6 +1,4 @@
-<view style="width: 100%;">
-  <image style="width: 300rpx;height: 300rpx;border-radius:50%;margin:0 auto;margin-top: 235rpx;display: block;" src="https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/green-circle-right-icon.jpg?sign=7fa6e412d07bfa0d5144ed2ed2716fff&t=1634542189"></image>
-</view>
-<view style="width: 100%;height: 48rpx;text-align:center;font-size: 34rpx;font-family: PingFangSC-Medium,PingFang SC;font-weight: 500;color: #0094FE;line-height: 48rpx;margin-top: 60rpx;">单据上传成功
-</view>
-<view bindtap="go" style="margin:0 auto;margin-top:156rpx;width: 650rpx;height: 80rpx;background:#0094FE;border-radius: 4rpx;color: #fff;text-align: center;font-size: 34rpx;font-family: PingFangSC-Regular, PingFang SC;font-weight: 400;line-height: 80rpx;">继续拍单据</view>
+<view style="padding-top: 10vh;">
+  <image mode="aspectFit" style="width: 50vw;border: 1px solid green;" src="{{src}}"></image>
+  <image mode="aspectFit" style="width: 50vw;border: 1px solid blue;" src="{{path}}"></image>
+</view>

+ 9 - 5
miniprogram/pages/takeBill/takeBill.js

@@ -27,12 +27,11 @@ Page({
       quality: 'high',
       success: (res) => {
         let src = res.tempImagePath
+        let ch = res.height * 2
+        let cw = res.width * 2
         wx.getImageInfo({
           src,
           success: e => {
-            console.log(e)
-            let ch = e.height * 2
-            let cw = e.width * 2
             this.setData({
               ch,
               cw
@@ -50,7 +49,7 @@ Page({
               img.onload = () => {
                 ctx.drawImage(img, -w * 0.05, -h * 0.05);
               }
-              this.saveImg()
+              this.saveImg(src)
             })
           }
         })
@@ -63,7 +62,7 @@ Page({
       url: '/pages/takePhoto/takePhoto',
     })
   },
-  async saveImg() {
+  async saveImg(src) {
     const query = wx.createSelectorQuery();
     const canvas = await new Promise((resolve, reject) => {
       query.select('#myCanvas')
@@ -79,6 +78,11 @@ Page({
     wx.canvasToTempFilePath({
       canvas,
       success: async e => {
+        // let path = e.tempFilePath
+        // wx.navigateTo({
+        //   url: `/pages/takeBill/success/success?src=${src}&path=${path}`
+        // })
+        // return
         let res = await uploadFile(e.tempFilePath, {
           type: 0,
           userId: wx.getStorageSync('userId'),

+ 2 - 1
miniprogram/pages/takeBill/takeBill.json

@@ -1,3 +1,4 @@
 {
-  "usingComponents": {}
+  "usingComponents": {},
+  "pageOrientation": "portrait"
 }