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
9d1965ff
Commit
9d1965ff
authored
Aug 25, 2020
by
李硕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
奖品的排行榜和保存库存值判断
parent
cdc42d4b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
139 additions
and
23 deletions
+139
-23
prize-dialog.js
client/components/dialog/prize-dialog/prize-dialog.js
+38
-18
add.axml
client/pages/activity/addBackup/add.axml
+1
-1
helper.js
client/utils/helper.js
+100
-4
No files found.
client/components/dialog/prize-dialog/prize-dialog.js
View file @
9d1965ff
...
...
@@ -3,9 +3,7 @@ const { function: fc } = cloud;
const
plugin
=
requirePlugin
(
"myPlugin"
);
import
{
bizCode
}
from
"/config"
;
import
{
queryBenefitByEname
}
from
"/api"
;
import
{
chooseImage
,
getImageInfo
,
validateRangeNumber
}
from
"/utils"
;
const
EQUITY_TYPE
=
1
;
const
CREDITS_TYPE
=
2
;
const
OBJECT_TYPE
=
3
;
...
...
@@ -360,14 +358,31 @@ Component({
this
.
showItemTips
(
"prizeNameTips"
,
"success"
,
""
);
}
if
((
type
==
OBJECT_TYPE
||
type
==
EQUITY_TYPE
)
&&
switchStock
===
STOCK_LIMIT
&&
!
validateRangeNumber
(
stock
,
[
0
,
9999
]))
{
//库存奖品的库存值判断
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
))
{
if
(
!
validateRangeNumber
(
stock
,
[
0
,
99999
]))
{
this
.
showItemTips
(
"prizeNumberTips"
,
"error"
,
"奖品库存为0-9999之间的整数"
"奖品库存为0-99999之间的整数且大于发放库存"
);
}
if
(
!
usePass
)
{
this
.
showItemTips
(
"prizeNumberTips"
,
"error"
,
"奖品库存必须大于发放库存"
);
}
}
else
{
this
.
showItemTips
(
"prizeNumberTips"
,
"success"
,
""
);
}
else
{
this
.
showItemTips
(
"prizeNumberTips"
,
"success"
,
""
);
}
if
(
type
==
CREDITS_TYPE
&&
!
validateRangeNumber
(
credits
,
[
0
,
999
]))
{
...
...
@@ -380,8 +395,16 @@ Component({
this
.
showItemTips
(
"creditsValueTips"
,
"success"
,
""
);
}
//排行榜奖品保存判断
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
(
!
rank
)
{
if
(
!
isRankPass
)
{
this
.
showItemTips
(
"rankValueTips"
,
"error"
,
...
...
@@ -390,17 +413,14 @@ Component({
}
else
{
this
.
showItemTips
(
"rankValueTips"
,
"success"
,
""
);
}
}
const
rankArr
=
rank
.
split
(
'-'
);
if
(
dialogType
===
'rank'
&&
maxRankLimit
&&
rankArr
[
rankArr
.
length
-
1
]
>
maxRankLimit
)
{
if
(
maxRankLimit
&&
rankArr
[
rankArr
.
length
-
1
]
>
maxRankLimit
)
{
my
.
showToast
({
type
:
"fail"
,
content
:
`最多配置前
${
maxRankLimit
}
名奖品`
});
return
;
}
}
const
{
probablityTips
,
prizeNumberTips
,
creditsValueTips
}
=
this
.
data
;
const
isImagePass
=
image
&&
imageTips
.
status
!==
"error"
;
...
...
client/pages/activity/addBackup/add.axml
View file @
9d1965ff
...
...
@@ -217,7 +217,7 @@
</form-item>
<view class="submit-btn">
<!--
20200824LS
活动结束不可编辑 -->
<!-- 活动结束不可编辑 -->
<button a:if="{{!isEnd}}" onTap="onSubmit" type="primary">确定</button>
<button onTap="cancelEdit">取消</button>
</view>
...
...
client/utils/helper.js
View file @
9d1965ff
export
function
debounce
(
fn
,
wait
)
{
function
debounce
(
fn
,
wait
)
{
var
timeout
=
null
return
function
()
{
if
(
timeout
!==
null
)
clearTimeout
(
timeout
)
timeout
=
setTimeout
(
fn
,
wait
)
}
}
//域名
const
passUrlList
=
[
'1688.cn'
,
'1688.com'
,
'alibaba.cn'
,
'alibaba.com'
,
'aliexpress.com'
,
'alimama.cn'
,
'alimama.com'
,
'alipay.com.cn'
,
'alipay.com'
,
'alipay.net'
,
'aliplay.com'
,
'alisoft.cn'
,
'alisoft.com'
,
'aliyun.com'
,
'aliyun.net'
,
'koubei.cn'
,
'koubei.com'
,
'taobao.cn'
,
'taobao.com'
,
'taobao.net'
,
'tb.cn'
,
'tmall.com'
,
'zhifu.com'
,
'zhifubao.com'
,
'juhuasuan.com'
,
'tmall.hk'
,
'tmall.com.hk'
,
'jiyoujia.com'
,
'pailitao.com'
,
'cainiao.com'
,
'dingtalk.com'
,
'yushanfang.com'
,
'guoguo - app.com'
,
'alihealth.cn'
,
'miaostreet.com'
,
'uc123.com'
,
'uc.cn'
,
'ucweb.com'
,
'aliyun - inc.com'
,
'cainiaoyizhan.com'
,
'umeng.com'
,
'aliplus.com'
,
'aliplay.com'
,
'taopiaopiao.com'
,
'youku.com'
,
'tudou.com'
,
'xinlingshou.cn'
,
'fliggy.com'
,
'feizhu.com'
,
'feizhu.cn'
];
// 解决小数相加精度问题
export
function
addFloat
(
num1
,
num2
)
{
function
addFloat
(
num1
,
num2
)
{
var
r1
,
r2
,
m
r1
=
num1
.
toString
().
split
(
"."
)[
1
]
?
num1
.
toString
().
split
(
"."
)[
1
].
length
:
0
r2
=
num2
.
toString
().
split
(
"."
)[
1
]
?
num2
.
toString
().
split
(
"."
)[
1
].
length
:
0
m
=
Math
.
pow
(
10
,
Math
.
max
(
r1
,
r2
))
return
(
num1
*
m
+
num2
*
m
)
/
m
}
//小数相除
const
accMul
=
function
(
arg1
,
arg2
)
{
var
m
=
0
,
s1
=
arg1
.
toString
(),
s2
=
arg2
.
toString
();
try
{
m
+=
s1
.
split
(
"."
)[
1
].
length
;
}
catch
(
e
)
{
}
try
{
m
+=
s2
.
split
(
"."
)[
1
].
length
;
}
catch
(
e
)
{
}
return
(
(
Number
(
s1
.
replace
(
"."
,
""
))
*
Number
(
s2
.
replace
(
"."
,
""
)))
/
Math
.
pow
(
10
,
m
)
);
}
//小数相乘
const
signFigures
=
function
(
num
,
rank
=
6
)
{
if
(
!
num
)
return
0
;
const
sign
=
num
/
Math
.
abs
(
num
);
const
number
=
num
*
sign
;
const
temp
=
rank
-
1
-
Math
.
floor
(
Math
.
log10
(
number
));
let
ans
;
if
(
temp
>
0
)
{
ans
=
parseFloat
(
number
.
toFixed
(
temp
));
}
else
if
(
temp
<
0
)
{
ans
=
Math
.
round
(
number
/
Math
.
pow
(
10
,
temp
))
*
temp
;
}
else
{
ans
=
Math
.
round
(
number
);
}
return
ans
*
sign
;
};
module
.
exports
=
{
passUrlList
,
signFigures
,
debounce
,
accMul
,
addFloat
};
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