Commit 27aa7709 authored by gongs's avatar gongs

购物袋推荐位后台功能和接口

parent ce4f5d93
...@@ -2,9 +2,11 @@ ...@@ -2,9 +2,11 @@
namespace addons\shopro\controller; namespace addons\shopro\controller;
use addons\shopro\service\goods\GoodsService;
use app\admin\model\shopro\Cart as CartModel; use app\admin\model\shopro\Cart as CartModel;
use app\admin\model\shopro\goods\Goods; use app\admin\model\shopro\goods\Goods;
use app\admin\model\shopro\goods\SkuPrice; use app\admin\model\shopro\goods\SkuPrice;
use think\Db;
class Cart extends Common class Cart extends Common
{ {
...@@ -37,7 +39,25 @@ class Cart extends Common ...@@ -37,7 +39,25 @@ class Cart extends Common
$this->success('获取成功', $carts); $this->success('获取成功', $carts);
} }
/**
* 热门推荐
*/
public function getRecommend()
{
auth_user();
$page = $this->request->param('page', 1);
$listRows = $this->request->param('list_rows', 2);
$param = [
'page' => $page,
'list_rows' => $listRows
];
$goodsModel = new Goods();
$result = $goodsModel->where('recommend', 1)->paginate($param);
$this->success('获取成功', $result);
}
public function update() public function update()
{ {
......
...@@ -15,7 +15,6 @@ class AiTryon extends Common ...@@ -15,7 +15,6 @@ class AiTryon extends Common
public function _initialize() public function _initialize()
{ {
parent::_initialize(); parent::_initialize();
// \think\Lang::load(APP_PATH . 'api/lang/zh-cn/user.php'); // 加载语言包
} }
/** /**
......
...@@ -22,6 +22,7 @@ class Goods extends Common ...@@ -22,6 +22,7 @@ class Goods extends Common
use SkuPriceTrait, StockWarningTrait; use SkuPriceTrait, StockWarningTrait;
protected $noNeedRight = ['getType', 'select', 'activitySelect']; protected $noNeedRight = ['getType', 'select', 'activitySelect'];
protected $recommend = [ '无', '购物袋热门推荐' ];
/** /**
* 商品模型对象 * 商品模型对象
...@@ -52,7 +53,6 @@ class Goods extends Common ...@@ -52,7 +53,6 @@ class Goods extends Common
} }
$goodsTableName = $this->model->getQuery()->getTable(); $goodsTableName = $this->model->getQuery()->getTable();
$goods = $this->model->sheepFilter()->with(['max_sku_price']); $goods = $this->model->sheepFilter()->with(['max_sku_price']);
// 聚合库存 (包含下架的规格) // 聚合库存 (包含下架的规格)
...@@ -68,6 +68,8 @@ class Goods extends Common ...@@ -68,6 +68,8 @@ class Goods extends Common
if ($data_type == 'score_shop') { if ($data_type == 'score_shop') {
$goods->is_score_shop = $goods->is_score_shop; $goods->is_score_shop = $goods->is_score_shop;
} }
$goods->recommend = $this->recommend[$goods->recommend];
}); });
$this->success('获取成功', null, $goods); $this->success('获取成功', null, $goods);
...@@ -79,12 +81,13 @@ class Goods extends Common ...@@ -79,12 +81,13 @@ class Goods extends Common
{ {
$activityTypes = $this->activityModel->typeList(); $activityTypes = $this->activityModel->typeList();
$statusList = $this->model->statusList(); $statusList = $this->model->statusList();
$recommendList = $this->model->recommendList();
$result = [ $result = [
'activity_type' => $activityTypes, 'activity_type' => $activityTypes,
'status' => $statusList 'status' => $statusList,
'recommend_type' => $recommendList
]; ];
$data = []; $data = [];
foreach ($result as $key => $list) { foreach ($result as $key => $list) {
$data[$key][] = ['name' => '全部', 'type' => 'all']; $data[$key][] = ['name' => '全部', 'type' => 'all'];
...@@ -183,7 +186,7 @@ class Goods extends Common ...@@ -183,7 +186,7 @@ class Goods extends Common
$params = $this->request->only([ $params = $this->request->only([
'type', 'title', 'subtitle', 'image', 'images', 'image_wh', 'params', 'type', 'title', 'subtitle', 'image', 'images', 'image_wh', 'params',
'original_price', 'price', 'is_sku', 'limit_type', 'limit_num', 'sales_show_type', 'original_price', 'price', 'is_sku', 'limit_type', 'limit_num', 'sales_show_type',
'stock_show_type', 'show_sales', 'service_ids', 'dispatch_type', 'dispatch_id', 'is_offline', 'status', 'weigh', 'stock_show_type', 'show_sales', 'service_ids', 'dispatch_type', 'dispatch_id', 'is_offline', 'status', 'weigh','recommend'
]); // likes, views, sales, ]); // likes, views, sales,
$this->request->has('content') && $params['content'] = $this->request->param('content', '', null); // content 不经过全局过滤 $this->request->has('content') && $params['content'] = $this->request->param('content', '', null); // content 不经过全局过滤
$this->svalidate($params); $this->svalidate($params);
......
...@@ -73,6 +73,17 @@ class Goods extends Common ...@@ -73,6 +73,17 @@ class Goods extends Common
} }
/** /**
* recommend 中文
*/
public function recommendList()
{
return [
'no' => '无',
'cart' => '购物袋热门推荐'
];
}
/**
* status 中文 * status 中文
*/ */
public function dispatchTypeList() public function dispatchTypeList()
......
...@@ -289,6 +289,10 @@ ...@@ -289,6 +289,10 @@
<el-table-column label="更新时间" width="172"> <el-table-column label="更新时间" width="172">
<template #default>-</template> <template #default>-</template>
</el-table-column> </el-table-column>
<el-table-column label="推荐位" min-width="100">
<!-- <template #default="scope">-->
<!-- {{ scope.row.recommend || '-' }}</template>-->
</el-table-column>
<el-table-column label="操作" min-width="240"> <el-table-column label="操作" min-width="240">
<template #default="scope"> <template #default="scope">
{if $auth->check('shopro/goods/sku_price/edit')} {if $auth->check('shopro/goods/sku_price/edit')}
...@@ -327,8 +331,8 @@ ...@@ -327,8 +331,8 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column type="selection" width="48" align="center"></el-table-column> <el-table-column type="selection" width="48" align="center"></el-table-column>
<el-table-column sortable="custom" prop="id" label="ID" min-width="90"></el-table-column> <el-table-column sortable="custom" prop="id" label="ID" min-width="50"></el-table-column>
<el-table-column label="商品" min-width="440"> <el-table-column label="商品" min-width="420">
<template #default="scope"> <template #default="scope">
<div class="goods-item sa-flex sa-col-top"> <div class="goods-item sa-flex sa-col-top">
<sa-image class="goods-image" :url="scope.row.image" size="64"></sa-image> <sa-image class="goods-image" :url="scope.row.image" size="64"></sa-image>
...@@ -398,9 +402,12 @@ ...@@ -398,9 +402,12 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="更新时间" width="172"> <el-table-column label="更新时间" width="165">
<template #default="scope">{{ scope.row.createtime || '-' }}</template> <template #default="scope">{{ scope.row.createtime || '-' }}</template>
</el-table-column> </el-table-column>
<el-table-column label="推荐位" width="160">
<template #default="scope">{{ scope.row.recommend }}</template>
</el-table-column>
<el-table-column label="操作" min-width="240" fixed="right"> <el-table-column label="操作" min-width="240" fixed="right">
<template #default="scope"> <template #default="scope">
<div class="sa-flex"> <div class="sa-flex">
...@@ -472,6 +479,10 @@ ...@@ -472,6 +479,10 @@
<el-button type="info" :disabled="!batchHandle.data.length" @click="onBatchHandle('hidden')">隐藏 <el-button type="info" :disabled="!batchHandle.data.length" @click="onBatchHandle('hidden')">隐藏
</el-button> </el-button>
{/if} {/if}
<el-button type="success" :disabled="!batchHandle.data.length" @click="onBatchHandle('recommend')">推荐购物袋热门推荐
</el-button>
<el-button type="success" :disabled="!batchHandle.data.length" @click="onBatchHandle('unrecommend')">取消购物袋热门推荐
</el-button>
</div> </div>
</div> </div>
<sa-pagination v-model="pagination" @pagination-change="getData"></sa-pagination> <sa-pagination v-model="pagination" @pagination-change="getData"></sa-pagination>
......
...@@ -20,6 +20,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -20,6 +20,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
keyword: { field: 'id', value: '' }, keyword: { field: 'id', value: '' },
category_ids: 'all', category_ids: 'all',
activity_type: '', activity_type: '',
recommend_type: '',
price: { min: '', max: '' }, price: { min: '', max: '' },
sales: { min: '', max: '' }, sales: { min: '', max: '' },
}, },
...@@ -63,9 +64,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -63,9 +64,21 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
// }, // },
// }, // },
// }, // },
activity_type: { // activity_type: {
// type: 'tselect',
// label: '活动类型',
// value: '',
// options: {
// data: [],
// props: {
// label: 'name',
// value: 'type',
// },
// },
// },
recommend_type: {
type: 'tselect', type: 'tselect',
label: '活动类型', label: '推荐位',
value: '', value: '',
options: { options: {
data: [], data: [],
...@@ -102,7 +115,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -102,7 +115,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}, function (ret, res) { }, function (ret, res) {
type.data = res.data type.data = res.data
for (key in state.filter.tools) { for (key in state.filter.tools) {
if (key == 'activity_type') { if (key == 'activity_type' || key == 'recommend_type') {
state.filter.tools[key].options.data = res.data[key] state.filter.tools[key].options.data = res.data[key]
} }
} }
...@@ -128,7 +141,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -128,7 +141,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}, function (ret, res) { }) }, function (ret, res) { })
} }
function getData() { function getData(){
let tempSearch = JSON.parse(JSON.stringify(state.filter.data)); let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
for (key in tempSearch) { for (key in tempSearch) {
if (key == 'price' || key == 'sales') { if (key == 'price' || key == 'sales') {
...@@ -137,6 +150,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -137,6 +150,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
} }
} }
} }
// recommend_type 搜索
let recommend_list = ['no','cart']
let recommend_list_obj = {'no': 0, 'cart':1};
if (recommend_list.includes(state.filter.data.recommend_type)) {
tempSearch.recommend = recommend_list_obj[state.filter.data.recommend_type];
}
delete tempSearch.recommend_type;
let search = composeFilter(tempSearch, { let search = composeFilter(tempSearch, {
title: 'like', title: 'like',
subtitle: 'like', subtitle: 'like',
...@@ -146,6 +168,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -146,6 +168,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
price: 'between', price: 'between',
sales: 'between', sales: 'between',
}); });
console.log('search:'+search);
Fast.api.ajax({ Fast.api.ajax({
url: 'shopro/goods/goods', url: 'shopro/goods/goods',
type: 'GET', type: 'GET',
...@@ -197,6 +220,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -197,6 +220,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
function onBatchHandle(type) { function onBatchHandle(type) {
let ids = [] let ids = []
batchHandle.data.forEach((item) => { batchHandle.data.forEach((item) => {
// console.log(item);
ids.push(item.id) ids.push(item.id)
}) })
switch (type) { switch (type) {
...@@ -209,6 +233,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -209,6 +233,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
onDelete(ids.join(',')) onDelete(ids.join(','))
}); });
break; break;
case 'recommend':
Fast.api.ajax({
url: `shopro/goods/goods/edit/id/`+ids.join(','),
type: 'POST',
data: {
recommend: 1
}
}, function (ret, res) {
getData()
}, function (ret, res) { })
break;
case 'unrecommend':
Fast.api.ajax({
url: `shopro/goods/goods/edit/id/`+ids.join(','),
type: 'POST',
data: {
recommend: 0
}
}, function (ret, res) {
getData()
}, function (ret, res) { })
break;
default: default:
onCommand({ id: ids.join(','), type: type }) onCommand({ id: ids.join(','), type: type })
break; break;
...@@ -1027,6 +1073,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -1027,6 +1073,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
max: new URLSearchParams(location.search).get('max') || 0, max: new URLSearchParams(location.search).get('max') || 0,
ids: new URLSearchParams(location.search).get('ids'), // 选中的商品ids ids: new URLSearchParams(location.search).get('ids'), // 选中的商品ids
goods_ids: new URLSearchParams(location.search).get('goods_ids'), // 需要搜索的商品id列表 goods_ids: new URLSearchParams(location.search).get('goods_ids'), // 需要搜索的商品id列表
// recommend_type: new URLSearchParams(location.search).get('recommend_type'),
data: [], data: [],
filter: { filter: {
drawer: false, drawer: false,
...@@ -1084,10 +1131,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -1084,10 +1131,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
if (state.activity_type) { if (state.activity_type) {
tempSearch.activity_type = state.activity_type; tempSearch.activity_type = state.activity_type;
} }
// recommend_type 搜索
// let recommend_list = ['no','cart']
// let recommend_list_obj = {'no': 0, 'cart':1};
// if (recommend_list.includes(state.recommend_type)) {
// tempSearch.recommend = recommend_list_obj[state.recommend_type];
// }
// id 搜索 // id 搜索
if (state.goods_ids) { if (state.goods_ids) {
tempSearch.goods = { field: 'id', value: state.goods_ids }; tempSearch.goods = { field: 'id', value: state.goods_ids };
} }
// console.log('tempSearch:'+tempSearch);
let search = composeFilter(tempSearch, { let search = composeFilter(tempSearch, {
keyword: 'like', keyword: 'like',
price: 'between', price: 'between',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment