examTeamApp/pages/business/business.vue

148 lines
2.7 KiB
Vue
Raw Normal View History

2024-05-29 16:35:45 +08:00
<template>
2024-07-08 10:50:07 +08:00
<view class="content">
<view class="add" @click="handleAddDevice()">添加设备</view>
<view class="list" v-if="list.length">
<view class="item" v-for="(item,index) in list" @click="handleunbind(item,index)">
<view class="left">
<image :src="item.pic"></image>
<view class="name">
<text>{{item.name}}</text>
<text>{{item.bind_time}}</text>
</view>
</view>
<view class="bing">解绑</view>
</view>
</view>
2024-05-29 16:35:45 +08:00
</view>
</template>
<script>
2024-07-08 10:50:07 +08:00
import {
mapState
} from "vuex";
2024-05-29 16:35:45 +08:00
export default {
data() {
return {
2024-07-08 10:50:07 +08:00
// list: []
2024-05-29 16:35:45 +08:00
}
},
2024-07-08 10:50:07 +08:00
computed: {
...mapState(["user", "userDeviceList"]),
list() {
return this.userDeviceList
}
},
onLoad() {
let that = this
that.$store.dispatch('getUserDeviceList')
},
watch: {
userDeviceList() {
let that = this
console.log("userDeviceList变了", that.userDeviceList)
},
},
2024-05-29 16:35:45 +08:00
methods: {
2024-07-08 10:50:07 +08:00
handleunbind(item, index) {
let that = this
uni.showModal({
title: '友情提示',
content: '是否解绑该设备?',
success: function(res) {
if (res.confirm) {
that.$model.getUnbinding({
id: item.id
}).then(res => {
if (res.code != 0) {
that.$tools.msg(res.msg)
return
}
that.$tools.msg("操作成功")
that.list.splice(index, 1)
})
} else if (res.cancel) {
that.$tools.msg("您已取消操作!");
}
},
})
},
handleAddDevice() {
uni.navigateTo({
url: "/pages/business/addDevice"
})
},
2024-05-29 16:35:45 +08:00
}
}
</script>
2024-07-08 10:50:07 +08:00
<style lang="scss" scoped>
.content {
font-size: 14px;
padding: 15px;
background-color: #F5F6FA;
min-height: calc(100vh - 30px);
}
.add {
width: 100%;
height: 35px;
line-height: 35px;
font-size: 14px;
margin-bottom: 15px;
color: #fff;
border-radius: 15px;
display: flex;
justify-content: center;
background: $btncolor;
}
.list {
width: 100%;
2024-05-29 16:35:45 +08:00
2024-07-08 10:50:07 +08:00
.item {
width: calc(100% - 20px);
padding: 5px 10px;
display: flex;
align-items: center;
justify-content: space-between;
border-radius: 10px;
background-color: #fff;
margin-bottom: 10px;
2024-05-29 16:35:45 +08:00
2024-07-08 10:50:07 +08:00
.left {
width: 80%;
display: flex;
align-items: center;
image {
2024-07-22 14:13:19 +08:00
width: 50px;
height: 50px;
margin-right: 10px;
2024-07-08 10:50:07 +08:00
}
.name {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
text-align: center;
text {
width: 100%;
display: block;
text-align: left;
margin-top: 10px;
}
}
}
.bing {
width: auto;
float: right;
background-color: #dfdfdf;
border-radius: 10px;
padding: 5px 10px;
}
}
}
</style>