瀏覽代碼

更新 上传逻辑

wzh 3 年之前
父節點
當前提交
eed4e25c07
共有 3 個文件被更改,包括 21 次插入9 次删除
  1. 17 5
      miniprogram/pages/takeBill/takeBill.js
  2. 1 1
      miniprogram/pages/takeBill/takeBill.wxml
  3. 3 3
      project.private.config.json

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

@@ -13,9 +13,15 @@ Page({
     authModal: false,
     modalText: "位置",
     cw: '',
-    ch: ''
+    ch: '',
+    disabled: false
   },
-  test() {
+  takeBill() {
+    if (this.data.disabled) return
+    wx.showLoading({
+      title: '正在上传...',
+    })
+    this.data.disabled = true
     const ctx = wx.createCameraContext()
     ctx.takePhoto({
       quality: 'high',
@@ -75,14 +81,20 @@ Page({
       success: async e => {
         let res = await uploadFile(e.tempFilePath, {
           type: 0,
-          // userId: wx.getStorageSync('userId'),
-          userId: 89,
+          userId: wx.getStorageSync('userId'),
+          // userId: 89,
           location: ''
         })
+        wx.hideLoading({
+          success: (res) => {},
+        })
         wx.showToast({
           title: res.msg,
         })
-        this.goBack()
+        setTimeout(() => {
+          this.data.disabled = false
+          this.goBack()
+        }, 1000)
       },
       fail(res) {
         console.log('fail');

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

@@ -5,7 +5,7 @@
 <view class="left back fixed"></view>
 <view class="dashed fixed"></view>
 <view class="text fixed">请 将 磅 单 置 于 拍 摄 框 内</view>
-<view class="out fixed" bindtap="test">
+<view class="out fixed" bindtap="takeBill">
   <view class="in"></view>
 </view>
 <view class="go-back fixed" bindtap="goBack">返 回</view>

+ 3 - 3
project.private.config.json

@@ -68,14 +68,14 @@
           "name": "",
           "pathName": "pages/takeBill/canvas/canvas",
           "query": "",
-          "scene": null,
-          "launchMode": "default"
+          "launchMode": "default",
+          "scene": null
         }
       ]
     }
   },
   "setting": {
-    "urlCheck": false,
+    "urlCheck": true,
     "es6": true,
     "enhance": true,
     "postcss": true,