|
@@ -248,7 +248,8 @@ class InfoController extends AbstractAction |
|
@@ -248,7 +248,8 @@ class InfoController extends AbstractAction |
248
|
// 单张图
|
248
|
// 单张图
|
249
|
elseif (isset($value['singleImage'])) {
|
249
|
elseif (isset($value['singleImage'])) {
|
250
|
$build['bigImage'] = Helpers::getImageUrl($value['singleImage']['data'][0]['src'], 640, 640);
|
250
|
$build['bigImage'] = Helpers::getImageUrl($value['singleImage']['data'][0]['src'], 640, 640);
|
251
|
- } elseif (isset($value['smallPic']['data'])) {
|
251
|
+ }
|
|
|
252
|
+ elseif (isset($value['smallPic']['data'])) {
|
252
|
$imgs = $value['smallPic']['data'];
|
253
|
$imgs = $value['smallPic']['data'];
|
253
|
$build['smallImage'] = array(
|
254
|
$build['smallImage'] = array(
|
254
|
array(
|
255
|
array(
|
|
@@ -342,5 +343,118 @@ class InfoController extends AbstractAction |
|
@@ -342,5 +343,118 @@ class InfoController extends AbstractAction |
342
|
$detail = array();
|
343
|
$detail = array();
|
343
|
$data = array();
|
344
|
$data = array();
|
344
|
}
|
345
|
}
|
|
|
346
|
+
|
|
|
347
|
+ /**
|
|
|
348
|
+ * 提供给YOHO资讯站调用的接口
|
|
|
349
|
+ *
|
|
|
350
|
+ * @param int id 逛内容ID
|
|
|
351
|
+ * @return json
|
|
|
352
|
+ */
|
|
|
353
|
+ public function foryohoAction()
|
|
|
354
|
+ {
|
|
|
355
|
+ $result = array();
|
|
|
356
|
+
|
|
|
357
|
+ do {
|
|
|
358
|
+ /* 判断参数是否有效 */
|
|
|
359
|
+ $id = $this->get('id');
|
|
|
360
|
+ if (!is_numeric($id)) {
|
|
|
361
|
+ break;
|
|
|
362
|
+ }
|
|
|
363
|
+
|
|
|
364
|
+ $app = $this->get('app');
|
|
|
365
|
+ $isApp = empty($app) ? false : true;
|
|
|
366
|
+
|
|
|
367
|
+ /* 判断是否有内容 */
|
|
|
368
|
+ $detail = DetailData::package($id, $isApp);
|
|
|
369
|
+ if (empty($detail['getArticleContent'])) {
|
|
|
370
|
+ break;
|
|
|
371
|
+ }
|
|
|
372
|
+
|
|
|
373
|
+ /* 品牌信息 */
|
|
|
374
|
+ $result['brand'] = $detail['getBrand'];
|
|
|
375
|
+
|
|
|
376
|
+ $build = array();
|
|
|
377
|
+ $good = array();
|
|
|
378
|
+ $skns = array();
|
|
|
379
|
+ $product = array();
|
|
|
380
|
+
|
|
|
381
|
+ /* 商品信息 */
|
|
|
382
|
+ foreach ($detail['getArticleContent'] as $value) {
|
|
|
383
|
+ $build = array();
|
|
|
384
|
+ // 文字
|
|
|
385
|
+ if (isset($value['text'])) {
|
|
|
386
|
+ $build['text'] = $value['text']['data']['text'];
|
|
|
387
|
+ }
|
|
|
388
|
+ // 单张图
|
|
|
389
|
+ elseif (isset($value['singleImage'])) {
|
|
|
390
|
+ $build['bigImage'] = Helpers::getImageUrl($value['singleImage']['data'][0]['src'], 640, 640);
|
|
|
391
|
+ }
|
|
|
392
|
+ elseif (isset($value['smallPic']['data'])) {
|
|
|
393
|
+ $imgs = $value['smallPic']['data'];
|
|
|
394
|
+ $build['smallImage'] = array(
|
|
|
395
|
+ array(
|
|
|
396
|
+ 'src' => Helpers::getImageUrl($imgs[0]['src'], 315, 420)
|
|
|
397
|
+ ),
|
|
|
398
|
+ array(
|
|
|
399
|
+ 'src' => Helpers::getImageUrl($imgs[1]['src'], 315, 420)
|
|
|
400
|
+ )
|
|
|
401
|
+ );
|
|
|
402
|
+ }
|
|
|
403
|
+ elseif (isset($value['goods']['data'])) {
|
|
|
404
|
+ $good = array();
|
|
|
405
|
+ // 遍历取得SKN
|
|
|
406
|
+ $skns = array();
|
|
|
407
|
+ foreach ($value['goods']['data'] as $goods) {
|
|
|
408
|
+ $skns[] = $goods['id'];
|
|
|
409
|
+ }
|
|
|
410
|
+ // 通过SKN获取商品信息
|
|
|
411
|
+ $product = ListData::productInfoBySkns($skns);
|
|
|
412
|
+ if (!empty($product['data']['product_list'])) {
|
|
|
413
|
+ foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
414
|
+ // 最多显示4个
|
|
|
415
|
+ if ($i > 3) {
|
|
|
416
|
+ break;
|
|
|
417
|
+ }
|
|
|
418
|
+ $good[] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
419
|
+ }
|
|
|
420
|
+ }
|
|
|
421
|
+ // 没有商品
|
|
|
422
|
+ if (!isset($i)) {
|
|
|
423
|
+ continue;
|
|
|
424
|
+ }
|
|
|
425
|
+ $result['goods'] = $good;
|
|
|
426
|
+ }
|
|
|
427
|
+ // 悬停浮动商品
|
|
|
428
|
+ elseif (isset($value['goodsGroup']['data'])) {
|
|
|
429
|
+ foreach ($value['goodsGroup']['data'] as $goods) {
|
|
|
430
|
+ $good = array();
|
|
|
431
|
+ $good['img'] = Helpers::getImageUrl($goods['cover']['cover'], 235, 314);
|
|
|
432
|
+ $good['icon'] = Helpers::getProductIcon($goods['cover']['maxSortId']);
|
|
|
433
|
+ $good['goods'] = array();
|
|
|
434
|
+ $skns = array();
|
|
|
435
|
+ foreach ($goods['list'] as $mini) {
|
|
|
436
|
+ $skns[] = $mini['id'];
|
|
|
437
|
+ }
|
|
|
438
|
+ // 通过SKN获取商品信息
|
|
|
439
|
+ $product = ListData::productInfoBySkns($skns);
|
|
|
440
|
+ if (!empty($product['data']['product_list'])) {
|
|
|
441
|
+ foreach ($product['data']['product_list'] as $i => $goods) {
|
|
|
442
|
+ $good['goods'][] = Helpers::formatProduct($goods, false, true, true, 235, 314, true);
|
|
|
443
|
+ }
|
|
|
444
|
+ $result['group'][] = $good;
|
|
|
445
|
+ }
|
|
|
446
|
+ }
|
|
|
447
|
+ }
|
|
|
448
|
+
|
|
|
449
|
+ // 内容详情
|
|
|
450
|
+ if (array() !== $build) {
|
|
|
451
|
+ $result['content'][] = $build;
|
|
|
452
|
+ }
|
|
|
453
|
+ }
|
|
|
454
|
+ }
|
|
|
455
|
+ while (false);
|
|
|
456
|
+
|
|
|
457
|
+ $this->echoJson($result);
|
|
|
458
|
+ }
|
345
|
|
459
|
|
346
|
} |
460
|
} |