<!--
* @Descripttion:
* @Author: ''
* @Date: 2021-03-05 15:30:48
* @LastEditors: ''
* @LastEditTime: 2021-04-04 15:04:32
-->
<template>
<div class="home app_content">
<ProductInfo :productData="BasicDdata" ></ProductInfo>
<SupplierInfo :SupplyData="PublicSupply"></SupplierInfo>
<Examineinfo :CheckData="CheckInfo"></Examineinfo>
</div>
</template>
<script>
import ProductInfo from '@/components/Productinfo.vue'
import SupplierInfo from '@/components/Supplierinfo.vue'
import Examineinfo from '@/components/Examineinfo.vue'
import {onMounted, reactive, toRefs} from 'vue'
import { RequirebasicInfo,RequireSupplierInfo,RequireQuick} from '@/request/Datamethod.js'
import { InterceptURL} from '@/util/util.js'
import { useStore } from 'vuex'
export default {
name: 'Home',
components: {
ProductInfo,
SupplierInfo,
Examineinfo
},
setup(){
const store = useStore()
const data = reactive({
BasicDdata:{},
PublicSupply:{},
CheckInfo:{},
proddate:"",
publicdata:{},
})
const methodsMap = {
getBasicInfo:async (val)=>{
const res = await RequirebasicInfo(val);
if(res.code==200){
var resdata= res.data;
var leftunit="";
if(resdata.shelfLifeUnit==1){
leftunit="年"
}
if(resdata.shelfLifeUnit==2){
leftunit="月"
}
if(resdata.shelfLifeUnit==3){
leftunit="日"
}
var basicdata={
basicimage:resdata.pictureUrl,
basicname:resdata.salesSubItemName,
basicamount:resdata.netAmount+resdata.netAmountUnit,
basicunit:resdata.itemUnit,
basicLevel:resdata.specificationLevel,
basicdate:data.proddate,
basicshelflife:resdata.shelfLife+leftunit
};
data.BasicDdata=basicdata;
return Promise.resolve(resdata)
}
// console.log(res)
},
getSupplierInfo:async (val)=>{
const res = await RequireSupplierInfo(val);
if(res.code==200){
var resultdata= res.data;
var Supplydata={
supplyaddress:resultdata.address,
supplyname:resultdata.name,
LicenseNo:resultdata.licenseNo,
};
data.PublicSupply=Supplydata;
return Promise.resolve(resultdata)
}
},
onLoad:()=>{
},
}
async function getExamresult(result,date){
const resdata = await RequireQuick(result,date);
data.CheckInfo=resdata.data;
}
//开始的开始
onMounted(() => {
InterceptURL(window.location.href).then(function(res){
data.proddate= res.productionDate;
Promise.all([
methodsMap.getBasicInfo(res.salesSubItemCode),
methodsMap.getSupplierInfo(res.supplierId),
]).then((result)=>{
getExamresult(result,res.productionDate)
})
})
})
return {
...toRefs(data),
...methodsMap
}
}
}
</script>
<style lang="less" scoped>
</style>
``
网友评论