公用模块放common
This commit is contained in:
61
pages/common/scan/scan.vue
Normal file
61
pages/common/scan/scan.vue
Normal file
@ -0,0 +1,61 @@
|
||||
<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({
|
||||
success: (res) => { // 改为箭头函数保持this指向
|
||||
console.log('条码内容:' + res.result);
|
||||
// 跳转并传递扫描结果
|
||||
uni.navigateTo({
|
||||
url: `/pages/common/qrcode/qrcode?deviceId=${encodeURIComponent(res.result)}`
|
||||
});
|
||||
},
|
||||
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>
|
Reference in New Issue
Block a user