Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
qinhaitao
taobao-mini-template
Commits
76939dff
Commit
76939dff
authored
Sep 22, 2020
by
qinhaitao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:
🐛
bug
parent
878c35c3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
63 deletions
+81
-63
prize-dialog.js
client/components/dialog/prize-dialog/prize-dialog.js
+81
-63
No files found.
client/components/dialog/prize-dialog/prize-dialog.js
View file @
76939dff
...
...
@@ -25,7 +25,7 @@ const INIT_DATA = {
name
:
""
,
switchStock
:
STOCK_NO_LIMIT
,
useStock
:
0
,
rank
:
""
rank
:
""
,
};
Component
({
...
...
@@ -69,6 +69,10 @@ Component({
status
:
"success"
,
content
:
""
,
},
goodIdTips
:
{
status
:
"success"
,
content
:
""
,
},
rankValueTips
:
{
status
:
"success"
,
content
:
""
,
...
...
@@ -87,30 +91,29 @@ Component({
name
:
""
,
switchStock
:
STOCK_NO_LIMIT
,
useStock
:
0
,
rank
:
""
rank
:
""
,
},
},
props
:
{
prizeDialogData
:
{
index
:
''
,
record
:
{}
index
:
""
,
record
:
{}
,
},
maxRankLimit
:
''
,
// 限制最高排名
type
:
'probability'
,
// 奖品弹窗类型 probability: 概率 rank: 排名
maxRankLimit
:
""
,
// 限制最高排名
type
:
"probability"
,
// 奖品弹窗类型 probability: 概率 rank: 排名
imageLimit
:
[
250
,
250
],
activityOutId
:
""
,
isEdit
:
false
,
visible
:
false
,
hasEditPrize
:
false
,
datasource
:
[],
onCloseDialog
:
function
()
{
},
onUpdate
:
function
()
{
}
onCloseDialog
:
function
()
{},
onUpdate
:
function
()
{
},
},
didMount
()
{
this
.
initPosition
();
this
.
resetPrizeInit
();
this
.
initBenefit
();
},
methods
:
{
initPosition
()
{
...
...
@@ -125,13 +128,20 @@ Component({
bizCode
,
//此处输入想配置的商家应用appID
//这个方法用于获取插件中用户选择的奖池enname
async
getCheckBenefitID
({
ename
,
poolID
})
{
my
.
showToast
({
type
:
"success"
,
content
:
"已选择权益奖品"
,
});
const
{
success
,
data
,
message
}
=
await
queryBenefitByEname
({
ename
});
const
{
benefitName
,
rightTypeId
,
startTime
,
endTime
,
stock
}
=
data
[
0
];
const
{
success
,
data
,
message
}
=
await
queryBenefitByEname
({
ename
,
});
const
{
benefitName
,
rightTypeId
,
startTime
,
endTime
,
stock
,
}
=
data
[
0
];
if
(
success
)
{
//切换不同优惠券内容置空
if
(
ename
==
that
.
data
.
prizeInitData
.
ename
)
{
...
...
@@ -142,7 +152,7 @@ Component({
type
:
EQUITY_TYPE
,
startTime
,
endTime
,
stock
:
stock
stock
:
stock
,
},
});
}
else
{
...
...
@@ -154,9 +164,9 @@ Component({
startTime
,
_id
:
null
,
endTime
,
stock
:
''
,
stock
:
""
,
useStock
:
0
,
switchStock
:
2
switchStock
:
2
,
},
});
}
...
...
@@ -188,7 +198,7 @@ Component({
prizeInitData
:
{
...
INIT_DATA
,
type
,
rank
rank
,
},
});
},
...
...
@@ -207,7 +217,7 @@ Component({
credits
:
""
,
probability
:
""
,
name
:
""
,
switchStock
:
STOCK_NO_LIMIT
switchStock
:
STOCK_NO_LIMIT
,
};
if
(
type
!==
value
)
{
this
.
resetPrizeData
(
+
value
,
rank
);
...
...
@@ -216,7 +226,7 @@ Component({
this
.
setData
({
prizeInitData
:
{
...
this
.
data
.
prizeInitData
,
...
initData
...
initData
,
},
});
},
...
...
@@ -228,9 +238,9 @@ Component({
},
resetPrizeInit
()
{
const
{
isEdit
,
prizeDialogData
}
=
this
.
props
;
console
.
log
(
isEdit
,
prizeDialogData
)
console
.
log
(
isEdit
,
prizeDialogData
)
;
if
(
isEdit
)
{
console
.
log
(
prizeDialogData
)
console
.
log
(
prizeDialogData
)
;
const
{
...
rest
}
=
prizeDialogData
.
record
;
this
.
setData
({
prizeInitData
:
{
...
...
@@ -239,7 +249,7 @@ Component({
});
}
else
{
this
.
setData
({
prizeInitData
:
INIT_DATA
prizeInitData
:
INIT_DATA
,
});
}
},
...
...
@@ -249,7 +259,7 @@ Component({
prizeInitData
:
{
...
this
.
data
.
prizeInitData
,
switchStock
:
value
,
stock
:
value
===
0
?
''
:
this
.
data
.
prizeInitData
.
stock
stock
:
value
===
0
?
""
:
this
.
data
.
prizeInitData
.
stock
,
},
});
},
...
...
@@ -260,7 +270,7 @@ Component({
});
const
res
=
await
chooseImage
();
this
.
setData
({
showDialogMask
:
true
showDialogMask
:
true
,
});
if
(
!
res
.
apFilePaths
.
length
)
return
;
...
...
@@ -284,13 +294,12 @@ Component({
fileName
:
path
.
split
(
"/"
).
pop
(),
});
this
.
setData
({
prizeInitData
:
{
...
this
.
data
.
prizeInitData
,
image
:
url
,
},
showDialogMask
:
true
showDialogMask
:
true
,
});
}
catch
(
error
)
{
this
.
setData
({
...
...
@@ -339,7 +348,11 @@ Component({
const
{
type
:
dialogType
,
maxRankLimit
}
=
this
.
props
;
let
probabilityRexp
=
/^
\d
+
(\.\d{1,2})?
$/
;
if
(
!
probabilityRexp
.
test
(
probability
)
||
probability
>
100
||
probability
==
0
)
{
if
(
!
probabilityRexp
.
test
(
probability
)
||
probability
>
100
||
probability
==
0
)
{
this
.
showItemTips
(
"probabilityTips"
,
"error"
,
...
...
@@ -349,7 +362,7 @@ Component({
this
.
showItemTips
(
"probabilityTips"
,
"success"
,
""
);
}
if
(
dialogType
!==
'probability'
)
{
if
(
dialogType
!==
"probability"
)
{
this
.
showItemTips
(
"probabilityTips"
,
"success"
,
""
);
}
...
...
@@ -369,14 +382,16 @@ Component({
return
;
}
//使用链接
if
(
type
==
EQUITY_TYPE
)
{
if
(
!
urlCheck
(
useUrl
,
passUrlList
).
status
)
{
this
.
showItemTips
(
'useUrlTips'
,
'error'
,
urlCheck
(
useUrl
,
passUrlList
).
message
);
}
else
{
this
.
showItemTips
(
'useUrlTips'
,
'success'
,
''
);
this
.
showItemTips
(
"useUrlTips"
,
"error"
,
urlCheck
(
useUrl
,
passUrlList
).
message
);
}
else
{
this
.
showItemTips
(
"useUrlTips"
,
"success"
,
""
);
}
}
//实物奖品的配置商品id
...
...
@@ -390,10 +405,9 @@ Component({
// }
if
(
type
==
EQUITY_TYPE
||
type
==
OBJECT_TYPE
)
{
if
(
!
desc
)
{
this
.
showItemTips
(
'prizeDescTips'
,
'error'
,
'请填写奖品描述'
);
}
else
{
this
.
showItemTips
(
'prizeDescTips'
,
'success'
,
''
);
this
.
showItemTips
(
"prizeDescTips"
,
"error"
,
"请填写奖品描述"
);
}
else
{
this
.
showItemTips
(
"prizeDescTips"
,
"success"
,
""
);
}
if
(
!
name
)
{
this
.
showItemTips
(
"prizeNameTips"
,
"error"
,
"请输入奖品名称"
);
...
...
@@ -401,13 +415,17 @@ Component({
this
.
showItemTips
(
"prizeNameTips"
,
"success"
,
""
);
}
if
(
!
image
)
{
this
.
showItemTips
(
'imageTips'
,
"error"
,
"请配置奖品图片"
);
this
.
showItemTips
(
"imageTips"
,
"error"
,
"请配置奖品图片"
);
}
}
//库存奖品的库存值判断
let
usePass
=
switchStock
==
1
?
+
stock
>=
+
useStock
:
true
;
console
.
log
(
'stock=='
,
stock
,
'useStock=='
,
useStock
);
if
((
type
==
OBJECT_TYPE
||
type
==
EQUITY_TYPE
)
&&
switchStock
===
STOCK_LIMIT
&&
(
!
validateRangeNumber
(
stock
,
[
0
,
99999
])
||
!
usePass
))
{
console
.
log
(
"stock=="
,
stock
,
"useStock=="
,
useStock
);
if
(
(
type
==
OBJECT_TYPE
||
type
==
EQUITY_TYPE
)
&&
switchStock
===
STOCK_LIMIT
&&
(
!
validateRangeNumber
(
stock
,
[
0
,
99999
])
||
!
usePass
)
)
{
if
(
!
validateRangeNumber
(
stock
,
[
0
,
99999
]))
{
this
.
showItemTips
(
"prizeNumberTips"
,
...
...
@@ -422,13 +440,8 @@ Component({
"奖品库存必须大于发放库存"
);
}
}
else
{
this
.
showItemTips
(
"prizeNumberTips"
,
"success"
,
""
);
}
else
{
this
.
showItemTips
(
"prizeNumberTips"
,
"success"
,
""
);
}
if
(
type
==
CREDITS_TYPE
&&
!
validateRangeNumber
(
credits
,
[
0
,
999
]))
{
...
...
@@ -442,32 +455,37 @@ Component({
}
//排行榜奖品保存判断
const
rankArr
=
rank
.
split
(
'-'
);
let
isRankPass
=
dialogType
==
"rank"
?
(
rankArr
.
length
==
2
?
+
rankArr
[
0
]
<=
+
rankArr
[
1
]
&&
/^
[
1-9
]
+
[
0-9
]
*$/
.
test
(
+
rankArr
[
0
])
&&
/^
[
1-9
]
+
[
0-9
]
*$/
.
test
(
+
rankArr
[
1
])
:
false
)
:
true
;
if
(
dialogType
===
'rank'
)
{
const
rankArr
=
rank
.
split
(
"-"
);
let
isRankPass
=
dialogType
==
"rank"
?
rankArr
.
length
==
2
?
+
rankArr
[
0
]
<=
+
rankArr
[
1
]
&&
/^
[
1-9
]
+
[
0-9
]
*$/
.
test
(
+
rankArr
[
0
])
&&
/^
[
1-9
]
+
[
0-9
]
*$/
.
test
(
+
rankArr
[
1
])
:
false
:
true
;
if
(
dialogType
===
"rank"
)
{
if
(
!
isRankPass
)
{
this
.
showItemTips
(
"rankValueTips"
,
"error"
,
"请输入正确的领奖名次"
);
this
.
showItemTips
(
"rankValueTips"
,
"error"
,
"请输入正确的领奖名次"
);
}
else
{
this
.
showItemTips
(
"rankValueTips"
,
"success"
,
""
);
}
if
(
maxRankLimit
&&
rankArr
[
rankArr
.
length
-
1
]
>
maxRankLimit
)
{
my
.
showToast
({
type
:
"fail"
,
content
:
`最多配置前
${
maxRankLimit
}
名奖品`
content
:
`最多配置前
${
maxRankLimit
}
名奖品`
,
});
return
;
}
}
const
{
probabilityTips
,
prizeNumberTips
,
creditsValueTips
,
useUrlTips
,
prizeDescTips
,
goodIdTips
}
=
this
.
data
;
const
{
probabilityTips
,
prizeNumberTips
,
creditsValueTips
,
useUrlTips
,
prizeDescTips
,
goodIdTips
,
}
=
this
.
data
;
const
isImagePass
=
image
&&
imageTips
.
status
!==
"error"
;
let
stockPass
=
true
;
...
...
@@ -518,10 +536,10 @@ Component({
};
if
(
isEdit
)
{
console
.
log
(
prizeData
,
'--prizeData--'
)
console
.
log
(
prizeData
,
"--prizeData--"
);
onUpdate
&&
onUpdate
(
prizeData
,
prizeDialogData
.
index
);
}
else
{
onAdd
&&
onAdd
(
prizeData
)
onAdd
&&
onAdd
(
prizeData
)
;
}
this
.
onCloseDialog
();
...
...
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