supermall - ES6中使用类

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);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

@阿猫阿狗~

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值