541 lines
10 KiB
Vue
541 lines
10 KiB
Vue
<template>
|
||
<view class="page">
|
||
<u-navbar title="设备二维码" :border-bottom="false" :background="bgc" title-color='#2E4975' title-size='36'
|
||
height='36'></u-navbar>
|
||
<view class="cards" v-if='loading'>
|
||
<view class="top">
|
||
<view class="img">
|
||
<image src="https://api.ccttiot.com/smartmeter/img/static/uoQO0pUZ1UHcW5uVKkuR" mode=""></image>
|
||
</view>
|
||
|
||
<view class="info">
|
||
<view class="top" v-if="deviceInfo.remark==null">
|
||
{{ deviceInfo.deviceName }}号
|
||
</view>
|
||
<view class="top" v-if="deviceInfo.remark!=null">
|
||
{{ deviceInfo.remark }}
|
||
</view>
|
||
|
||
<view class="bot">
|
||
电表号:{{ deviceInfo.deviceId }}
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="ewm">
|
||
<canvas id="qrcode" canvas-id="qrcode" style="width: 381.98rpx;height:381.98rpx;" />
|
||
</view>
|
||
<view class="tip">
|
||
租客扫码进行添加设备绑定
|
||
</view>
|
||
</view>
|
||
<u-mask :show="showYjTip" @click="showYjTip = false" :z-index='100' duration='0' />
|
||
<view class="pops" v-if="showYjTip">
|
||
<view class="tit" style="font-weight: 600;">
|
||
温馨提示
|
||
</view>
|
||
<view class="cont_box" style="text-align: center;color: #808080;justify-content: center;font-size: 36rpx;">
|
||
解绑之后,用户将无法查看该电表数据以及充值。
|
||
</view>
|
||
|
||
<view class="btn_box">
|
||
<view class="btn1" @click="showYjTip = false">
|
||
取消
|
||
</view>
|
||
<view class="btn2" @click="offband()" style="background-color:#FF4F4F;">
|
||
确认解绑
|
||
</view>
|
||
</view>
|
||
|
||
</view>
|
||
<view class="cont" v-if="tenantList.length>0&&loading">
|
||
<view class="card" v-for="(item,index) in tenantList" :key="index">
|
||
|
||
<view class="card_cont">
|
||
<view class="text">用户手机号:{{item.user.phonenumber}}</view>
|
||
<view class="text">用户Id:{{item.user.userId}}</view>
|
||
|
||
<view class="txt">
|
||
{{item.createTime}}
|
||
</view>
|
||
</view>
|
||
<view class="card_right" @click="unband(item.user.userId)">
|
||
解绑
|
||
</view>
|
||
</view>
|
||
</view>
|
||
<view class="btn" @click="saveQrcode">
|
||
保存到相册
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
|
||
|
||
import UQRCode from 'uqrcodejs';
|
||
export default {
|
||
data() {
|
||
return {
|
||
|
||
bgc: {
|
||
backgroundColor: "#F7FAFE",
|
||
},
|
||
id: '',
|
||
deviceInfo: {},
|
||
userType:'',
|
||
tenantList:{},
|
||
showYjTip:false,
|
||
tenantId:'',
|
||
loading:false
|
||
|
||
}
|
||
},
|
||
onLoad(e) {
|
||
this.id = e.id
|
||
|
||
this.getuserinfo()
|
||
},
|
||
methods: {
|
||
unband(id){
|
||
this.tenantId=id
|
||
this.showYjTip=true
|
||
},
|
||
offband(){
|
||
this.$u.delete(`/app/device/tenant/unbind/byLandlord/${this.id}/${this.tenantId}`).then((res) => {
|
||
// this.$forceUpdate()
|
||
if (res.code == 200) {
|
||
this.showYjTip=false
|
||
this.getuserList()
|
||
|
||
} else {
|
||
uni.showToast({
|
||
title:res.msg,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
});
|
||
},
|
||
getuserinfo() {
|
||
this.$u.get("/app/user/userInfo").then((res) => {
|
||
// this.$forceUpdate()
|
||
|
||
if (res.code == 200) {
|
||
this.getDevice(this.id)
|
||
uni.setStorageSync('userType', res.data.userType)
|
||
this.userType = res.data.userType
|
||
if (this.userType == '01') {
|
||
this.getuserList()
|
||
} else if (this.userType == '00') {
|
||
|
||
}
|
||
|
||
} else {
|
||
uni.showToast({
|
||
title:res.msg,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
});
|
||
},
|
||
getuserList(){
|
||
this.$u.get(`/app/device/${this.id}/tenantList`).then((res) => {
|
||
// this.$forceUpdate()
|
||
if (res.code == 200) {
|
||
this.tenantList=res.data
|
||
|
||
} else {
|
||
uni.showToast({
|
||
title:res.msg,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
});
|
||
},
|
||
getDevice(id) {
|
||
this.loading=false
|
||
this.$u.get("/app/device/" + id).then((res) => {
|
||
if (res.code == 200) {
|
||
this.deviceInfo = res.data
|
||
this.loading=true
|
||
this.generateQrcode()
|
||
}else{
|
||
uni.showToast({
|
||
title:res.msg,
|
||
icon: 'none',
|
||
duration: 2000
|
||
});
|
||
}
|
||
});
|
||
},
|
||
generateQrcode() {
|
||
|
||
const qr = new UQRCode();
|
||
qr.data = 'https://znb.ccttiot.com/w?sn=' + this.deviceInfo.sn
|
||
qr.size = 200;
|
||
qr.make();
|
||
const ctx = uni.createCanvasContext('qrcode', this); // 组件内调用需传this,vue3 中 this 为 getCurrentInstance()?.proxy
|
||
qr.canvasContext = ctx;
|
||
qr.drawCanvas();
|
||
},
|
||
saveQrcode() {
|
||
uni.canvasToTempFilePath({
|
||
canvasId: 'qrcode',
|
||
success: (res) => {
|
||
uni.saveImageToPhotosAlbum({
|
||
filePath: res.tempFilePath,
|
||
success: () => {
|
||
uni.showToast({
|
||
title: '保存成功',
|
||
icon: 'success'
|
||
})
|
||
},
|
||
fail: (err) => {
|
||
uni.showToast({
|
||
title: '保存失败',
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
},
|
||
fail: (err) => {
|
||
uni.showToast({
|
||
title: '生成二维码失败',
|
||
icon: 'none'
|
||
})
|
||
}
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
|
||
|
||
|
||
<style lang="scss" >
|
||
page{
|
||
background-color: #F7FAFE;
|
||
}
|
||
.page{
|
||
width: 750rpx;
|
||
.pops {
|
||
padding: 46rpx 36rpx;
|
||
position: fixed;
|
||
top: 400rpx;
|
||
left: 74rpx;
|
||
width: 604rpx;
|
||
// height: 606rpx;
|
||
background: #fff;
|
||
border-radius: 20rpx 20rpx 20rpx 20rpx;
|
||
z-index: 110;
|
||
|
||
.close {
|
||
position: absolute;
|
||
left: 266rpx;
|
||
bottom: -100rpx;
|
||
|
||
image {
|
||
width: 80rpx;
|
||
height: 80rpx;
|
||
}
|
||
}
|
||
|
||
.btn_box {
|
||
margin-top: 80rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
|
||
.btn1 {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 216rpx;
|
||
height: 90rpx;
|
||
background: #989898;
|
||
border-radius: 54rpx 54rpx 54rpx 54rpx;
|
||
|
||
font-weight: 500;
|
||
font-size: 40rpx;
|
||
color: #FFFFFF;
|
||
}
|
||
|
||
.btn2 {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 268rpx;
|
||
height: 90rpx;
|
||
background: #4C97E7;
|
||
border-radius: 54rpx 54rpx 54rpx 54rpx;
|
||
|
||
font-weight: 500;
|
||
font-size: 40rpx;
|
||
color: #FFFFFF;
|
||
}
|
||
}
|
||
|
||
.time {
|
||
margin-top: 20rpx;
|
||
text-align: center;
|
||
font-weight: 500;
|
||
font-size: 48rpx;
|
||
color: #4C97E7;
|
||
}
|
||
|
||
.cont {
|
||
height: 500rpx;
|
||
overflow-x: hidden;
|
||
overflow-y: auto;
|
||
}
|
||
|
||
.tit {
|
||
// width: 604rpx;
|
||
text-align: center;
|
||
font-weight: 500;
|
||
font-size: 36rpx;
|
||
color: #3D3D3D;
|
||
margin-bottom: 54rpx;
|
||
}
|
||
|
||
.cont_box {
|
||
margin-top: 36rpx;
|
||
display: flex;
|
||
flex-wrap: nowrap;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
|
||
.left {
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
font-weight: 600;
|
||
font-size: 36rpx;
|
||
color: #3D3D3D;
|
||
|
||
.km {
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #3D3D3D;
|
||
}
|
||
|
||
.speed {
|
||
margin-top: 18rpx;
|
||
width: 226rpx;
|
||
height: 22rpx;
|
||
background: #ccc;
|
||
border-radius: 16rpx 16rpx 16rpx 16rpx;
|
||
|
||
.speeds {
|
||
// width: 90%;
|
||
height: 100%;
|
||
background: #77B8FD;
|
||
border-radius: 16rpx 16rpx 16rpx 16rpx;
|
||
}
|
||
}
|
||
|
||
.NO {
|
||
font-weight: 400;
|
||
font-size: 24rpx;
|
||
color: #3D3D3D;
|
||
}
|
||
}
|
||
|
||
.right {
|
||
font-weight: 600;
|
||
font-size: 36rpx;
|
||
color: #3D3D3D;
|
||
|
||
image {
|
||
width: 244rpx;
|
||
height: 196rpx;
|
||
}
|
||
}
|
||
}
|
||
|
||
.text {
|
||
margin-top: 36rpx;
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
// align-items: center;
|
||
|
||
.yuan {
|
||
margin-top: 10rpx;
|
||
margin-right: 12rpx;
|
||
width: 20rpx;
|
||
height: 20rpx;
|
||
background: #000;
|
||
border-radius: 50%;
|
||
}
|
||
|
||
span {
|
||
width: 90%;
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #3D3D3D;
|
||
}
|
||
}
|
||
|
||
.btn {
|
||
margin-left: 40rpx;
|
||
margin-top: 50rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 470rpx;
|
||
height: 90rpx;
|
||
background: #4C97E7;
|
||
border-radius: 54rpx 54rpx 54rpx 54rpx;
|
||
font-weight: 500;
|
||
font-size: 40rpx;
|
||
color: #FFFFFF;
|
||
}
|
||
|
||
.act1{
|
||
background-color: #ccc;
|
||
}
|
||
}
|
||
|
||
|
||
.cont{
|
||
padding-bottom: 200rpx;
|
||
width: 672rpx;
|
||
margin: 16rpx auto 0;
|
||
display: flex;
|
||
// justify-content: center;
|
||
flex-wrap: wrap;
|
||
|
||
.card{
|
||
padding-top: 20rpx;
|
||
padding-left: 44rpx ;
|
||
padding-right: 38rpx;
|
||
display: flex;
|
||
flex-wrap: nowrap;
|
||
justify-content: space-between;
|
||
align-items: center;
|
||
margin-top: 16rpx;
|
||
width: 672rpx;
|
||
// height: 180rpx;
|
||
background: #FFFFFF;
|
||
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42,130,228,0.1);
|
||
border-radius: 30rpx;
|
||
.left{
|
||
width: 58rpx;
|
||
height: 58rpx;
|
||
image{
|
||
width: 58rpx;
|
||
height: 58rpx;
|
||
}
|
||
}
|
||
.card_cont{
|
||
width: 310rpx;
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
.text{
|
||
width: 310rpx;
|
||
font-weight: 400;
|
||
font-size: 24rpx;
|
||
color: #262B37;
|
||
}
|
||
.txt{
|
||
width: 310rpx;
|
||
font-weight: 400;
|
||
font-size: 24rpx;
|
||
color: #95989D;
|
||
line-height: 64rpx;
|
||
}
|
||
}
|
||
.card_right{
|
||
padding: 10rpx 30rpx;
|
||
border-radius: 20rpx;
|
||
background:#FF4F4F ;
|
||
font-weight: 400;
|
||
font-size: 28rpx;
|
||
color: #fff;
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
.cards{
|
||
display: flex;
|
||
flex-wrap: wrap;
|
||
justify-content: center;
|
||
align-items: baseline;
|
||
padding-top: 73rpx;
|
||
width: 586rpx;
|
||
height: 823rpx;
|
||
background: #FFFFFF;
|
||
border-radius: 30rpx;
|
||
box-shadow: 0rpx 14rpx 35rpx 0rpx rgba(42,130,228,0.1);
|
||
margin: 85rpx auto 0;
|
||
.top{
|
||
|
||
display: flex;
|
||
flex-wrap: nowrap;
|
||
align-items: center;
|
||
.img{
|
||
width: 36rpx;
|
||
height: 96rpx;
|
||
image{
|
||
width: 36rpx;
|
||
height: 96rpx;
|
||
}
|
||
}
|
||
|
||
.info{
|
||
margin-left: 26rpx;
|
||
.top{
|
||
font-size: 38rpx;
|
||
font-family: Source Han Sans, Source Han Sans;
|
||
font-weight: 400;
|
||
color: #383838;
|
||
}
|
||
.bot{
|
||
margin-top: 5rpx;
|
||
font-size: 28rpx;
|
||
font-family: Source Han Sans, Source Han Sans;
|
||
font-weight: 400;
|
||
color: #383838;
|
||
}
|
||
}
|
||
}
|
||
.ewm{
|
||
margin-top: 73rpx;
|
||
width: 381.98rpx;
|
||
height: 381.98rpx;
|
||
image{
|
||
width: 381.98rpx;
|
||
height: 381.98rpx;
|
||
}
|
||
}
|
||
.tip{
|
||
font-size: 28rpx;
|
||
font-family: Source Han Sans, Source Han Sans;
|
||
font-weight: 400;
|
||
color: #808080;
|
||
}
|
||
}
|
||
.btn{
|
||
position: fixed;
|
||
bottom: 100rpx;
|
||
left: 180rpx;
|
||
margin: 118rpx auto 0;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
width: 396rpx;
|
||
height: 80rpx;
|
||
background: #8883F0;
|
||
border-radius: 40rpx;
|
||
|
||
font-size: 28rpx;
|
||
font-family: Source Han Sans, Source Han Sans;
|
||
font-weight: 400;
|
||
color: #FFFFFF;
|
||
}
|
||
}
|
||
</style>
|