<template>
    <view>
        <block>
            <view style="height: 10px;" />
            <user :list="[detail]" />
        </block>

        <displayCell :showList="showList" :detail="detail" />

        <view style="height: 70px;" />
        <view class="footer">
            <navigator class="insert" v-if="detail.iswechatbind == 0"
                :url="'/team/userCenter/wechatbind?id=' + detail.sys_enterprise_hrid + '&name=' + detail.name">
                绑定微信
            </navigator>
            <view class="invite" style="flex: 1;" @click="toEdit" hover-class="navigator-hover">
                编辑
            </view>
        </view>
    </view>
</template>

<script>
import user from "../../components/userList.vue"
export default {
    components: { user },
    data() {
        return {
            sys_enterprise_hrid: 0,
            detail: {
                userid: 0
            },
            showList: []
        }
    },
    onLoad(options) {
        console.log("options", options)
        this.sys_enterprise_hrid = options.id;
        uni.setNavigationBarTitle({
            title: '人员信息'
        });
        this.getDetail()
    },
    onUnload() {
        delete this.$Http.uploadUserDetail;
    },
    methods: {
        getDetail() {
            this.$Http.basic({
                "id": "20240411085402",
                "content": {
                    "sys_enterprise_hrid": this.sys_enterprise_hrid
                }
            }).then(res => {
                console.log("门店人员信息", res)
                if (this.cutoff(res.msg)) return;
                this.detail = res.data;
                this.showList = [{
                    label: "姓名",
                    key: "name"
                }, {
                    label: "手机号",
                    key: "phonenumber"
                }, {
                    label: "性别",
                    key: "sex"
                }, {
                    label: "生日",
                    key: "birthday"
                }, {
                    label: "邮箱",
                    key: "email"
                }, {
                    label: "店内职位",
                    key: "position"
                }, {
                    label: "角色",
                    key: "rolenames"
                }, {
                    label: "人员类型",
                    value: res.isleader ? '主账号' : '子账号'
                }, {
                    label: "所属门店",
                    key: "storenames"
                }]
            })
        },
        toEdit() {
            this.$Http.uploadUserDetail = this.getDetail.bind(this);
            uni.navigateTo({
                url: '/team/userCenter/insert?title=编辑人员&data=' + JSON.stringify(this.detail)
            });
        }
    },
}
</script>

<style lang="scss" scoped>
.footer {
    position: fixed;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    width: 100vw;
    height: 65px;
    background: #FFFFFF;
    box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
    padding: 5px 10px;
    box-sizing: border-box;

    .insert {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 168px;
        height: 45px;
        background: #FFFFFF;
        border-radius: 5px;
        border: 1px solid #999999;
        font-family: PingFang SC, PingFang SC;
        font-size: 16px;
        color: #666666;
        box-sizing: border-box;
        margin-right: 10px;
    }

    .invite {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 177px;
        height: 45px;
        background: #C30D23;
        border-radius: 5px;
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 16px;
        color: #FFFFFF;
    }
}
</style>