import * as React from 'react' import 'intersection-observer' import log from '../utils/lofter-log' import { getCouponData4Show, getPreferentialText } from '../utils/couponFormat' import {getParmvalByKey, imgResize} from '../utils/imgResize' import LazyLoad from 'react-lazy-load' import * as Styled from './index.style' import {genSpmLink} from "../utils/statistics"; import { trackingClickEvent } from '../lofterProduct' export interface ProductItemType { // 商品部分字段 shopUrl: string, bounties: Object[], iconText: string image: string name: string onSaleTime: string preSaleType: number priceType: number productId: string productType: number restStock: number saledStock: string status: number storePrice: number supplierId: string, marketPrice:number, tags?: string, shop?:string, coupon?:Object[], activity:any, desc?:string } export default class LofterProductLarge extends React.Component<{product:ProductItemType}> { private async toProductDetail(id:string,specialArea:string,event:React.MouseEvent) { event.stopPropagation(); await trackingClickEvent(id) if(specialArea && this.props.product.shopUrl){ location.href = this.props.product.shopUrl return ; } const spmLink = genSpmLink({url: `https://www.lofter.com/market/fe/html/product.html?productId=${id}&njb_navigator=false`, name: 'spmCmspageProduct'}) location.href = spmLink; } public render() { let product = this.props.product return { product.iconText &&
{product.iconText.split(',').map((iconText:string, index) => { return {iconText} })}
}
{product.name}
{product.desc} { !product.desc && product.shop && product.shopUrl && <>
{/*
*/} {product.shop || '进店选购'} 进店
}
{ ( !!product.coupon || !!product.bounties && product.bounties.length > 0 ) &&
{ !!product.coupon &&
{getPreferentialText(product.coupon)}
} { !!product.bounties && product.bounties.length > 0 &&
津贴
}
} { !!product.activity && [1,2].includes(product.activity.type) &&
{product.activity.type == 1 ? '秒杀' : '限时购'}
}
{ product.priceType == 0 ? {product.storePrice} : ¥{product.storePrice} { (product.storePrice||0)<(product.marketPrice||0) && ¥{product.marketPrice} } }
立即抢购
{/* */} } }