Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tools
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
tools
Commits
909bf717
Commit
909bf717
authored
Jan 28, 2023
by
庄欣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ok
parent
995a2ea7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
117 deletions
+86
-117
mp-remark-v4/js/service.js
+86
-117
No files found.
mp-remark-v4/js/service.js
View file @
909bf717
...
...
@@ -132,7 +132,9 @@ function getReadingIdByBase64(url) {
show
();
}
function
getUserIdFromAvatar
(
avatar
)
{
function
getUserIdFromAvatar
(
callback
)
{
let
img
=
$
(
".container"
).
find
(
".user-portrait"
).
children
(
"img"
);
var
avatar
=
img
.
attr
(
"src"
);
var
uid
=
""
;
var
medaInfo
=
$
(
"meta[name=sn]"
);
if
(
medaInfo
.
length
>
0
)
{
...
...
@@ -162,32 +164,19 @@ function getUserIdFromAvatar(avatar) {
if
(
isNaN
(
Manager
.
userId
)
||
Manager
.
userId
<=
0
)
{
showToast
(
"暂时不能获取用户信息"
);
}
show
();
callback
();
return
;
})
}
else
{
Manager
.
userId
=
uid
;
show
();
callback
();
}
}
function
getAuth
()
{
getData
(
API
.
auth
,
{},
(
res
)
=>
{
if
(
res
.
code
.
toString
()
===
"100001"
)
{
Manager
.
isAuth
=
true
;
}
if
(
res
.
code
.
toString
()
===
"100002"
)
{
Manager
.
isAuth
=
false
;
}
});
}
function
assertIn
()
{
let
url
=
window
.
location
.
href
;
let
avatar
=
$
(
".container"
).
find
(
".user-portrait"
).
children
(
"img"
);
let
canOpen
=
false
;
if
(
url
.
indexOf
(
"article"
)
>
-
1
&&
url
.
indexOf
(
"list"
)
===
-
1
)
{
Manager
.
isReading
=
true
;
Manager
.
isUserInfo
=
true
;
getReadingIdByBase64
(
url
);
}
if
(
url
.
indexOf
(
"works"
)
>
-
1
&&
url
.
indexOf
(
"list"
)
===
-
1
)
{
...
...
@@ -195,28 +184,11 @@ function assertIn() {
Manager
.
isUserInfo
=
true
;
getWorksIdByBase64
(
url
);
}
if
(
url
.
indexOf
(
"photographyer"
)
>
-
1
)
{
Manager
.
isUserInfo
=
true
;
getUserIdFromAvatar
(
$
(
avatar
).
attr
(
"src"
));
}
if
(
!
Manager
.
isUserInfo
&&
avatar
!==
undefined
&&
$
(
"title"
).
text
().
indexOf
(
"米拍摄影社区"
)
>
-
1
)
{
Manager
.
isUserInfo
=
true
;
canOpen
=
true
;
}
else
{
canOpen
=
true
;
}
if
(
Manager
.
isUserInfo
)
{
getUserIdFromAvatar
(
$
(
avatar
).
attr
(
"src"
));
}
return
canOpen
;
}
function
openUi
()
{
let
canOpen
=
assertIn
();
Manager
.
canOpen
=
canOpen
;
if
(
canOpen
)
{
//获取基本信息并显示在编辑框
assertIn
();
getUserIdFromAvatar
(
function
()
{
getData
(
API
.
getUserInfo
,
{
uid
:
Manager
.
userId
},
data
=>
{
...
...
@@ -229,92 +201,89 @@ function openUi() {
Manager
.
user
.
nickname
=
res
.
nickname
;
showUserInfo
(
Manager
.
user
);
});
});
getData
(
API
.
getRemark
,
{
object_id
:
Manager
.
userId
,
type
:
TYPE_USER
},
res
=>
{
if
(
res
.
code
.
toString
()
===
"100001"
)
{
Manager
.
userRemark
=
res
.
data
.
remark
;
Manager
.
userYyRemark
=
res
.
data
.
operate_remark
;
Manager
.
userPermission
=
res
.
data
.
permission
;
Manager
.
userToken
=
res
.
data
.
lock_token
Manager
.
authType
=
"now"
;
show
();
}
})
if
(
Manager
.
isWorks
)
{
getData
(
API
.
getRemark
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
res
=>
{
if
(
res
.
code
.
toString
()
===
"100001"
)
{
Manager
.
remark
=
res
.
data
.
remark
;
Manager
.
permission
=
res
.
data
.
permission
;
Manager
.
token
=
res
.
data
.
lock_token
;
Manager
.
yyRemark
=
res
.
data
.
operate_remark
;
}
});
getData
(
API
.
getIsYoumi
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
data
=>
{
if
(
data
.
data
.
result
.
toString
()
===
"1"
)
{
Manager
.
isYoumi
=
1
;
Manager
.
youmiCreateTime
=
data
.
data
.
create_time
;
Manager
.
dateyoumiCreateTime
=
Date
.
parse
(
data
.
data
.
create_time
);
}
else
{
Manager
.
isYoumi
=
0
;
}
Manager
.
picContent
=
Manager
.
picContent
.
replace
(
"{url}"
,
"https://m.mepai.me/works/"
+
Manager
.
objectId
)
Manager
.
authType
=
"pic"
;
show
();
});
}
if
(
Manager
.
isReading
)
{
getData
(
API
.
getRemark
,
{
object_id
:
Manager
.
user
Id
,
type
:
TYPE_USER
object_id
:
Manager
.
object
Id
,
type
:
Manager
.
type
},
res
=>
{
if
(
res
.
code
.
toString
()
===
"100001"
)
{
Manager
.
userRemark
=
res
.
data
.
remark
;
Manager
.
userYyRemark
=
res
.
data
.
operate_remark
;
Manager
.
userPermission
=
res
.
data
.
permission
;
Manager
.
userToken
=
res
.
data
.
lock_token
Manager
.
authType
=
"now"
;
show
();
Manager
.
remark
=
res
.
data
.
remark
;
Manager
.
permission
=
res
.
data
.
permission
;
Manager
.
token
=
res
.
data
.
lock_token
;
Manager
.
yyRemark
=
res
.
data
.
operate_remark
;
}
});
getData
(
API
.
getIsYoumi
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
data
=>
{
if
(
data
.
data
.
result
==
1
)
{
Manager
.
isYoumi
=
1
;
Manager
.
youmiCreateTime
=
data
.
data
.
create_time
;
Manager
.
dateyoumiCreateTime
=
Date
.
parse
(
data
.
data
.
create_time
);
}
else
{
Manager
.
isYoumi
=
0
;
}
Manager
.
authType
=
"now"
;
show
();
});
}
if
(
Manager
.
isReading
||
Manager
.
isWorks
)
{
getData
(
API
.
getZone
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
res
=>
{
let
data
=
res
.
data
if
(
data
.
length
===
0
)
{
Manager
.
inZone
=
false
;
}
else
{
Manager
.
inZone
=
true
;
}
show
();
})
if
(
Manager
.
isWorks
)
{
getData
(
API
.
getRemark
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
res
=>
{
if
(
res
.
code
.
toString
()
===
"100001"
)
{
Manager
.
remark
=
res
.
data
.
remark
;
Manager
.
permission
=
res
.
data
.
permission
;
Manager
.
token
=
res
.
data
.
lock_token
;
Manager
.
yyRemark
=
res
.
data
.
operate_remark
;
}
});
getData
(
API
.
getIsYoumi
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
data
=>
{
if
(
data
.
data
.
result
.
toString
()
===
"1"
)
{
Manager
.
isYoumi
=
1
;
Manager
.
youmiCreateTime
=
data
.
data
.
create_time
;
Manager
.
dateyoumiCreateTime
=
Date
.
parse
(
data
.
data
.
create_time
);
}
else
{
Manager
.
isYoumi
=
0
;
}
Manager
.
picContent
=
Manager
.
picContent
.
replace
(
"{url}"
,
"https://m.mepai.me/works/"
+
Manager
.
objectId
)
Manager
.
authType
=
"pic"
;
show
();
});
}
if
(
Manager
.
isReading
)
{
getData
(
API
.
getRemark
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
res
=>
{
if
(
res
.
code
.
toString
()
===
"100001"
)
{
Manager
.
remark
=
res
.
data
.
remark
;
Manager
.
permission
=
res
.
data
.
permission
;
Manager
.
token
=
res
.
data
.
lock_token
;
Manager
.
yyRemark
=
res
.
data
.
operate_remark
;
}
});
getData
(
API
.
getIsYoumi
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
data
=>
{
if
(
data
.
data
.
result
==
1
)
{
Manager
.
isYoumi
=
1
;
Manager
.
youmiCreateTime
=
data
.
data
.
create_time
;
Manager
.
dateyoumiCreateTime
=
Date
.
parse
(
data
.
data
.
create_time
);
}
else
{
Manager
.
isYoumi
=
0
;
}
Manager
.
authType
=
"now"
;
show
();
});
}
if
(
Manager
.
isReading
||
Manager
.
isWorks
)
{
getData
(
API
.
getZone
,
{
object_id
:
Manager
.
objectId
,
type
:
Manager
.
type
},
res
=>
{
let
data
=
res
.
data
if
(
data
.
length
===
0
)
{
Manager
.
inZone
=
false
;
}
else
{
Manager
.
inZone
=
true
;
}
show
();
})
}
}
else
{
Manager
.
err
=
"不在个人中心或作品详情或文章详情页"
;
show
();
}
}
...
...
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