...
|
...
|
@@ -54,10 +54,10 @@ class Helpers |
|
|
/**
|
|
|
* 根据尺寸获得图片url
|
|
|
*
|
|
|
* @param string $url 路径
|
|
|
* @param integer $width 图片宽度
|
|
|
* @param integer $height 图片高度
|
|
|
* @param integer $mode 模式
|
|
|
* @param string $url 路径
|
|
|
* @param integer $width 图片宽度
|
|
|
* @param integer $height 图片高度
|
|
|
* @param integer $mode 模式
|
|
|
* @return string 图片地址
|
|
|
*/
|
|
|
public static function getImageUrl($url, $width, $height, $mode = 2)
|
...
|
...
|
@@ -88,7 +88,8 @@ class Helpers |
|
|
{
|
|
|
$url = strtr($url, array('.m.yohobuy.com' => SUB_DOMAIN, OLD_MAIN => SITE_MAIN, 'www.yohobuy.com' => SITE_MAIN));
|
|
|
if (strrpos($url, 'm.yohobuy.com') && !strrpos($url, 'sale.m.yohobuy.com') && !strrpos($url, 'cuxiao.m.yohobuy.com')
|
|
|
&& !strrpos($url, 'activity.m.yohobuy.com') && !strrpos($url, 'huodong.m.yohobuy.com') && strrpos($url, 'cdn.yoho.cn/myohobuy') && !strrpos($url, '/home/orders/pay')) {
|
|
|
&& !strrpos($url, 'activity.m.yohobuy.com') && !strrpos($url, 'huodong.m.yohobuy.com') && strrpos($url, 'cdn.yoho.cn/myohobuy') && !strrpos($url, '/home/orders/pay')
|
|
|
) {
|
|
|
$url = strtr($url, array('http://' => '//'));
|
|
|
}
|
|
|
|
...
|
...
|
@@ -183,7 +184,7 @@ class Helpers |
|
|
/**
|
|
|
* 根据排序类型和类型值获得正确的排序参数
|
|
|
* @param integer $order 类型值
|
|
|
* @param string $type 排序类型
|
|
|
* @param string $type 排序类型
|
|
|
* @return string 转换之后的排序参数
|
|
|
*/
|
|
|
public static function transOrder($order, $type)
|
...
|
...
|
@@ -274,8 +275,8 @@ class Helpers |
|
|
}
|
|
|
$result['is_soon_sold_out'] = ($productData['is_soon_sold_out'] === 'Y');
|
|
|
$url = self::url('/product/pro_' . $productData['product_id'] . '_'
|
|
|
. $productData['goods_list'][0]['goods_id']
|
|
|
. '/' . $productData['cn_alphabet'] . '.html');
|
|
|
. $productData['goods_list'][0]['goods_id']
|
|
|
. '/' . $productData['cn_alphabet'] . '.html');
|
|
|
$result['url'] = strtr($url, array('http://' => '//'));
|
|
|
|
|
|
// APP访问需要加附加的参数
|
...
|
...
|
@@ -296,13 +297,12 @@ class Helpers |
|
|
// 打折与即将售完组合显示打折
|
|
|
if ($result['is_soon_sold_out'] && $result['tags']['is_discount']) {
|
|
|
$result['tags']['is_new'] = false;
|
|
|
}
|
|
|
// 打折与其它组合则隐藏打折
|
|
|
} // 打折与其它组合则隐藏打折
|
|
|
elseif ($result['tags']['is_discount'] &&
|
|
|
($result['tags']['is_new'] || $result['tags']['is_limited'] || $result['tags']['is_yohood'] || $result['tags']['is_advance'])) {
|
|
|
($result['tags']['is_new'] || $result['tags']['is_limited'] || $result['tags']['is_yohood'] || $result['tags']['is_advance'])
|
|
|
) {
|
|
|
$result['tags']['is_discount'] = false;
|
|
|
}
|
|
|
// YOHOOD和新品组合显示YOHOOD
|
|
|
} // YOHOOD和新品组合显示YOHOOD
|
|
|
elseif ($result['tags']['is_yohood'] && $result['tags']['is_new']) {
|
|
|
$result['tags']['is_new'] = false;
|
|
|
}
|
...
|
...
|
@@ -354,7 +354,7 @@ class Helpers |
|
|
$result['showTags'] = $showTag;
|
|
|
$result['img'] = isset($articleData['src']) ? self::getImageUrl($articleData['src'], 640, 640) : '';
|
|
|
//逛详情页app跳转url处理 20160601
|
|
|
$result['url'] = $isApp ? self::getUrlSafe($articleData['url']) . '&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"' . $articleData['id'] . '"},"shareparam":{"id":"' . $articleData['id'] . '"},"share":"/guang/api/v1/share/guang","id":' . $articleData['id'] . ',"type":1,"url":"' .'http:'. self::url('/info/index', array(), 'guang') . '","islogin":"N"}}' : $articleData['url'];
|
|
|
$result['url'] = $isApp ? self::getUrlSafe($articleData['url']) . '&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"' . $articleData['id'] . '"},"shareparam":{"id":"' . $articleData['id'] . '"},"share":"/guang/api/v1/share/guang","id":' . $articleData['id'] . ',"type":1,"url":"' . 'http:' . self::url('/info/index', array(), 'guang') . '","islogin":"N"}}' : $articleData['url'];
|
|
|
//$result['url'] = $articleData['url']; // ? $articleData['url'] : self::url('/info/index', array('id' => $articleData['id']), 'guang');
|
|
|
|
|
|
if (strrpos($result['url'], 'feature.yoho.cn') || strrpos($result['url'], 'cdn.yoho.cn')) {
|
...
|
...
|
@@ -371,16 +371,19 @@ class Helpers |
|
|
$result['collect'] = array();
|
|
|
$result['collect']['isCollected'] = isset($articleData['isFavor']) && $articleData['isFavor'] === 'Y';
|
|
|
$result['collect']['url'] = !empty($uid) ? 'javascript:;' : strtr($articleData['url'], array('"islogin":"N"' => '"islogin":"Y"'));
|
|
|
}
|
|
|
// 点赞
|
|
|
} // 点赞
|
|
|
else {
|
|
|
$result['like'] = array();
|
|
|
$result['like']['count'] = $articleData['praise_num'];
|
|
|
$result['like']['isLiked'] = isset($articleData['isPraise']) && $articleData['isPraise'] === 'Y';
|
|
|
}
|
|
|
|
|
|
// 分享链接
|
|
|
$result['share'] = $isApp && isset($articleData['share']['url']) ? $articleData['share']['url'] : false;
|
|
|
if ($isApp && isset($articleData['share']['url'])) {
|
|
|
$shareLink = $articleData['share']['url'] . '?openby:yohobuy={"action":"go.share","params":{"title":"' . $articleData['title'] . '","content":"' . $articleData['intro'] . '","url":"' . $articleData['share']['url'] . '","pic":"' . $result['img'] . '"}}';
|
|
|
|
|
|
// 分享链接
|
|
|
$result['share'] = $shareLink;
|
|
|
}
|
|
|
|
|
|
// 判断是否显示作者信息
|
|
|
if ($showAuthor && !empty($articleData['author'])) {
|
...
|
...
|
@@ -388,7 +391,7 @@ class Helpers |
|
|
$articleData['author']['url'] = Helpers::getFilterUrl($articleData['author']['url']);
|
|
|
}
|
|
|
//编辑人员 app跳转url处理 20160601
|
|
|
$articleData['author']['url'] = self::getUrlSafe($articleData['author']['url']).'&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"' . $articleData['author']['author_id'] . '"},"share":"","id":' . $articleData['author']['author_id'] . ',"type":0,"islogin":"N","url":"' .'https:'.self::url('/author/index', array(), 'guang') . '"}}';
|
|
|
$articleData['author']['url'] = self::getUrlSafe($articleData['author']['url']) . '&openby:yohobuy={"action":"go.h5","params":{"param":{"id":"' . $articleData['author']['author_id'] . '"},"share":"","id":' . $articleData['author']['author_id'] . ',"type":0,"islogin":"N","url":"' . 'https:' . self::url('/author/index', array(), 'guang') . '"}}';
|
|
|
$result['author'] = $articleData['author'];
|
|
|
if (isset($result['author']['avatar'])) {
|
|
|
$result['author']['avatar'] = strtr($result['author']['avatar'], array('http://' => '//'));
|
...
|
...
|
@@ -482,7 +485,7 @@ class Helpers |
|
|
if (empty($mobile)) {
|
|
|
return false;
|
|
|
}
|
|
|
return (bool) preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile));
|
|
|
return (bool)preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile));
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -496,7 +499,7 @@ class Helpers |
|
|
if (empty($password)) {
|
|
|
return false;
|
|
|
}
|
|
|
return (bool) preg_match('/^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/', trim($password));
|
|
|
return (bool)preg_match('/^([a-zA-Z0-9\-\+_!@\#$%\^&\*\(\)\:\;\.=\[\]\\\',\?]){6,20}$/', trim($password));
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -542,14 +545,14 @@ class Helpers |
|
|
*
|
|
|
* @return string 处理之后的地址
|
|
|
*/
|
|
|
public static function transUrl($url, $channel='woman')
|
|
|
public static function transUrl($url, $channel = 'woman')
|
|
|
{
|
|
|
$extra = '';
|
|
|
if(!empty($url) && stripos($url, '?') === false) {
|
|
|
$extra = '?channel='.$channel;
|
|
|
if (!empty($url) && stripos($url, '?') === false) {
|
|
|
$extra = '?channel=' . $channel;
|
|
|
}
|
|
|
if(!empty($url) && stripos($url, '?') !== false){
|
|
|
$extra = '&channel='.$channel;
|
|
|
if (!empty($url) && stripos($url, '?') !== false) {
|
|
|
$extra = '&channel=' . $channel;
|
|
|
}
|
|
|
return $url . $extra;
|
|
|
}
|
...
|
...
|
@@ -563,47 +566,47 @@ class Helpers |
|
|
$verify = array(
|
|
|
86 => array(
|
|
|
'name' => '中国',
|
|
|
'match' => (bool) preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^1[3|4|5|8|7][0-9]{9}$/', trim($mobile)),
|
|
|
),
|
|
|
852 => array(
|
|
|
'name' => '中国香港',
|
|
|
'match' => (bool) preg_match('/^[9|6|5][0-9]{7}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^[9|6|5][0-9]{7}$/', trim($mobile)),
|
|
|
),
|
|
|
853 => array(
|
|
|
'name' => '中国澳门',
|
|
|
'match' => (bool) preg_match('/^[0-9]{8}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^[0-9]{8}$/', trim($mobile)),
|
|
|
),
|
|
|
886 => array(
|
|
|
'name' => '中国台湾',
|
|
|
'match' => (bool) preg_match('/^[0-9]{10}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^[0-9]{10}$/', trim($mobile)),
|
|
|
),
|
|
|
65 => array(
|
|
|
'name' => '新加坡',
|
|
|
'match' => (bool) preg_match('/^[9|8][0-9]{7}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^[9|8][0-9]{7}$/', trim($mobile)),
|
|
|
),
|
|
|
60 => array(
|
|
|
'name' => '马来西亚',
|
|
|
'match' => (bool) preg_match('/^1[1|2|3|4|6|7|9][0-9]{8}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^1[1|2|3|4|6|7|9][0-9]{8}$/', trim($mobile)),
|
|
|
),
|
|
|
1 => array(
|
|
|
'name' => '加拿大&美国',
|
|
|
'match' => (bool) preg_match('/^[0-9]{10}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^[0-9]{10}$/', trim($mobile)),
|
|
|
),
|
|
|
82 => array(
|
|
|
'name' => '韩国',
|
|
|
'match' => (bool) preg_match('/^01[0-9]{9}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^01[0-9]{9}$/', trim($mobile)),
|
|
|
),
|
|
|
44 => array(
|
|
|
'name' => '英国',
|
|
|
'match' => (bool) preg_match('/^7[7|8|9][0-9]{8}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^7[7|8|9][0-9]{8}$/', trim($mobile)),
|
|
|
),
|
|
|
81 => array(
|
|
|
'name' => '日本',
|
|
|
'match' => (bool) preg_match('/^0[9|8|7][0-9]{9}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^0[9|8|7][0-9]{9}$/', trim($mobile)),
|
|
|
),
|
|
|
61 => array(
|
|
|
'name' => '澳大利亚',
|
|
|
'match' => (bool) preg_match('/^[0-9]{11}$/', trim($mobile)),
|
|
|
'match' => (bool)preg_match('/^[0-9]{11}$/', trim($mobile)),
|
|
|
),
|
|
|
);
|
|
|
if (isset($verify[$area])) {
|
...
|
...
|
@@ -652,7 +655,7 @@ class Helpers |
|
|
return $arr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* 格式化购物车商品
|
|
|
*
|
|
|
* @param array $cartGoods 购物车商品列表
|
...
|
...
|
@@ -722,7 +725,7 @@ class Helpers |
|
|
* @param int $count 计商品件数
|
|
|
* @return array $arr 处理之后的加价购商品数据
|
|
|
*/
|
|
|
public static function formatAdvanceGoods($advanceGoods,&$count = 0,$isGift = false)
|
|
|
public static function formatAdvanceGoods($advanceGoods, &$count = 0, $isGift = false)
|
|
|
{
|
|
|
$arr = array();
|
|
|
|
...
|
...
|
@@ -745,7 +748,7 @@ class Helpers |
|
|
$oneGoods['count'] = $single['storage_number'];
|
|
|
|
|
|
$gift['goods'][] = $oneGoods;
|
|
|
$number ++;
|
|
|
$number++;
|
|
|
}
|
|
|
|
|
|
$arr[] = $gift;
|
...
|
...
|
@@ -901,12 +904,12 @@ class Helpers |
|
|
* @param unknown $productSkc
|
|
|
* @return string
|
|
|
*/
|
|
|
public static function getUrlBySkc($product_id, $goods_id, $cn_alphabet='')
|
|
|
public static function getUrlBySkc($product_id, $goods_id, $cn_alphabet = '')
|
|
|
{
|
|
|
if (empty($cn_alphabet)) {
|
|
|
$cn_alphabet = 'goods.html';
|
|
|
}
|
|
|
return '//item.yohobuy.com/product/pro_' . $product_id . '_' . $goods_id . '/' . $cn_alphabet. '.html';
|
|
|
return '//item.yohobuy.com/product/pro_' . $product_id . '_' . $goods_id . '/' . $cn_alphabet . '.html';
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -926,18 +929,18 @@ class Helpers |
|
|
return $ip;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 组合国际手机号
|
|
|
* @param $area
|
|
|
* @param $mobile
|
|
|
* @return string
|
|
|
*/
|
|
|
/**
|
|
|
* 组合国际手机号
|
|
|
* @param $area
|
|
|
* @param $mobile
|
|
|
* @return string
|
|
|
*/
|
|
|
public static function makeMobile($area, $mobile)
|
|
|
{
|
|
|
if(empty($area) || $area == 86){
|
|
|
if (empty($area) || $area == 86) {
|
|
|
return $mobile;
|
|
|
}
|
|
|
return $area.'-'.$mobile;
|
|
|
return $area . '-' . $mobile;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -968,11 +971,11 @@ class Helpers |
|
|
{
|
|
|
return preg_replace('/^\/\//', 'http://', $url);
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* http和https转换成//
|
|
|
* @param type $url 地址
|
|
|
* @return type string
|
|
|
* @return type string
|
|
|
*/
|
|
|
public static function getUrlSafe($url)
|
|
|
{
|
...
|
...
|
@@ -980,10 +983,10 @@ class Helpers |
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 除去数组中的空值和签名参数
|
|
|
* @param $para 签名参数组
|
|
|
* return 去掉空值与签名参数后的新签名参数组
|
|
|
*/
|
|
|
* 除去数组中的空值和签名参数
|
|
|
* @param $para 签名参数组
|
|
|
* return 去掉空值与签名参数后的新签名参数组
|
|
|
*/
|
|
|
public static function paraFilter(&$para)
|
|
|
{
|
|
|
$para_filter = array();
|
...
|
...
|
@@ -995,16 +998,17 @@ class Helpers |
|
|
}
|
|
|
return $para_filter;
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 判断是否是微信客户端
|
|
|
* @return boolean
|
|
|
*/
|
|
|
public static function is_weixin(){
|
|
|
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
|
|
|
public static function is_weixin()
|
|
|
{
|
|
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
} |
...
|
...
|
|