Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
activity-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
liupengfei
activity-core
Commits
fd815e7c
Commit
fd815e7c
authored
Jul 20, 2020
by
liupengfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
栗子
parent
047b16e0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
148 additions
and
0 deletions
+148
-0
README.md
src/plus/README.md
+0
-0
index.js
src/plus/index.js
+0
-0
index.html
test/tapableTest/index.html
+0
-0
index.js
test/tapableTest/index.js
+148
-0
index.less
test/tapableTest/index.less
+0
-0
No files found.
src/plus/README.md
deleted
100644 → 0
View file @
047b16e0
src/plus/index.js
deleted
100644 → 0
View file @
047b16e0
test/tapable
-t
est/index.html
→
test/tapable
T
est/index.html
View file @
fd815e7c
File moved
test/tapable
-t
est/index.js
→
test/tapable
T
est/index.js
View file @
fd815e7c
/* eslint-disable */
/*
* @Author: flyharvest
* @Date: 2020-07-14 14:09:40
* @LastEditTime: 2020-07-
20 15:54:52
* @LastEditTime: 2020-07-
19 13:49:33
* @LastEditors: flyharvest
*/
import
*
as
rem
from
'@lib/flexible'
import
{
ajax
}
from
'@lib/xhr'
import
services
from
'@lib/services'
import
{
HandleDojoin
}
from
'@lib/handleDojoin'
import
{
CustomError
}
from
'@lib/utils'
import
{
CouponModal
}
from
'@lib/couponModal'
import
{
isFn
}
from
'@lib/utils'
import
$
from
'jquery'
import
'./index.less'
...
...
@@ -18,132 +17,94 @@ rem.setViewPort()
rem
.
init
(
750
,
750
)
services
.
use
(
ajax
)
const
Do
j
oin
=
services
.
DoJoin
const
Do
J
oin
=
services
.
DoJoin
const
dojoin
=
new
Dojoin
()
const
couponModal
=
new
CouponModal
()
const
handleDojoin
=
new
HandleDojoin
()
const
handOut
=
(
opts
,
sign
,
external
=
{})
=>
{
const
steam
=
[
dojoin
,
handleDojoin
,
couponModal
]
steam
.
forEach
(
e
=>
{
e
.
hooksDefine
.
forEach
(
name
=>
{
const
cb
=
(
data
)
=>
{
const
fn
=
opts
[
name
]
if
(
fn
&&
isFn
(
fn
)
&&
fn
.
then
)
{
return
fn
(
data
,
external
[
name
])
}
else
if
(
fn
&&
isFn
(
fn
))
{
return
Promise
.
resolve
(
fn
(
data
,
external
[
name
]))
}
else
{
return
Promise
.
resolve
()
}
}
e
.
hooks
[
name
].
tapPromise
(
sign
,
cb
)
})
})
}
const
coreMethods
=
{
/**
* @description: 初始化并挂载,并挂载通用的周期
* @example:
* @param {type}
* @return:
*/
const
dojoin
=
new
DoJoin
({
beforeDojoin
(
data
)
{
console
.
log
(
'我被调用-core'
)
return
{
haha
:
123123
}
}
})
const
couponModal
=
new
CouponModal
({
close
(
type
)
{
return
type
},
mediaMsg
()
{
console
.
log
(
media
+
'ss'
)
},
modifyDom
({
el
})
{
$
(
el
).
find
(
'.content'
).
css
({
replaceHtml
(
data
)
{
$
(
data
).
find
(
'.content'
).
css
({
background
:
'red'
})
}
}
}
)
const
handleDojoin
=
new
HandleDojoin
({
mediaMsg
(
media
)
{
console
.
log
(
media
+
'ss'
)
}
})
/**
* @description:
假装这个methods 是由继承提供的。
* @description:
分配到不同模块的hooks
* @example:
* @param {type}
* @return:
*/
const
methods
=
{
beforeDojoin
(
data
)
{
console
.
log
(
'我被调用了-skinName'
)
return
{
lala
:
'123213'
}
},
modifyDom
({
el
},
fn
)
{
console
.
log
(
fn
)
$
(
el
).
find
(
'.confirm'
).
css
({
background
:
'green'
})
return
{
el
}
}
const
allHooks
=
{
dojoin
:
dojoin
.
allHooksName
,
handleDojoin
:
handleDojoin
.
allHooksName
,
couponModal
:
couponModal
.
allHooksName
}
handOut
(
methods
,
'skinDefault'
,
coreMethods
)
handOut
(
coreMethods
,
'core'
)
let
inited
=
false
const
tempHandOut
=
(
opts
,
sign
,
external1
=
{},
external2
=
{})
=>
{
if
(
inited
)
{
tempHandOut
.
setOpts
(
opts
)
return
const
handout
=
(
opts
=
{})
=>
{
const
cbs
=
{
dojoin
:
{},
handleDojoin
:
{},
couponModal
:
{}
}
inited
=
true
tempHandOut
.
setOpts
(
opts
)
const
steam
=
[
dojoin
,
handleDojoin
,
couponModal
]
steam
.
forEach
(
e
=>
{
e
.
hooksDefine
.
forEach
(
name
=>
{
const
cb
=
(
data
)
=>
{
const
fn
=
tempHandOut
.
getOpts
()[
name
]
if
(
fn
&&
isFn
(
fn
)
&&
fn
.
then
)
{
return
fn
(
data
,
external1
[
name
],
external2
[
name
])
}
else
if
(
fn
&&
isFn
(
fn
))
{
return
Promise
.
resolve
(
fn
(
data
,
external1
[
name
],
external2
[
name
]))
}
else
{
return
Promise
.
resolve
()
for
(
const
i
in
opts
)
{
if
(
opts
[
i
])
{
for
(
const
name
in
allHooks
)
{
if
(
allHooks
[
name
].
indexOf
(
i
)
>
-
1
)
{
cbs
[
name
][
i
]
=
opts
[
i
]
}
}
e
.
hooks
[
name
].
tapPromise
({
name
:
sign
,
stage
:
-
1
},
cb
)
})
})
}
tempHandOut
.
setOpts
=
(
opts
)
=>
{
tempHandOut
.
opts
=
opts
return
opts
}
tempHandOut
.
getOpts
=
()
=>
{
return
tempHandOut
.
opts
}
}
return
cbs
}
const
$doJoin
=
(
opts
=
{})
=>
{
tempHandOut
(
opts
,
'skinTemp'
)
console
.
log
(
dojoin
)
return
dojoin
.
start
().
then
(
res
=>
{
return
handleDojoin
.
start
(
res
)
/**
* @description: 类比现在的dojoin
* @example:
* @param {type}
* @return:
*/
const
$doJoin
=
(
opts
)
=>
{
const
cbs
=
handout
(
opts
)
console
.
log
(
cbs
)
return
dojoin
.
start
(
cbs
.
dojoin
)
.
then
(
res
=>
{
return
handleDojoin
.
handle
(
res
,
cbs
.
handleDojoin
)
})
.
then
(
res
=>
{
return
couponModal
.
start
(
res
)
return
couponModal
.
show
(
res
,
cbs
.
couponModal
)
})
.
then
((
data
)
=>
{
console
.
log
(
data
)
.
catch
(
err
=>
{
if
(
err
instanceof
CustomError
)
{
console
.
log
(
err
)
}
console
.
log
(
err
)
})
}
let
times
=
0
const
replaceHtml
=
({
couponModalResolve
})
=>
{
console
.
log
(
++
times
)
const
getDom
=
({
couponModalResolve
})
=>
{
const
loading
=
$
(
'<div class="loading"></div>'
)
loading
.
text
(
'加载中...'
)
$
(
'body'
).
append
(
loading
)
...
...
@@ -163,23 +124,25 @@ const replaceHtml = ({ couponModalResolve }) => {
},
2000
)
})
}
$doJoin
({
beforeDojoin
(
data
)
{
console
.
log
(
'我被调用了-特殊'
)
}
})
/**
* @description: 调用
* @example:
* @param {type}
* @return:
*/
$doJoin
()
.
then
(()
=>
{
return
$doJoin
({
replaceHtml
getDom
})
})
.
then
(()
=>
{
$doJoin
({
modifyDom
({
el
}
)
{
$
(
el
).
find
(
'.close'
).
css
({
replaceHtml
(
data
)
{
$
(
data
).
find
(
'.close'
).
css
({
background
:
'blue'
})
return
{
el
}
}
})
})
\ No newline at end of file
})
test/tapable
-t
est/index.less
→
test/tapable
T
est/index.less
View file @
fd815e7c
File moved
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