barcodeQuery.vue
2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<template>
<view class="container">
<Navbar title="条码查询" safeAreaInsetTop placeholder canBack bgColor="#161F2E" textColor="#fff"
leftIconColor="#fff"></Navbar>
<view class="padding-lr-xl flex align-center w100 flex-direction" style="margin-top: 300rpx;">
<view class="text-white margin-bottom text-lgz">
请输入条码查询气瓶
</view>
<view class="w80">
<u-input v-model="code" placeholder="请输入条码查询气瓶"></u-input>
</view>
<view class="w80 flex justify-between margin-top-xl">
<view class="w40" @click="goback">
<u-button shape="circle" color="#4B2C24" iconColor="#fff" icon="scan" text="扫一扫"></u-button>
</view>
<view class="w40" @click="handleCode">
<u-button shape="circle" color="#EA5504" text="确定"></u-button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
components: {
},
data() {
return {
code:"",
mode:1,
};
},
onLoad(data) {
if(data.mode){
this.mode = parseInt(data.mode);
console.log("输入模式",this.mode);
}
},
mounted() {
},
methods: {
goback() {
this.$goBack();
},
async handleCode() {
if(this.code === ''){
uni.$u.toast('请输入气瓶条码');
return
}
this.$modal.showLoading('查询中...');
let query = {
qptm: this.code
}
const result = await this.$api.gasApi.getDetailByQuery(query);
this.$modal.closeLoading();
let {
state,
message
} = result;
if (!state) {
uni.$u.toast(message)
return;
}
if (this.mode === 1) {
uni.redirectTo({
url: '/pages/home/appList/gasInformation/gasInformation?qptm=' + this.code
})
} else if (this.mode === 2) {
//在需要扫码获取code的地方使用uni.$on监听scanCode即可获取code
uni.$emit("scanCode", this.code);
uni.navigateBack({
delta:2
});
}
}
}
}
</script>
<style lang="scss" scoped>
.container {
display: flex;
flex: 1;
overflow: hidden;
width: 750rpx;
height: 100vh;
background: #161F2E;
}
.u-input {
background: #fff;
}
</style>