购物车列表数据处理分离+css细节优化

feat/task1-c-wallet
gongfuxiang 2022-04-05 17:07:05 +08:00
parent 982f59d219
commit afe6d300ee
2 changed files with 23 additions and 4 deletions

View File

@ -229,6 +229,7 @@ class BuyService
return DataReturn($ret, -1); return DataReturn($ret, -1);
} }
// 获取购物车数据
$where = (!empty($params['where']) && is_array($params['where'])) ? $params['where'] : []; $where = (!empty($params['where']) && is_array($params['where'])) ? $params['where'] : [];
$where['c.user_id'] = $params['user']['id']; $where['c.user_id'] = $params['user']['id'];
@ -236,6 +237,22 @@ class BuyService
$data = Db::name('Cart')->alias('c')->leftJoin('goods g', 'g.id=c.goods_id')->where($where)->field($field)->order('c.id desc')->select()->toArray(); $data = Db::name('Cart')->alias('c')->leftJoin('goods g', 'g.id=c.goods_id')->where($where)->field($field)->order('c.id desc')->select()->toArray();
// 数据处理 // 数据处理
$data = self::CartListDataHandle($data, $params);
return DataReturn('操作成功', 0, $data);
}
/**
* 购物车列表数据处理
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2022-04-05
* @desc description
* @param [array] $data [购物车数据]
* @param [array] $params [输入参数]
*/
public static function CartListDataHandle($data, $params = [])
{
if(!empty($data)) if(!empty($data))
{ {
foreach($data as &$v) foreach($data as &$v)
@ -316,8 +333,7 @@ class BuyService
} }
} }
} }
return $data;
return DataReturn('操作成功', 0, $data);
} }
/** /**
@ -538,7 +554,7 @@ class BuyService
'is_delete_time' => 0, 'is_delete_time' => 0,
'is_shelves' => 1, 'is_shelves' => 1,
], ],
'field' => 'id, id AS goods_id, title, images, inventory_unit, buy_min_number, buy_max_number, model', 'field' => 'id AS goods_id, title, images, inventory_unit, buy_min_number, buy_max_number, model',
]); ]);
$ret = GoodsService::GoodsList($goods_params); $ret = GoodsService::GoodsList($goods_params);
if(empty($ret['data'][0])) if(empty($ret['data'][0]))
@ -550,6 +566,9 @@ class BuyService
// 规格 // 规格
$goods['spec'] = self::GoodsSpecificationsHandle($params); $goods['spec'] = self::GoodsSpecificationsHandle($params);
// id处理、避免不同规格导致id一样
$goods['id'] = md5($goods['goods_id'].(empty($goods['spec']) ? 'default' : implode('', array_column($goods['spec'], 'value'))));
// 获取商品基础信息 // 获取商品基础信息
$spec_params = array_merge($params, [ $spec_params = array_merge($params, [
'id' => $goods['goods_id'], 'id' => $goods['goods_id'],

View File

@ -449,7 +449,7 @@ ul {margin-top:0;}
*/ */
.am-container {padding-left:0px;padding-right:0px ;} .am-container {padding-left:0px;padding-right:0px ;}
@media only screen and (min-width: 641px) { @media only screen and (min-width: 641px) {
.submit { display: none; } #tree tr .submit { display: none; }
#tree tr:hover .submit { display: block !important; } #tree tr:hover .submit { display: block !important; }
} }
@media only screen and (min-width: 1025px) { @media only screen and (min-width: 1025px) {