axios接口调用get传值,2022/6/4am

export async function getStore (storeNo: string) {
  const urlall: any = geturl() // 获取路由
  // console.log(urlall)
  const resulturl = urlall.getStore + storeNo // 获取数据接口
  const resultdata = {
    params: {
      storeNo
    }
  }
  return new Promise((resolve, reject) => {
    axios.get(resulturl, resultdata).then((res) => {
      resolve(res)
    })
  })
}
getStores (storeNo: string) {
        Store.commit('changeLoadingFlag', true)
        getStore(storeNo).then(async (res: any) => {
          // console.log(typeof (res.data.data.total), 'res')
          console.log(res.data.data)
          const tableDatelist = await res.data.data
          // alert(res.data.data.name)
          Store.commit('baibiaochangerowList', tableDatelist)
        })
      // console.log(reault)
      }

    })
无需传参
E:\gongzuo\xmx\element\whiteStoreManage\src\api
export async function getMaxStoreNo () {
  const urlall: any = geturl()
  const resulturl = urlall.getMaxStoreNo
  return new Promise((resolve) => {
    axios.get(resulturl).then((res) => {
      resolve(res)
    })
  })
}

<script lang="ts">
import { defineComponent, toRefs, reactive, computed, ref, onMounted } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import { getMaxStoreNo } from '@/api/Microstores/microstoresapi'
import logoUpLoad from '@/components/Microstores/infomation/upload/logoUpload.vue'
export default defineComponent({
  name: 'microstoresTable',
  components: {
    logoUpLoad
  },
  setup () {
    const Store = useStore()
    const Router = useRouter()
    const data = reactive({
      getMaxStoreNos: (ruleFormData:any) => {
        // 调用get接口
        getMaxStoreNo().then((res: any) => {
          .......做点啥
        })
      },

    })
 return {
      ...toRefs(data),

    }
  }

})
</script>

 

Url传参:
E:\gongzuo\xmx\element\whiteStoreManage\src\api
export async function getStorestylesPics (styleNo: any) {
  const urlall: any = geturl()
  const storeNo = sessionStorage.getItem('baibiaostatus') == 'add' ? sessionStorage.getItem('MaxStoreNos') : sessionStorage.getItem('storeNo')
  const resulturl = urlall.getStoreStyles + storeNo + '/styles/' + styleNo 
  return new Promise((resolve) => {
    axios.get(resulturl).then((res) => {
      resolve(res)
    })
  })
}

<script lang="ts">
import { defineComponent, toRefs, reactive, computed, ref, onMounted } from 'vue'
import { useStore } from 'vuex'
import { useRouter } from 'vue-router'
import { getStorestylesPics } from '@/api/Microstores/microstoresapi'
import logoUpLoad from '@/components/Microstores/infomation/upload/logoUpload.vue'
export default defineComponent({
  name: 'microstoresTable',
  components: {
    logoUpLoad
  },
  setup () {
    const Store = useStore()
    const Router = useRouter()
    const handleClick = async () => {
      await getStorestylesPics(styleNo).then((res: any) => {
        if (res.data.message == 'success') {
          console.log(res.data.data.pics, '获取数据成功')
        }
      })
    }
    const data = reactive({
     

    })
 return {
      ...toRefs(data),handleClick

    }
  }

})
</script>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值