const formatTime = function (value) { var date = new Date(parseInt(value)); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); return `${year}.${String(month).length < 2 ? '0' + month : month}.${String(day).length < 2 ? '0' + day : day}`; } /** * 津贴标签文案 * @param {Object} bountyInfo */ const getBountyPreferentialText = function (bountyInfo) { if(bountyInfo.previewText){ return bountyInfo.previewText }else if(bountyInfo.rule == 0){ return `${bountyInfo.preferential}元无门槛` }else if(bountyInfo.allowDuplicateUse == 0){ return `满${bountyInfo.rule}减${bountyInfo.preferential}` }else{ return `每满${bountyInfo.rule}减${bountyInfo.preferential}` } } /** * 乐乎市集津贴显示数据映射 */ const getBountyData4Show = function (bounty) { let dataMap = {}; //生效状态 dataMap.effective = bounty.effective; //优惠额度 dataMap.facevalue = '¥' + bounty.preferential; dataMap.preferential = bounty.preferential; //使用门槛 let doorsill = '' if(bounty.rule == 0){ doorsill = `无门槛` }else if(bounty.allowDuplicateUse == 0){ doorsill = `满${bounty.rule}` }else{ doorsill = `每满${bounty.rule}` } dataMap.doorsill = doorsill //券的核心内容 dataMap.corecnt = getBountyPreferentialText(bounty) //名称 dataMap.name = bounty.name || bounty.bountyName; dataMap.id = bounty.id || bounty.bountyId; dataMap.description = bounty.description || '可跨仓库、与优惠券叠加使用'; //有效期 dataMap.startTime = formatTime(bounty.startTime); dataMap.endTime = formatTime(bounty.endTime); return dataMap; } const getBountyFaceValue = function (bounty) { return `¥${bounty.preferential}`; } const bountyDateFormat = formatTime; export {getBountyData4Show, getBountyPreferentialText, getBountyFaceValue, bountyDateFormat}