import { request } from './request'
export function getDetail(iid) {
return request({
url: '/detail/1muqif6.json',
params:{
iid
}
});
}
// 获取详情页推荐信息
export function getRecommend() {
return request({
url: '/detail/recommend.json?123456',
});
}
// 3、获取商品信息
export class Goods {
constructor(itemInfo,skuInfo,priceInfo,shopInfo,detailInfo){
// constructor(itemInfo,detailInfo,skuInfo,columns,services){
this.title = itemInfo.title//获取标题 当前路径:data.result.itemInfo.title
this.desc = itemInfo.extra.express//全国包邮 当前路径:data.result.itemInfo.extra.express
this.newPrice = skuInfo.skus[0].price//价格 当前路径:data.result.skuInfo.skus[0].price
this.oldPrice = skuInfo.skus[0].nowprice//旧的价格 当前路径:data.result.skuInfo.skus[0].nowprice
this.discount = priceInfo.eventPriceDesc.text //活动价格 当前路径:data.result.priceInfo.eventPriceDesc.text
this.services = detailInfo.detailImage[0].list //图文详情 当前路径:data.result.detailInfo.detailImage[0].list
this.guanZhu = shopInfo.shopLabels[0].text//9065人关注 当前路径:data.result.shopInfo.shopLabels[0].text
this.cSells = shopInfo.shopLabels[1].text//累计销量 当前路径:data.result.shopInfo.shopLabels[1].text
this.laoZihao = shopInfo.shopLabels[2].text//3年老字号 当前路径:data.result.shopInfo.shopLabels[2].text
}
}
// 4、创建店铺信息的对象
export class Shop {
constructor(shopInfo){
this.logo = shopInfo.shopLogo//店铺logo 当前路径:data.result.shopInfo.shopLogo
this.name = shopInfo.name//店铺名称//当前路径:data.result.shopInfo.name
this.fans = shopInfo.cFans//月销售量
this.sells = shopInfo.cSells//累计销售量
this.score = shopInfo.score//描述相符-质量满意 当前路径:data.result.shopInfo.score[0].score
this.goodsCount = shopInfo.cGoods//在架商品 116 当前路径:data.result.shopInfo.cGoods
}
}
// 6、保存参数信息
export class GoodsParams{
constructor(info,rule){
// 注:images可能没有值(某些商品有值,某些没有值)
// this.image = info.image ? info.image[0] : '';
this.infos = info;
this.set = info.set; // 当前路径:data.result.itemParams.info.set
this.Sizes = rule.tables; // 当前路径:data.result.itemParams.rule.tables
}
}
// ES6中使用类
class Person{
constructor(name,age){
this.name = name;
this.age = age;
}
}
const p = new Person('why',18)
console.log(p.name);
supermall - ES6中使用类
最新推荐文章于 2022-03-06 05:16:38 发布