bonus-material-app/src/pages/back/backCodeScan.nvue

280 lines
7.3 KiB
Plaintext
Raw Normal View History

2025-01-03 18:19:03 +08:00
<template>
<view class="page-container">
<view>
<live-pusher v-once id="livePusher" ref="livePusher" class="livePusher" mode="FHD" beauty="0" whiteness="0"
device-position="back" :auto-focus="false" :muted="true" :enable-camera="true" :enable-mic="true"
:zoom="true" :style="[{height: cameraHeight+'rpx' ,width:'750rpx'}]">
</live-pusher>
</view>
<view class="table-list-item">
<view class="scan-btn" @click="handleInstruct('shutter')">
<text style="color: #FFF;">开始识别</text>
</view>
</view>
<view class="table-list-item">
<uni-row :gutter="24" style="display: flex; align-items: center">
<uni-col :span="5">
<text> 设备编码 </text>
</uni-col>
<uni-col :span="10">
<view>
<uni-easyinput v-model="queryCodeParams.maCode" placeholder="请输入内容" />
</view>
</uni-col>
<uni-col :span="6">
<view class="coding-btn" style="padding: 10rpx 0;color: #fe9a09;background-color: #fff7eb;border: 1px solid #fe9a09;"
@click="getMaInfo">
<text style="color: #fe9a09;text-align: center;">编码检索</text>
</view>
</uni-col>
</uni-row>
</view>
<view class="table-list-item">
<scroll-view class="scroll-view" scroll-y="true" style="height: 500rpx;">
<uni-forms :model="codeData" label-width="100" :border="true">
<uni-forms-item label="物资类型:" name="typeName">
<text class="form-view">{{ codeData.typeName }}</text>
</uni-forms-item>
<uni-forms-item label="规格型号:" name="materialName">
<text class="form-view">{{ codeData.materialName }}</text>
</uni-forms-item>
<uni-forms-item label="设备状态:" name="maStatusName">
<text class="form-view">{{ codeData.maStatusName }}</text>
</uni-forms-item>
<uni-forms-item label="设备数量:">
<text class="form-view">1</text>
</uni-forms-item>
</uni-forms>
</scroll-view>
</view>
<view class="outbound-btn" @tap="onHandleOutbound">
<text style="color: #FFF;">退料</text>
</view>
</view>
</template>
<script>
// import { getMachineApi } from '../../services/back.js';
export default {
data() {
return {
livePusher: null,
ready: true,
cameraHeight: '', //相机画面宽度
coverImage: null,
queryParams:{},
queryCodeParams:{
maCode:""
},
codeData:{}
}
},
onLoad(options) {
this.queryParams = JSON.parse(options.queryParams)
this.queryCodeParams.typeId = this.queryParams.typeId
},
onReady() {
this.cameraHeight = uni.getSystemInfoSync().screenHeight * 0.22
console.log(this.cameraHeight)
this.init()
},
methods: {
init() {
this.livePusher = uni.createLivePusherContext('livePusher', this);
console.log(this.livePusher)
setTimeout(() => {
this.startPreview()
}, 1000)
},
startPreview() {
this.livePusher.startPreview({
success: () => {
console.log('相机初始化成功');
switch (plus.os.name) {
case 'Android':
break;
case 'iOS':
this.livePusher.switchCamera()
break
}
},
fail: (err) => {
console.log(err)
}
});
},
handleInstruct(instruct) {
if (this.ready) {
this.ready = false
this.livePusher.snapshot({
success: (res) => {
console.log(res)
this.ready = true
this.$emit('getImage', res.message.tempImagePath)
}
})
}
},
//根据编码获取设备类型
async getMaInfo(){
let param={
"maCode":this.queryCodeParams.maCode,
"unitId":this.queryParams.unitId,
"proId":this.queryParams.proId
}
// const res = await getMachine(param)
// console.log(res)
// if(res.code==200){
// if(res.data&&res.data.length>0){
// this.codeData = res.data[0]
// }else{
// uni.showToast({ title: '该编码非该单位工程领用,不可退料!', icon: 'none' })
// }
// }
},
async onHandleOutbound(){
let paramsList = []
paramsList.push({
maCode: this.codeData.maCode,
maId: this.codeData.maId,
leaseType:0,
outType:2,
outNum:1,
typeId:this.codeData.typeId,
manageType: this.codeData.manageType,
parentId: this.queryParams.parentId,
// typeName: this.codeData.typeName,
// typeModelName: this.codeData.typeModelName
})
console.log('333333333', paramsList)
// const res = await setOutboundNumAPI({ leaseOutDetailsList: paramsList })
// if (res.code === 200) {
// uni.showToast({
// title: '出库成功!',
// icon: 'none',
// })
// this.queryCodeParams.maCode = ''
// this.codeData = {}
// }
}
}
}
</script>
<style>
.page-container {
display: flex;
height: auto;
flex-direction: column;
background-color: #f7f8fa;
padding: 24rpx;
}
.table-list-item {
margin-top: 10rpx;
background: #fff;
padding: 20rpx;
border-radius: 20rpx;
box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06);
margin-bottom: 20rpx;
}
.scan-btn {
/* width: 100%; */
height: 88rpx;
background: #4b8eff;
display: flex;
justify-content: center;
align-items: center;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
/* transition: all 0.3s ease; */
margin: 0;
padding: 0;
}
.coding-btn {
/* padding: 12rpx 0; */
background: #fff;
color: #ff9800;
border: 2rpx solid rgba(255, 152, 0, 0.5);
background: linear-gradient(to bottom, rgba(255, 152, 0, 0.05), rgba(255, 152, 0, 0.1));
border-radius: 12rpx;
text-align: center;
font-size: 28rpx;
font-weight: 600;
letter-spacing: 1rpx;
/* transition: all 0.3s ease; */
/* &:active {
background: rgba(255, 152, 0, 0.15);
border-color: rgba(255, 152, 0, 0.6);
transform: translateY(1rpx);
} */
}
.outbound-btn {
position: fixed;
bottom: 40rpx;
left: 20%;
/* transform: translateX(-50%); */
/* width: 90%; */
height: 88rpx;
width: 620rpx;
margin: 0 10px;
/* background: linear-gradient(135deg, #4b8eff 0%, #3784fb 100%); */
background: #4b8eff;
display: flex;
align-items: center;
justify-content: center;
color: #fff;
border-radius: 12rpx;
font-size: 32rpx;
font-weight: 600;
box-shadow: 0 6rpx 20rpx rgba(55, 132, 251, 0.2);
/* transition: all 0.3s ease; */
/* &:active {
transform: translateX(-50%) scale(0.98);
opacity: 0.9;
} */
}
.camera-background {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
}
.cover-image {
position: fixed;
top: 0;
left: 0;
z-index: 99;
}
.camera-options {
flex-direction: row;
align-items: center;
}
.camera-item {
flex: 1;
flex-direction: row;
justify-content: center;
align-items: center;
height: 100%;
}
.camera-item .camera-item-image {
width: 80rpx;
height: 80rpx;
}
.camera-options-center .camera-item-image {
width: 120rpx;
height: 120rpx;
}
</style>