Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
loveisland
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘小敏
loveisland
Commits
27aa7709
Commit
27aa7709
authored
Apr 25, 2026
by
gongs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购物袋推荐位后台功能和接口
parent
ce4f5d93
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
110 additions
and
12 deletions
+110
-12
Cart.php
addons/shopro/controller/Cart.php
+20
-0
AiTryon.php
addons/shopro/controller/user/AiTryon.php
+0
-1
Goods.php
application/admin/controller/shopro/goods/Goods.php
+7
-4
Goods.php
application/admin/model/shopro/goods/Goods.php
+11
-0
index.html
application/admin/view/shopro/goods/goods/index.html
+14
-3
goods.js
public/assets/js/backend/shopro/goods/goods.js
+58
-4
No files found.
addons/shopro/controller/Cart.php
View file @
27aa7709
...
@@ -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
()
{
{
...
...
addons/shopro/controller/user/AiTryon.php
View file @
27aa7709
...
@@ -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'); // 加载语言包
}
}
/**
/**
...
...
application/admin/controller/shopro/goods/Goods.php
View file @
27aa7709
...
@@ -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
);
...
...
application/admin/model/shopro/goods/Goods.php
View file @
27aa7709
...
@@ -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
()
...
...
application/admin/view/shopro/goods/goods/index.html
View file @
27aa7709
...
@@ -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=
"
9
0"
></el-table-column>
<el-table-column
sortable=
"custom"
prop=
"id"
label=
"ID"
min-width=
"
5
0"
></el-table-column>
<el-table-column
label=
"商品"
min-width=
"4
4
0"
>
<el-table-column
label=
"商品"
min-width=
"4
2
0"
>
<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=
"1
72
"
>
<el-table-column
label=
"更新时间"
width=
"1
65
"
>
<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>
...
...
public/assets/js/backend/shopro/goods/goods.js
View file @
27aa7709
...
@@ -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'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment