Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7-Eleven
Overview
Overview
Details
Activity
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
高淑倩
7-Eleven
Commits
ef86203a
Commit
ef86203a
authored
Sep 21, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add watch
parent
0bcc4b80
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
1 deletions
+43
-1
watch.js
src/utils/watch.js
+42
-0
wxService.js
src/utils/wxService.js
+1
-1
No files found.
src/utils/watch.js
0 → 100644
View file @
ef86203a
function
observe
(
obj
,
key
,
watchFun
,
deep
,
page
)
{
let
val
=
obj
[
key
];
if
(
val
!=
null
&&
typeof
val
===
"object"
&&
deep
)
{
Object
.
keys
(
val
).
forEach
((
item
)
=>
{
observe
(
val
,
item
,
watchFun
,
deep
,
page
);
});
}
Object
.
defineProperty
(
obj
,
key
,
{
configurable
:
true
,
enumerable
:
true
,
set
:
function
(
value
)
{
watchFun
.
call
(
page
,
value
,
val
);
val
=
value
;
if
(
deep
)
{
observe
(
obj
,
key
,
watchFun
,
deep
,
page
);
}
},
get
:
function
()
{
return
val
;
}
});
}
export
function
setWatcher
(
page
)
{
let
data
=
page
.
data
;
let
watch
=
page
.
watch
;
if
(
!
watch
)
return
false
Object
.
keys
(
watch
).
forEach
((
item
)
=>
{
let
targetData
=
data
;
let
keys
=
item
.
split
(
"."
);
for
(
let
i
=
0
;
i
<
keys
.
length
-
1
;
i
++
)
{
targetData
=
targetData
[
keys
[
i
]];
}
let
targetKey
=
keys
[
keys
.
length
-
1
];
let
watchFun
=
watch
[
item
].
handler
||
watch
[
item
];
let
deep
=
watch
[
item
].
deep
;
observe
(
targetData
,
targetKey
,
watchFun
,
deep
,
page
);
});
}
src/utils/wxService.js
View file @
ef86203a
...
...
@@ -18,7 +18,7 @@ const config = require('../config/index').envInfo
import
utils
from
'./util'
const
citysData
=
require
(
'./city.js'
)
import
{
Integer
}
from
'./integerDigitalConvertion'
import
*
as
watch
from
"./watch.js"
;
let
openCardLister
=
null
/**
...
...
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