Comment.php 1.64 KB
<?php

use Action\WebAction;
use WebPlugin\Helpers;
use Home\UserModel;
use Home\CommentModel;
use LibModels\Web\Home\CommentData;

/**
 * 个人中心——我的评论
 */
class CommentController extends WebAction
{

    /**
     * 我的评论
     */
    public function indexAction()
    {
        //判断是否登录
        $this->auditJumpLogin();
        //头部导航
        $channel = Helpers::getChannelNameByCookie();
        $this->setWebNavHeader($channel);

        $uid = $this->getUid();
        //接收是否评论,和分页参数
        $isComment = $this->get('isComment');
        $page = $this->get('page','1');

        //调用模型获得数据(每页显示十条订单的评论数据)
        $data = CommentModel::getCommentList($uid, $isComment, $page, $limit = 10);

        $this->_view->display('comment', array('meCommentPage' => true, 'comment' => $data));
    }


    //提交评论
    public function saveCommentAction()
    {
        /* 判断是不是AJAX请求 */
        if (!$this->isAjax()) {
            return;
        }

        $uid = $this->getUid();
        //接收评论相关参数
        $productSkn = $this->post('productSkn');
        $productId = $this->post('productId');
        $content = $this->post('content');
        $goodsId = $this->post('goodsId');
        $orderId = $this->post('orderId');
        $erpSkuId = $this->post('erpSkuId');
        //调用评论接口完成评论
        $result = CommentData::saveShareOrder($uid, $productSkn, $productId, $content, $goodsId, $orderId, $erpSkuId);

        $this->echoJson($result);
    }

}