Kaynağa Gözat

更新 拍摄单据逻辑

wzh 3 yıl önce
ebeveyn
işleme
6411ffe634

+ 3 - 1
miniprogram/app.json

@@ -5,7 +5,9 @@
     "pages/cachePage/cachePage",
     "pages/takePhoto/success/success",
     "pages/share/share",
-    "pages/newCachePage/newCachePage"
+    "pages/newCachePage/newCachePage",
+    "pages/takeBill/takeBill",
+    "pages/takeBill/success/success"
   ],
   "window": {
     "backgroundColor": "#F6F6F6",

BIN
miniprogram/images/1.png


BIN
miniprogram/images/2.png


BIN
miniprogram/images/3.png


BIN
miniprogram/images/4.png


BIN
miniprogram/images/5.png


BIN
miniprogram/images/6.png


+ 7 - 0
miniprogram/pages/takeBill/success/success.js

@@ -0,0 +1,7 @@
+Page({
+  go() {
+    wx.navigateTo({
+      url: '/pages/takePhoto/takePhoto',
+    })
+  },
+})

+ 3 - 0
miniprogram/pages/takeBill/success/success.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

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

@@ -0,0 +1,6 @@
+<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>

+ 1 - 0
miniprogram/pages/takeBill/success/success.wxss

@@ -0,0 +1 @@
+/* pages/takePhoto/success/success.wxss */

+ 99 - 0
miniprogram/pages/takeBill/takeBill.js

@@ -0,0 +1,99 @@
+import {
+  uploadFile
+} from "../../utils/upload"
+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: "位置"
+  },
+
+  takePhotoAction: function () {
+    const ctx = wx.createCameraContext()
+    ctx.takePhoto({
+      quality: 'high',
+      success: (res) => {
+        console.log(res)
+        let src = res.tempImagePath
+        wx.compressImage({
+          src,
+          quality: 80, // 压缩质量
+          success: async e => {
+            console.log("图片压缩成功!", e)
+            wx.hideLoading({
+              success: (res) => {},
+            })
+            if (wx.getStorageSync('userName')) {
+              wx.showLoading({
+                title: '正在上传...',
+              })
+              let postData = {
+                type: 0,
+                userId: wx.getStorageSync('userId'),
+              }
+
+              postData.location = ''
+              let res = await uploadFile(e.tempFilePath, postData)
+              console.log("上传结束", res)
+              if (res.status == 0) {
+                wx.showToast({
+                  title: res.msg
+                })
+                wx.setStorageSync('shareImageUrl', res.result.viewUrl)
+                console.log(wx.getStorageSync('shareImageUrl'))
+                wx.downloadFile({
+                  url: res.result.viewUrl,
+                  success: e => {
+                    console.log("下载调用!", e)
+                    wx.setStorageSync('cacheImage', e.tempFilePath)
+                    wx.redirectTo({
+                      url: '/pages/takeBill/success/success',
+                    })
+                  },
+                  fail: e => {
+                    console.log("失败3", e)
+                  }
+                })
+
+
+              } else {
+                wx.showToast({
+                  title: res.msg
+                })
+              }
+            } else {
+              // 新用户图片
+              console.log("新用户图片", e)
+              wx.setStorageSync('type', 1)
+              wx.setStorageSync('file', e.tempFilePath)
+              wx.redirectTo({
+                url: `/pages/newCachePage/newCachePage`,
+              })
+            }
+          },
+          fail: e => {
+            console.log("失败2", e)
+          }
+        })
+      }
+    })
+  },
+  onLoad() {
+    let userName = wx.getStorageSync('userName')
+    let userId = wx.getStorageSync('userId')
+    let phone = wx.getStorageSync('phone')
+    let shipId = wx.getStorageSync('shipId')
+    this.setData({
+      userName,
+      phone,
+      userId,
+      shipId
+    })
+  }
+})

+ 3 - 0
miniprogram/pages/takeBill/takeBill.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 7 - 0
miniprogram/pages/takeBill/takeBill.wxml

@@ -0,0 +1,7 @@
+<view style="background: #000;height: 30vh;"></view>
+<camera style="height: 30vh;"></camera>
+<view style="background: #000;height: 40vh;display:flex;justify-content: center;align-items: center;">
+  <view bindtap="takePhotoAction" style="border: 4rpx solid #fff;border-radius: 50%;padding: 5px;">
+    <view style="height:10vh;width:10vh;border-radius: 50%;background: #fff;margin:0 auto;"></view>
+  </view>
+</view>

+ 1 - 0
miniprogram/pages/takeBill/takeBill.wxss

@@ -0,0 +1 @@
+/* pages/takeBill/takeBill.wxss */

+ 5 - 0
miniprogram/pages/takePhoto/takePhoto.js

@@ -40,6 +40,11 @@ Page({
       }
     })
   },
+  takeBill() {
+    wx.navigateTo({
+      url: '/pages/takeBill/takeBill',
+    })
+  },
   takePhoto(e) {
     let {
       mediatype

+ 1 - 1
miniprogram/pages/takePhoto/takePhoto.wxml

@@ -8,7 +8,7 @@
 
 </view>
 <view wx:if="{{userId&&shipId}}" class="new-camera camera-bill">
-  <image class="icon" data-mediatype="{{0}}" bindtap="takePhoto" src="{{newCameraIcon}}"></image>
+  <image class="icon" data-mediatype="{{0}}" bindtap="takeBill" src="{{newCameraIcon}}"></image>
   <view> 拍单据
   </view>
 </view>

+ 1 - 1
miniprogram/pages/takePhoto/takePhoto.wxss

@@ -102,7 +102,7 @@
 
 .camera-bill {
   height: 33vh;
-  background: #3bb1da;
+  background: #fa283d;
 }
 
 .new-camera {

+ 7 - 0
project.private.config.json

@@ -73,6 +73,13 @@
           "name": "",
           "pathName": "pages/takePhoto/takePhoto",
           "query": "",
+          "launchMode": "default",
+          "scene": null
+        },
+        {
+          "name": "",
+          "pathName": "pages/takeBill/takeBill",
+          "query": "",
           "scene": null,
           "launchMode": "default"
         }