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
3dcd2320
Commit
3dcd2320
authored
Jul 10, 2020
by
秦海涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add: validate
parent
79ed990b
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
51 additions
and
11 deletions
+51
-11
app.json
client/app.json
+1
-1
prize-dialog.js
client/components/dialog/prize-dialog/prize-dialog.js
+1
-0
config.js
client/config.js
+3
-3
package-lock.json
client/package-lock.json
+5
-0
package.json
client/package.json
+1
-0
add.axml
client/pages/activity/add/add.axml
+4
-3
add.js
client/pages/activity/add/add.js
+2
-1
validate.js
client/pages/activity/add/validate.js
+5
-3
validate.js
client/utils/validate.js
+29
-0
No files found.
client/app.json
View file @
3dcd2320
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
"pages/cmp/index/index"
"pages/cmp/index/index"
],
],
"window"
:
{
"window"
:
{
"defaultTitle"
:
"
www
"
"defaultTitle"
:
"
店铺漂流记商家管理后台
"
},
},
"plugins"
:
{
"plugins"
:
{
"myPlugin"
:
{
"myPlugin"
:
{
...
...
client/components/dialog/prize-dialog/prize-dialog.js
View file @
3dcd2320
...
@@ -311,6 +311,7 @@ Component({
...
@@ -311,6 +311,7 @@ Component({
if
(
dialogType
!==
'probablity'
)
{
if
(
dialogType
!==
'probablity'
)
{
this
.
showItemTips
(
"probablityTips"
,
"success"
,
""
);
this
.
showItemTips
(
"probablityTips"
,
"success"
,
""
);
}
}
const
{
const
{
LUKCY_POCKET_TYPE
,
LUKCY_POCKET_TYPE
,
COUPON_TYPE
,
COUPON_TYPE
,
...
...
client/config.js
View file @
3dcd2320
...
@@ -6,11 +6,11 @@ export default {
...
@@ -6,11 +6,11 @@ export default {
env
:
"test"
,
// online 线上 test 测试
env
:
"test"
,
// online 线上 test 测试
// 默认云函数名称
// 默认云函数名称
cloudFnName
:
'
backstage
'
,
cloudFnName
:
'
duiba
'
,
// 小程序appId
// 小程序appId
appId
:
"
eee
"
,
appId
:
"
3000000002590532
"
,
// 配置应用appID, 权益插件用
// 配置应用appID, 权益插件用
bizCode
:
"
222
"
,
bizCode
:
"
3000000002693435
"
,
};
};
client/package-lock.json
View file @
3dcd2320
...
@@ -18,6 +18,11 @@
...
@@ -18,6 +18,11 @@
"resolved"
:
"https://registry.npm.taobao.org/dayjs/download/dayjs-1.8.28.tgz"
,
"resolved"
:
"https://registry.npm.taobao.org/dayjs/download/dayjs-1.8.28.tgz"
,
"integrity"
:
"sha1-N6piAd9IPQiWRctsj2zvbwxNvAc="
"integrity"
:
"sha1-N6piAd9IPQiWRctsj2zvbwxNvAc="
},
},
"lodash"
:
{
"version"
:
"4.17.19"
,
"resolved"
:
"https://registry.npm.taobao.org/lodash/download/lodash-4.17.19.tgz?cache=0&sync_timestamp=1594226805918&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.19.tgz"
,
"integrity"
:
"sha1-5I3e2+MLMyF4PFtDAfvTU7weSks="
},
"miniapp-router"
:
{
"miniapp-router"
:
{
"version"
:
"0.1.7"
,
"version"
:
"0.1.7"
,
"resolved"
:
"https://registry.npm.taobao.org/miniapp-router/download/miniapp-router-0.1.7.tgz"
,
"resolved"
:
"https://registry.npm.taobao.org/miniapp-router/download/miniapp-router-0.1.7.tgz"
,
...
...
client/package.json
View file @
3dcd2320
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
"@tbmp/mp-cloud-sdk"
:
"1.1.4"
,
"@tbmp/mp-cloud-sdk"
:
"1.1.4"
,
"async-validator"
:
"^3.3.0"
,
"async-validator"
:
"^3.3.0"
,
"dayjs"
:
"^1.8.28"
,
"dayjs"
:
"^1.8.28"
,
"lodash"
:
"^4.17.19"
,
"miniapp-router"
:
"^0.1.6"
,
"miniapp-router"
:
"^0.1.6"
,
"moment"
:
"^2.24.0"
"moment"
:
"^2.24.0"
}
}
...
...
client/pages/activity/add/add.axml
View file @
3dcd2320
...
@@ -20,7 +20,6 @@
...
@@ -20,7 +20,6 @@
originalStartTime="{{originalStartTime}}"
originalStartTime="{{originalStartTime}}"
onChange="onTimeChange"
onChange="onTimeChange"
disableStartTime="{{isStart}}"
disableStartTime="{{isStart}}"
tips="demo"
/>
/>
</form-item>
</form-item>
...
@@ -37,6 +36,7 @@
...
@@ -37,6 +36,7 @@
dataName="title"
dataName="title"
hasLimitHint="{{true}}"
hasLimitHint="{{true}}"
onChange="onChange"
onChange="onChange"
tips="活动名称仅在配置后台展示,用于区分活动,不在C端展示"
/>
/>
</form-item>
</form-item>
...
@@ -53,6 +53,7 @@
...
@@ -53,6 +53,7 @@
dataName="subtitle"
dataName="subtitle"
hasLimitHint="{{true}}"
hasLimitHint="{{true}}"
onChange="onChange"
onChange="onChange"
tips="活动副标题用于C端游戏首页展示,需与活动奖品相关,用于吸引用户参与"
/>
/>
</form-item>
</form-item>
...
@@ -69,7 +70,7 @@
...
@@ -69,7 +70,7 @@
<tb-label title="任务配置"/>
<tb-label title="任务配置"/>
<form-item
<
!-- <
form-item
class="edit-content-form-item"
class="edit-content-form-item"
label="关注店铺"
label="关注店铺"
validateState="{{formState['taskMap.attentionStore'].status}}"
validateState="{{formState['taskMap.attentionStore'].status}}"
...
@@ -84,7 +85,7 @@
...
@@ -84,7 +85,7 @@
onChange="onTaskInputChange",
onChange="onTaskInputChange",
placeholder="1-99"
placeholder="1-99"
/>
/>
</form-item>
</form-item>
-->
<form-item
<form-item
class="edit-content-form-item"
class="edit-content-form-item"
...
...
client/pages/activity/add/add.js
View file @
3dcd2320
...
@@ -242,7 +242,8 @@ Component({
...
@@ -242,7 +242,8 @@ Component({
const
_this
=
this
;
const
_this
=
this
;
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
,
reject
)
=>
{
validator
.
validate
(
data
,
(
errors
,
fields
)
=>
{
validator
.
validate
(
data
,
(
errors
,
fields
)
=>
{
console
.
log
(
errors
,
fields
)
console
.
log
(
'errors'
,
errors
);
console
.
log
(
'fields'
,
fields
);
const
{
formState
}
=
_this
.
data
;
const
{
formState
}
=
_this
.
data
;
_this
.
setFormTips
(
formState
,
errors
,
target
)
_this
.
setFormTips
(
formState
,
errors
,
target
)
if
(
errors
)
{
if
(
errors
)
{
...
...
client/pages/activity/add/validate.js
View file @
3dcd2320
import
{
TASK_RATE_TYPE
}
from
'../const'
import
{
TASK_RATE_TYPE
}
from
'../const'
import
flatten
from
'lodash/flatten'
import
{
rankTableValidator
}
from
"../../../utils/validate"
;
// 使用 async-validator 校验
// 文档地址: https://github.com/yiminghe/async-validator
export
const
descriptor
=
{
export
const
descriptor
=
{
title
:
{
title
:
{
required
:
true
,
required
:
true
,
...
@@ -14,8 +17,7 @@ export const descriptor = {
...
@@ -14,8 +17,7 @@ export const descriptor = {
},
},
prizeInfoList
:
{
prizeInfoList
:
{
required
:
true
,
required
:
true
,
validator
:
(
rule
,
value
)
=>
!!
value
.
length
,
validator
:
rankTableValidator
message
:
"请至少添加一项奖品配置"
},
},
timeRange
:
{
timeRange
:
{
required
:
true
required
:
true
...
...
client/utils/validate.js
View file @
3dcd2320
...
@@ -39,3 +39,32 @@ export const validateRangeNumber = (number, [ min, max ] = [], fixed = 0) => {
...
@@ -39,3 +39,32 @@ export const validateRangeNumber = (number, [ min, max ] = [], fixed = 0) => {
return
true
;
return
true
;
}
}
// 配置验证
// 排名表格验证
export
const
rankTableValidator
=
(
rule
,
value
,
callback
,
source
,
options
)
=>
{
if
(
!
value
.
length
)
return
new
Error
(
'请配置至少一项奖品配置'
);
// rank字段不存在或为0
if
(
value
.
some
(
v
=>
!
v
.
rank
))
return
new
Error
(
'名次配置错误, 请检查'
);
const
rankArr
=
(
value
.
map
(
v
=>
v
.
rank
.
split
(
'-'
)));
// 判断排名连续
let
valid
=
true
;
rankArr
.
forEach
((
rank
,
i
)
=>
{
if
(
i
===
0
)
return
;
let
lastRank
=
rankArr
[
i
-
1
][
rankArr
[
i
-
1
].
length
-
1
];
let
curRank
=
rank
[
0
];
if
(
curRank
-
lastRank
!==
1
)
{
valid
=
false
;
}
})
if
(
!
valid
)
return
new
Error
(
'名次索引必须连续, 请检查'
);
return
callback
()
}
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