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>