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;
}
//////////////////////////////////////////////////////////////////六月婷婷中文字幕_国产综合久久久久久_亚洲能在线看的黄色网站_亚洲欧美激情在线一区