1
0
forked from dyf/APP
Files
APP/pages/common/scan/scan.vue

60 lines
1.1 KiB
Vue
Raw Permalink Normal View History

2025-07-05 14:49:26 +08:00
<template>
<view class="pageContent">
<view class="pause" @click="scanCode">
<uni-icons type="scan" size="100" color="rgba(255, 255, 255, 0.5)"></uni-icons>
<view class="scanT">扫一扫添加设备</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
}
},
methods: {
// 扫描
scanCode() {
uni.scanCode({
2025-07-07 18:59:34 +08:00
success: (res) => {
2025-07-05 14:49:26 +08:00
console.log('条码内容:' + res.result);
// 跳转并传递扫描结果
uni.navigateTo({
2025-07-07 09:21:39 +08:00
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(res.result)}`
2025-07-05 14:49:26 +08:00
});
},
fail: (err) => {
console.log('扫码失败', err);
uni.showToast({
title: '扫码失败',
icon: 'none'
});
}
});
}
}
}
</script>
<style scoped>
.pageContent {
height: 100vh;
background-color: rgb(18, 18, 18);
padding: 30rpx;
}
.pause {
text-align: center;
transform: translate(-50%, -100%);
position: absolute;
left: 50%;
top: 40%;
}
.scanT {
color: rgba(255, 255, 255, 0.87);
font-size: 38rpx;
padding-top: 20rpx;
}
</style>