首页 新闻 搜索 专区 学院

asyncData中如何将this.$route.params中的id作为参数传入到请求中.

0
悬赏园豆:80 [待解决问题]
<template>
<section>
<div class="details_info pos_r">
<div class="details_info_main pos_r h100">
<p class="info_name" v-model="customName">{{customName}}</p>
<p class="goods_price pos_r">
<span class="price_minus"></span>
<span class="min_price" v-model="priceMin">{{priceMin}}</span>
<span class="link_minus">-</span>
<span class="max_price" v-model="p_max">{{p_max}}</span>
</p>
<p class="goods_sales flex flex-pack-justify">
<span>
<b>快递:</b>
<b v-model="made_kp" v-if="made_kp === '0'">免运费</b>
<b v-model="made_kp" v-else>{{made_kp}}</b>
</span>
<span v-model="shop_address">{{shop_address}}</span>
</p>
<div class="info_btn pos_r clearfix">
<div class="info_btn_l h100 fl">
<a href="javascript:;" class="dialogue fl" @click="chatClick()">
<i class="fa fa-comments-o d-b text-c"></i>
<span class="d-b text-c">客服</span>
</a>
<a href="javascript:;" class="collect fr" @click="chatClick()">
<i class="fa fa-star-o d-b text-c"></i>
<span class="d-b text-c">收藏</span>
</a>
</div>
<div class="info_btn_r h100 fr">
<a href="javascript:;" class="customBtn d-b h100 text-c" @click="chatClick()">立即订制</a>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import '../static/css/public.css'
import '../static/css/customDInfo.css'
import globalconfig from '../plugins/globalconfig/globalconfig'
import axios from 'axios'

export default {
data () {
return {
customName: '',
priceMin: '',
p_max: '',
made_kp: '',
shop_address: ''
}
},
head () {
return {
title: this.customName,
meta: [
{hid: 'source', name: this.customName, content: this.customName},
{hid: 'source1', name: '诚订1', content: this.customName}
]
}
},
async asyncData ({params}) { // 运行状态监测
// 获取订制商品价格等信息
let goodsTopUrl = globalconfig.getUrl('customInfo')
console.log({params})
let customGoods = axios.post(goodsTopUrl, {
made_id: 580
}).then(function (res) {
console.log(res)
let madeName = res.data.data.made_name
let pMin = res.data.data.made_pmin
let pMax = res.data.data.made_pmax
let madeKp = res.data.data.made_kp
let shopAddress = res.data.data.shop_address
return {
customName: madeName,
priceMin: pMin,
p_max: pMax,
made_kp: madeKp,
shop_address: shopAddress
}
})
return customGoods
},
mounted: function () {
let b = this.$route.params
console.log(b)
},
methods: {
// 点击跳转下载APP页面
chatClick: function () {
this.$router.push({path: '/downLoad/'})
}
}
}
</script>

<style scoped>

</style>
Web邵艳峰的主页 Web邵艳峰 | 初学一级 | 园豆:2
提问于:2017-12-25 15:56
< >
分享
所有回答(1)
0

建议给代码加上高亮

dudu | 园豆:37728 (高人七级) | 2017-12-25 17:12
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册