// 全局变量使用
import { createStore } from 'vuex'

export default createStore({
  state: {
    // 定义全局变量模块，存储与使用格式如下
    //this.$store.getters.userid
    // this.$store.commit('setPhonenumber',res.data.phonenumber);
    usrid:"",
    username:"",
    gender:false,
    phonenumber:"",
    address:"",
    code:"",
    age:18,

    //医生信息
    doctor:"",
    doctorname:""
  },
  getters: {
    username: state=> state.username,
    userid: state=>state.usrid,
    gender:state=>state.gender,
    phonenumber:state=>state.phonenumber,
    address:state=>state.address,
    code: state=> state.code,
    age:state=> state.age,

    doctorname:state=> state.doctorname,
    doctor: state=>state.doctor
  },
  mutations: {
    setAge:(state,age)=>{
      state.age=age},
    setId:(state,userid)=>{
      state.usrid=userid;},
    setName:(state,username)=>{
      state.username=username;},
    setGender:(state,gender)=>{
      state.gender=gender;},
    setPhonenumber:(state,phone)=>{
      state.phonenumber=phone;},
    setAddress:(state,address)=>{
      state.address=address;},
    setCode:(state,code)=>{
      state.code=code;},
    setDoctorname:(state,dname)=>{
      state.doctorname=dname;},
    setdoctor:(state,doc)=>{
      state.doctor=doc}
  },
  actions: {
  },
  modules: {
  }
})
