判断接口中是否有数据

2020-07-29  本文已影响0人  琳媚儿

判断接口中是否有数据,有数据输入框不可填写,没有数据输入框可填写
:disabled="isUserHaveInfo"

    <input :disabled="isUserHaveInfo" type="text" style="width: 435rpx;font-size: 30rpx;" placeholder="请输入姓名" placeholder-style="color: #CCCCCC;"
                     :maxlength="50" v-model="user_information.name" />

community_id:this.community.id,传参,获取接口中的community_id

data(){
    isUserHaveInfo:false,
    community:{
                id:'',
                name:''
        },
    user_information: {
            id: '',
            name: '', //姓名
            ID_card_type: {}, //证件类型
            ID_card_no: '' //证件号码
    },
}
methods:{
        //用户获取用户信息
            getapiApiPortalCommunityPeopleGetByUseId() {
                this.$api.apiPortal_communityPeople_getByUseId(
                {
                        community_id:this.community.id,
                    
                }, res => {
                    if(res.ret.name==''&&res.ret.ID_card_type==''&&res.ret.ID_card_no==''){
                        this.isUserHaveInfo=false;
                        return;
                    }
                    this.user_information = {
                        id:res.ret.id,
                        name:res.ret.name,
                        ID_card_type:{
                            id:res.ret.ID_card_type,
                            name:res.ret.ID_card_type_str,                      
                        },
                        ID_card_no:res.ret.ID_card_no
                    }
                    this.isUserHaveInfo=true;
                    console.log("社区****======================================",res.ret)
                })
            },
    onLoad(data) {
            this.community.id = data.community_id;
            this.community.name = data.community_name;
        },
}

生命要传的参数

community:{
        id:'',
        name:''
        },

A界面将id,name 传给B 界面,

this.$router.push({
                path: '/community/addPeople/peopleIDCard',
                query:{
                    community_id:this.community.id,
                    community_name:this.community.name
                }
            });

B界面接受上一个界面的页面参数

onLoad(data) {
            this.community.id = data.community_id;
            this.community.name = data.community_name;
        },
上一篇 下一篇

猜你喜欢

热点阅读