Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
whb
9 years ago
Commit
3d2177727f742e016b6b16093e16031bb47d5d60
1 parent
f20b15d3
pc的webplugin 的helpers
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
89 additions
and
17 deletions
library/WebPlugin/Helpers.php
library/WebPlugin/Helpers.php
View file @
3d21777
...
...
@@ -347,16 +347,37 @@ class Helpers
if
(
!
isset
(
$articleData
[
'id'
]))
{
return
false
;
}
$width
=
$height
=
360
;
if
(
$articleData
[
'conver_image_type'
]
==
2
)
{
$width
=
360
;
$height
=
240
;
}
$result
=
array
();
$result
[
'id'
]
=
$articleData
[
'id'
];
$result
[
'showTags'
]
=
$showTag
;
$result
[
'img'
]
=
self
::
getImageUrl
(
$articleData
[
'src'
],
640
,
640
);
$result
[
'classification'
]
=
$articleData
[
'category_name'
];
$result
[
'isReco'
]
=
$articleData
[
'is_recommended'
];
$result
[
'url'
]
=
$isApp
?
$articleData
[
'url'
]
:
self
::
url
(
'/info/index'
,
array
(
'id'
=>
$articleData
[
'id'
]),
'guang'
);
$result
[
'img'
]
=
self
::
getImageUrl
(
$articleData
[
'src'
],
$width
,
$height
);
$result
[
'isSquareImg'
]
=
true
;
$result
[
'title'
]
=
$articleData
[
'title'
];
$result
[
'text'
]
=
$articleData
[
'intro'
];
$result
[
'publishTime'
]
=
$articleData
[
'publish_time'
];
$result
[
'pageView'
]
=
$articleData
[
'views_num'
];
if
(
empty
(
$articleData
[
'author'
])){
$articleData
[
'author'
][
'name'
]
=
''
;
$articleData
[
'author'
][
'avatar'
]
=
''
;
}
$result
[
'author'
]
=
$articleData
[
'author'
][
'name'
];
$result
[
'editorUrl'
]
=
$articleData
[
'author'
][
'avatar'
];
$result
[
'pTime'
]
=
$articleData
[
'publish_time'
];
$result
[
'pView'
]
=
$articleData
[
'views_num'
];
$result
[
'content'
]
=
$articleData
[
'intro'
];
$result
[
'showTags'
]
=
$showTag
;
$tags
=
array
();
if
(
!
empty
(
$articleData
[
'tags'
]))
{
foreach
(
$articleData
[
'tags'
]
as
$tag
)
{
$tags
[]
=
self
::
formatTag
(
$tag
,
$isApp
);
}
}
$result
[
'tags'
]
=
$tags
;
$result
[
'comment'
]
=
$articleData
[
'comment_num'
];
// 收藏
if
(
$isApp
)
{
...
...
@@ -366,9 +387,8 @@ class Helpers
}
// 点赞
else
{
$result
[
'like'
]
=
array
();
$result
[
'like'
][
'count'
]
=
$articleData
[
'praise_num'
];
$result
[
'like'
][
'isLiked'
]
=
isset
(
$articleData
[
'isPraise'
])
&&
$articleData
[
'isPraise'
]
===
'Y'
;
$result
[
'like'
]
=
$articleData
[
'praise_num'
];
$result
[
'liked'
]
=
isset
(
$articleData
[
'isPraise'
])
&&
$articleData
[
'isPraise'
]
===
'Y'
;
}
// 分享链接
...
...
@@ -402,10 +422,31 @@ class Helpers
break
;
}
}
return
$result
;
}
public
static
function
formatTag
(
$tagData
,
$isApp
=
false
,
$uid
=
null
)
{
$result
=
array
();
$result
[
'tag'
]
=
$tagData
[
'name'
];
$result
[
'url'
]
=
$tagData
[
'url'
];
return
$result
;
}
public
static
function
formatAd
(
$adData
,
$isApp
=
false
,
$uid
=
null
)
{
//此处不需要ad的id
//if (!isset($adData['id'])) {
// return false;
//}
$result
=
array
();
// $result['id'] = $adData['id'];
$result
[
'img'
]
=
self
::
getImageUrl
(
$adData
[
'src'
],
640
,
640
);
$result
[
'url'
]
=
$isApp
?
$adData
[
'url'
]
:
self
::
url
(
'/info/index'
,
array
(
'id'
=>
$adData
[
'id'
]),
'guang'
);
$result
[
'title'
]
=
$adData
[
'title'
];
$result
[
'bgColor'
]
=
$adData
[
'bgColor'
];
return
$result
;
}
/**
* 格式化广告焦点图数据
*
...
...
@@ -644,11 +685,12 @@ class Helpers
* @param boolean $isValid 是否是可用商品(非失效商品),默认是
* @return array 处理之后的购物车商品数据
*/
public
static
function
formatCartGoods
(
$cartGoods
,
$isAdvanceCart
,
$isValid
=
true
)
public
static
function
formatCartGoods
(
$cartGoods
,
$isAdvanceCart
,
$isValid
=
true
,
$isOffShelves
=
false
)
{
$result
=
array
();
$oneGoods
=
array
();
$cnAlphaBet
=
''
;
foreach
(
$cartGoods
as
$value
)
{
$oneGoods
=
array
();
$oneGoods
[
'id'
]
=
$value
[
'product_sku'
];
...
...
@@ -659,13 +701,19 @@ class Helpers
$oneGoods
[
'imgCover'
]
=
!
empty
(
$value
[
'goods_images'
])
?
Images
::
getImageUrl
(
$value
[
'goods_images'
],
60
,
60
)
:
''
;
$oneGoods
[
'productColor'
]
=
$value
[
'color_name'
];
$oneGoods
[
'productSize'
]
=
$value
[
'size_name'
];
$oneGoods
[
'productPrice'
]
=
self
::
transPrice
(
$value
[
'real_price'
]);
$oneGoods
[
'productPrice'
]
=
self
::
transPrice
(
$value
[
'
last_vip_price'
]);
//self::transPrice($value['
real_price']);
$oneGoods
[
'productNum'
]
=
$value
[
'buy_number'
];
$oneGoods
[
'isVipPrice'
]
=
$value
[
'sales_price'
]
!==
$value
[
'last_vip_price'
];
$oneGoods
[
'yohoIcon'
]
=
isset
(
$value
[
'get_yoho_coin'
])
?
$value
[
'get_yoho_coin'
]
:
0
;
$oneGoods
[
'productSubtotal'
]
=
isset
(
$value
[
'subtotal'
])
?
self
::
transPrice
(
$value
[
'subtotal'
])
:
$oneGoods
[
'productPrice'
];
$oneGoods
[
'productSubtotal'
]
=
self
::
transPrice
(
floatval
(
$value
[
'last_vip_price'
])
*
intval
(
$value
[
'buy_number'
])
);
$oneGoods
[
'promotionId'
]
=
empty
(
$value
[
'promotion_id'
])
?
'0'
:
$value
[
'promotion_id'
];
if
(
$isValid
)
{
// 已下架
if
(
$isOffShelves
)
{
$oneGoods
[
'isTipNoStore'
]
=
true
;
$oneGoods
[
'tipMessage'
]
=
'库存不足'
;
}
else
if
(
$isValid
)
{
if
(
$value
[
'buy_number'
]
>
$value
[
'storage_number'
])
{
$oneGoods
[
'isTipNoStore'
]
=
true
;
// 是否在结算时候显示库存不足
$oneGoods
[
'tipMessage'
]
=
'库存不足'
;
...
...
@@ -676,7 +724,7 @@ class Helpers
$oneGoods
[
'inValid'
]
=
true
;
}
//
,
advanceBuy=>是否加价购,soldOut=>失效商品;
//
advanceBuy=>是否加价购,soldOut=>失效商品;
if
(
!
isset
(
$value
[
'goods_type'
]))
{
$oneGoods
[
'inValid'
]
=
true
;
}
...
...
@@ -705,8 +753,10 @@ class Helpers
if
(
$isAdvanceCart
&&
!
empty
(
$value
[
'expect_arrival_time'
]))
{
$oneGoods
[
'preSellDate'
]
=
$value
[
'expect_arrival_time'
];
}
// 商品链接
$oneGoods
[
'link'
]
=
self
::
url
(
'/product/show_'
.
$value
[
'product_sku'
]
.
'_'
.
$value
[
'product_skn'
]
.
'.html'
);
$cnAlphaBet
=
isset
(
$value
[
'cn_alphabet'
])
?
$value
[
'cn_alphabet'
]
:
md5
(
$value
[
'product_name'
]);
$oneGoods
[
'link'
]
=
self
::
url
(
'/product/pro_'
.
$value
[
'product_id'
]
.
'_'
.
$value
[
'goods_id'
]
.
'/'
.
$cnAlphaBet
.
'.html'
,
null
,
'item'
);
$result
[]
=
$oneGoods
;
}
...
...
@@ -739,6 +789,7 @@ class Helpers
$number
=
0
;
$subjoinInfo
=
array
();
$cnAlphaBet
=
''
;
foreach
(
$value
[
'goods_list'
]
as
$single
)
{
++
$number
;
...
...
@@ -751,7 +802,14 @@ class Helpers
$oneGoods
[
'marketPrice'
]
=
$isGift
?
''
:
self
::
transPrice
(
$single
[
'market_price'
]);
// 市场价
$oneGoods
[
'yohoIcon'
]
=
0
;
// 返YOHO币
// $oneGoods['storageNum'] = $single['storage_number']; // 库存量
$oneGoods
[
'subjoinLink'
]
=
self
::
url
(
'/product/show_'
.
$single
[
'product_id'
]
.
'_'
.
$single
[
'product_skn'
]
.
'.html'
);
// 商品链接
if
(
isset
(
$single
[
'goods_id'
]))
{
$cnAlphaBet
=
isset
(
$single
[
'cn_alphabet'
])
?
$single
[
'cn_alphabet'
]
:
md5
(
$single
[
'product_name'
]);
$oneGoods
[
'subjoinLink'
]
=
self
::
url
(
'/product/pro_'
.
$single
[
'product_id'
]
.
'_'
.
$single
[
'goods_id'
]
.
'/'
.
$cnAlphaBet
.
'.html'
,
null
,
'item'
);
}
else
{
$oneGoods
[
'subjoinLink'
]
=
self
::
url
(
'/product/show_'
.
$single
[
'product_id'
]
.
'_'
.
$single
[
'product_skn'
]
.
'/'
.
Helpers
::
makeToken
(
$single
[
'product_skn'
])
.
'.html'
,
null
,
'item'
);
}
// 赠品
if
(
$isGift
)
{
$oneGoods
[
'isGift'
]
=
true
;
...
...
@@ -948,4 +1006,18 @@ class Helpers
}
return
$area
.
'-'
.
$mobile
;
}
/**
* 判断是否是新用户 (未下单)
*
* @return bool (true:是, false:否)
*/
public
static
function
isNewUser
()
{
if
(
isset
(
$_COOKIE
[
'_isOldUser'
])
&&
$_COOKIE
[
'_isOldUser'
]
==
'4'
)
{
return
false
;
}
return
true
;
}
}
...
...
Please
register
or
login
to post a comment