12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <template>
- <view class="barcode">
- <text>条码类型{{scanType}}</text>
- <view class="ba1">
- <text>条码内容{{result}}</text>
- </view>
- <button type="primary" class="but" @click="sc">扫码</button>
- </view>
- </template>
- <script>
- export default {
- components:{
-
- },
- data() {
- return {
- scanType:"",
- result:"",
- }
- },
- onHide() {
- uni.stopBluetoothDevicesDiscovery({
- success(res) {
- console.log(res)
- }
- })
- uni.closeBluetoothAdapter({
- success(res) {
- console.log(res)
- }
- })
- },
- mounted() {
-
- },
- methods: {
- sc(){
- uni.scanCode({
- success: (res) => {
- console.log('条码类型:' + res.scanType);
- this.result = res.result
- this.scanType = res.scanType
- console.log('条码内容:' + res.result);
- },
- fail:(e) =>{
- console.log(e)
- }
- });
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .barcode {
- padding:60rpx 20rpx;
- .ba1{
- margin:30rpx 0;
- }
- }
- .but{
- margin:50rpx;
- }
- </style>
|