adultDeviceApp/components/drawer/drawer.vue

147 lines
3.2 KiB
Vue

<template>
<view>
<view class="wrapper" v-if="isDrawe">
<view class="bg" @click="clear"></view>
<view class="wrapper_box">
<view class="top" :style="{background:appTheme}">
<image class="headimage mt-10" v-if="userinfo.headimg" :src="userinfo.headimg"></image>
<view class="overflow">{{userinfo.nickname||userinfo.name}}</view>
</view>
<view class="drawerList">
<view v-if="List.length">
<view class="drawerList_item" v-for="(item, index) in List" :key="index" @click="toggle(item)">
<image v-if="item.headimg" :src="item.headimg" class="image1"></image>
<view class="right">
<view class="name">
<view class="overflow">
{{item.name}}
</view>
<view class="dangqian" v-if="item.id == userinfo.familyid">当前</view>
</view>
<view class="info">
<view>{{item.mage}}</view>
<view>{{item.sex==0?'未知':item.sex==1?'男':'女'}}</view>
<view>{{item.type}}</view>
</view>
</view>
</view>
</view>
<view class="add">
<view @click="addInfo('add')">
+
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {};
},
computed: {
...mapState(["user", "familayList", "isDrawe", "appTheme"]),
userinfo() {
return this.user
},
List() {
return this.familayList
},
},
methods: {
// 切换用户
toggle(val) {
let that = this
uni.setStorageSync('familyid', val.familyid)
that.$store.dispatch("getResult", {
birthday: val.birthday,
familyid: val.familyid,
height: val.height,
sex: val.sex,
});
that.$store.dispatch("getUserInfo", {
familyid: val.familyid,
});
that.$store.commit("changeDrawe", false);
},
//添加
addInfo(type) {
uni.navigateTo({
url: "/pageTwo/me/adduser?type=" + type
})
},
clear() {
this.$store.commit("changeDrawe", false);
},
}
}
</script>
<style lang="scss" scoped>
.wrapper {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 999;
}
.bg {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
height: 100vh;
background-color: rgba(0, 0, 0, 0.4);
z-index: 99;
}
.uniDrawer {
width: 220px;
background-color: #fff;
z-index: 1000;
}
@keyframes uniDrawer {
0% {
transform: translateX(-100%);
}
100% {
transform: translateX(0%);
}
}
.list {
position: relative;
top: 0;
left: 0;
flex-direction: column;
flex: 1;
justify-content: flex-end;
margin-bottom: 20rpx;
width: 220px;
height: calc(100vh - 100px);
overflow-y: scroll;
}
.name {
width: 100%;
display: flex;
justify-content: space-between;
.overflow {
width: 60%;
}
}
</style>