examTeamApp/pageTwo/business/business.vue

154 lines
2.9 KiB
Vue

<template>
<view class="content">
<view class="add" @click="handleAddDevice()">{{$t("common.titleBusinesAdd")}}</view>
<view class="list">
<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">{{$t("common.btnUnbind")}}</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
// list: []
}
},
computed: {
...mapState(["user", "userDeviceList"]),
list() {
return this.userDeviceList
}
},
onLoad() {
let that = this
that.$store.dispatch('getUserDeviceList')
},
onPullDownRefresh() {
let that = this
that.$store.dispatch('getUserDeviceList')
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1000);
},
methods: {
handleunbind(item, index) {
let that = this
uni.showModal({
title: that.$t('tips.msgTitle'),
content: that.$t('tips.verifyUnbindt'),
cancelText: that.$t('tips.btnSancellation'),
confirmText: that.$t('tips.btnConfirm'),
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.$t("tips.msgUnBind"))
that.list.splice(index, 1)
that.$store.dispatch('getUserInfo', {
aud_id: uni.getStorageSync('userid')
})
})
} else if (res.cancel) {
that.$tools.msg(that.$t("tips.msgCancel"));
}
},
})
},
handleAddDevice() {
uni.navigateTo({
url: "/pageTwo/business/addDevice"
})
},
}
}
</script>
<style lang="scss" scoped>
.content {
font-size: 32rpx;
padding: 15px;
background-color: #F5F6FA;
min-height: calc(100vh - 30px);
}
.add {
width: 100%;
height: 35px;
line-height: 35px;
font-size: 32rpx;
margin-bottom: 15px;
color: #fff;
border-radius: 15px;
display: flex;
justify-content: center;
background: $btncolor;
}
.list {
width: 100%;
.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;
.left {
width: 80%;
display: flex;
align-items: center;
image {
width: 50px;
height: 50px;
margin-right: 10px;
}
.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>