Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
3eeb5574
authored
Aug 23, 2024
by
YunaiV
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【代码评审】商城:满减送活动的实现
parent
f2f39c3a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
src/views/mall/promotion/rewardActivity/components/RewardRuleCouponShowcase.vue
+8
-5
No files found.
src/views/mall/promotion/rewardActivity/components/RewardRuleCouponShowcase.vue
View file @
3eeb5574
...
...
@@ -40,7 +40,7 @@ import { isEmpty } from '@/utils/is'
import
{
useVModel
}
from
'@vueuse/core'
import
{
findIndex
}
from
'@/utils'
defineOptions
({
name
:
'RewardRuleCouponShowcase'
})
// TODO @puhui999:要不就叫 RewardRuleCouponSelect
const
props
=
defineProps
<
{
modelValue
:
RewardRule
...
...
@@ -58,11 +58,12 @@ interface GiveCouponVO extends CouponTemplateApi.CouponTemplateVO {
giveCount
?:
number
}
const
couponSelectRef
=
ref
<
InstanceType
<
typeof
CouponSelect
>>
()
// 优惠券选择
/** 选择优惠券 */
const
couponSelectRef
=
ref
<
InstanceType
<
typeof
CouponSelect
>>
()
// 优惠券选择
const
selectCoupon
=
()
=>
{
couponSelectRef
.
value
?.
open
()
}
/** 选择优惠券后的回调 */
const
handleCouponChange
=
(
val
:
CouponTemplateApi
.
CouponTemplateVO
[])
=>
{
for
(
const
item
of
val
)
{
...
...
@@ -72,23 +73,24 @@ const handleCouponChange = (val: CouponTemplateApi.CouponTemplateVO[]) => {
list
.
value
.
push
(
item
)
}
}
/** 删除优惠券 */
const
deleteCoupon
=
(
index
:
number
)
=>
{
list
.
value
.
splice
(
index
,
1
)
}
/** 初始化赠送的优惠券列表
-如果有的话
*/
/** 初始化赠送的优惠券列表
*/
const
initGiveCouponList
=
async
()
=>
{
// 朝赵优惠劵
if
(
isEmpty
(
rewardRule
.
value
)
||
isEmpty
(
rewardRule
.
value
.
couponIds
))
{
return
}
const
data
=
await
CouponTemplateApi
.
getCouponTemplateList
(
rewardRule
.
value
.
couponIds
!
)
if
(
!
data
)
{
return
}
for
(
let
i
=
0
,
len
=
data
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
;
i
<
data
.
length
;
i
++
)
{
const
coupon
=
data
[
i
]
const
index
=
findIndex
(
rewardRule
.
value
.
couponIds
!
,
(
item
)
=>
item
.
id
===
coupon
.
id
)
list
.
value
.
push
({
...
...
@@ -110,6 +112,7 @@ const setGiveCouponList = () => {
couponIds
.
push
(
list
.
value
[
i
].
id
)
couponCounts
.
push
(
list
.
value
[
i
].
giveCount
!
)
}
// TODO @puhui999:可以考虑,直接使用 list 的 map 操作,简单一些。性能没啥差别的
rewardRule
.
value
.
couponIds
=
couponIds
rewardRule
.
value
.
couponCounts
=
couponCounts
}
...
...
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