Commit 909bf717 by 庄欣

ok

parent 995a2ea7
...@@ -132,7 +132,9 @@ function getReadingIdByBase64(url) { ...@@ -132,7 +132,9 @@ function getReadingIdByBase64(url) {
show(); show();
} }
function getUserIdFromAvatar(avatar) { function getUserIdFromAvatar(callback) {
let img = $(".container").find(".user-portrait").children("img");
var avatar = img.attr("src");
var uid = ""; var uid = "";
var medaInfo = $("meta[name=sn]"); var medaInfo = $("meta[name=sn]");
if (medaInfo.length > 0) { if (medaInfo.length > 0) {
...@@ -162,32 +164,19 @@ function getUserIdFromAvatar(avatar) { ...@@ -162,32 +164,19 @@ function getUserIdFromAvatar(avatar) {
if (isNaN(Manager.userId) || Manager.userId <= 0) { if (isNaN(Manager.userId) || Manager.userId <= 0) {
showToast("暂时不能获取用户信息"); showToast("暂时不能获取用户信息");
} }
show(); callback();
return;
}) })
} else { } else {
Manager.userId = uid; 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() { function assertIn() {
let url = window.location.href; 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) { if (url.indexOf("article") > -1 && url.indexOf("list") === -1) {
Manager.isReading = true; Manager.isReading = true;
Manager.isUserInfo = true;
getReadingIdByBase64(url); getReadingIdByBase64(url);
} }
if (url.indexOf("works") > -1 && url.indexOf("list") === -1) { if (url.indexOf("works") > -1 && url.indexOf("list") === -1) {
...@@ -195,28 +184,11 @@ function assertIn() { ...@@ -195,28 +184,11 @@ function assertIn() {
Manager.isUserInfo = true; Manager.isUserInfo = true;
getWorksIdByBase64(url); 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() { function openUi() {
let canOpen = assertIn(); assertIn();
Manager.canOpen = canOpen; getUserIdFromAvatar(function() {
if (canOpen) {
//获取基本信息并显示在编辑框
getData(API.getUserInfo, { getData(API.getUserInfo, {
uid: Manager.userId uid: Manager.userId
}, data => { }, data => {
...@@ -229,92 +201,89 @@ function openUi() { ...@@ -229,92 +201,89 @@ function openUi() {
Manager.user.nickname = res.nickname; Manager.user.nickname = res.nickname;
showUserInfo(Manager.user); 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, { getData(API.getRemark, {
object_id: Manager.userId, object_id: Manager.objectId,
type: TYPE_USER type: Manager.type
}, res => { }, res => {
if (res.code.toString() === "100001") { if (res.code.toString() === "100001") {
Manager.userRemark = res.data.remark; Manager.remark = res.data.remark;
Manager.userYyRemark = res.data.operate_remark; Manager.permission = res.data.permission;
Manager.userPermission = res.data.permission; Manager.token = res.data.lock_token;
Manager.userToken = res.data.lock_token Manager.yyRemark = res.data.operate_remark;
Manager.authType = "now";
show();
} }
});
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();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment