不影響原來返回參數, getViewInfo 增加返回參數處理
返回參數示例:
原來的:
"customField":[
{
"name":"hall_1",
"title":"hall",
"dtype":"text",
"value":"hall"
},
{
"name":"hall_2",
"title":"hall",
"dtype":"htmltext",
"value":"hall"
}]
增加的:
"customFieldObject": {
"hall": "hall",
"product_desc": "hall",
"desc": "hall",
"number": "A12333",
"logo": "hall",
"name": "hall"
},
//$customFieldObject = new StdClass();這個函數本地環境不支持
$customFieldObject = json_decode('{}');
foreach ($customField as $key => $value) {
$name = $customField[$key]['name'];
if ('img' == $value['dtype']) {
$customField[$key]['value'] = $this->get_default_pic($detailExt[$key]);
$customFieldObject->$name = $this->get_default_pic($detailExt[$key]);
} else if ('media' == $value['dtype']) {
$customField[$key]['value'] = $this->get_default_pic($detailExt[$key]);
$customFieldObject->$name = $this->get_default_pic($detailExt[$key]);
} else if ('imgs' == $value['dtype']) {
foreach ($detailExt[$key] as $kk => $vv) {
$detailExt[$key][$kk]['image_url'] = $this->get_default_pic($vv['image_url']);
}
$customField[$key]['value'] = $detailExt[$key];
$customFieldObject->$name = $detailExt[$key];
} else {
$customField[$key]['value'] = $detailExt[$key];
$customFieldObject->$name = $detailExt[$key];
}
}
$detail['customFieldObject'] = !empty($customFieldObject) ? $customFieldObject : false;