Commit b1abaa7c by 匡雅琴

接口调取

1 parent 392671b7
......@@ -6,7 +6,7 @@
<!-- 采购选项下拉 -->
<div class="purchase-plugin">
<div class="purchase" @click.stop="switchPurchase">
{{ purchase }}
{{ purchase.labelName }}
<img class="arrow-down" src="@/assets/images/arrow-down.png" alt="" />
</div>
<SelectBox :isShow="isShow" @clickOutside="clickOutside" isObject :dataList="purchaseList" :boxWidth="'28.61vw'" @selectVal="selectPurchase" :labelName="'labelName'"></SelectBox>
......@@ -51,7 +51,7 @@ export default {
}],
rankingList: {},
// 采购额排名当前选中值
purchase: '',
purchase: {},
// 采购额排名门店数据
merchantsList: [],
merchantsDataObj: [
......@@ -67,7 +67,7 @@ export default {
},
mounted() {
this.purchase = this.purchaseList[0].labelName
this.purchase = this.purchaseList[0]
},
methods: {
......@@ -95,7 +95,7 @@ export default {
// 排名下拉选中
selectPurchase(item) {
console.log(item)
this.purchase = item.labelName
this.purchase = item
const purchaseIndex = this.purchaseList.findIndex(itm => itm.value === item.value)
// 只获取排名前五的数据
this.merchantsList = this.rankingList[this.purchaseList[purchaseIndex].value].slice(0, 5)
......@@ -105,7 +105,7 @@ export default {
// 跳转太阳膜详情页
goDetailPage(item) {
console.log(item)
this.$router.push({ path: `solarDetail?merchantid=${item.merchantid}&merchantname=${item.merchantname}` })
this.$router.push({ path: `solarDetail?merchantid=${item.merchantid}&merchantname=${item.merchantname}&purchaseType=${this.purchase.value}` })
},
// 点击外部控制排名下拉隐藏
clickOutside() {
......
......@@ -2,7 +2,7 @@
<div class="layout">
<view-container>
<template #title>
<DetailTitle :dataList="merchantList" :dataListObj="merchantListObj" :tabName="tabName"></DetailTitle>
<DetailTitle :dataList="merchantList" :dataListObj="merchantListObj" :tabObject="tabObject"></DetailTitle>
</template>
<template #content>
<div class="solar-detail-content">
......@@ -98,7 +98,7 @@ export default {
labelName: 'merchantname',
valueName: 'merchantid'
},
tabName: '',
tabObject: {},
dataList: [],
solarDetailList: [
{
......@@ -185,14 +185,28 @@ export default {
created() {},
methods: {
...mapActions(['setSolarYear']),
init() {
async init() {
console.log(this.$route.query, '999')
this.merchantList = this.$store.state.app.merchantRankingList
console.log(this.merchantList, 'this.merchantList')
this.businessTime = this.$store.state.app.solarTime
this.businessYear = this.$store.state.app.solarYear
const { merchantid, merchantname } = this.$route.query
this.tabName = merchantname
const { merchantid, purchaseType } = this.$route.query
let _merchantList = this.$store.state.app.merchantRankingList
// 页面刷新导致门店数据置空,重新请求数据
// if (!_merchantList.length) {
// this.api.solar.getAllRanking({ year: 2023 }).then(res => {
// console.log(res, '000')
// if (!res.code === '0') {
// this.openMessage('获取商品采购额排名失败')
// return
// }
// const _data = res.data.dataList[0]
// _merchantList = _data[purchaseType]
// })
// }
if (!_merchantList.length) _merchantList = await this.getAllRanking(purchaseType)
this.merchantList = _merchantList
console.log(this.merchantList, 'this.merchantList')
this.tabObject = this.$route.query
this.getMerchantGoodsRatio(this.businessYear, merchantid)
this.getMerchantPurchase(this.businessYear, merchantid)
this.getMerchantPurchaseTrend(this.businessYear, merchantid)
......@@ -247,6 +261,21 @@ export default {
// 切换年份
yearValue(val) {
this.setSolarYear(val)
},
getAllRanking(purchaseType) {
return new Promise(resolve => {
let _merchantList
this.api.solar.getAllRanking({ year: 2023 }).then(res => {
console.log(res, '000')
if (!res.code === '0') {
this.openMessage('获取商品采购额排名失败')
return
}
const _data = res.data.dataList[0]
_merchantList = _data[purchaseType]
resolve(_merchantList)
})
})
}
}
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!