Files
app-govern/pages/device/transfer.vue

118 lines
3.3 KiB
Vue
Raw Normal View History

2023-02-09 16:37:53 +08:00
<template>
2023-08-30 10:03:07 +08:00
<Cn-page :loading="loading" beforeRender>
2023-07-24 15:00:19 +08:00
<view slot="body">
<view class="transfer">
<!-- <div class="transfer-img" ref="qrCodeUrl" /> -->
2023-08-11 11:03:31 +08:00
<!-- <uqrcode ref="uqrcode" canvas-id="qrcode" :value="content" :options="{ margin: 10 }"></uqrcode> -->
2023-08-30 10:03:07 +08:00
<uqrcode ref="uqrcode" canvas-id="qrcode" :value="content" size="200"
@complete="complete"
2023-08-23 16:22:08 +08:00
:loading="false"></uqrcode>
2023-08-30 10:03:07 +08:00
<view style="height: 200rpx"></view>
<view class="transfer-text ">请让接收人员扫码接收</view>
2023-02-09 16:37:53 +08:00
<view class="transfer-btn">
2023-07-24 15:00:19 +08:00
<button class="transfer-btn-item" style="background-color: #fff; color: #111" @click="back">
返回
</button>
2023-08-23 16:22:08 +08:00
<button class="transfer-btn-item ml20" @click="scan">扫一扫</button>
2023-02-09 16:37:53 +08:00
</view>
</view>
</view>
</Cn-page>
</template>
<script>
2023-07-24 15:00:19 +08:00
// import QRCode from 'qrcodejs2'
// import UQRCode from '@/uni_modules/Sansnn-uQRCode/js_sdk/uqrcode/uqrcode.js';
2023-08-23 16:22:08 +08:00
import {transferDevice} from "@/common/api/device";
2023-02-09 16:37:53 +08:00
export default {
2023-07-24 15:00:19 +08:00
data() {
2023-02-09 16:37:53 +08:00
return {
2023-08-30 10:03:07 +08:00
loading: true,
2023-07-31 09:00:30 +08:00
content: '',
2023-08-23 16:22:08 +08:00
options: {},
2023-02-09 16:37:53 +08:00
}
},
methods: {
2023-08-30 10:03:07 +08:00
complete() {
this.loading = false
},
2023-07-24 15:00:19 +08:00
back() {
2023-08-23 16:22:08 +08:00
uni.navigateBack({delta: 1})
2023-02-09 16:37:53 +08:00
},
2023-07-24 15:00:19 +08:00
home() {
2023-08-23 16:22:08 +08:00
uni.navigateBack({delta: 1})
},
transferDevice(userId) {
transferDevice(this.options.id, userId).then((res) => {
uni.showToast({
title: '移交成功',
icon: 'none',
})
uni.navigateBack()
})
},
scan() {
uni.scanCode({
success: (res) => {
console.log(res)
let data = JSON.parse(res.result)
if (data.type === 'userId') {
this.transferDevice(data.id)
} else {
uni.showToast({
title: '请扫描正确的二维码',
icon: 'none',
})
}
},
})
2023-07-24 15:00:19 +08:00
},
},
onLoad(options) {
2023-08-23 16:22:08 +08:00
this.options = options
2023-07-31 09:00:30 +08:00
this.content = JSON.stringify({
type: 'transferDevice',
id: options.id,
})
2023-07-24 15:00:19 +08:00
},
2023-02-09 16:37:53 +08:00
}
</script>
2023-07-24 15:00:19 +08:00
<style lang="scss">
2023-02-09 16:37:53 +08:00
.transfer {
padding: 200rpx 34rpx 0;
display: flex;
flex-direction: column;
align-items: center;
.transfer-img {
}
.transfer-text {
font-size: 28rpx;
color: #999999;
margin-top: 30rpx;
}
.transfer-btn {
display: flex;
flex-direction: row;
justify-content: space-between;
margin-top: 100rpx;
width: 100%;
.transfer-btn-item {
flex: 1;
height: 80rpx;
border-radius: 12rpx;
2023-08-03 14:51:36 +08:00
background-color: $uni-theme-color;
2023-02-09 16:37:53 +08:00
font-size: 28rpx;
color: #fff;
display: flex;
justify-content: center;
align-items: center;
}
}
}
2023-07-24 15:00:19 +08:00
</style>