纯h5页面利用HbuilderX打包成App调用手机通讯录

    methods: {
        getInfor(data){
            getAddressBook({
                bookStr:data
            }).then(res => {
                if(res.data.status == 10000){
                    console.log(JSON.stringify(res))
                    this.$store.dispatch("setMailListData",res.data.data);
                    this.$router.push({
                        name:'addressBook'
                    })
                } else {
                    this.$toast(res.data.data)
                }
            })
        },
        getCallLog() {   // 打包生app请求通讯录
            let that = this;
            var content="";
            try{
                plus.contacts.getAddressBook(plus.contacts.ADDRESSBOOK_PHONE, function (addressbook) {
                    addressbook.find(["displayName","phoneNumbers"],function(contacts){
                        that.mailListL = JSON.stringify(contacts)
                        console.log(JSON.stringify(that.mailListL)+'里面的');    // 获取手机号数据
                        console.log("请求接口")
                        that.getInfor(that.mailListL) // 获取成功后调用方法传给后端
                        console.log("请求成功")
                    }, function () {
                        content="error";
                    },{multiple:true});
                },function(e){
                    content="Get address book failed: " + e.message;
                });
            } catch(e){
                content+=e.message;
            }
            console.log(JSON.stringify(that.mailListL)+'外面的');
        }
    },

你可能感兴趣的:(webApp)