Authored by hf

do register login call api data model

... ... @@ -426,7 +426,7 @@
ps: {
id: 1,
banner: '',
log: '',
logo: '',
name: '',
isLike: '',
likeUrl: '',
... ...
... ... @@ -122,5 +122,15 @@ class AbstractAction extends Controller_Abstract
{
return $this->_request->isXmlHttpRequest();
}
/**
* 跳转到错误页面
*/
protected function error()
{
headers_sent() || header('Location: /error.html');
exit;
}
}
... ...
... ... @@ -4,6 +4,7 @@ namespace LibModels\Wap\Guang;
use Api\Sign;
use Api\Yohobuy;
use Plugin\Helpers;
/**
* 明星品牌和原创品牌相关的数据模型
... ... @@ -125,14 +126,15 @@ class PlusstarData
break;
}
//$result['getNewProduct'] = $newProduct['data']['product_list'];
$skn = '';
foreach ($newProduct['data']['product_list'] as $value) {
if (empty($value['goods_list'])) {
continue;
}
// 商品信息列表
$result['getNewProduct'][] = Helpers::formatProduct($value);
// 用户是否收藏该商品
$skn = $value['product_skn'];
$result['getUidProductFav'][ $skn ] = false;
... ... @@ -141,8 +143,6 @@ class PlusstarData
$result['getUidProductFav'][ $skn ] = empty($retval['data']) ? false : $retval['data'];
});
}
// @todo 需要根据页面结构封装返回数据
}
} while (false);
... ... @@ -151,63 +151,8 @@ class PlusstarData
return $result;
// @todo 根据页面展示数据封装
// $url = '';
// if($uid > 0){
// $isLike = Favorite::getUidProductFav($uid, $new_goods_info['product_skn']);
// }
// if($client_type == 'web'){
// $baseUrl = QUtilsConfig::$websiteRoot['yohobuy'];
// }else{
// $baseUrl = QUtilsConfig::$websiteRoot['h5'];
// }
// $goods_url = MakeUrl::h5ProductDetailUrl($baseUrl,$new_goods_info['product_id'],$new_goods_info['goods_list'][0]['goods_id'],$new_goods_info['cn_alphabet']);
// $url = MakeUrl::makeUrl('go.productDetail',$goods_url, array('product_skn'=>$new_goods_info['product_skn']),$client_type);
// if((int)$new_goods_info['market_price'] == (int)$new_goods_info['sales_price'])
// {
// $new_goods_info['market_price'] = '';
// }
// $tags = array(
// 'isNew' => false,
// 'isSale' => false,
// 'isLimit' => false,
// 'isYohood' => false,
// 'midYear' => false,
// 'yearEnd' => false,
// );
// foreach ($new_goods_info['tags'] as $v){
// if($v == 'is_new'){
// $tags['isNew'] = true;
// }elseif($v == 'is_discount'){
// $tags['isSale'] = true;
// }elseif($v == 'is_limited'){
// $tags['isLimit'] = true;
// }elseif($v == 'is_yohood'){
// $tags['isYohood'] = true;
// }elseif($v == 'mid-year'){
// $tags['midYear'] = true;
// }elseif($v == 'year-end'){
// $tags['yearEnd'] = true;
// }
// }
// $newPatterns[$new_goods_info['product_skn']]= array (
// 'id'=>$new_goods_info['product_skn'],
// 'product_id'=>$new_goods_info['product_id'],
// 'product_skn'=>$new_goods_info['product_skn'],
// 'thumb' => $new_goods_info['default_images'],
// 'name' => $new_goods_info['product_name'],
// 'isLike' => $isLike,
// 'price' => $new_goods_info['market_price'],
// 'salePrice' => $new_goods_info['sales_price'],
// 'isSale' => $new_goods_info['is_discount'] == 'Y' ? true : false,
// 'isFew' => $new_goods_info['is_soon_sold_out'] == 'Y' ? true : false,
// 'isNew' => $new_goods_info['is_new'] == 'Y' ? true : false,
// 'url' => $url,
// 'tags' => $tags
// );
}
}
... ...
... ... @@ -17,4 +17,36 @@ use Api\Yohobuy;
class LoginData
{
/**
* 登录
*
* @param string $profile 邮箱或手机号
* @param string $password 密码
* @return array
*/
public static function signin($profile, $password)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.signin';
$param['profile'] = $profile;
$param['password'] = $password;
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 用户信息
*
* @param int $uid 用户唯一ID
* @return array
*/
public static function profile($uid)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.profile';
$param['uid'] = $uid;
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -82,8 +82,8 @@ class RegData
$param = Yohobuy::param();
$param['method'] = 'app.passport.register';
$param['area'] = $area;
$param['mobile'] = $mobile;
$param['profile'] = $password;
$param['profile'] = $mobile;
$param['password'] = $password;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
... ...
... ... @@ -22,15 +22,55 @@ class Helpers
}
/**
* 从数组中中获取指定键值对应的元素
* @param array $array 需要获取的数组
* @param array|string $keys 指定键值,数组或者字符串
* @return array 获取的数据
* 格式化商品信息
*
* @param array $productData 需要格式化的商品数据
* @return array | false
*/
/*public static function array_get($array, $keys)
public static function formatProduct($productData)
{
return array_intersect_key($array, array_flip((array) $keys));
// 商品信息有问题,则不显示
if (!isset($productData['product_skn'])) {
return false;
}
// 市场价和售价一样,则不显示市场价
if (intval($productData['market_price']) === intval($productData['sales_price'])) {
$productData['market_price'] = '';
}
$result = array();
$result['id'] = $productData['product_skn'];
$result['product_id'] = $productData['product_id'];
$result['thumb'] = $productData['default_images'];
$result['name'] = $productData['product_name'];
$result['price'] = $productData['market_price'];
$result['salePrice'] = $productData['sales_price'];
$result['isFew'] = ($productData['is_soon_sold_out'] === 'Y') ? true : false;
$result['url'] = ''; // @todo
$result['tags'] = array(
'isNew' => false, // 新品
'isSale' => false, // 在售
'isLimit' => false, // 限量
'isNewFestival' => false, // 新品节
'isReNew' => false, // 再到着
'isYohood' => false, // YOHOOD
'midYear' => false, // 年中
'yearEnd' => false, // 年末
);
foreach ($productData['tags'] as $tag) {
if ($tag['is_limited'] === 'Y') {
$result['tags']['isLimit'] = true;
} elseif ($tag['is_yohood'] === 'Y') {
$result['tags']['isYohood'] = true;
} elseif ($tag['is_new'] === 'Y') {
$result['tags']['isNew'] = true;
}
}
return $result;
}
*/
}
\ No newline at end of file
... ...
... ... @@ -32,7 +32,7 @@ class TemplateLayout implements View_Interface
*/
public function assign($name, $value = null)
{
$this->tpl_vars[$name] = $value;
$this->_tpl_vars[$name] = $value;
}
/**
... ... @@ -43,10 +43,10 @@ class TemplateLayout implements View_Interface
*/
public function clear($name = null)
{
if (isset($this->tpl_vars[$name])) {
unset($this->tpl_vars[$name]);
if (isset($this->_tpl_vars[$name])) {
unset($this->_tpl_vars[$name]);
} else {
$this->tpl_vars = array();
$this->_tpl_vars = array();
}
}
... ...
... ... @@ -94,12 +94,46 @@ class PlusstarController extends AbstractAction
*/
public function detailAction()
{
$data = array();
$id = $this->get('id');
$gender = $this->get('gender', '1,3');
$uid = 0; // @todo
$udid = null; // @todo
do {
/* 判断参数是否有效 */
if (!is_numeric($id) || ($gender !== '1,3' && $gender !== '2,3')) {
break;
}
/* 判断品牌信息是否为空 */
$brandInfo = PlusstarData::brandInfo($id, $gender, $uid, $udid); var_dump($brandInfo); exit;
if (empty($brandInfo['getBrandInfo']['brand_id'])) {
break;
}
$data['id'] = $brandInfo['getBrandInfo']['brand_id'];
$data['banner'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['cover_img'], 640, 309);
$data['logo'] = Helpers::getImageUrl($brandInfo['getBrandInfo']['brand_ico'], 160, 160);
$data['name'] = $brandInfo['getBrandInfo']['name'];
$data['isLike'] = $brandInfo['getUidBrandFav'];
$data['likeUrl'] = "http://guang.m.yohobuy.com/plustar/brandinfo?id=285&openby:yohobuy={"action":"go.weblogin","params":{"jumpurl":{"url":"http:\/\/guang.m.yohobuy.com\/plustar\/brandinfo","param":{"id":285}},"requesturl":{"url":"\/guang\/api\/v1\/favorite\/togglebrand","param":{"brand_id":"701"}},"priority":"Y"}}";
$data['intro'] = empty($brandInfo['brand_intro']) ? '' : strip_tags($brandInfo['brand_intro']);
$data['newArrival'] = array();
$data['newArrival']['moreUrl'] = ''; // @todo
$data['newArrival']['naList'] = $brandInfo['getNewProduct'];
$data['infos'] = array();
$brandInfo = array();
} while (false);
$test = PlusstarData::brandInfo(67, '1,3', 123456);
var_dump($test);
if (array() === $data) {
$this->error();
} else {
$this->_view->display('detail', $data);
}
}
}
... ...