我的足迹

feat/task1-c-wallet
devil_gong 2018-10-15 18:21:44 +08:00
parent 5ebf8c220f
commit 19bd390630
15 changed files with 491 additions and 85 deletions

View File

@ -63,6 +63,9 @@ class GoodsController extends CommonController
// 商品访问统计
GoodsService::GoodsAccessCountInc(['goods_id'=>$id]);
// 用户商品浏览
GoodsService::GoodsBrowseSave(['goods_id'=>$id, 'user'=>$this->user]);
// 左侧商品 看了又看
$params = [
'where' => [

View File

@ -57,13 +57,20 @@ class UserController extends CommonController
*/
public function Index()
{
// 登录校验
$this->Is_Login();
// 订单总数
$where = ['user_id'=>$this->user['id'], 'is_delete_time'=>0, 'user_is_delete_time'=>0];
$this->assign('user_order_count', OrderService::OrderTotal($where));
// 商品收藏总数
$where = ['user_id'=>$this->user['id']];
$this->assign('user_goods_favor_count', GoodsService::FavorGoodsTotal($where));
$this->assign('user_goods_favor_count', GoodsService::GoodsFavorTotal($where));
// 商品浏览总数
$where = ['user_id'=>$this->user['id']];
$this->assign('user_goods_browse_count', GoodsService::GoodsBrowseTotal($where));
// 用户订单状态
$user_order_status = OrderService::OrderStatusStepTotal(['user_type'=>'user', 'user'=>$this->user, 'is_comments'=>1]);

View File

@ -47,10 +47,10 @@ class UserFavorController extends CommonController
$number = 10;
// 条件
$where = GoodsService::HomeFavorGoodsListWhere($params);
$where = GoodsService::UserGoodsFavorListWhere($params);
// 获取总数
$total = GoodsService::FavorGoodsTotal($where);
$total = GoodsService::GoodsFavorTotal($where);
// 分页
$page_params = array(
@ -68,7 +68,7 @@ class UserFavorController extends CommonController
'limit_number' => $number,
'where' => $where,
);
$data = GoodsService::FavorGoodsList($data_params);
$data = GoodsService::GoodsFavorList($data_params);
$this->assign('data_list', $data['data']);
// 参数

View File

@ -0,0 +1,102 @@
<?php
namespace Home\Controller;
use Service\GoodsService;
/**
* 用户商品浏览
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
class UserGoodsBrowseController extends CommonController
{
/**
* [_initialize 前置操作-继承公共前置方法]
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-03T12:39:08+0800
*/
public function _initialize()
{
// 调用父类前置方法
parent::_initialize();
// 是否登录
$this->Is_Login();
}
/**
* 商品浏览列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-10-09
* @desc description
*/
public function Index()
{
// 参数
$params = array_merge($_POST, $_GET);
$params['user'] = $this->user;
// 分页
$number = 10;
// 条件
$where = GoodsService::UserGoodsBrowseListWhere($params);
// 获取总数
$total = GoodsService::GoodsBrowseTotal($where);
// 分页
$page_params = array(
'number' => $number,
'total' => $total,
'where' => $params,
'url' => U('Home/UserGoodsBrowse/Goods'),
);
$page = new \Library\Page($page_params);
$this->assign('page_html', $page->GetPageHtml());
// 获取列表
$data_params = array(
'limit_start' => $page->GetPageStarNumber(),
'limit_number' => $number,
'where' => $where,
);
$data = GoodsService::GoodsBrowseList($data_params);
$this->assign('data_list', $data['data']);
$this->assign('ids', empty($data['data']) ? '' : implode(',', array_column($data['data'], 'id')));
// 参数
$this->assign('params', $params);
$this->display('Index');
}
/**
* 商品浏览删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-14
* @desc description
*/
public function Delete()
{
// 是否ajax请求
if(!IS_AJAX)
{
$this->error(L('common_unauthorized_access'));
}
$params = $_POST;
$params['user'] = $this->user;
$ret = GoodsService::GoodsBrowseDelete($params);
$this->ajaxReturn($ret['msg'], $ret['code'], $ret['data']);
}
}
?>

View File

@ -71,6 +71,20 @@ return array(
'is_show' => 1,
'icon' => 'am-icon-user-secret',
),
array(
'control' => 'Message',
'action' => 'Index',
'name' => '我的消息',
'is_show' => 1,
'icon' => 'am-icon-bell-o',
),
array(
'control' => 'UserGoodsBrowse',
'action' => 'Index',
'name' => '我的足迹',
'is_show' => 1,
'icon' => 'am-icon-lastfm',
),
array(
'control' => 'User',
'action' => 'Logout',

View File

@ -1,34 +0,0 @@
<?php
/**
* 模块语言包-冒泡
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
return array(
'bubble_mood_placeholder' => '说点什么吧',
'bubble_mood_format' => '先随便说两句吧......',
'bubble_mood_error' => '说说内容格式 1~168 个字符之间',
'bubble_visible_text' => '可见范围:',
'bubble_visible_error' => '可见范围值有误',
'bubble_is_sign_hover' => '同步至个人签名',
'bubble_mood_no_exist_error' => '该说说不存在',
'bubble_mood_delete_error' => '只能删除自己的说说',
'bubble_mood_praise_error' => '不能点赞自己的说说',
'bubble_mood_comments_error' => '不能评论自己的说说',
'bubble_comments_placeholder' => '评论内容',
'bubble_comments_format' => '先随便说两句吧......',
'bubble_comments_content_error' => '评论内容格式 1~255 个字符之间',
'bubble_comments_mood_id_error' => '说说记录不存在',
'bubble_comments_reply_id_error' => '评论记录不存在',
'bubble_comments_parent_id_error' => '父级评论记录不存在',
'bubble_comments_reply_error' => '不能回复自己的评论',
'bubble_comments_delete_error' => '只能删除自己的评论',
'bubble_nav_list' => array(
array('type' => 'all', 'url' => U('Home/Bubble/Index', ['type'=>'all']), 'name' => '冒泡广场'),
array('type' => 'own', 'url' => U('Home/Bubble/Index', ['type'=>'own']),'name' => '本人冒泡'),
),
);
?>

View File

@ -1,31 +0,0 @@
<?php
/**
* 模块语言包-学生
* @author Devil
* @blog http://gong.gg/
* @version 0.0.1
* @datetime 2016-12-01T21:51:08+0800
*/
return array(
'student_operation_binding_text' => '学生绑定',
'student_username_text' => '学生真实姓名',
'student_username_name' => '学生姓名',
'student_username_format' => '姓名格式 2~16 个字符',
'student_student_number_format' => '请填写学生编号',
'student_accounts_text' => '手机/邮箱',
'student_accounts_format' => '手机/邮箱格式有误',
'student_accounts_on_exist_error' => '帐号不存在',
'student_join_accounts_exist_tips' => '该账户已关联',
'student_class_text' => '班级',
'student_birthday_text' => '出生日期',
'student_my_mobile_name' => '学生手机',
'student_tuition_state_text' => '缴费状态',
'student_sign_up_name' => '报名时间',
'common_bundled_time_name' => '绑定时间',
'student_semester_text' => '学期',
'student_score_text' => '查成绩',
'student_operation_score' => '成绩查询',
'student_score_title_list' => array('科目', '分数', '等级', '时间','点评'),
);
?>

View File

@ -41,7 +41,7 @@
<tr>
<td>
<span>类型:</span>
<select name="type" class="chosen-select" data-placeholder="业务类型...">
<select name="type" class="chosen-select" data-placeholder="消息类型...">
<option value="-1">消息类型...</option>
<notempty name="common_message_type_list">
<foreach name="common_message_type_list" item="v">

View File

@ -56,8 +56,8 @@
</a>
</li>
<li>
<a href="{{:U('Home/History/Index')}}">
<p>0</p>
<a href="{{:U('Home/UserGoodsBrowse/Index')}}">
<p>{{$user_goods_browse_count}}</p>
<p>我的足迹</p>
</a>
</li>

View File

@ -25,7 +25,7 @@
<form class="am-form form-validation" method="post" action="{{:U('Home/UserFavor/Goods')}}" request-type="form">
<div class="thin">
<div class="am-input-group am-input-group-sm am-fl so">
<input type="text" name="keywords" class="am-radius" placeholder="账单号或关键字" value="<notempty name="params.keywords">{{$params.keywords}}</notempty>" />
<input type="text" name="keywords" class="am-radius" placeholder="其实搜索很简单 ^_^" value="<notempty name="params.keywords">{{$params.keywords}}</notempty>" />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default am-radius" type="submit" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
</span>
@ -64,7 +64,7 @@
<p class="line-price">¥{{$goods.price}}</p>
</td>
<td>
<button type="button" class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block submit-ajax submit-cancel" data-url="{{:U('Home/UserFavor/Cancel')}}" data-id="{{$goods.goods_id}}" data-view="reload">取消</button>
<button type="button" class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block submit-ajax" data-url="{{:U('Home/UserFavor/Cancel')}}" data-id="{{$goods.goods_id}}" data-view="reload">取消</button>
</td>
</tr>
</foreach>

View File

@ -0,0 +1,96 @@
<include file="Public/Header" />
<!-- header top nav -->
<include file="Public/HeaderTopNav" />
<!-- search -->
<include file="Public/NavSearch" />
<!-- header nav -->
<include file="Public/HeaderNav" />
<!-- goods category -->
<include file="Public/GoodsCategory" />
<!-- content -->
<div class="am-container user-main">
<!-- user menu start -->
<include file="Public/UserMenu" />
<!-- user menu end -->
<!-- content start -->
<div class="user-content">
<div class="user-content-body">
<form class="am-form form-validation" method="post" action="{{:U('Home/UserGoodsBrowse/Index')}}" request-type="form">
<div class="thin">
<div class="am-input-group am-input-group-sm am-fl so">
<input type="text" name="keywords" class="am-radius" placeholder="其实搜索很简单 ^_^" value="<notempty name="params.keywords">{{$params.keywords}}</notempty>" />
<span class="am-input-group-btn">
<button class="am-btn am-btn-default am-radius" type="submit" data-am-loading="{spinner:'circle-o-notch', loadingText:'搜索中...'}">搜索</button>
</span>
</div>
</div>
</form>
<!-- 商品列表 -->
<div class="data-list">
<table class="am-table">
<thead>
<tr>
<th class="base">商品信息</th>
<th class="price">价格</th>
<th class="operate">操作</th>
</tr>
</thead>
<tbody>
<notempty name="data_list">
<foreach name="data_list" item="v">
<tr id="data-list-{{$v.id}}">
<td>
<div class="goods-detail">
<a href="{{$v.goods_url}}" target="_blank">
<img src="{{$v.images}}">
</a>
<div class="goods-base">
<a href="{{$v.goods_url}}" target="_blank" class="goods-title">{{$v.title}}</a>
</div>
</div>
</td>
<td>
<if condition="$v['original_price'] gt 0">
<p class="original-price">¥{{$v.original_price}}</p>
</if>
<p class="line-price">¥{{$v.price}}</p>
</td>
<td>
<button type="button" class="am-btn am-btn-danger am-btn-xs am-radius am-btn-block submit-delete" data-url="{{:U('Home/UserGoodsBrowse/Delete')}}" data-id="{{$v.id}}" data-view="delete">删除</button>
</td>
</tr>
</foreach>
</notempty>
<empty name="data_list">
<tr>
<td colspan="3">
<div class="table-no"><i class="am-icon-warning"></i> {{:L('common_not_data_tips')}}</div>
</td>
</tr>
</empty>
</tbody>
</table>
</div>
<notempty name="data_list">
<a href="javascript:;" class="am-btn am-btn-warning am-radius am-btn-sm submit-ajax" data-url="{{:U('Home/UserGoodsBrowse/Delete')}}" data-id="{{$ids}}" data-view="reload" data-msg="清空后不可恢复、确认操作吗?">清空</a>
<!-- 分页 -->
{{$page_html}}
</notempty>
</div>
</div>
<!-- content end -->
</div>
<!-- footer start -->
<include file="Public/Footer" />
<!-- footer end -->

View File

@ -414,7 +414,7 @@ class GoodsService
* @desc description
* @param [array] $params [输入参数]
*/
public static function HomeFavorGoodsListWhere($params = [])
public static function UserGoodsFavorListWhere($params = [])
{
$where = [
'g.is_delete_time' => 0,
@ -443,7 +443,7 @@ class GoodsService
* @desc description
* @param [array] $where [条件]
*/
public static function FavorGoodsTotal($where = [])
public static function GoodsFavorTotal($where = [])
{
return (int) M('GoodsFavor')->alias('f')->join('__GOODS__ AS g ON g.id=f.goods_id')->where($where)->count();
}
@ -457,7 +457,7 @@ class GoodsService
* @desc description
* @param [array] $params [输入参数]
*/
public static function FavorGoodsList($params = [])
public static function GoodsFavorList($params = [])
{
// 请求参数
$p = [
@ -493,7 +493,7 @@ class GoodsService
$order_by = empty($params['order_by']) ? 'f.id desc' : I('order_by', '', '', $params);
$field = 'f.*, g.title, g.original_price, g.price, g.images';
// 获取订单
// 获取数据
$data = M('GoodsFavor')->alias('f')->join('__GOODS__ AS g ON g.id=f.goods_id')->field($field)->where($params['where'])->limit($limit_start, $limit_number)->order($order_by)->select();
if(!empty($data))
{
@ -525,5 +525,203 @@ class GoodsService
}
return false;
}
/**
* 商品浏览保存
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-10-15
* @desc description
* @param [array] $params [输入参数]
*/
public static function GoodsBrowseSave($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'goods_id',
'error_msg' => '商品id有误',
],
[
'checked_type' => 'is_array',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = params_checked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
$m = M('GoodsBrowse');
$where = ['goods_id'=>intval($params['goods_id']), 'user_id'=>$params['user']['id']];
$temp = $m->where($where)->find();
$data = [
'goods_id' => intval($params['goods_id']),
'user_id' => $params['user']['id'],
'upd_time' => time(),
];
if(empty($temp))
{
$data['add_time'] = time();
$status = $m->add($data) > 0;
} else {
$status = $m->where($where)->save($data) !== false;
}
if($status)
{
return DataReturn('处理成功', 0);
}
return DataReturn('处理失败', -100);
}
/**
* 前端商品浏览列表条件
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function UserGoodsBrowseListWhere($params = [])
{
$where = [
'g.is_delete_time' => 0,
];
// 用户id
if(!empty($params['user']))
{
$where['b.user_id'] = $params['user']['id'];
}
if(!empty($params['keywords']))
{
$where['g.title'] = array('like', '%'.I('keywords').'%');
}
return $where;
}
/**
* 商品浏览总数
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $where [条件]
*/
public static function GoodsBrowseTotal($where = [])
{
return (int) M('GoodsBrowse')->alias('f')->join('__GOODS__ AS g ON g.id=f.goods_id')->where($where)->count();
}
/**
* 商品浏览列表
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-29
* @desc description
* @param [array] $params [输入参数]
*/
public static function GoodsBrowseList($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'where',
'error_msg' => '条件不能为空',
],
[
'checked_type' => 'is_array',
'key_name' => 'where',
'error_msg' => '条件格式有误',
],
[
'checked_type' => 'isset',
'key_name' => 'limit_start',
'error_msg' => '分页起始值有误',
],
[
'checked_type' => 'isset',
'key_name' => 'limit_number',
'error_msg' => '分页数量不能为空',
],
];
$ret = params_checked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
$limit_start = max(0, intval($params['limit_start']));
$limit_number = max(1, intval($params['limit_number']));
$order_by = empty($params['order_by']) ? 'b.id desc' : I('order_by', '', '', $params);
$field = 'b.*, g.title, g.original_price, g.price, g.images';
// 获取数据
$data = M('GoodsBrowse')->alias('b')->join('__GOODS__ AS g ON g.id=b.goods_id')->field($field)->where($params['where'])->limit($limit_start, $limit_number)->order($order_by)->select();
if(!empty($data))
{
$images_host = C('IMAGE_HOST');
foreach($data as &$v)
{
$v['images_old'] = $v['images'];
$v['images'] = empty($v['images']) ? null : $images_host.$v['images'];
$v['goods_url'] = HomeUrl('Goods', 'Index', ['id'=>$v['goods_id']]);
}
}
return DataReturn('处理成功', 0, $data);
}
/**
* 商品浏览删除
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2018-09-14
* @desc description
* @param [array] $params [输入参数]
*/
public static function GoodsBrowseDelete($params = [])
{
// 请求参数
$p = [
[
'checked_type' => 'empty',
'key_name' => 'id',
'error_msg' => '删除数据id有误',
],
[
'checked_type' => 'empty',
'key_name' => 'user',
'error_msg' => '用户信息有误',
],
];
$ret = params_checked($params, $p);
if($ret !== true)
{
return DataReturn($ret, -1);
}
// 删除
$where = [
'id' => ['in', explode(',', $params['id'])],
'user_id' => $params['user']['id']
];
if(M('GoodsBrowse')->where($where)->delete())
{
return DataReturn(L('common_operation_delete_success'), 0);
}
return DataReturn(L('common_operation_delete_error'), -100);
}
}
?>

View File

@ -24,11 +24,11 @@ button { outline: none; }
*, body, .am-btn { font-size: 12px; }
.am-form select, .am-form textarea, .am-form input[type="text"], .am-form input[type="password"], .am-form input[type="datetime"], .am-form input[type="datetime-local"], .am-form input[type="date"], .am-form input[type="month"], .am-form input[type="time"], .am-form input[type="week"], .am-form input[type="number"], .am-form input[type="email"], .am-form input[type="url"], .am-form input[type="search"], .am-form input[type="tel"], .am-form input[type="color"], .am-form-field {
font-size: 14px;
font-size: 12px;
}
.am-input-group-sm > .am-input-group-btn > .am-btn {
height: 32px;
font-size: 14px !important;
height: 28px;
font-size: 12px !important;
}
/*所有超链接不要下划线*/

View File

@ -0,0 +1,38 @@
/**
*
*/
.thin { overflow: hidden; }
/**
*
*/
.data-list { margin-top: 10px; }
.goods-detail img { width: 80px; height: 80px; }
.goods-detail { position: relative; }
.goods-title { display: block; max-height: 36px; overflow: hidden; text-overflow: ellipsis; }
.goods-title:hover { text-decoration: underline; }
.goods-base { position: absolute; top: 0; left: 85px; }
.original-price, .line-price { font-family: Verdana,Tahoma,arial; }
.original-price { color: #9c9c9c; text-decoration: line-through; }
.line-price { color: #3c3c3c; font-weight: 700; }
.am-table { margin-bottom: 10px; }
.am-table > tbody > tr > td { border-top: 1px solid #F5F5F5; }
.am-table > thead > tr > th { border-bottom: 1px solid #f7f7f7; }
@media only screen and (min-width:640px) {
.data-list tr .base { width: 50%; }
.data-list tr .price { width: 20%; }
.data-list tr .operate { width: 10%; }
/**
*
*/
.thin .so { width:66%; }
}
@media only screen and (max-width:640px) {
.data-list tr .base { width: 65%; }
.data-list tr .price { width: 15%; }
.data-list tr .operate { width: 20%; }
.goods-detail img { width: 50px; height: 50px; }
.goods-base { left: 55px; }
}

File diff suppressed because one or more lines are too long