Authored by Rock Zhang

添加根据手机系统判定限定商品打开app链接的功能

Code Review By Rock Zhang
@@ -335,7 +335,7 @@ class DetailModel @@ -335,7 +335,7 @@ class DetailModel
335 self::procShowStatus($result, $showStatus, $isBeginSale); 335 self::procShowStatus($result, $showStatus, $isBeginSale);
336 336
337 $result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode']; 337 $result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];
338 - $result['cartInfo']['limitCodeUrl'] = 'yohobuy://' . Helpers::url('/product', array('skn' => $baseInfo['erpProductId'])); 338 + $result['cartInfo']['limitCodeUrl'] = self::getLimitCodeUrl($baseInfo['erpProductId']);
339 } 339 }
340 340
341 // 是否收藏 341 // 是否收藏
@@ -897,4 +897,22 @@ class DetailModel @@ -897,4 +897,22 @@ class DetailModel
897 } 897 }
898 } 898 }
899 899
  900 + /**
  901 + * 根据设备类型获得限购商品跳转app的url
  902 + *
  903 + * @param string $skn 商品skn
  904 + * @return string 限购商品跳转url
  905 + */
  906 + private static function getLimitCodeUrl($skn)
  907 + {
  908 + $url = 'yohoapp://yoho.app/openwith?product_skn=' . $skn;
  909 +
  910 + // 苹果设备或者苹果IPAD
  911 + if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
  912 + $url = 'yohobuy://' . Helpers::url('/product', array('skn' => $skn));
  913 + }
  914 +
  915 + return $url;
  916 + }
  917 +
900 } 918 }