Explorar o código

更新 拍摄运单

wzh %!s(int64=3) %!d(string=hai) anos
pai
achega
d268c70662

+ 1 - 0
miniprogram/app.json

@@ -12,6 +12,7 @@
     "pages/sharePage/sharePage",
     "pages/voyageManage/createVoyage/createVoyage",
     "pages/voyageManage/myBills/myBills",
+    "pages/voyageManage/takeBill/takeBill",
     "pages/voyageManage/myBills/examine/examine",
     "pages/voyageManage/myDaily/myDaily",
     "pages/voyageManage/myVoyages/myVoyages",

+ 2 - 2
miniprogram/pages/voyageManage/myDaily/examine/examine.wxml

@@ -10,7 +10,7 @@
 </view>
 <!-- </block> -->
 <!-- <block wx:if="{{trans=='卸货中'}}"> -->
-<view class="df aic jcc">
+<!-- <view class="df aic jcc">
   <button style="width: 300rpx;line-height: 80rpx;padding: 0;font-weight: 400;" open-type="share" data-type="{{3}}" class="next">分享卸货报告</button>
-</view>
+</view> -->
 <!-- </block> -->

+ 116 - 0
miniprogram/pages/voyageManage/takeBill/takeBill.js

@@ -0,0 +1,116 @@
+import {
+  uploadFile
+} from "../../../utils/uploadImage"
+Page({
+  data: {
+    avatar: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/avatar-icon.jpg?sign=f5c66c94d189436f82353eb48cb01f08&t=1634538864",
+    cameraIcon: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera-icon.png?sign=11a65871a2800cd04ecaa8991687fccd&t=1634607415",
+    newCameraIcon: "https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/miniapp-static/camera.png?sign=ad0fe8bead6a46cb20f45f792d4bed67&t=1645502416",
+    userName: "",
+    phone: "",
+    shipName: "",
+    shipMmsi: "",
+    authModal: false,
+    modalText: "位置",
+    cw: '',
+    ch: '',
+    disabled: false,
+    imgCache: ''
+  },
+  takeBill() {
+    if (this.data.disabled) return
+    wx.showLoading({
+      title: '正在上传...',
+    })
+    this.data.disabled = true
+    const ctx = wx.createCameraContext()
+    ctx.takePhoto({
+      quality: 'high',
+      success: (res) => {
+        let src = res.tempImagePath
+        let ch = res.height * 2
+        let cw = res.width * 2
+        wx.getImageInfo({
+          src,
+          success: e => {
+            this.setData({
+              ch,
+              cw
+            })
+            const query = wx.createSelectorQuery();
+            query.select('#myCanvas').node().exec((res) => {
+              const canvas = res[0].node;
+              const ctx = canvas.getContext('2d');
+              const img = canvas.createImage();
+              let h = ch / 2
+              let w = cw / 2
+              canvas.height = h * 0.85
+              canvas.width = w * 0.9
+              img.src = src
+              img.onload = () => {
+                ctx.drawImage(img, -w * 0.05, -h * 0.05);
+              }
+              this.saveImg(src)
+            })
+          }
+        })
+
+      }
+    })
+  },
+  goBack() {
+    wx.navigateBack()
+  },
+  async saveImg(src) {
+    const query = wx.createSelectorQuery();
+    const canvas = await new Promise((resolve, reject) => {
+      query.select('#myCanvas')
+        .fields({
+          node: true,
+          size: true
+        })
+        .exec(async (res) => {
+          resolve(res[0].node);
+        })
+    });
+
+    wx.canvasToTempFilePath({
+      canvas,
+      success: async e => {
+        // let path = e.tempFilePath
+        // wx.navigateTo({
+        //   url: `/pages/takeBill/success/success?src=${src}&path=${path}`
+        // })
+        // return
+        this.setData({
+          imgCache: e.tempFilePath
+        })
+        let res = await uploadFile("/voyage/uploadVoyageWayBill", e.tempFilePath, {
+          type: this.data.type,
+          voyageId: this.data.voyageId
+        })
+        wx.hideLoading({
+          success: (res) => {},
+        })
+        console.log(res)
+        wx.showToast({
+          title: res.msg,
+        })
+        setTimeout(() => {
+          this.data.disabled = false
+          wx.setStorageSync('addStatus', "success")
+          this.goBack()
+        }, 1000)
+      },
+      fail(res) {
+        console.log('fail');
+      }
+    })
+  },
+
+  onLoad(options) {
+    this.setData({
+      ...options
+    })
+  }
+})

+ 4 - 0
miniprogram/pages/voyageManage/takeBill/takeBill.json

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

+ 13 - 0
miniprogram/pages/voyageManage/takeBill/takeBill.wxml

@@ -0,0 +1,13 @@
+<camera resolution="high" style="height: 100vh;width: 100vw;"></camera>
+<view class="top back fixed"></view>
+<view class="right back fixed"></view>
+<view class="bottom back fixed"></view>
+<view class="left back fixed"></view>
+<view class="dashed fixed"></view>
+<view class="text fixed">请 将 磅 单 置 于 拍 摄 框 内</view>
+<view class="out fixed" bindtap="takeBill">
+  <view class="in"></view>
+</view>
+<view class="go-back fixed" bindtap="goBack">返 回</view>
+<canvas type="2d" id="myCanvas" style="position:fixed;left: -100vw;width:{{cw*0.9*0.25}}rpx;height: {{ch*0.85*0.25}}rpx;box-sizing: border-box"></canvas>
+<image wx:if="{{imgCache}}" style="position: fixed;width: 100vw;height: 100vh;top: 0;left: 0;z-index: 100;" src="{{imgCache}}"></image>

+ 93 - 0
miniprogram/pages/voyageManage/takeBill/takeBill.wxss

@@ -0,0 +1,93 @@
+/* pages/takeBill/takeBill.wxss */
+page {
+  /* 拍摄框宽度 */
+  --w: 90vw;
+
+  /* 拍摄框高度 */
+  --h: 85vh;
+
+  /* 拍摄框上边距 */
+  --tg: 5vh
+}
+
+.back {
+  background: #000;
+  opacity: 0.5;
+}
+
+.fixed {
+  position: fixed;
+}
+
+
+.top {
+  top: 0;
+  width: 100vw;
+  height: var(--tg);
+}
+
+.right {
+  right: 0;
+  height: var(--h);
+  width: calc((100vw - var(--w)) / 2);
+  top: var(--tg);
+}
+
+.bottom {
+  bottom: 0;
+  width: 100vw;
+  height: calc(100vh - var(--tg) - var(--h));
+}
+
+.left {
+  left: 0;
+  height: var(--h);
+  width: calc((100vw - var(--w)) / 2);
+  top: var(--tg);
+}
+
+.dashed {
+  height: var(--h);
+  width: var(--w);
+  top: var(--tg);
+  left: calc((100vw - var(--w)) / 2);
+  border: 4rpx dashed grey;
+}
+
+.text {
+  top: 22vh;
+  transform: rotate(90deg);
+  transform-origin: left;
+  left: 52vw;
+  color: #fff;
+  opacity: 0.7;
+  font-size: 4vh;
+  white-space: nowrap;
+}
+
+.out {
+  height: calc((100vh - var(--tg) - var(--h)) / 2);
+  width: calc((100vh - var(--tg) - var(--h)) / 2);
+  border: 4rpx solid #fff;
+  bottom: calc((100vh - var(--tg) - var(--h)) / 4);
+  left: calc(50vw - (100vh - var(--tg) - var(--h)) / 4);
+  border-radius: 50%;
+  padding: 2rpx;
+  display: flex;
+  justify-content: center;
+  align-items: center;
+}
+
+.in {
+  width: 90%;
+  height: 90%;
+  background: #fff;
+  border-radius: 50%;
+}
+
+.go-back {
+  font-size: 2vh;
+  color: #fff;
+  bottom: calc((100vh - var(--tg) - var(--h)) / 3);
+  right: calc((100vh - var(--tg) - var(--h)) / 2);
+}

+ 7 - 3
miniprogram/pages/voyageManage/voyageManage.js

@@ -32,9 +32,14 @@ Page({
     this.getList()
   },
   changeMainTab(e) {
+    let {
+      maintab,
+      api: currentApi
+    } = e.currentTarget.dataset
+    app.globalData.maintab = maintab
     this.setData({
-      maintab: e.currentTarget.dataset.maintab,
-      currentApi: e.currentTarget.dataset.api,
+      maintab,
+      currentApi,
       status: 1,
       list: [],
       currentPage: 1
@@ -164,7 +169,6 @@ Page({
 
   },
   onShow() {
-
     this.setData({
       maintab: app.globalData.maintab,
       todayDate: datetimeFormat("年月月日日")

+ 6 - 0
miniprogram/pages/voyages/detail/detail.js

@@ -459,6 +459,12 @@ Page({
     })
   },
 
+  uploadBillCanvas() {
+    wx.navigateTo({
+      url: `/pages/voyageManage/takeBill/takeBill?type=1&voyageId=${this.data.id}`,
+    })
+  },
+
   onLoad(options) {
     let {
       id

+ 2 - 2
miniprogram/pages/voyages/detail/detail.wxml

@@ -10,7 +10,7 @@
   <view class="tabsview" bindtap="changeTab" data-tab="{{4}}" style="color:{{tab==4?'#0d8fcc':''}};border-bottom:{{tab==4?'2rpx solid #0d8fcc':''}}">单据信息</view>
   <!-- <view class="tabsview" bindtap="changeTab" data-tab="{{5}}" style="color:{{tab==5?'#0d8fcc':''}};border-bottom:{{tab==5?'2rpx solid #0d8fcc':''}}">航次照片</view> -->
 </view>
-<scroll-view scroll-y="true" style="height:calc(100vh - 570rpx);font-size: 28rpx;color:#222;padding-bottom: 50rpx;" lower-threshold="50" bindscrolltolower="test">
+<scroll-view scroll-y="true" style="height:calc(100vh - 570rpx);font-size: 28rpx;color:#222;padding-bottom: 50rpx;" lower-threshold="50">
   <view wx:if="{{tab==1}}">
     <view class="line">
       <view class="line-full-item">
@@ -194,7 +194,7 @@
       <image data-src="{{item.viewUrl}}" bindtap="previewImage" src="{{item.viewUrl}}" style="width: 60%;height: 240rpx;" mode="aspectFit"></image>
       <view wx:if="{{waybills.length&&waybills.length!=1}}" class="mt10 mb10" style="border-bottom: 2rpx solid #eee;"></view>
     </view>
-    <view class="next" bindtap="uploadBill" data-type="{{1}}">上传运单</view>
+    <view class="next" bindtap="uploadBillCanvas" data-type="{{1}}">上传运单</view>
   </view>
   <view class="p30" wx:if="{{tab==3}}">
     <scroll-view scroll-x="{{true}}" style="white-space: nowrap;">

+ 1 - 0
miniprogram/utils/uploadImage.js

@@ -67,5 +67,6 @@ function uploadImage(path, params) {
 
 
 module.exports = {
+  uploadFile,
   uploadImage
 }

+ 7 - 0
project.private.config.json

@@ -29,6 +29,13 @@
           "query": "id=170&trans=%E8%BF%90%E8%BE%93%E4%B8%AD",
           "launchMode": "default",
           "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/voyageManage/myDaily/examine/examine",
+          "query": "id=170&trans=%E5%8D%B8%E8%B4%A7%E4%B8%AD",
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }