2 lines
3.7 KiB
JavaScript
2 lines
3.7 KiB
JavaScript
"use strict";const t=require("../../common/vendor.js"),s=require("../url/index.js"),e=require("../util/index.js");function u(t,s,e){if(e=e||0,"exact"===s)return t+e;if(e<10)return`${t}≤10`;const u=e.toString();return`${t}${u[0]}${"0".repeat(u.length-1)}+`}const r=[".avi",".mp4"];function n(t){return(t/100).toFixed(2)}exports.convertProductPropertyList=function(t){const s=[];for(const e of t)if(e.properties)for(const t of e.properties){let e=s.find((s=>s.id===t.propertyId));e||(e={id:t.propertyId,name:t.propertyName,values:[]},s.push(e));e.values.find((s=>s.id===t.valueId))||e.values.push({id:t.valueId,name:t.valueName})}return s},exports.fen2yuan=n,exports.formatAfterSaleStatus=function(t){return 10===t.status?"申请售后":20===t.status?"商品待退货":30===t.status?"商家待收货":40===t.status?"等待退款":50===t.status?"退款成功":61===t.status?"买家取消":62===t.status?"商家拒绝":63===t.status?"商家拒收货":"未知状态"},exports.formatAfterSaleStatusDescription=function(t){return 10===t.status?"退款申请待商家处理":20===t.status?"请退货并填写物流信息":30===t.status?"退货退款申请待商家处理":40===t.status?"等待退款":50===t.status?"退款成功":61===t.status?"退款关闭":62===t.status?`商家不同意退款申请,拒绝原因:${t.auditReason}`:63===t.status?`商家拒绝收货,不同意退款,拒绝原因:${t.auditReason}`:"未知状态"},exports.formatGoodsSwiper=function(t){return(null==t?void 0:t.filter((t=>t)).map(((t,e)=>({type:r.some((s=>t.includes(s)))?"video":"image",src:s.$url.cdn(t)}))))||[]},exports.formatOrderColor=function(t){return 0===t.status?"info-color":10===t.status||20===t.status||30===t.status&&!t.commentStatus?"warning-color":30===t.status&&t.commentStatus?"success-color":"danger-color"},exports.formatOrderStatus=function(t){return 0===t.status?"待付款":10===t.status&&1===t.deliveryType?"待发货":10===t.status&&2===t.deliveryType?"待核销":20===t.status?"待收货":30!==t.status||t.commentStatus?30===t.status&&t.commentStatus?"已完成":"已关闭":"待评价"},exports.formatOrderStatusDescription=function(t){return 0===t.status?`请在 ${e.formatDate(t.payExpireTime)} 前完成支付`:10===t.status?"商家未发货,请耐心等待":20===t.status?"商家已发货,请耐心等待":30!==t.status||t.commentStatus?30===t.status&&t.commentStatus?"交易完成,感谢您的支持":"交易关闭":"已收货,快去评价一下吧"},exports.formatRewardActivityRule=function(t,s){return 10===t.conditionType?`满 ${n(s.limit)} 元减 ${n(s.discountPrice)} 元`:20===t.conditionType?`满 ${s.limit} 件减 ${n(s.discountPrice)} 元`:""},exports.formatSales=function(t,s){return u("exact"!==t&&s<10?"销量":"已售",t,s)},exports.formatStock=function(t,s){return u("库存",t,s)},exports.handleAfterSaleButtons=function(t){t.buttons=[],[10,20,30].includes(t.status)&&t.buttons.push("cancel"),20===t.status&&t.buttons.push("delivery")},exports.handleOrderButtons=function(t){t.buttons=[],3===t.type&&t.buttons.push("combination"),20===t.status&&t.buttons.push("confirm"),t.logisticsId>0&&t.buttons.push("express"),0===t.status&&(t.buttons.push("cancel"),t.buttons.push("pay")),30!==t.status||t.commentStatus||t.buttons.push("comment"),40===t.status&&t.buttons.push("delete")},exports.useDurationTime=function(s,e=""){s=function(s){if((s=s.toString()).indexOf("-")>0)return t.dayjs(s);if(s.length>10)return t.dayjs(parseInt(s));if(10===s.length)return t.dayjs.unix(parseInt(s))}(s),""===e&&(e=t.dayjs());const u=t.ref(s-e);u.value>0&&setTimeout((()=>{u.value>0&&(u.value-=1e3)}),1e3);const r=t.dayjs.duration(u.value);return{h:(30*r.months()*24+24*r.days()+r.hours()).toString().padStart(2,"0"),m:r.minutes().toString().padStart(2,"0"),s:r.seconds().toString().padStart(2,"0"),ms:r.$ms}};
|