Authored by 梁志锋

Merge branch 'develop' of http://git.dev.yoho.cn/web/yohobuy into develop

... ... @@ -25,7 +25,7 @@ class LoginData extends \LibModels\Wap\Passport\LoginData
* @param string $shoppingKey 未登录用户唯一识别码, 默认为空
* @return array 登录返回结果
*/
public static function signinByOpenID($nickname, $openId, $sourceType, $shoppingKey = null)
public static function signinByOpenID($nickname, $openId, $sourceType, $shoppingKey = null, $replaceId = '')
{
// 构建必传参数
$param = Yohobuy::param();
... ... @@ -35,13 +35,18 @@ class LoginData extends \LibModels\Wap\Passport\LoginData
$param['openId'] = $openId;
$param['source_type'] = $sourceType;
$param['nickname'] = $nickname;
//wechat传入replace_id
if (!empty($replaceId)) {
$param['replace_id'] = $replaceId;
}
//购物车
if (!empty($shoppingKey)) {
$param['shopping_key'] = $shoppingKey;
}
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::get(Yohobuy::API_URL2, $param);
}
}
... ...
<?php
namespace Plugin\Partner\wechat;
use Plugin\Partner\Factory;
define('WECHAT_CLASS_PATH', dirname(__FILE__) . '/class/');
require WECHAT_CLASS_PATH . 'Wechat.class.php';
/**
* 微信的调用接口
*
* @name Call
* @package lib/partner/wechat
* @copyright yoho.inc
* @version 5.0 (2016-01-12 10:54:54)
* @author xiaowei <xiaowei.gong@yoho.cn>
*/
class Call extends Factory
{
//微信对象
protected $wechat;
/**
* 初始化
*/
protected function init()
{
$this->wechat = new \WechatAuth($this->apiConfig['appId'], $this->apiConfig['appKey']);
}
/**
* 获取授权URL
*
* @return string
*/
public function getAuthorizeUrl()
{
return $this->wechat->getAuthorizeURL($this->apiConfig['callback'], $this->apiConfig['scope']);
}
/**
* 获取授权的TOKEN
*
* @return array
*/
public function getAccessToken()
{
$token = array();
if (isset($_REQUEST['code']) && !empty($_REQUEST['code'])) {
try {
$token = $this->wechat->getAccessToken($_REQUEST['code']);
}
catch (Exception $e) {
// do nothing
}
}
return $token;
}
/**
* 获取当前用户的基本资料
*
* @param object $token 授权成功的TOKEN, 默认为NULL
* @return array
*/
public function getUserInfo($token)
{
$userInfo = array();
if (!empty($token)) {
$userInfo = $this->wechat->getUserInfo($token['access_token'], $token['openid']);
}
return $userInfo;
}
public function getFriends($token, $params)
{
}
public function syncShare($token, $content, $image, $link)
{
}
}
... ...
<?php
defined('SITE_MAIN') || define('SITE_MAIN', $_SERVER['HTTP_HOST']);
return array(
'appId' => 'wx3ae21dcbb82ad672',
'appKey' => 'e78afb2321e6a19085767e1a0f0d52c1',
'callback' => SITE_MAIN . '/passport/autosign/wechatback',
'scope' => 'snsapi_login'
);
... ...
<?php
/**
* @ignore
*/
class OAuthException extends Exception
{
// pass
}
class WechatAuth
{
/**
* @ignore
*/
public $appId;
/**
* @ignore
*/
public $appKey;
/**
* @ignore
*/
public $accessToken;
/**
* @ignore
*/
public $refreshToken;
/**
* Set API URLS
*/
/**
* @ignore
*/
function userInfoURL()
{
return 'https://api.weixin.qq.com/sns/userinfo';
}
/**
* @ignore
*/
function authorizeURL()
{
return 'https://open.weixin.qq.com/connect/qrconnect';
}
/**
* @ignore
*/
function accessTokenURL()
{
return 'https://api.weixin.qq.com/sns/oauth2/access_token';
}
/**
* construct WeichatOAuth object
*/
function __construct($appId, $appKey, $accessToken = NULL)
{
$this->appId = $appId;
$this->appKey = $appKey;
$this->accessToken = $accessToken;
}
/**
* authorize接口
* $callBackurl 回调地址
*/
function getAuthorizeURL($callBackurl, $scope, $responseType = 'code', $state = 'STATE#wechat_redirect')
{
$params = array();
$params['appid'] = $this->appId;
$params['redirect_uri'] = $callBackurl;
$params['response_type'] = $responseType;
$params['scope'] = $scope;
$params['state'] = $state;
return $this->authorizeURL() . "?" . http_build_query($params);
}
/*
* 获取accesstoken
* code:授权链接返回的code
*/
function getAccessToken($code, $grant_type = 'authorization_code')
{
if (empty($code)) {
return '';
}
$params = array();
$params['appid'] = $this->appId;
$params['secret'] = $this->appKey;
$params['code'] = $code;
$params['grant_type'] = $grant_type;
$url = $this->accessTokenURL() . "?" . http_build_query($params);
$result = self::getCurl($url);
return json_decode($result, true);
}
// 获取用户信息
function getUserInfo($access_token, $openid)
{
if (empty($access_token) || empty($openid)) {
return array();
}
$params = array();
$params['access_token'] = $access_token;
$params['openid'] = $openid;
$url = $this->userInfoURL() . "?" . http_build_query($params);
$result = self::getCurl($url);
return json_decode($result, true);
}
/**
* Send a GET requst using cURL
* @param string $url to request
* @param array $get values to send
* @param array $options for cURL
* @return string
*/
public static function getCurl($url,$method="GET")
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
}
... ...
{{> layout/header}}
<div class="brand-page brand-search-page yoho-page">
<div class="newbrand-search">
<form class="search-box clearfix">
<input type="text" class="search-input" id="keyword" placeholder="查找品牌">
<form class="search-box clearfix">
<input type="text" class="search-input" id="keyword" placeholder="查找品牌" autofocus>
<i class="search-icon iconfont">&#xe60f;</i>
<div class="search-action">
<span class="iconfont clear-text">&#xe623;</span>
... ...
{{> layout/header}}
<div class="product-search-page product-page yoho-page center-content">
{{# search}}
{{> layout/path-nav}}
{{> product/standard-content}}
{{> product/latest-walk}}
{{/ search}}
</div>
{{> layout/footer}}
\ No newline at end of file
{{> layout/header}}
<div class="product-search-page product-page yoho-page center-content">
{{# search}}
{{> layout/path-nav}}
{{# shopEntry}}
<div class="shop-entry clearfix">
<a class="pull-left" href="{{home}}">
<img class="logo" src="{{logo}}">
</a>
<div class="name pull-left">
<a class="shop-name" href="{{home}}">{{shopName}}</a>
<p class="sorts">
{{#each sort}}
<a href="{{href}}">{{name}}</a>
{{#unless @last}}
/
{{/unless}}
{{/each}}
</p>
</div>
<a class="entry-btn pull-right" href="{{home}}">
进入品牌店铺
<span class="iconfont">&#xe601;</span>
</a>
</div>
{{/ shopEntry}}
{{> product/standard-content}}
{{> product/latest-walk}}
{{/ search}}
</div>
{{> layout/footer}}
\ No newline at end of file
{{> layout/header}}
<div class="new-sale-page product-page yoho-page">
{{# newSale}}
{{# saleBanner}}
<div class="banner-img" style="height: {{bannerHeight}}px;background:url({{img}}) no-repeat top center;"></div>
{{/ saleBanner}}
<div class="center-content clearfix">
{{> layout/path-nav}}
{{# saleTitle}}
<div class="header-title">
{{name}}
<p class="line-through"></p>
<p class="count-wrap">
<span class="count">共{{count}}个结果</span>
</p>
</div>
{{/ saleTitle}}
<div class="list-left pull-left">
{{> product/left-content}}
</div>
<div class="list-right pull-right">
{{# newMain}}
<div class="new-banner">
<a href="{{bannerHref}}">
<img src="{{banner}}">
</a>
</div>
<div class="new-brands clearfix">
<span class="iconfont pre">&#xe607;</span>
<div class="brands-wrap">
<ul class="brands">
{{# brands}}
<li>
<a href="{{href}}">
<img src="{{logo}}">
</a>
</li>
{{/ brands}}
</ul>
</div>
<span class="iconfont next">&#xe608;</span>
</div>
<div class="new-floor-title">
<span class="date">{{date}}</span>
<span class="title">{{title}}</span>
</div>
{{/ newMain}}
{{> product/standard-content}}
</div>
</div>
{{/ newSale}}
</div>
{{> layout/footer}}
\ No newline at end of file
... ...
... ... @@ -136,7 +136,7 @@ function picCaptchaAjaxFn(page, callback) {
type: 'POST',
url: url,
data: {
code: $ca.val()
verifyCode: $ca.val()
//mobile: $pn.val(),
//area: $region.text().split('+')[1]
... ... @@ -169,7 +169,7 @@ function msgCaptchaAjaxFn(page, callback) {
type: 'POST',
url: url,
data: {
code: $ca.val(),
verifyCode: $ca.val(),
mobile: $pn.val(),
area: $region.text().split('+')[1]
}
... ... @@ -465,7 +465,7 @@ exports.init = function(page) {
$regionSelect.change(function() {
$region.text('+' + $('#region').val());
$region.text($('#region').val());
validateRule(page, $pn, showErrTip); //验证
});
... ... @@ -493,7 +493,7 @@ exports.init = function(page) {
data: {
area: $region.text().split('+')[1],
mobile: $pn.val(),
code: $ca.val()
verifyCode: $ca.val()
}
}).then(function(data) {
if (data.code === 200) {
... ...
... ... @@ -259,9 +259,12 @@ if ($udPrice.length > 0) {
//【高级选项】鼠标移入显示子项
$seniorAttrWrap.on('mouseenter', '.attr', function() {
var index = $(this).addClass('hover').index();
var $this = $(this);
var index = $this.index();
$this.addClass('hover').siblings().removeClass('hover');
$seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide');
$seniorSubWrap.children('.senior-sub:eq(' + index + ')').removeClass('hide').siblings().addClass('hide');
}).on('mouseleave', '.attr', function() {
var $this = $(this),
index = $this.index();
... ... @@ -296,4 +299,4 @@ $('.senior-sub').on('click', '.multi-select', function() {
clearTimeout(seniorHoverTime);
}).on('mouseleave', function() {
hideSeniorPanel();
});
\ No newline at end of file
});
... ...
... ... @@ -265,6 +265,7 @@
top: 39px;
background: #fff;
border: 1px solid #eaeceb;
z-index: 1;
ul {
max-width: 950px;
... ...
... ... @@ -5,16 +5,17 @@
*/
.product-search-page {
@import "shop-entry";
.goods-container {
height: auto;
padding: 25px 0 0 0;
position: relative;
width: 1150px + 10px;//每列增加右边距
}
@import "shop-entry";
.good-info {
width: 222px;
}
}
}
... ...
... ... @@ -70,16 +70,13 @@ class Bootstrap extends Bootstrap_Abstract
$module = 'Index';
$controller = 'Index';
$action = 'Index';
// 级域名
// 级域名
if (2 === $level) {
$subDomain = strval($hostParts[0]);
switch (strtolower($subDomain)) {
case 'm': // 老版(到频道选择)
case 'buy': // 测试环境的域名, 以后可去掉
case 'login': // 登录
break;
case 'new': // 原新版(到男生首页)
$controller = 'Boys';
case 'www': // 主站
case 'new': // 原新版
case 'dev': // 开发环境
break;
case 'search': // 搜索
$controller = 'Search';
... ... @@ -89,11 +86,13 @@ class Bootstrap extends Bootstrap_Abstract
$module = 'Guang';
break;
case 'list': // 商品列表
case 'item': // 商品详情
$module = 'Product';
break;
case 'cart': // 购物车
$module = 'Cart';
case 'sale'://促销
$module = 'Product';
$controller = 'sale';
$saleRequest = new Yaf\Request\Http('/product/sale/index');
$dispatcher->setRequest($saleRequest);
break;
default: // 其它(识别为品牌)
$module = 'Product';
... ...
... ... @@ -230,12 +230,14 @@ class HomeModel
$sortList = ChannelConfig::$newArrivalSortList[$channel];
// 获取分类列表获取商品信息
$goodsList = SearchData::getSearchDataBySort($params, $sortList);
$pos = 1;
foreach ($goodsList as $goods) {
// 格式化数据
$val = Helpers::formatProduct($goods, true, true, true, 280, 373);
if ($val['price'] == false) {
$val['price'] = $val['salePrice'];
}
$val['url'] = sprintf('%s?channel=%s&from=%s-n_%s', $val['url'], $channel , $channel, $pos++);
//TODO 字段要调整
$val['isFew'] = $val['is_soon_sold_out'];
$val['tags']['isLimit'] = $val['tags']['is_limited'];
... ...
<?php
namespace Product;
use LibModels\Wap\Product\SearchData;
use LibModels\Web\Product\SearchData as WebProduct;
use Plugin\HelperSearch;
use \LibModels\Web\Product\SearchData as Search;
use Plugin\Images;
/**
* sale首页模板数据模型
*
*/
class NewModel
{
public static function getNewSearchData($params, $options)
{
$data = array();
// 调用接口查询商品数据
$result = SearchData::searchElasticByCondition($params);
if (isset($result['code']) && $result['code'] === 200) {
// 调用分类信息
$category = Search::getClassesData();
if (isset($category['code']) && $category['code'] === 200) {
$result['data']['filter']['group_sort'] = $category['data']['sort'];
}
// 调用折扣区间
$discount = Search::getDiscount();
if (isset($discount['code']) && $discount['code'] === 200) {
$result['data']['filter']['discount'] = $discount['data']['discount'];
}
// 调用最新上架
$recent = Search::recentShelve();
if (isset($discount['code']) && $discount['code'] === 200) {
$result['data']['filter']['recent'] = $recent['data']['recent'];
}
//用户浏览记录
$result['data']['filter']['review'] = Search::getRecentReview();
// 组织模板数据
$data = HelperSearch::getList($result, $options);
//new页面模拟数据
$data['newMain'] = array(
'banner' => 'http://img11.static.yhbimg.com/yhb-img01/2015/11/23/07/010a459d41b99a839cba9377532f1c19b2.jpg?imageView/3/w/970/h/200',
'date' => '12月16日',
'title' => '新品到着',
'brands' => array(
array(
'href' => '',
'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/02/28/15/02b2b5ded161ab31e2e097a327ed475052.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/11/09/09/023721f44182f775d79904010af421331e.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img11.static.yhbimg.com/brandLogo/2012/12/13/17/01408fb72646c8f3fa59d870514f08a356.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img13.static.yhbimg.com/brandLogo/2012/12/24/13/0265b45e37af697c5ba12d5415fb341f27.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img11.static.yhbimg.com/brandLogo/2015/08/11/15/012d09a5cae187af1f6f3ed246b9b5a4fc.jpg?imageView/2/w/170/h/120'
),
array(
'href' => '',
'logo' => 'http://img11.static.yhbimg.com/brandLogo/2015/08/20/16/01047ffb3ca182871821d551af31ac2378.jpg?imageView/2/w/170/h/120'
)
)
);
}
return array(
'productListPage' => true,
'newSale' => $data
);
}
}
... ...
... ... @@ -32,7 +32,7 @@ class SearchModel
$result = SearchData::searchElasticByCondition($condition);
if (isset($result['code']) && $result['code'] === 200) {
// 调用分类信息
$category = SearchData::getClassesData();
$category = SearchData::getClassesData($condition);
if (isset($category['code']) && $category['code'] === 200) {
$result['data']['filter']['group_sort'] = $category['data']['sort'];
}
... ...
... ... @@ -2,7 +2,6 @@
use Action\AbstractAction;
use LibModels\Web\Passport\LoginData;
use Passport\PassportModel as PassportModel;
use Plugin\Helpers;
use Plugin\Partner\Factory;
... ... @@ -62,13 +61,14 @@ class AutosignController extends AbstractAction
$this->go(Factory::create('douban')->getAuthorizeUrl());
}
/**
/**
* 微信网站授权入口
*/
public function wechatAction(){
$url = QINWechat_Sdk_Open::getCode('http://www.yohobuy.com/passport/autosign/wechatback');
$this->helpGo($url);
public function wechatAction()
{
$this->setSession('_TOKEN', '');
$this->go(Factory::create('wechat')->getAuthorizeUrl());
}
/**
... ... @@ -88,7 +88,12 @@ class AutosignController extends AbstractAction
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/bind/index', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $userId, 'sourceType' => 'alipay', 'nickname' => $realName)));
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
}
$refer = $this->getCookie('refer');
... ... @@ -126,11 +131,6 @@ class AutosignController extends AbstractAction
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['openid'], 'qq', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$this->go(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
... ... @@ -139,6 +139,16 @@ class AutosignController extends AbstractAction
$refer = rawurldecode($refer);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['openid'], 'sourceType' => 'qq', 'nickname' => $partnerInfo['nickname'])));
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
... ... @@ -169,7 +179,12 @@ class AutosignController extends AbstractAction
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
}
$refer = $this->getCookie('refer');
... ... @@ -199,18 +214,21 @@ class AutosignController extends AbstractAction
{
$renren = Factory::create('renren');
$access = $renren->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $renren->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
if ($access && is_array($access)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'renren', $shoppingKey);
$result = LoginData::signinByOpenID($access['user']['name'], $access['user']['id'], 'renren', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['nick_name'])));
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$fillHerf = rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['user']['id'], 'sourceType' => 'renren', 'nickname' => $access['user']['name'])));
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
}
$refer = $this->getCookie('refer');
... ... @@ -238,20 +256,25 @@ class AutosignController extends AbstractAction
*/
public function doubanbackAction()
{
$sina = Factory::create('douban');
$access = $sina->getAccessToken();
$douban = Factory::create('douban');
$access = $douban->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $sina->getUserInfo($access);
$partnerInfo = $douban->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'], $access['uid'], 'douban', $shoppingKey);
$result = LoginData::signinByOpenID($partnerInfo['name'], $partnerInfo['uid'], 'douban', $shoppingKey);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
// $this->go(Helpers::url('/passport/bind/index', array('openId' => $access['uid'], 'sourceType' => 'sina', 'nickname' => $partnerInfo['screen_name'])));
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$fillHerf =rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $access['douban_user_id'], 'sourceType' => 'douban', 'nickname' => $partnerInfo['name'])));
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
}
$refer = $this->getCookie('refer');
... ... @@ -273,52 +296,51 @@ class AutosignController extends AbstractAction
$this->go($refer);
}
}
/**
* 微信网站授权获取用户信息并登录
* @param string code
*/
public function wechatbackAction(){
$code = $this->helpGquery('code');
$accessToken = QINWechat_Sdk_Open::getAccessToken($code);
$userInfo = array();
if(empty($accessToken)){
$this->helpGo('/signin.html');
}
if(!isset($accessToken['access_token']) || !isset($accessToken['unionid']) || empty($accessToken['access_token']) || empty($accessToken['unionid'])){
$this->helpGo('/signin.html');
}
$userInfo = QINWechat_Sdk_Open::getUserInfo($accessToken['access_token'], $accessToken['unionid']);
if(empty($userInfo)){
$this->helpGo('/signin.html');
}
$this->wechatlogin($userInfo);
}
/**
* 微信登录
* @param array $userInfo
*/
public function wechatlogin($userInfo){
if(empty($userInfo)){
$this->helpGo('/signin.html');
}
try {
$oauthUserInfo = QINAuth_User_Utils::check('wechat', $userInfo['unionid'], $userInfo['nickname'], null, $userInfo);
$auth = QINAuth_Factory::profile('wechat');
$res=$auth->associate($oauthUserInfo['email'], array(
'password' => QINAuth_User_Utils::$defaultPassword,
'open_id' => $userInfo['unionid'],
'nick_name' => $userInfo['nickname']
));
} catch (Exception $e) {
$this->helpSession('passport_space')->__set('error_message', 'wechat' . $e->getMessage());
$this->helpGo('/signin.html');
}
//跳转到
$url = $this->authInfo($res, 'wechat' , $oauthUserInfo['email']);
$this->helpGo($url);
}
public function wechatbackAction()
{
$wechat = Factory::create('wechat');
$access = $wechat->getAccessToken();
/* 获取用户的详细信息 */
$partnerInfo = $wechat->getUserInfo($access);
$result = array();
if ($partnerInfo && is_array($partnerInfo)) {
$shoppingKey = Helpers::getShoppingKeyByCookie();
$result = LoginData::signinByOpenID($partnerInfo['nickname'],$partnerInfo['openid'], 'wechat', $shoppingKey,$partnerInfo['openid']);
}
//判定是否需要绑定手机号
if (isset($result['data']['mobile']) && $result['data']['mobile'] == '') {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$fillHerf =rawurlencode(Helpers::url('/passport/autouserinfo/userinfo', array('openId' => $partnerInfo['openid'], 'sourceType' => 'wechat', 'nickname' => $partnerInfo['nickname'])));
$this->go(Helpers::syncUserSession($result['data']['uid'], $fillHerf));
}
$refer = $this->getCookie('refer');
if (empty($refer)) {
$refer = SITE_MAIN . '/?go=1';
}
else {
$refer = rawurldecode($refer);
}
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data']['uid'])) {
$token = Helpers::makeToken($result['data']['uid']);
$this->setSession('_TOKEN', $token);
$this->setSession('_LOGIN_UID', $result['data']['uid']);
$this->setCookie('_TOKEN', $token);
$this->go(Helpers::syncUserSession($result['data']['uid'], $refer));
}
else {
$this->go($refer);
}
}
}
... ...
... ... @@ -61,15 +61,15 @@ class IndexController extends WebAction
//每页显示商品数
if(!isset($condition['viewNum']) || empty($condition['viewNum'])){
$condition['viewNum'] = 59;
$condition['viewNum'] =60;
}
$view_num_arr = array(60, 100, 200);
if (!in_array($condition['viewNum'], $view_num_arr)) {
$condition['viewNum'] = 59;
$condition['viewNum'] = 60;
}
//每行显示的商品数量
if(!isset($condition['rowNum']) || empty($condition['rowNum'])){
$condition['rowNum'] = 5;
$condition['rowNum'] =5;
}
if ($condition['rowNum'] == 6) {
$imgSize = array(195, 260);
... ... @@ -88,11 +88,13 @@ class IndexController extends WebAction
'gender' => $gender,
'needPd' => 'Y',
'rowNum' => $condition['rowNum'],
'viewNum' => $condition['viewNum'] - 1,
'viewNum' => $condition['viewNum'],
);
$params = $condition + $_GET;
$params = array_filter($params);
//每页记录数减1,下一页占位
$params['viewNum'] = $params['viewNum'] - 1;
$data = Product\BrandsModel::getBrandSearchData($params,$options,$domain,$uid,$brandId,$node);
$cate = array('boys','girls','kids','lifestyle');
$this->setWebNavHeader($cate[$gender-1]);
... ...
... ... @@ -73,11 +73,11 @@ class SaleController extends WebAction
//每页显示商品数
if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {
$condition['viewNum'] = 59;
$condition['viewNum'] = 60;
}
$view_num_arr = array(60, 100, 200);
if (!in_array($condition['viewNum'], $view_num_arr)) {
$condition['viewNum'] = 59;
$condition['viewNum'] = 60;
}
//每行显示的商品数量
if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {
... ... @@ -100,13 +100,15 @@ class SaleController extends WebAction
'gender' => $gender,
'needPd' => 'Y',
'rowNum' => $condition['rowNum'],
'viewNum' => $condition['viewNum'] - 1,
'viewNum' => $condition['viewNum'],
'specialsale_id' => 'Y'
);
$params = $condition + $_GET;
$params['attribute_not'] = 2;
$params = array_filter($params);
//每页记录数减1,下一页占位
$params['viewNum'] = $params['viewNum'] - 1;
$data = Product\SaleModel::getSaleSearchData($params, $options, $specialInfo);
$cate = array('boys', 'girls', 'kids', 'lifestyle');
... ...
... ... @@ -60,7 +60,7 @@ class SearchController extends WebAction
if (!$price[0]) {
$price[0] = 0;
}
if ($price[1]) {
if (!$price[1]) {
$price[1] = 99999;
}
$condition['price'] = implode(',', $price);
... ...
<?php
use Action\WebAction;
use LibModels\Web\Product\SaleData;
/**
* new页
*
*/
class NewController extends WebAction
{
public function indexAction()
{
/* 过滤请求参数 */
$condition = array();
$condition = filter_input_array(INPUT_GET, array(
//'query' => FILTER_SANITIZE_STRING,
'sort' => FILTER_VALIDATE_INT,
'msort' => FILTER_VALIDATE_INT,
'misort' => FILTER_VALIDATE_INT,
'color' => FILTER_VALIDATE_INT,
'size' => FILTER_VALIDATE_INT,
'style' => FILTER_DEFAULT,
'price' => FILTER_DEFAULT,
'gender' => FILTER_DEFAULT,
'p_d' => FILTER_DEFAULT,
'shelve_time' => FILTER_DEFAULT,
'isNew' => FILTER_DEFAULT,
'specialoffer' => FILTER_DEFAULT,
'limited' => FILTER_DEFAULT,
'order' => FILTER_DEFAULT,
'viewNum' => FILTER_VALIDATE_INT,
'rowNum' => FILTER_VALIDATE_INT,
'page' => FILTER_VALIDATE_INT,), false);
//字符转码
if (!empty($condition)) {
foreach ($condition as &$value) {
$value = rawurldecode($value);
}
}
//获取性别数据
$gender = $this->get('gender') ? ($this->get('gender') == '2,3' ? 2 : 1) : (!isset($_COOKIE['_Gender']) ? '3' : ($_COOKIE['_Gender'] == '2,3' ? 2 : 1));
$condition['gender'] = $gender;
//每页显示商品数
if (!isset($condition['viewNum']) || empty($condition['viewNum'])) {
$condition['viewNum'] = 60;
}
$view_num_arr = array(60, 100, 200);
if (!in_array($condition['viewNum'], $view_num_arr)) {
$condition['viewNum'] = 60;
}
//每行显示的商品数量
if (!isset($condition['rowNum']) || empty($condition['rowNum'])) {
$condition['rowNum'] = 5;
}
if ($condition['rowNum'] == 6) {
$imgSize = array(195, 260);
$minImgSize = array(50, 67);
} else {
$condition['rowNum'] = 5;
$imgSize = array(235, 314);
$minImgSize = array(60, 80);
}
//搜索词
//$query = $this->get('query');
$condition['needFilter'] = 1;
$options = array(
'imgSize' => $imgSize,
'minImgSize' => $minImgSize,
'gender' => $gender,
'needPd' => 'Y',
'rowNum' => $condition['rowNum'],
'viewNum' => $condition['viewNum'],
'specialsale_id' => 'Y'
);
$params = $condition + $_GET;
$params['attribute_not'] = 2;
$params = array_filter($params);
//每页记录数减1,下一页占位
$params['viewNum'] = $params['viewNum'] - 1;
$data = Product\NewModel::getNewSearchData($params, $options);
$cate = array('boys', 'girls', 'kids', 'lifestyle');
$this->setWebNavHeader($cate[$gender - 1]);
//渲染模板
$this->_view->display('new-sale', $data);
}
}
... ...