zhaozhipeng 3 ani în urmă
părinte
comite
d974322550
3 a modificat fișierele cu 26 adăugiri și 11 ștergeri
  1. 14 0
      src/common/native.js
  2. 10 9
      src/components/dj-modal.vue
  3. 2 2
      src/pages/index/upKeepInfo.vue

+ 14 - 0
src/common/native.js

@@ -19,4 +19,18 @@ export function returnApp () {
       }
     )
   })
+}
+
+// 扫码
+export function scanCode () {
+  return new Promise((resolve, reject) => {
+    window.YifengPlugins.scanQRCode(
+	  result => {
+		resolve(result)
+	  },
+	  error => {
+		reject(error)
+	  }
+    )
+  })
 }

+ 10 - 9
src/components/dj-modal.vue

@@ -122,15 +122,16 @@
 			// 扫码新增
 			sao_add() {
 				this.cancle()
-				uni.scanCode({
-				    onlyFromCamera: true,
-				    success: function (res) {
-						let number = res.result
-				        uni.navigateTo({
-				        	url: `/pages/index/addUpkeep?number=${number}`
-				        })
-				    }
-				});
+				scanCode().then(res=>{
+					uni.navigateTo({
+						url: `/pages/index/addUpkeep?number=${res}`
+					})
+				}).catch(res=> {
+					this.$refs.uToast.show({
+						title: '扫码失败',
+						type: 'error'
+					}) 
+				})
 			}
 		}
 	}

+ 2 - 2
src/pages/index/upKeepInfo.vue

@@ -7,9 +7,9 @@
 					<view class="d-flex j-sb a-center">
 						<view class="u-font-xl">{{ item.projectName }}: {{ item.projectValue }}</view>
 						<view class="d-flex">
-							<dj-button v-if="item.status === '1'" class="u-m-r-12" content="NOK" borderRadius="0" ifPlain width="111" height="53" bColor="#fff" color="#FE0000" border="#FE0000" @click.native="btn_click(index,false)"></dj-button>
+							<dj-button v-if="item.status === '' || item.status === '1'" class="u-m-r-12" content="NOK" borderRadius="0" ifPlain width="111" height="53" bColor="#fff" color="#FE0000" border="#FE0000" @click.native="btn_click(index,false)"></dj-button>
 							<dj-button v-else class="u-m-r-12" content="NOK" width="111" height="53" bColor="#FE0000" borderRadius="0" color="#fff" border="#FE0000"></dj-button>
-							<dj-button v-if="item.status === '0'" content="OK" ifPlain  borderRadius="0" width="111" height="53" bColor="#fff" color="#2196F3" border="#2196F3" @click.native="btn_click(index,true)"></dj-button>
+							<dj-button v-if="!item.status || item.status === '0'" content="OK" ifPlain  borderRadius="0" width="111" height="53" bColor="#fff" color="#2196F3" border="#2196F3" @click.native="btn_click(index,true)"></dj-button>
 							<dj-button v-else content="OK" width="111" height="53" bColor="#2196F3" borderRadius="0" color="#fff" border="#2196F3"></dj-button>
 						</view>
 					</view>