Commit 1efedae0 authored by 龚双喜's avatar 龚双喜

Merge branch 'dev' of git.ruanyiit.com:liuxiaomin/loveisland into dev

parents cfbc2e0c eb30b6b8
......@@ -2,9 +2,11 @@
namespace addons\shopro\controller;
use addons\shopro\service\goods\GoodsService;
use app\admin\model\shopro\Cart as CartModel;
use app\admin\model\shopro\goods\Goods;
use app\admin\model\shopro\goods\SkuPrice;
use think\Db;
class Cart extends Common
{
......@@ -37,7 +39,25 @@ class Cart extends Common
$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()
{
......
......@@ -15,7 +15,6 @@ class AiTryon extends Common
public function _initialize()
{
parent::_initialize();
// \think\Lang::load(APP_PATH . 'api/lang/zh-cn/user.php'); // 加载语言包
}
/**
......
......@@ -22,6 +22,7 @@ class Goods extends Common
use SkuPriceTrait, StockWarningTrait;
protected $noNeedRight = ['getType', 'select', 'activitySelect'];
protected $recommend = [ '无', '购物袋热门推荐' ];
/**
* 商品模型对象
......@@ -52,7 +53,6 @@ class Goods extends Common
}
$goodsTableName = $this->model->getQuery()->getTable();
$goods = $this->model->sheepFilter()->with(['max_sku_price']);
// 聚合库存 (包含下架的规格)
......@@ -68,6 +68,8 @@ class Goods extends Common
if ($data_type == 'score_shop') {
$goods->is_score_shop = $goods->is_score_shop;
}
$goods->recommend = $this->recommend[$goods->recommend];
});
$this->success('获取成功', null, $goods);
......@@ -79,12 +81,13 @@ class Goods extends Common
{
$activityTypes = $this->activityModel->typeList();
$statusList = $this->model->statusList();
$recommendList = $this->model->recommendList();
$result = [
'activity_type' => $activityTypes,
'status' => $statusList
'status' => $statusList,
'recommend_type' => $recommendList
];
$data = [];
foreach ($result as $key => $list) {
$data[$key][] = ['name' => '全部', 'type' => 'all'];
......@@ -183,7 +186,7 @@ class Goods extends Common
$params = $this->request->only([
'type', 'title', 'subtitle', 'image', 'images', 'image_wh', 'params',
'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,
$this->request->has('content') && $params['content'] = $this->request->param('content', '', null); // content 不经过全局过滤
$this->svalidate($params);
......
......@@ -73,6 +73,17 @@ class Goods extends Common
}
/**
* recommend 中文
*/
public function recommendList()
{
return [
'no' => '无',
'cart' => '购物袋热门推荐'
];
}
/**
* status 中文
*/
public function dispatchTypeList()
......
......@@ -289,6 +289,10 @@
<el-table-column label="更新时间" width="172">
<template #default>-</template>
</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">
<template #default="scope">
{if $auth->check('shopro/goods/sku_price/edit')}
......@@ -327,8 +331,8 @@
</template>
</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 label="商品" min-width="440">
<el-table-column sortable="custom" prop="id" label="ID" min-width="50"></el-table-column>
<el-table-column label="商品" min-width="420">
<template #default="scope">
<div class="goods-item sa-flex sa-col-top">
<sa-image class="goods-image" :url="scope.row.image" size="64"></sa-image>
......@@ -398,9 +402,12 @@
</div>
</template>
</el-table-column>
<el-table-column label="更新时间" width="172">
<el-table-column label="更新时间" width="165">
<template #default="scope">{{ scope.row.createtime || '-' }}</template>
</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">
<template #default="scope">
<div class="sa-flex">
......@@ -472,6 +479,10 @@
<el-button type="info" :disabled="!batchHandle.data.length" @click="onBatchHandle('hidden')">隐藏
</el-button>
{/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>
<sa-pagination v-model="pagination" @pagination-change="getData"></sa-pagination>
......
......@@ -20,6 +20,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
keyword: { field: 'id', value: '' },
category_ids: 'all',
activity_type: '',
recommend_type: '',
price: { min: '', max: '' },
sales: { min: '', max: '' },
},
......@@ -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',
label: '活动类型',
label: '推荐位',
value: '',
options: {
data: [],
......@@ -102,7 +115,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}, function (ret, res) {
type.data = res.data
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]
}
}
......@@ -128,7 +141,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}, function (ret, res) { })
}
function getData() {
function getData(){
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
for (key in tempSearch) {
if (key == 'price' || key == 'sales') {
......@@ -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, {
title: 'like',
subtitle: 'like',
......@@ -146,6 +168,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
price: 'between',
sales: 'between',
});
console.log('search:'+search);
Fast.api.ajax({
url: 'shopro/goods/goods',
type: 'GET',
......@@ -197,6 +220,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
function onBatchHandle(type) {
let ids = []
batchHandle.data.forEach((item) => {
// console.log(item);
ids.push(item.id)
})
switch (type) {
......@@ -209,6 +233,28 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
onDelete(ids.join(','))
});
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:
onCommand({ id: ids.join(','), type: type })
break;
......@@ -1027,6 +1073,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
max: new URLSearchParams(location.search).get('max') || 0,
ids: new URLSearchParams(location.search).get('ids'), // 选中的商品ids
goods_ids: new URLSearchParams(location.search).get('goods_ids'), // 需要搜索的商品id列表
// recommend_type: new URLSearchParams(location.search).get('recommend_type'),
data: [],
filter: {
drawer: false,
......@@ -1084,10 +1131,17 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
if (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 搜索
if (state.goods_ids) {
tempSearch.goods = { field: 'id', value: state.goods_ids };
}
// console.log('tempSearch:'+tempSearch);
let search = composeFilter(tempSearch, {
keyword: 'like',
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