12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- // 获得最大可购买值
- const getMaxBuyNum = (goodsItem = {}) => {
- const {
- buyLimitType = '',
- stock = 0,
- buyLimitCount = 0,
- stockStatus = 'N',
- } = goodsItem;
- // 展示库存 && 限购
- if (stockStatus === 'Y' && buyLimitType === 'GENERAL') {
- return Math.min(stock, buyLimitCount);
- }
- if (buyLimitType === 'GENERAL') {
- return buyLimitCount;
- }
- if (stockStatus === 'Y') {
- return stock;
- }
- return 99;
- };
- // 获得最大可够类型
- const getNumType = (goodsItem = {}) => {
- const {
- buyLimitType = '',
- stock = 0,
- buyLimitCount = 0,
- stockStatus = 'N',
- } = goodsItem;
- // 展示库存 && 限购
- if (stockStatus === 'Y' && buyLimitType === 'GENERAL') {
- return Math.min(stock, buyLimitCount) === buyLimitCount ? 'limit' : 'stock';
- }
- if (buyLimitType === 'GENERAL') {
- return 'limit';
- }
- if (stockStatus === 'Y') {
- return 'stock';
- }
- return 'limit';
- };
- export default {
- getNumType,
- getMaxBuyNum,
- };
|