var lyGlobal = {} // 真实姓名 ////////////////////////////////////////////////////////////////// // $first_name //名 // $last_name //姓 lyGlobal.real_name = ($first_name='', $last_name='')=>{ let name = $first_name+' '+$last_name; if (name.search(/^[a-zA-Z0-9_ \-]+$/)>-1) { return name; } else { return $last_name+' '+$first_name; } } ////////////////////////////////////////////////////////////////// // 汇率 rate ////////////////////////////////////////////////////////////////// /** * 货币类型,并且转换汇率 * @param {float} $price 价钱 * @param {string} 返回类型 默认0:返回汇率符号+价格,1:返回汇率符号,2:返回两位小数点的价格 * @return {string|float} */ lyGlobal.rate = ($price, $type)=>{ if($price){ return '$'; }else if($type){ return '100' }else{ return '$100' } } ////////////////////////////////////////////////////////////////// // 订单 orders ////////////////////////////////////////////////////////////////// // 订单进度条状态 lyGlobal.orders_progress_status = ()=>{} // 订单价格 lyGlobal.orders_real_price = ()=>{ // } // 订单价格 lyGlobal.orders_real_price = ()=>{ // } ////////////////////////////////////////////////////////////////// // 产品 products ////////////////////////////////////////////////////////////////// // 计算产品真实价格 // $_ARG['row'] 产品数据 // $_ARG['wb_products_parameter_id'] 产品所选参数id // $_ARG['qty'] 批发价格 lyGlobal.products_parameter_price = function($_ARG){ let $row = $_ARG.row; let $realPrice = $row.Price; let $realStock = $row.Stock; let $realSKU = $row.SKU; let $realPicture = {}; let $Price = 0; let $Stock = 0; let $SKU = 0; let $Picture = {path:'',alt:''}; if(!Array.isArray($row.Pictures)){ $row.Pictures = $.json($row.Pictures); } $realPicture = $row.Pictures[0]||{path:'',alt:$row.Name}; let $wb_products_parameter=[]; let $wb_products_parameter_price=[]; //产品可选参数的组合 if(!Array.isArray($row.wb_products_parameter_price)){ $wb_products_parameter = $.json($row.wb_products_parameter); $wb_products_parameter_price = $.json($row.wb_products_parameter_price); } // console.log('$_ARG',$_ARG,$wb_products_parameter,$wb_products_parameter_price); let $wb_products_parameter_id_buy = ''; //购买的产品 所选的参数id let $wb_products_parameter_buy = [];//购买的产品 所选的参数具体数据 if ($_ARG.wb_products_parameter_id&&$wb_products_parameter_price.length) { $wb_products_parameter_price.forEach($v => { if ($_ARG.wb_products_parameter_id==$v.parameter_id) { $wb_products_parameter_buy = $v.parameter; $Stock = $v.stock; $SKU = $v.SKU; $Price = $v.price; $wb_products_parameter_id_buy = $v.parameter_id; if ($v.picture) { $Picture.path = $v.picture; } } }); } // 参数价格 if ($row.ProPriceType==1&&$wb_products_parameter_id_buy) { $realPicture = $Picture; $realPrice = $Price; $realStock = $Stock; $realSKU = $SKU; } // 批发价 if ($_ARG.qty) { // $row['WholesalePrice'] } return { 'Picture': $realPicture, 'Price': $realPrice, 'Stock': $realStock, 'SKU': $realSKU, 'ProPriceType': $row.ProPriceType, 'wb_products_parameter_id_buy': $wb_products_parameter_id_buy, 'wb_products_parameter_buy': $wb_products_parameter_buy, }; }; ////////////////////////////////////////////////////////////////// // 语言包 ////////////////////////////////////////////////////////////////// lyGlobal.language_concat_format = function($_ARG){ var all = [...$.global.wb_language.new,...$.language.all] var res = []; all.forEach(v => { let name = v.name?v.name:(v?v:''); let url = v.url?v.url:''; if(res.findIndex(i=>{return i.name==v})<0){ res.push({ name:name, url:url }) } }); return res; } //////////////////////////////////////////////////////////////////