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
19d8f20e
Commit
19d8f20e
authored
Jul 22, 2020
by
秦海涛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
7eabebef
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
94 additions
and
164 deletions
+94
-164
tb-rule.axml
client/components/form/tb-rule/tb-rule.axml
+1
-0
tb-rule.js
client/components/form/tb-rule/tb-rule.js
+2
-1
add.js
client/pages/activity/add/add.js
+32
-163
mixins.js
client/pages/activity/add/mixins.js
+59
-0
No files found.
client/components/form/tb-rule/tb-rule.axml
View file @
19d8f20e
...
...
@@ -7,6 +7,7 @@
style="width:400px;margin: 10px 0 0 0"
value="{{value}}"
onChange="onChange"
data-name="{{dataName}}"
maxLength="2000"
hasLimitHint="{{true}}"
>
...
...
client/components/form/tb-rule/tb-rule.js
View file @
19d8f20e
...
...
@@ -5,13 +5,14 @@ Component({
props
:
{
onChange
:
()
=>
{},
value
:
''
,
dataName
:
''
,
generateRuleInfo
:
{}
},
didMount
()
{},
didUpdate
()
{},
methods
:
{
onChange
(
e
)
{
this
.
props
.
onChange
&&
this
.
props
.
onChange
(
e
.
detail
.
value
);
this
.
props
.
onChange
&&
this
.
props
.
onChange
(
e
.
detail
.
value
,
e
.
target
.
dataset
.
name
);
},
async
handleTapGeneralRule
()
{
console
.
log
(
this
.
props
.
generateRuleInfo
,
'this.props.generateRuleInfo'
)
...
...
client/pages/activity/add/add.js
View file @
19d8f20e
import
moment
from
'moment'
import
schema
from
'async-validator'
;
import
{
methods
}
from
'./mixins'
import
{
descriptor
,
formatValidator
...
...
@@ -16,18 +17,6 @@ import {
const
THANKS_TYPE
=
5
var
validator
=
new
schema
(
descriptor
);
Component
({
data
:
{
labelCol
:
{
fixedSpan
:
5
},
id
:
''
,
startTime
:
''
,
endTime
:
''
,
<%
for
(
var
i
=
0
;
i
<
configList
.
length
;
++
i
)
{
%>
<%-
!
taskKeys
.
includes
(
configList
[
i
].
key
)
&&
configList
[
i
].
key
!==
'label'
?
`
${
configList
[
i
].
key
}
:
${
configList
[
i
].
defaultValue
||
"''"
}
,`
:
''
%><%
}
%>
taskList
:
[
// {
// type: "beMembership",//会员
// value: 20,//完成任务获得值
...
...
@@ -84,8 +73,16 @@ Component({
// value: 90,
// itemIds: "111,222,333",
// }
],
Component
({
mixins
:
[
methods
],
data
:
{
labelCol
:
{
fixedSpan
:
5
},
id
:
''
,
startTime
:
''
,
endTime
:
''
,
<%
for
(
var
i
=
0
;
i
<
configList
.
length
;
++
i
)
{
%>
<%-
!
taskKeys
.
includes
(
configList
[
i
].
key
)
&&
configList
[
i
].
key
!==
'label'
?
`
${
configList
[
i
].
key
}
:
${
configList
[
i
].
defaultValue
||
"''"
}
,`
:
''
%><%
}
%>
taskList
:
[],
taskMap
:
{
attentionStore
:
{
value
:
''
,
...
...
@@ -142,136 +139,34 @@ Component({
originalStartTime
:
''
,
formState
:
formatValidator
(
descriptor
)
},
props
:
{},
didMount
()
{
const
{
id
}
=
this
.
$page
.
$router
.
params
if
(
id
)
{
this
.
getActivityInfo
(
id
)
}
const
{
id
}
=
this
.
$page
.
$router
.
params
id
&&
this
.
getActivityInfo
(
id
)
},
methods
:
{
// 获取
i
d活动信息
// 获取
activityI
d活动信息
async
getActivityInfo
(
activityId
)
{
try
{
const
{
success
,
data
,
message
}
=
await
getActivityDetail
({
activityId
})
const
{
success
,
data
,
message
}
=
await
getActivityDetail
({
activityId
})
if
(
!
success
)
{
this
.
showFailToast
(
message
);
return
;
}
let
{
prizeInfoList
,
...
rest
}
=
data
;
this
.
setData
({
...
rest
,
timeRange
:
[
+
rest
.
startTime
,
+
rest
.
endTime
],
originalStartTime
:
+
rest
.
startTime
,
isStart
:
+
rest
.
startTime
<
Date
.
now
(),
isEnd
:
+
rest
.
endTime
<
Date
.
now
(),
taskList
:
rest
.
taskList
,
taskMap
:
this
.
formatTaskListToMap
(
rest
.
taskList
)
...
data
,
timeRange
:
[
+
data
.
startTime
,
+
data
.
endTime
],
originalStartTime
:
+
data
.
startTime
,
isStart
:
+
data
.
startTime
<
Date
.
now
(),
isEnd
:
+
data
.
endTime
<
Date
.
now
(),
taskList
:
data
.
taskList
,
taskMap
:
this
.
formatTaskListToMap
(
data
.
taskList
)
})
}
catch
(
error
)
{
console
.
log
(
error
,
'err'
)
}
},
onChange
(
e
)
{
const
{
value
}
=
e
.
detail
;
const
{
name
}
=
e
.
target
.
dataset
;
this
.
setData
({
[
name
]:
value
})
},
onRuleChange
(
rule
)
{
this
.
setData
({
rule
})
},
setDataByKey
(
val
,
name
)
{
const
keys
=
name
.
split
(
'.'
);
if
(
keys
.
length
===
1
)
{
this
.
setData
({
[
keys
[
0
]]:
val
})
}
if
(
keys
.
length
===
2
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
})
}
if
(
keys
.
length
===
3
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]][
keys
[
2
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
})
}
},
onConfigInputChange
(
e
)
{
const
{
name
}
=
e
.
target
.
dataset
;
const
{
value
}
=
e
.
detail
;
this
.
setDataByKey
(
value
,
name
);
},
onCheckChange
(
e
)
{
const
{
name
}
=
e
.
target
.
dataset
;
const
{
value
}
=
e
.
detail
;
this
.
setDataByKey
(
value
,
name
);
},
onTaskChange
(
data
,
key
)
{
console
.
log
(
data
,
key
)
this
.
setDataByKey
(
data
,
key
);
},
onTimeChange
(
timeRange
,
error
)
{
const
{
formState
}
=
this
.
data
;
this
.
setData
({
timeRange
,
startTime
:
timeRange
[
0
],
endTime
:
timeRange
[
1
],
formState
:
{
...
formState
,
timeRange
:
{
status
:
error
?
'error'
:
'success'
,
message
:
error
||
''
}
}
})
},
onPrizeListChange
(
list
,
target
)
{
this
.
setData
({
[
target
]:
list
})
},
validateForm
(
data
,
target
)
{
const
_this
=
this
;
return
new
Promise
((
resolve
,
reject
)
=>
{
...
...
@@ -316,11 +211,10 @@ Component({
// 提交信息
async
onSubmit
()
{
console
.
log
(
this
.
data
)
console
.
log
(
this
.
data
,
'this.data'
)
const
isValidForm
=
await
this
.
validateForm
(
this
.
data
);
// console.log(this.formatActivityParams(this.data))
if
(
!
isValidForm
)
return
;
...
...
@@ -329,19 +223,16 @@ Component({
const
params
=
this
.
formatActivityParams
(
this
.
data
)
console
.
log
(
params
)
console
.
log
(
params
,
'params'
)
saveActivityInfo
(
params
)
.
then
(
res
=>
{
if
(
res
.
success
)
{
const
{
success
,
message
}
=
await
saveActivityInfo
(
params
)
if
(
success
)
{
this
.
backList
()
}
else
{
this
.
showFailToast
(
res
.
message
)
}
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
},
showFailToast
(
text
)
{
my
.
showToast
({
...
...
@@ -416,28 +307,6 @@ Component({
}
return
prizeInfoListCopy
},
cancelEdit
()
{
this
.
backList
()
},
onInputChange
(
e
)
{
let
{
detail
:
{
value
},
currentTarget
:
{
dataset
}
}
=
e
let
{
name
}
=
dataset
this
.
setData
({
[
name
]:
value
})
},
onChangeByDataName
(
val
,
dataName
)
{
this
.
setDataByKey
(
val
,
dataName
)
},
backList
()
{
this
.
$page
.
$router
.
push
(
"/activity/list"
);
}
...
...
client/pages/activity/add/mixins.js
0 → 100644
View file @
19d8f20e
export
const
methods
=
{
// 根据dataName 改变值
onInputChangeByDataName
(
e
)
{
const
{
name
}
=
e
.
target
.
dataset
;
const
{
value
}
=
e
.
detail
;
this
.
setDataByKey
(
value
,
name
);
},
onTimeChange
(
timeRange
,
error
)
{
const
{
formState
}
=
this
.
data
;
this
.
setData
({
timeRange
,
startTime
:
timeRange
[
0
],
endTime
:
timeRange
[
1
],
formState
:
{
...
formState
,
timeRange
:
{
status
:
error
?
'error'
:
'success'
,
message
:
error
||
''
}
}
})
},
onChangeByDataName
(
val
,
key
)
{
this
.
setDataByKey
(
val
,
key
)
},
/**
*根据key值改变数据, 支持key a/a.b/a.b.c的形式
*
* @param {*} val
* @param {string} key
*/
setDataByKey
(
val
,
key
)
{
const
keys
=
key
.
split
(
'.'
);
if
(
keys
.
length
===
1
)
{
this
.
setData
({
[
keys
[
0
]]:
val
})
}
if
(
keys
.
length
===
2
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
})
}
if
(
keys
.
length
===
3
)
{
let
targetKey
=
this
.
data
[
keys
[
0
]];
targetKey
[
keys
[
1
]][
keys
[
2
]]
=
val
;
let
newVal
=
Object
.
assign
({},
targetKey
)
this
.
setData
({
[
keys
[
0
]]:
newVal
})
}
},
}
\ No newline at end of file
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