Files
ruo-shan-cloud-pharmacy/miniprogram/package-live/volc-mini-sdk/utils/product-card-utils.js
T
陈誉午 994b267f5c feat: 电子药箱小程序 - 4Tab药品管理
- 电子药箱: 药品库存管理 + 手动录入 + 今日用药打卡
- 药品百科: 搜索 + 分类筛选 + 20种药品静态数据
- 惠教中心: 4条药品使用指南课程
- 我的: 家庭成员信息管理
- 自定义TabBar + navigation-bar组件
- SVG药品分类插图
2026-07-29 11:20:52 +08:00

1 line
4.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.withProductReminderText=exports.splitSellingPointTags=exports.reportProductMessage=exports.checkCardConfigChange=exports.buildProductReminderText=void 0;var _constant=require("./constant");function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"===_typeof(t)?t:String(t)}function _toPrimitive(e,t){if("object"!==_typeof(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}var checkCardConfigChange=function(e){var t,r,n,o,i=e.oldLiveInfo,l=e.newLiveInfo,u=(null==i||null===(t=i.Menus)||void 0===t?void 0:t.Menus)||[],c=(null==i||null===(r=i.Menus)||void 0===r?void 0:r.ProductV2)||{},d=(null==l||null===(n=l.Menus)||void 0===n?void 0:n.Menus)||[],a=(null==l||null===(o=l.Menus)||void 0===o?void 0:o.ProductV2)||{};return{menusChanged:JSON.stringify(u)!==JSON.stringify(d),productChanged:JSON.stringify(c)!==JSON.stringify(a)}};exports.checkCardConfigChange=checkCardConfigChange;var buildProductReminderText=function(e){var t=Number((null==e?void 0:e.ReminderType)||0);return 1===t&&null!=e&&e.HotSale?"热卖 x ".concat(e.HotSale):2===t&&null!=e&&e.Stock?"库存仅剩 x ".concat(e.Stock):""};exports.buildProductReminderText=buildProductReminderText;var splitSellingPointTags=function(e){return String(e||"").split(/[;]/).map(function(e){return e.trim()}).filter(Boolean)};exports.splitSellingPointTags=splitSellingPointTags;var PROMOTION_TAG_TEXT={2:"超值购",3:"惊喜特惠",4:"低价秒杀"},buildPromotionTag=function(e){var t=Number((null==e?void 0:e.PromotionTagType)||0);if(!t)return null;if(1===t&&null!=e&&e.PromotionTagUrl)return{isCustom:!0,image:e.PromotionTagUrl,text:""};var r=PROMOTION_TAG_TEXT[t];return r?{isCustom:!1,image:"",text:r,type:t}:null},withProductReminderText=function(e){return _objectSpread(_objectSpread({},e),{},{_reminderText_:buildProductReminderText(e),_reminderType_:Number((null==e?void 0:e.ReminderType)||0),_reminderValue_:1===Number((null==e?void 0:e.ReminderType)||0)?null==e?void 0:e.HotSale:null==e?void 0:e.Stock,_promotionTag_:buildPromotionTag(e),_sellingPointTags_:splitSellingPointTags(null==e?void 0:e.SellingPointTag),_memberPriceText_:null!=e&&e.MemberPrice&&1!==Number(null==e?void 0:e.PriceHidden)?"会员价 ".concat(e.MemberPrice):""})};exports.withProductReminderText=withProductReminderText;var isProductMessageEnabled=function(e){return!!(null!=e&&e.IsViewOrderEnable||null!=e&&e.IsViewInPurchaseEnable)},reportProductMessage=function(e,t){var r,n,o=(null==e||null===(r=e.store)||void 0===r||null===(n=r.get)||void 0===n?void 0:n.call(r,"liveInfo"))||{},i=o.ActivityId,l=Number(t);i&&l&&isProductMessageEnabled(o.CommentConfig||{})&&e.request(_constant.REQUEST_URL_MAP.PRODUCT_MESSAGE_SEND,{method:"POST",data:{ActivityId:i,ProductId:l}}).catch(function(t){var r,n;null==e||null===(r=e.reportTea)||void 0===r||r.call(e,"mini_sdk_product_message_send_fail",{ProductId:l,message:(null==t?void 0:t.message)||(null==t||null===(n=t.raw)||void 0===n?void 0:n.errMsg)||""})})};exports.reportProductMessage=reportProductMessage;