<template>
    <h3>居民血压管理系统</h3>
    <div id="result">{{result}}</div>
    居民姓名：<input type="text" id="userName" v-model="userName">
    sbp:<input type="text" id="sbp" v-model="sbp">
    dbp:<input type="text" id="dbp" v-model="dbp">
    <input type="button" id="getResult" @click="getResult" value="getResult">
</template>

<script>
    export default {
        name: "Hypertension_1",
        data(){
            return{
                proxy:"/examServer",
                url:"/public_api/v1/api_for_vue_exam_hypertension_1",
                userName:"",
                sbp:0,
                dbp:0,
                result:"",
            }
        },
        methods:{
            getResult(){

                const formData = new FormData();

                formData.append("userName", this.userName);
                formData.append("sbp", this.sbp);
                formData.append("dbp", this.dbp);

                let url = this.proxy+this.url;
                let that = this;

                this.axios.post(
                    url,
                    formData,
                    {
                        headers: {
                            'Content-Type': 'multipart/form-data'
                        }
                    }

                ).then(
                    function (response) {
                        that.result= response.data;
                    },
                    function (error) {
                        console.log("有可能是防火墙没有开");
                        console.log(error.data);
                    }
                )

            },
        },
        mounted() {
            window.myVue=this;
        }
    }
</script>

<style scoped>

</style>