Authored by Rock Zhang

Merge branch 'feature/wap323' into develop

Conflicts:
	library/LibModels/Wap/Product/DetailData.php
... ... @@ -31,3 +31,7 @@ script/nginx/logs/
compile/
nbproject/
web-static/npm-debug.log
.tags
.tags_sorted_by_file
yohobuyP.sublime-project
yohobuyP.sublime-workspace
\ No newline at end of file
... ...
... ... @@ -31,6 +31,7 @@ class Yohobuy
// /* 测试环境 */
// const API_URL = 'http://testapi.yoho.cn:28078/';
// const API_URL = 'http://192.168.102.205:8080/gateway/'; // 先临时使用网关
// const SERVICE_URL = 'http://testservice.yoho.cn:28077/';
// const YOHOBUY_URL = 'http://www.yohobuy.com/';
// const API_OLD = 'http://test2.open.yohobuy.com/';
... ...
... ... @@ -58,4 +58,6 @@ class CacheConfig
const KEY_INDEX_BRANDS_LIST_DATA = 'key_index_brands_list_data';//频道brands数据
const KEY_CODE_YOHOCOIN_BANNER = 'key_code_yohocoin_banner';// 有货币banner数据
}
... ...
... ... @@ -198,11 +198,18 @@ class UserData
*/
public static function yohoCoinTotal($uid)
{
$param = Yohobuy::param();
/*$param = Yohobuy::param();
$param['method'] = 'app.yohocoin.total';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);*/
$param = Yohobuy::param();
$param['method'] = 'app.yoho.yohocoin';
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
... ...
... ... @@ -64,16 +64,22 @@ class DetailData
/**
* 咨询内容列表
*
* @param int $uid 用户ID
* @param int $productId 产品ID
* @param int $pageNum 页码数
* @param int $pageSize 每页显示个数
* @return array
*/
public static function consultList($productId, $pageNum, $pageSize)
public static function consultList($uid, $productId, $pageNum, $pageSize)
{
$param = Yohobuy::param();
$param['method'] = 'h5.consult.li';
$param['method'] = 'app.consult.li';
$param['product_id'] = $productId;
if (!empty($uid)) {
$param['uid'] = $uid;
}
$param['page'] = $pageNum;
$param['limit'] = $pageSize;
$param['client_secret'] = Sign::getSign($param);
... ... @@ -154,4 +160,40 @@ class DetailData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 咨询点赞
*
* @param int $uid 用户ID
* @param int $id 咨询ID
* @return array
*/
public static function upvoteConsult($uid, $id)
{
$param = Yohobuy::param();
$param['method'] = 'app.consult.like';
$param['id'] = $id;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 咨询有用
*
* @param int $uid 用户ID
* @param int $id 咨询ID
* @return array
*/
public static function usefulConsult($uid, $id)
{
$param = Yohobuy::param();
$param['method'] = 'app.consult.useful';
$param['id'] = $id;
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -208,7 +208,7 @@ class FloorProcess
foreach ($data['list'] as &$one) {
if (isset($one['url'])) {
$one['url'] = Helpers::getFilterUrl($one['url']);
isset(self::$channel[$type]) && $one['url'] .= '?gender=' . self::$channel[$type];
// isset(self::$channel[$type]) && $one['url'] .= '?gender=' . self::$channel[$type];
}
$one['img'] = Helpers::getImageUrl($one['src'], 158, 174);
unset($one['src']);
... ... @@ -273,7 +273,7 @@ class FloorProcess
isset(self::$channel[$type]) && $urlParam['gender'] = self::$channel[$type];
$value['more_url'] = Helpers::url('', $urlParam, 'guang');
}
if ($key == 'list') {
if ($key == 'list' && is_array($value)) {
foreach ($value as &$one) {
if (isset($one['url'])) {
$one['url'] = Helpers::getFilterUrl($one['url']);
... ... @@ -379,9 +379,6 @@ class FloorProcess
*/
private static function small_pic($data, $type)
{
// 按照以前业务操作,不显示
return array();
$result = array();
foreach ($data as &$one) {
... ... @@ -391,7 +388,9 @@ class FloorProcess
$one['img'] = Helpers::getImageUrl($one['src'], 98, 98);
unset($one['src']);
}
$result['small_pic'] = $data;
if (!empty($data)) {
$result['smallPic']['list'] = $data;
}
return $result;
}
... ...
... ... @@ -13,6 +13,7 @@ var swiper,
$fixTitleBar,
$brandList = $('.brand-list'),
$icon = $('.search-icon'),
$genderItem = $('.genderNav li'),
hotBrandsSwiper;
var searchH = $('.newbrand-search').outerHeight(),
... ... @@ -177,3 +178,11 @@ if ($('.brand-search-page').length) {
});
}
if ($genderItem.length > 0) {
$genderItem.on('touchstart', function() {
$('.genderNav ul .active').removeClass('active');
$(this).addClass('active');
window.location.search = 'channel=' + ($(this).data('id') + 1);
});
}
... ...
... ... @@ -193,4 +193,4 @@ exports.set = function(c) {
});
};
require('./maybe-like');
\ No newline at end of file
require('./maybe-like')();
... ...
... ... @@ -4,40 +4,45 @@
* @date: 2015/10/12
*/
var $ = require('jquery'),
module.exports = function(specificGender) {
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
tip = require('../plugin/tip'),
loading = require('../plugin/loading'),
lazyLoad = require('yoho.lazyload');
var navHammer,
var navHammer,
winH = $(window).height(),
$goodList = $('#goods-list'),
searching = false,
page = 0,
gender = null,
kidsType = $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
lifestyleType = $('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false,
num,
url;
var $curNav,
//The kidsType can be specified by the parameter. Add by @ZhaoBiao
var kidsType = specificGender === 'kids' || $('.mobile-wrap').hasClass('kids-wrap') ? true : false,
lifestyleType = specificGender === 'lifestyle' ||
$('.mobile-wrap').hasClass('lifestyle-wrap') ? true : false;
var $curNav,
index,
$navList = $('#maybe-like-nav');
//ajax url
if (kidsType) {
//ajax url
if (kidsType) {
url = '/product/recom/maylikekids';
} else if (lifestyleType) {
} else if (lifestyleType) {
url = '/product/recom/maylikelife';
} else {
gender = $('.mobile-wrap').hasClass('boys-wrap') ? '1,3' : '2,3',
} else {
gender = (specificGender === 'boys' || $('.mobile-wrap').hasClass('boys-wrap')) ?
'1,3' : '2,3',
url = '/product/recom/maylike?gender=' + gender;
}
}
$curNav = $navList.children('.focus');
$curNav = $navList.children('.focus');
if (lifestyleType) {
if (lifestyleType) {
navHammer = new Hammer($navList[0]);
navHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
... ... @@ -63,11 +68,11 @@ if (lifestyleType) {
$(document).trigger('scroll'); //Trigger lazyLoad
e.srcEvent.stopPropagation();
});
}
}
loading.init($('.maybe-like'));
loading.init($('.maybe-like'));
function search() {
function search() {
if (searching) {
return;
}
... ... @@ -131,19 +136,25 @@ function search() {
loading.hideLoadingMask();
}
});
}
}
$('.maybe-like p').on('touchstart', function(e) {
$('.maybe-like p').on('touchstart', function(e) {
search();
});
});
function scrollHandler() {
function scrollHandler() {
if ($(window).scrollTop() + winH >= $(document).height() - 200) {
search();
}
}
}
//srcoll to load more
$(window).scroll(function() {
// 优惠券页面直接加载你可能喜欢。add by @zhaobiao
if (specificGender) {
search();
}
//srcoll to load more
$(window).scroll(function() {
window.requestAnimationFrame(scrollHandler);
});
\ No newline at end of file
});
};
... ...
/**
* 新有货币界面
* @author: 赵彪<bill.zhao@yoho.cn>
* @date: 2015/12/30
*/
function getGender() {
return window.cookie('_Channel');
}
require('../home/maybe-like')(getGender());
... ...
... ... @@ -19,3 +19,4 @@ require('./logistic');
require('./pay');
require('./personal-details');
require('./currency');
require('./currency-new');
... ...
... ... @@ -9,11 +9,18 @@ var $ = require('jquery'),
var commentsNum,consultsNum;
var navtabEle = document.getElementById('nav-tab'),
var consultFooterEle = $('.consult-content-footer')[0],
consultFooterHammer = consultFooterEle && new Hammer(consultFooterEle),
navtabEle = document.getElementById('nav-tab'),
navtabHammer = navtabEle && new Hammer(navtabEle),
gotoConsultEle = document.getElementById('goto-consult'),
gotoConsultHammer = gotoConsultEle && new Hammer(gotoConsultEle);
gotoConsultHammer = gotoConsultEle && new Hammer(gotoConsultEle),
readmore = document.getElementById('readmore'),
readmoreHammer = readmore && new Hammer(readmore);
(function() {
... ... @@ -63,6 +70,12 @@ if (navtabHammer) {
});
}
if (consultFooterHammer) {
consultFooterHammer.on('tap', function() {
location.href = $(consultFooterEle).data('href');
});
}
if (gotoConsultHammer) {
gotoConsultHammer.on('tap', function() {
location.href = $(gotoConsultEle).find('a').attr('href');
... ... @@ -74,3 +87,16 @@ if ($('.goods-consults-page').length > 0) {
$('#yoho-header').css('position', 'fixed').css('top', '0');
}
if ($('.goods-consults-page').length > 0) {
$('#yoho-footer').css('border-top', '1px solid #e0e0e0');
}
if (readmoreHammer) {
readmoreHammer.on('tap', function() {
$('.readmore').hide();
$('.goods-consults .consult-item').show();
return false;
});
}
require('./fav');
... ...
/**
* 商品详情咨询页 --点赞和帮助功能
* @author: Lynnic
* @date: 2015/12/09
*/
var $ = require('jquery'),
Hammer = require('yoho.hammer'),
tip = require('../../plugin/tip');
var goodsConsultsEle = $('#goods-consults')[0],
goodsConsultsHammer = goodsConsultsEle && new Hammer(goodsConsultsEle);
function showCountPlus($el) {
var $count = $el.find('.animate-count');
$count.css('display', 'inline');
$count.animate({
opacity: 0.25,
fontSize: '0.7rem',
right: '-=5'
}, 300, function() {
$count.css('display', 'none');
});
}
if (goodsConsultsHammer) {
goodsConsultsHammer.on('tap', function(e) {
var $this = $(e.target).closest('li'),
id = $this.closest('.consult-item').data('id'),
count = $this.find('.count').html() - 0,
url;
if (!$this.hasClass('highlight')) {
if ($this.hasClass('fav')) {
url = '/product/detail/consultupvote';
} else if ($this.hasClass('useful')) {
url = '/product/detail/consultuseful';
}
$.ajax({
method: 'post',
url: url,
data: {
id: id
}
}).done(function(data) {
if (data.code === 200) {
showCountPlus($this);
$this.addClass('highlight');
$this.find('.count').html(count + 1);
} else if (data.code === 401) {
location.href = data.data;//未登录跳转登录页
}
}).fail(function(data) {
tip.show('网络断开连接了~');
});
}
});
}
... ...
.brand-page {
.re-pos-search {
top: 170rem / $pxConvertRem !important;
}
.genderNav {
display: block;
width: 100%;
height: 80rem / $pxConvertRem;
line-height: 80rem / $pxConvertRem;
overflow: hidden;
color: #aeaeae;
z-index: 3;
position: fixed;
top: 90rem / $pxConvertRem;
border-bottom: 1px solid #e1e1e1;
background-color: #fff;
ul{
width: 100%;
height: 90%;
overflow: hidden;
li{
width: 25%;
height: 100%;
overflow: hidden;
float: left;
text-align: center;
position: relative;
font-size: 28rem / $pxConvertRem;
i{
width: 100%;
height: 40%;
overflow: hidden;
display: block;
}
span:not(.split-border){
width: 100%;
height: auto;
overflow: hidden;
display: block;
//line-height: 40rem / $pxConvertRem;
}
.split-border {
display: inline-block;
width: 2px;
height: 1rem;
background-color: #e1e1e1;
position: absolute;
top: 30%;
right: 0;
}
}
li:last-child {
.split-border {
display: none;
}
}
li.active {
color: #444;
}
}
}
.newbrand-search {
width: 93.75%;
height: 60rem / $pxConvertRem;
... ...
@import "header-download", "banner-top","banner-center","banner-bottom", "side-nav", "floor-header", "hot-brands", "fine-brands", "creative-life", "plus-star", "maybe-like",
"icons-enter","trendsetter-collocation",
"trend-topics","goods-category","hot-brands", "hot-category", "home-header";
"trend-topics","goods-category","hot-brands", "hot-category", "home-header", "thumb-row";
.mobile-container{
width: 100%;
... ...
#thumb-row {
@include flexbox((
display: box,
box-pack: justify
), $version: 1);
@include flexbox((
display: flex,
justify-content: space-around
), $version: 3);
background-color: #f0f0f0;
text-align: center;
padding: 32rem/$pxConvertRem 14rem/$pxConvertRem 0;
.thumb-row-box {
display: inline-block;
width: 275rem/$pxConvertRem;
height: 160rem/$pxConvertRem;
border-radius: 4px;
background-size: 100%;
background-repeat: no-repeat;
background-position: center;
}
}
... ...
... ... @@ -55,6 +55,7 @@
height: pxToRem(120px);
background-color: #ffffff;
border-bottom: 1px solid $borderC;
z-index: 10;
i,
span,
a {
... ... @@ -73,12 +74,20 @@
.goods-consults {
margin-top: 5.25rem;
overflow: hidden;
.consult-item:nth-child(1) {
display: block;
}
.consult-item:nth-child(2) {
display: block;
}
.consult-item {
margin-top: pxToRem(30px);
padding: pxToRem(20px) pxToRem(28px);
background-color: #fff;
border-bottom: 1px solid $borderC;
border-top: 1px solid $borderC;
display:none;
.question {
font-size: pxToRem(24px);
color: $mainFontC;
... ... @@ -114,6 +123,84 @@
overflow: hidden;
}
}
.operation {
width: 120%;
height: pxToRem(60px);
line-height: pxToRem(80px);
position: relative;
right: 12%;
border-top: 1px solid #e0e0e0;
margin-top: pxToRem(20px);
li{
&.highlight{
color: $basicBtnC;
}
font-size:pxToRem(28px);
float:left;
width: 50%;
text-align: center;
color:$subFontC;
.iconfont{
display: inline-block;
padding-right: 5px;
font-size: inherit;
}
position: relative;
.animate-count {
display: none;
position: absolute;
top: 0;
font-size: pxToRem(20px);
z-index: 5;
}
i.count {
position: absolute;
}
}
li.fav {
.animate-count {
right: pxToRem(100px);
}
}
li.useful {
.animate-count {
right: pxToRem(88px);
}
}
}
}
}
.readmore{
display: block;
height: pxToRem(88px);
line-height: pxToRem(88px);
background-color: #fff;
text-align: center;
color: $subFontC;
margin-top: pxToRem(30px);
border-top: 1px solid $borderC;
border-bottom: 1px solid $borderC;
font-size: pxToRem(28px);
i{
font-size: inherit;
}
}
.faq-title{
height: pxToRem(88px);
line-height: pxToRem(88px);
text-align: center;
font-size: pxToRem(32px);
}
.goods-consults .faq-item{
@extend .consult-item;
margin-top: 0;
margin-bottom: pxToRem(30px);
.answer{
border-bottom: none;
}
}
// .gap-block {
... ... @@ -174,6 +261,9 @@
&.focus {
color: #000;
}
.comments-num {
display: none;
}
}
.comment-nav {
border-right: 1px solid #ccc;
... ...
... ... @@ -2,7 +2,18 @@
<div class="brand-page yoho-page">
{{# channel}}
<div class="newbrand-search">
<div class="genderNav">
<ul>
{{# channels}}
<li {{#if active}}class="active"{{/if}} data-id="{{@index}}">
<span>{{name}}</span>
<span class="split-border"></span>
</li>
{{/channels}}
</ul>
</div>
<div class="newbrand-search re-pos-search">
<div class="search-box clearfix">
<a href="{{searchUrl}}" >
<input type="text" class="search-input" placeholder="查找品牌" readonly="true">
... ...
{{> layout/header}}
<div class="yoho-coin-new-page yoho-page">
<div class="coin">
{{# yohoCoin}}
<p class="coin-num">
7876
{{coinNum}}
</p>
<p class="info">
<span class="dollar"></span>
YOHO
</p>
<a href="" class="more">查看明细</a>
<a href="/home/currencyDetail" class="more">查看明细</a>
{{#if notice}}
<div class="coin-tip">
<span class="icon">!</span>
您有300个YOHO币即将于20171231日过期,请尽快使用
{{notice}}
</div>
{{/if}}
{{/ yohoCoin}}
</div>
<div class="banner">
<a href="">
{{#banner}}
<a href="{{url}}">
{{!-- 演示图片 --}}
<img src="http://temp.im/640x200" alt="">
<img src="{{img}}" alt="img">
</a>
{{/banner}}
</div>
{{> home/maybe_like}}
... ...
... ... @@ -81,7 +81,7 @@
优惠券
<span class="iconfont num">{{coupon_num}} &#xe604;</span>
</a>
<a class="list-item" href="/home/currencyDetail">
<a class="list-item" href="/home/currency">
<span class="iconfont icon">&#xe635;</span>
YOHO
<span class="iconfont num">{{yoho_coin_num}} &#xe604;</span>
... ...
... ... @@ -8,7 +8,7 @@
{{# consults}}
<div class="goods-consults" id="goods-consults">
{{#list}}
<div class="consult-item">
<div class="consult-item" data-id="{{id}}">
<div class="question">
<span class="iconfont">&#xe639;</span>
<p>
... ... @@ -21,10 +21,57 @@
<span class="iconfont">&#xe63f;</span>
<p>{{answer}}</p>
</div>
<ul class="operation">
<li class="fav {{#if isLike}}highlight{{/if}}">
<i class="iconfont ">&#xe601;</i>
<i class="count">{{#if like}}{{like}}{{/if}}</i>
<span class="animate-count">+1</span>
</li>
<li class="useful {{#if isUseful}}highlight{{/if}}">
<i class="iconfont ">&#xe605;</i>
有用
<i class="count">{{#if useful}}{{useful}}{{/if}}</i>
<span class="animate-count">+1</span>
</li>
</ul>
</div>
{{/list}}
</div>
{{/ consults}}
{{#showReadMore}}
<a href="javascript:;" id="readmore" class="readmore tap-hightlight" >查看更多 <i class="iconfont">&#xe604;</i></a>
{{/showReadMore}}
{{#faq}}
<h1 class="faq-title">
常见问题
</h1>
{{/faq}}
{{#faq}}
<div class="goods-consults" style="margin-top:0">
{{#list}}
<div class="faq-item">
<div class="question">
<span class="iconfont">&#xe639;</span>
<p>
{{question}}
</p>
</div>
<div class="answer">
<span class="iconfont">&#xe63f;</span>
<p>{{answer}}</p>
</div>
</div>
{{/list}}
</div>
{{/faq}}
</div>
{{> layout/footer}}
... ...
... ... @@ -14,6 +14,11 @@
{{> home/banner}}
{{/ banner}}
{{! 两个小图}}
{{# smallPic}}
{{> home/thumb_row}}
{{/ smallPic}}
{{! 热门品类}}
{{# hotCategory}}
{{> home/hot_category}}
... ...
<div id="thumb-row">
{{# list}}
<a href="{{url}}">
<div class="thumb-row-box" style="background-image:url({{img}})"></div>
</a>
{{/ list}}
</div>
... ...
... ... @@ -334,3 +334,9 @@
seajs.use('js/me/currency');
</script>
{{/if}}
{{#if currencyPage}}
<script>
seajs.use('js/me/currency-new');
</script>
{{/if}}
... ...
... ... @@ -261,9 +261,12 @@ class HomeController extends AbstractAction
$this->setNavHeader('YOHO币', true, false);
$currency = UserModel::getYohoCoinData($this->_uid);
// banenr数据
$currency['banner'] = UserModel::getYohoCoinBanner();
$currency['pageFooter'] = true;
$currency['currencyPage'] = true;
$this->_view->display('currency', $currency);
$this->_view->display('currency-new', $currency);
}
/**
... ...
... ... @@ -38,6 +38,24 @@ class BrandModel
$result = array();
$brand = array();
// 设置品牌一览顶部频道导航
$channels = array(
array(
'name' => 'Boy'
),
array(
'name' => 'Girl'
),
array(
'name' => 'Kid'
),
array(
'name' => 'Lifestyle'
)
);
$channels[$channel-1]['active'] = true;
$result['channels'] = $channels;
/* 根据频道调用接口 */
switch (intval($channel)) {
case 1: // 男生
... ...
... ... @@ -3,6 +3,7 @@
namespace Index;
use Configs\CacheConfig;
use LibModels\Wap\Home\IndexData;
use LibModels\Wap\Home\UserData;
use Plugin\Cache;
use Plugin\Helpers;
... ... @@ -18,6 +19,7 @@ use Plugin\Images;
*/
class UserModel
{
const CODE_YOHOCOIN_BANNER = '05afedf76886d732573f10f7451a1703';
/**
* 处理用户个人详情数据
... ... @@ -358,14 +360,58 @@ class UserModel
*/
public static function getYohoCoinData($uid)
{
$result = array();
$result = array(
'yohoCoin' => array(
'coinNum' => 0
)
);
// 调用接口获取YOHO币
$yohoCoin = UserData::yohoCoinTotal($uid);
// 处理YOHO币数据
if (isset($yohoCoin['data']) && !empty($yohoCoin['data'])) {
$result['yohoCoin']['coinNum'] = $yohoCoin['data']['total'];
$result['yohoCoin']['coinNum'] = $yohoCoin['data']['yohocoin_num'];
$result['yohoCoin']['notice'] = $yohoCoin['data']['notice'];
}
return $result;
}
public static function getYohoCoinBanner()
{
$result = false;
if (USE_CACHE) {
// 先尝试获取一级缓存(master), 有数据则直接返回.
$result = Cache::get(CacheConfig::KEY_CODE_YOHOCOIN_BANNER, 'master');
if (!empty($result)) {
return $result;
}
}
// 调用接口获取数据
$banner = IndexData::getBannerStart(self::CODE_YOHOCOIN_BANNER);
if (isset($banner['code']) && $banner['code'] == 200 && !empty($banner['data'])) {
$result = array();
// 处理数据
foreach ($banner['data'] as $val) {
foreach ($val['data'] as $single) {
$result['url'] = '';
$result['img'] = Helpers::getImageUrl($single['src'], 640, 200);
}
}
}
if (USE_CACHE) {
// 接口调用异常时, 不害怕,从我们的二级缓存(slave)里再取数据.
if (empty($result)) {
$result = Cache::get(CacheConfig::KEY_CODE_YOHOCOIN_BANNER, 'slave');
}
// 接口调用正常,数据封装完成, 则设置一级(master)和二级(slave)数据缓存
else {
Cache::set(CacheConfig::KEY_CODE_YOHOCOIN_BANNER, $result);
}
}
return $result;
... ...
... ... @@ -550,23 +550,30 @@ class DetailModel
/**
* 获取咨询列表
*
* @param int $uid 用户ID
* @param int $productId 产品ID
* @param int $pageNum 页码数
* @param int $pageSize 每页显示个数
* @return array
*/
public static function getConsults($productId, $pageNum = 1, $pageSize = 300)
public static function getConsults($uid, $productId, $pageNum = 1, $pageSize = 300)
{
$result = array();
if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
$consultList = DetailData::consultList($productId, $pageNum, $pageSize);
if (!empty($consultList)) {
$consultList = DetailData::consultList($uid, $productId, $pageNum, $pageSize);
if (isset($consultList['code']) && $consultList['code'] === 200) {
$consultList = $consultList['data']['list'];
$build = array();
foreach ($consultList as $value) {
$build['question'] = $value['ask'];
$build['time'] = $value['askTime'];
$build['time'] = $value['ask_time'];
$build['answer'] = $value['answer'];
$build['id'] = $value['id'];
$build['isLike'] = $value['is_like'] === 'Y';
$build['like'] = $value['like'];
$build['isUseful'] = $value['is_useful'] === 'Y';
$build['useful'] = $value['useful'];
$result[] = $build;
}
}
... ... @@ -577,6 +584,70 @@ class DetailModel
}
/**
* 咨询点赞
*
* @param int $uid 用户ID
* @param int $id 咨询ID
* @param int $productId 商品ID
* @return array
*/
public static function upvoteConsult($uid, $id, $productId)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
$record = DetailData::upvoteConsult($uid, $id);
if (empty($uid)) {
$result['code'] = 401;
$result['message'] = '用户id为空';
$result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consultform', array('product_id' => $productId))));
break;
}
// 处理数据
if ($record && isset($record['code'])) {
$result['code'] = $record['code'];
$result['message'] = $record['message'];
}
}while(false);
return $result;
}
/**
* 咨询有用
*
* @param int $uid 用户ID
* @param int $id 咨询ID
* @param int $productId 商品ID
* @return array
*/
public static function usefulConsult($uid, $id, $productId)
{
$result = array('code' => 400, 'message' => '出错啦~');
do {
$record = DetailData::usefulConsult($uid, $id);
if (empty($uid)) {
$result['code'] = 401;
$result['message'] = '用户id为空';
$result['data'] = Helpers::url('/signin.html', array('refer' => Helpers::url('/product/detail/consultform', array('product_id' => $productId))));
break;
}
// 处理数据
if ($record && isset($record['code'])) {
$result['code'] = $record['code'];
$result['message'] = $record['message'];
}
}while(false);
return $result;
}
/**
* 获取为你优选的商品
*
* @param int $productSkn 商品SKN
... ...
... ... @@ -150,12 +150,15 @@ class DetailController extends AbstractAction
}
$this->setTitle('购买咨询');
$uid = $this->getUid();
$consults = \Product\DetailModel::getConsults($uid, $productId);
$data = array(
'goodsConsultsPage' => true,
'pageFooter' => true,
'consults' => array(
'list' => \Product\DetailModel::getConsults($productId),
'list' => $consults
),
'showReadMore' => count($consults) > 2,
'link' => Helpers::url('/product/detail/consultform', array('product_id' => $productId)),
);
... ... @@ -163,6 +166,40 @@ class DetailController extends AbstractAction
$this->_view->display('consults', $data);
}
/*
* 咨询点赞
*/
public function consultupvoteAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->get('product_id', 0);
$uid = $this->getUid();
$id = $this->post('id');
$result = \Product\DetailModel::upvoteConsult($uid, $id, $productId);
}
$this->echoJson($result);
}
/*
* 咨询有用
*/
public function consultusefulAction()
{
$result = array();
if ($this->isAjax()) {
$productId = $this->get('product_id', 0);
$uid = $this->getUid();
$id = $this->post('id');
$result = \Product\DetailModel::usefulConsult($uid, $id, $productId);
}
$this->echoJson($result);
}
/**
* 我要咨询表单
*/
... ...