Untitled diff
2 removals
583 lines
15 additions
596 lines
// pages/detail/detail.js
// pages/childComment/childComment.js
var WxParse = require('../../wxParse/wxParse.js');
var WxParse = require('../../wxParse/wxParse.js');
Page({
Page({
data: {
data: {
detail: {},
detail: {},
hidden: false,
hidden: false,
tags:{},
tags:{},
comments:{},
comments:{},
replyTemArray:{},
replyTemArray:{},
tittle:"",
tittle:"",
author:"",
author:"",
permlink:"",
permlink:"",
childComments:[],
childComments:[],
showState:"Show",
showState:"Show",
commentShowState:false,
commentShowState:false,
commentBoxContent:""
commentBoxContent:""
},
},
onLoad: function (options) {
onLoad: function (options) {
// The page initializes options for the parameters of the page jump.
// The page initializes options for the parameters of the page jump.
var author = options.author;
var author = options.author;
var permlink = options.permlink;
var permlink = options.permlink;
var parent_author = options.parent_author;
var parent_permlink = options.parent_permlink;
console.log(permlink);
console.log(permlink);
this.setData({author:author,permlink:permlink})
this.setData({ author: author, permlink: permlink, parent_author: parent_author, parent_permlink: parent_permlink})
this.getPostdDtail(author,permlink);
this.getPostdDtail(author,permlink);
// this.getPostComment(author,permlink);
// this.getPostComment(author,permlink);
},
},
onShareAppMessage: function () {
onShareAppMessage: function () {
return {
return {
title: this.data.title,
title: this.data.title,
desc: "Steemit",
desc: "Steemit",
path: '/detail/detail?author=' + this.data.author + '&permlink=' + this.data.permlink
path: '/detail/detail?author=' + this.data.author + '&permlink=' + this.data.permlink
}
}
},
},
onReady: function () {
onReady: function () {
//Page rendering complete
//Page rendering complete
},
},
onShow: function () {
onShow: function () {
//Page shows
//Page shows
},
},
onHide: function () {
onHide: function () {
// Page hide
// Page hide
},
},
onUnload: function () {
onUnload: function () {
// Page close
// Page close
},
},
getReputation(rep) {
getReputation(rep) {
if (rep == 0) {
if (rep == 0) {
return 25
return 25
}
}
var score = (Math.log10(Math.abs(rep)) - 9) * 9 + 25;
var score = (Math.log10(Math.abs(rep)) - 9) * 9 + 25;
if (rep < 0) {
if (rep < 0) {
score = 50 - score;
score = 50 - score;
}
}
return Math.round(score);
return Math.round(score);
},
},
getTime(time) {
getTime(time) {
var postTime = new Date(time);
var postTime = new Date(time);
// console.log(Date.parse(postTime));
// console.log(Date.parse(postTime));
var nowTime = Date.now() - 28800000;
var nowTime = Date.now() - 28800000;
// console.log(nowTime);
// console.log(nowTime);
var ago = nowTime - postTime;
var ago = nowTime - postTime;
if (ago / 1000 / 60 / 60 / 24 >= 1) {
if (ago / 1000 / 60 / 60 / 24 >= 1) {
var dayNum = parseInt(ago / 1000 / 60 / 60 / 24);
var dayNum = parseInt(ago / 1000 / 60 / 60 / 24);
var getTimeData = dayNum.toString();
var getTimeData = dayNum.toString();
getTimeData += "天前";
getTimeData += "天前";
// console.log(getTimeData);
// console.log(getTimeData);
return getTimeData;
return getTimeData;
}
}
else if (ago / 1000 / 60 / 60 >= 1) {
else if (ago / 1000 / 60 / 60 >= 1) {
var hourNum = parseInt(ago / 1000 / 60 / 60);
var hourNum = parseInt(ago / 1000 / 60 / 60);
var getTimeData = hourNum.toString();
var getTimeData = hourNum.toString();
getTimeData += "小时前";
getTimeData += "小时前";
// console.log(getTimeData);
// console.log(getTimeData);
return getTimeData;
return getTimeData;
}
}
else if (ago / 1000 / 60 >= 1) {
else if (ago / 1000 / 60 >= 1) {
var minNum = parseInt(ago / 1000 / 60);
var minNum = parseInt(ago / 1000 / 60);
var getTimeData = minNum.toString();
var getTimeData = minNum.toString();
getTimeData += "分钟前";
getTimeData += "分钟前";
// console.log(getTimeData);
// console.log(getTimeData);
return getTimeData;
return getTimeData;
}
}
else if (ago / 1000 >= 1) {
else if (ago / 1000 >= 1) {
var secNum = parseInt(ago / 1000);
var secNum = parseInt(ago / 1000);
var getTimeData = secNum.toString();
var getTimeData = secNum.toString();
getTimeData += "秒前";
getTimeData += "秒前";
// console.log(getTimeData);
// console.log(getTimeData);
return getTimeData;
return getTimeData;
}
}
else {
else {
var getTimeData = "1秒前";
var getTimeData = "1秒前";
return getTimeData;
return getTimeData;
}
}
},
},
// Get the body and other detail info of the post whose permlink was transmitted by navigating
// Get the body and other detail info of the post whose permlink was transmitted by navigating
getPostdDtail(author,permlink){
getPostdDtail(author,permlink){
var that = this;
var that = this;
var obj = new Object();
var obj = new Object();
wx.request({
wx.request({
url: 'https://api.steemjs.com/get_content?author=' + author + '&permlink=' + permlink,
url: 'https://api.steemjs.com/get_content?author=' + author + '&permlink=' + permlink,
method: 'GET',
method: 'GET',
success: function (res) {
success: function (res) {
var data = res.data;
var data = res.data;
// console.log(data)
// console.log(data)
obj.author = data.author;
obj.author = data.author;
obj.permlink = data.permlink;
obj.permlink = data.permlink;
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.category = data.category;
obj.category = data.category;
obj.title = data.title;
obj.title = data.title;
obj.body = data.body;
obj.body = data.body;
obj.time = that.getTime(data.created);
obj.time = that.getTime(data.created);
obj.like_num = data.net_votes;
obj.like_num = data.net_votes;
obj.comment_num = data.children;
obj.comment_num = data.children;
obj.pending_payout_value = "$" + data.pending_payout_value.replace("SBD", "");
obj.pending_payout_value = "$" + data.pending_payout_value.replace("SBD", "");
obj.total_payout_value = "$" + data.total_payout_value.replace("SBD", "");
obj.total_payout_value = "$" + data.total_payout_value.replace("SBD", "");
obj.curator_payout_value = "$" + data.curator_payout_value.replace("SBD", "");
obj.curator_payout_value = "$" + data.curator_payout_value.replace("SBD", "");
obj.promoted = "$" + data.promoted.replace("SBD", "");
obj.promoted = "$" + data.promoted.replace("SBD", "");
obj.reputation = that.getReputation(data.author_reputation);
obj.reputation = that.getReputation(data.author_reputation);
obj.tags = JSON.parse(data.json_metadata).tags;
obj.tags = JSON.parse(data.json_metadata).tags;
WxParse.wxParse('content', 'md', obj.body, that, 5);
WxParse.wxParse('content', 'md', obj.body, that, 5);
that.setData({ detail: obj, hidden: true, tags: obj.tags ,title:obj.title,author:author,permlink:permlink})
that.setData({ detail: obj, hidden: true, tags: obj.tags ,title:obj.title,author:author,permlink:permlink})
// console.log(obj.tags);
// console.log(obj.tags);
}
}
})
})
},
},
// navigate to full content
viewFullContent:function(e){
var parent_permlink = this.data.parent_permlink;
var parent_author = this.data.parent_author;
wx.navigateTo({
url: '../detail/detail?author=' + parent_author + '&permlink=' + parent_permlink,
})
},
showComment:function(e){
showComment:function(e){
var author = this.data.author;
var author = this.data.author;
var permlink = this. data.permlink;
var permlink = this. data.permlink;
this.getPostComment(author, permlink);
this.getPostComment(author, permlink);
this.setData({ showState:"loading.."})
this.setData({ showState:"loading.."})
wx.showNavigationBarLoading();
wx.showNavigationBarLoading();
},
},
// get the first depth conment of the post
// get the first depth conment of the post
getPostComment(author,permlink){
getPostComment(author,permlink){
var that = this;
var that = this;
var commentData= [];
var commentData= [];
wx.request({
wx.request({
url: 'https://api.steemjs.com/get_content_replies?author=' + author + '&permlink=' + permlink,
url: 'https://api.steemjs.com/get_content_replies?author=' + author + '&permlink=' + permlink,
method: 'GET',
method: 'GET',
success: function (res) {
success: function (res) {
var data = res.data;
var data = res.data;
// console.log(data);
// console.log(data);
for(var d in data){
for(var d in data){
var obj = new Object();
var obj = new Object();
obj.author = data[d].author;
obj.author = data[d].author;
obj.permlink = data[d].permlink;
obj.permlink = data[d].permlink;
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.body = data[d].body;
obj.body = data[d].body;
obj.comment_num = data[d].children;
obj.comment_num = data[d].children;
obj.time = that.getTime(data[d].created);
obj.time = that.getTime(data[d].created);
obj.like_num = data[d].net_votes;
obj.like_num = data[d].net_votes;
obj.depth = data[d].depth;
obj.depth = data[d].depth;
obj.child = 0;
obj.child = 0;
obj.pending_payout_value = "$" + data[d].pending_payout_value.replace("SBD", "");
obj.pending_payout_value = "$" + data[d].pending_payout_value.replace("SBD", "");
obj.reputation = that.getReputation(data[d].author_reputation);
obj.reputation = that.getReputation(data[d].author_reputation);
commentData.push(obj);
commentData.push(obj);
}
}
console.log(commentData);
console.log(commentData);
},
},
complete: function () {
complete: function () {
console.log("commentData");
console.log("commentData");
var replyTemArray = commentData;
var replyTemArray = commentData;
// console.log("Get comment body");
// console.log("Get comment body");
if (commentData.length > 0) {
if (commentData.length > 0) {
for (let i = 0; i < commentData.length; i++) {
for (let i = 0; i < commentData.length; i++) {
WxParse.wxParse('reply' + i, 'md', commentData[i].body, that, 5);
WxParse.wxParse('reply' + i, 'md', commentData[i].body, that, 5);
if (i === commentData.length - 1) {
if (i === commentData.length - 1) {
WxParse.wxParseTemArray("replyTemArray", 'reply', commentData.length, that, 5)
WxParse.wxParseTemArray("replyTemArray", 'reply', commentData.length, that, 5)
}
}
}
}
}
}
that.setData({ comments: commentData, showState: "Refresh", commentShowState:false});
that.setData({ comments: commentData, showState: "Refresh", commentShowState:false});
wx.hideNavigationBarLoading();
wx.hideNavigationBarLoading();
}
}
})
})
},
},
/**
/**
* deal with the clicking operation on the child comments num button
* deal with the clicking operation on the child comments num button
* to deal with the showing order , i save all depth of child comments of the same parent comments in a array.
* to deal with the showing order , i save all depth of child comments of the same parent comments in a array.
* if clicking on the first depth child comments ,then add the second depth child comments of this first depth comment to the array in the order after this fisrst depth comment.
* if clicking on the first depth child comments ,then add the second depth child comments of this first depth comment to the array in the order after this fisrst depth comment.
**/
**/
loadChildComment:function(e){
loadChildComment:function(e){
var that = this;
var that = this;
var idx = e.currentTarget.dataset.idx;
var idx = e.currentTarget.dataset.idx;
var originidx = e.currentTarget.dataset.originidx;
var originidx = e.currentTarget.dataset.originidx;
var comment_item = e.currentTarget.dataset.item;
var comment_item = e.currentTarget.dataset.item;
var author = e.currentTarget.dataset.item.author;
var author = e.currentTarget.dataset.item.author;
var permlink = e.currentTarget.dataset.item.permlink;
var permlink = e.currentTarget.dataset.item.permlink;
var children = comment_item.children;
var children = comment_item.children;
var origin_children = [];
var origin_children = [];
var child = comment_item.child;
var child = comment_item.child;
var origin_depth = comment_item.depth;
var origin_depth = comment_item.depth;
if (origin_depth == 1){
if (origin_depth == 1){
idx= 1;
idx= 1;
}
}
var update_item_child = "comments[" + originidx + "].child";
var update_item_child = "comments[" + originidx + "].child";
var update_item_children = "comments[" + originidx + "].children";
var update_item_children = "comments[" + originidx + "].children";
console.log(idx);
console.log(idx);
console.log(comment_item);
console.log(comment_item);
origin_children = this.data.comments[originidx].children;
origin_children = this.data.comments[originidx].children;
var ChildCommentData =[];
var ChildCommentData =[];
if (origin_children){
if (origin_children){
ChildCommentData = origin_children;
ChildCommentData = origin_children;
}
}
console.log("ChildCommentData");
console.log("ChildCommentData");
console.log(ChildCommentData);
console.log(ChildCommentData);
var data_length = 0;
var data_length = 0;
var singleChildCommentData=[];
var singleChildCommentData=[];
wx.request({
wx.request({
url: 'https://api.steemjs.com/get_content_replies?author=' + author + '&permlink=' + permlink,
url: 'https://api.steemjs.com/get_content_replies?author=' + author + '&permlink=' + permlink,
method: 'GET',
method: 'GET',
success: function (res) {
success: function (res) {
var data = res.data;
var data = res.data;
var i =0;
var i =0;
data_length = data.length;
data_length = data.length;
console.log("data_length");
console.log("data_length");
console.log(data_length);
console.log(data_length);
var check_exist = false;
var check_exist = false;
for (var d in data) {
for (var d in data) {
var obj = new Object();
var obj = new Object();
i = i + 1;
i = i + 1;
obj.author = data[d].author;
obj.author = data[d].author;
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.permlink = data[d].permlink;
obj.permlink = data[d].permlink;
obj.body = data[d].body;
obj.body = data[d].body;
obj.comment_num = data[d].children;
obj.comment_num = data[d].children;
obj.time = that.getTime(data[d].created);
obj.time = that.getTime(data[d].created);
obj.like_num = data[d].net_votes;
obj.like_num = data[d].net_votes;
obj.depth = data[d].depth;
obj.depth = data[d].depth;
obj.parent_author = data[d].parent_author;
obj.parent_author = data[d].parent_author;
obj.pending_payout_value = "$" + data[d].pending_payout_value.replace("SBD", "");
obj.pending_payout_value = "$" + data[d].pending_payout_value.replace("SBD", "");
obj.reputation = that.getReputation(data[d].author_reputation);
obj.reputation = that.getReputation(data[d].author_reputation);
obj.showState = true;
obj.showState = true;
singleChildCommentData.push(obj);
singleChildCommentData.push(obj);
// judge the click operation if it is the fisrt clicking or not
// judge the click operation if it is the fisrt clicking or not
if (ChildCommentData.length == 0){
if (ChildCommentData.length == 0){
ChildCommentData.splice(idx + i, 0, obj);
ChildCommentData.splice(idx + i, 0, obj);
}
}
// if that is not the first clicking , it means there have been child comments saved in the array .
// if that is not the first clicking , it means there have been child comments saved in the array .
else{
else{
// everytime before adding child comments to the array , search if the same child comments if already existing in the array or not .
// everytime before adding child comments to the array , search if the same child comments if already existing in the array or not .
for (var existChildComment in origin_children){
for (var existChildComment in origin_children){
// if the ont of this level child coments have already been in the array , that means this level child comments are now in showing state which they should be hidden after the clicking .
// if the ont of this level child coments have already been in the array , that means this level child comments are now in showing state which they should be hidden after the clicking .
if (origin_children[existChildComment].permlink == obj.permlink){
if (origin_children[existChildComment].permlink == obj.permlink){
// setting the check_existing sign true means that this level child comments will not be able to saved in the array once more .On the contrary they should be deleted for having existed in the array .
// setting the check_existing sign true means that this level child comments will not be able to saved in the array once more .On the contrary they should be deleted for having existed in the array .
check_exist=true;
check_exist=true;
console.log("existChildComment");
console.log("existChildComment");
console.log(existChildComment);
console.log(existChildComment);
console.log(origin_children[existChildComment].permlink);
console.log(origin_children[existChildComment].permlink);
ChildCommentData.splice(existChildComment,1);
ChildCommentData.splice(existChildComment,1);
console.log(ChildCommentData);
console.log(ChildCommentData);
console.log(ChildCommentData.length);
console.log(ChildCommentData.length);
// when clicking the button to hide the child comments , firstly check if there have been further level child comments of this comments in the showing state or not .
// when clicking the button to hide the child comments , firstly check if there have been further level child comments of this comments in the showing state or not .
// if there have been further level child comments in the showing state , just hide them all when clicking to hide their parent comments .
// if there have been further level child comments in the showing state , just hide them all when clicking to hide their parent comments .
for (var j = existChildComment; j < ChildCommentData.length;j=j){
for (var j = existChildComment; j < ChildCommentData.length;j=j){
console.log('j');
console.log('j');
console.log(j);
console.log(j);
console.log("ChildCommentData_length");
console.log("ChildCommentData_length");
console.log(ChildCommentData.length);
console.log(ChildCommentData.length);
if (origin_children[j].depth == obj.depth) {
if (origin_children[j].depth == obj.depth) {
break;
break;
}
}
if (origin_children[j].depth > obj.depth){
if (origin_children[j].depth > obj.depth){
ChildCommentData.splice(j, 1);
ChildCommentData.splice(j, 1);
}
}
}
}
break;
break;
}
}
}
}
// if thses child comments have not been in the array , just add to the array in the order after the parent comment to show in the UI
// if thses child comments have not been in the array , just add to the array in the order after the parent comment to show in the UI
if ((origin_depth!=1)&& (!check_exist)){
if ((origin_depth!=1)&& (!check_exist)){
ChildCommentData.splice(idx + i, 0, obj);
ChildCommentData.splice(idx + i, 0, obj);
console.log("add new child");
console.log("add new child");
}
}
else{
else{
console.log("existing ");
console.log("existing ");
}
}
}
}
}
}
},
},
// after dealing with the array , set into the showing array, then can show in the page UI
// after dealing with the array , set into the showing array, then can show in the page UI
complete: function () {
complete: function () {
that.setData({ [update_item_child]: 1, [update_item_children]: ChildCommentData });
that.setData({ [update_item_child]: 1, [update_item_children]: ChildCommentData });
console.log("childComments");
console.log("childComments");
console.log(ChildCommentData);
console.log(ChildCommentData);
console.log(that.data.comments[originidx])
console.log(that.data.comments[originidx])
}
}
})
})
},
},
// according to the parent comments , loading different depth of child comments data
// according to the parent comments , loading different depth of child comments data
getChildComment(author, permlink){
getChildComment(author, permlink){
var that = this;
var that = this;
var ChildCommentData = [];
var ChildCommentData = [];
wx.request({
wx.request({
url: 'https://api.steemjs.com/get_content_replies?author=' + author + '&permlink=' + permlink,
url: 'https://api.steemjs.com/get_content_replies?author=' + author + '&permlink=' + permlink,
method: 'GET',
method: 'GET',
success: function (res) {
success: function (res) {
var data = res.data;
var data = res.data;
// console.log(data);
// console.log(data);
for (var d in data) {
for (var d in data) {
var obj = new Object();
var obj = new Object();
obj.author = data[d].author;
obj.author = data[d].author;
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.body = data[d].body;
obj.body = data[d].body;
obj.comment_num = data[d].children;
obj.comment_num = data[d].children;
obj.time = that.getTime(data[d].created);
obj.time = that.getTime(data[d].created);
obj.like_num = data[d].net_votes;
obj.like_num = data[d].net_votes;
obj.depth = data[d].depth;
obj.depth = data[d].depth;
obj.parent_author = data[d].parent_author;
obj.parent_author = data[d].parent_author;
obj.pending_payout_value = "$" + data[d].pending_payout_value.replace("SBD", "");
obj.pending_payout_value = "$" + data[d].pending_payout_value.replace("SBD", "");
obj.reputation = that.getReputation(data[d].author_reputation);
obj.reputation = that.getReputation(data[d].author_reputation);
ChildCommentData.push(obj);
ChildCommentData.push(obj);
}
}
},
},
complete: function () {
complete: function () {
}
}
})
})
},
},
showPayout: function (e) {
showPayout: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
var currentStatu = e.currentTarget.dataset.statu;
var time = e.currentTarget.dataset.time;
var time = e.currentTarget.dataset.time;
var detail = e.currentTarget.dataset.detail;
var detail = e.currentTarget.dataset.detail;
/* create thte animation */
/* create thte animation */
// Step 1:setup an animation instance
// Step 1:setup an animation instance
var animation = wx.createAnimation({
var animation = wx.createAnimation({
duration: 200, //Animation duration
duration: 200, //Animation duration
timingFunction: "linear", //linear
timingFunction: "linear", //linear
delay: 0 //0 means not delay
delay: 0 //0 means not delay
});
});
// Step 2: this animation instance is assigned to the current animation instance.
// Step 2: this animation instance is assigned to the current animation instance.
this.animation = animation;
this.animation = animation;
// Step 3: perform the first set of animations.
// Step 3: perform the first set of animations.
animation.opacity(0).rotateX(-100).step();
animation.opacity(0).rotateX(-100).step();
// Step 4: export the animation object to the data object store.
// Step 4: export the animation object to the data object store.
this.setData({
this.setData({
animationData: animation.export()
animationData: animation.export()
})
})
// Step 5: set the timer to the specified time and execute the second set of animations.
// Step 5: set the timer to the specified time and execute the second set of animations.
setTimeout(function () {
setTimeout(function () {
// Execute the second set of animations.
// Execute the second set of animations.
animation.opacity(1).rotateX(0).step();
animation.opacity(1).rotateX(0).step();
// The first set of animations that are stored for the data object are replaced by the animation objects that perform the second animation.
// The first set of animations that are stored for the data object are replaced by the animation objects that perform the second animation.
this.setData({
this.setData({
animationData: animation
animationData: animation
})
})
//hide
//hide
if (currentStatu == "close") {
if (currentStatu == "close") {
this.setData(
this.setData(
{
{
showModalStatus: false
showModalStatus: false
}
}
);
);
}
}
}.bind(this), 200)
}.bind(this), 200)
var payout = 0;
var payout = 0;
// show
// show
if (currentStatu == "open") {
if (currentStatu == "open") {
if ((detail.time.indexOf("天") != -1)){
if ((detail.time.indexOf("天") != -1)){
if (parseInt((detail.time.split('天')[0])) > 7){
if (parseInt((detail.time.split('天')[0])) > 7){
payout = parseInt((detail.time.split('天')[0])) - 7;
payout = parseInt((detail.time.split('天')[0])) - 7;
payout = payout+"天前";
payout = payout+"天前";
}
}
else{
else{
payout = 7 - parseInt((detail.time.split('天')[0])) ;
payout = 7 - parseInt((detail.time.split('天')[0])) ;
payout = payout + "天后";
payout = payout + "天后";
}
}
}
}
else{
else{
payout = "7天后";
payout = "7天后";
}
}
this.setData(
this.setData(
{
{
PotentialPayout: detail.pending_payout_value,
PotentialPayout: detail.pending_payout_value,
PromotedPayout:detail.promoted,
PromotedPayout:detail.promoted,
AuthorPayout: detail.total_payout_value,
AuthorPayout: detail.total_payout_value,
CurationPayout: detail.curator_payout_value,
CurationPayout: detail.curator_payout_value,
Payout: payout,
Payout: payout,
showModalStatus: true
showModalStatus: true
}
}
);
);
}
}
},
},
showVoters: function (e) {
showVoters: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
var currentStatu = e.currentTarget.dataset.statu;
var detail = e.currentTarget.dataset.detail;
var detail = e.currentTarget.dataset.detail;
var animation = wx.createAnimation({
var animation = wx.createAnimation({
duration: 200, //Animation duration
duration: 200, //Animation duration
timingFunction: "linear", //linear
timingFunction: "linear", //linear
delay: 0 //0 means not delay
delay: 0 //0 means not delay
});
});
this.animation = animation;
this.animation = animation;
animation.opacity(0).rotateX(-100).step();
animation.opacity(0).rotateX(-100).step();
this.setData({
this.setData({
voterListAnimationData: animation.export()
voterListAnimationData: animation.export()
})
})
setTimeout(function () {
setTimeout(function () {
animation.opacity(1).rotateX(0).step();
animation.opacity(1).rotateX(0).step();
this.setData({
this.setData({
voterListAnimationData: animation
voterListAnimationData: animation
})
})
if (currentStatu == "close") {
if (currentStatu == "close") {
this.setData(
this.setData(
{
{
voterListShowModalStatus: false
voterListShowModalStatus: false
}
}
);
);
}
}
}.bind(this), 200)
}.bind(this), 200)
var payout = 0;
var payout = 0;
// show
// show
if (currentStatu == "open") {
if (currentStatu == "open") {
var that= this;
var that= this;
var votersList = [];
var votersList = [];
wx:wx.request({
wx:wx.request({
url: 'https://api.steemjs.com/get_active_votes?author=' + that.data.author + '&permlink=' + that.data.permlink,
url: 'https://api.steemjs.com/get_active_votes?author=' + that.data.author + '&permlink=' + that.data.permlink,
method: 'GET',
method: 'GET',
success: function(res) {
success: function(res) {
if(res.statusCode == '200'){
if(res.statusCode == '200'){
var voterDatas = res.data;
var voterDatas = res.data;
for(var voterData in voterDatas){
for(var voterData in voterDatas){
var obj = new Object();
var obj = new Object();
obj.voter = voterDatas[voterData].voter;
obj.voter = voterDatas[voterData].voter;
obj.percent = String(voterDatas[voterData].percent/100) +'%';
obj.percent = String(voterDatas[voterData].percent/100) +'%';
obj.reputation = that.getReputation(voterDatas[voterData].reputation);
obj.reputation = that.getReputation(voterDatas[voterData].reputation);
obj.time = that.getTime(voterDatas[voterData].time);
obj.time = that.getTime(voterDatas[voterData].time);
obj.weight = voterDatas[voterData].weight;
obj.weight = voterDatas[voterData].weight;
votersList.push(obj);
votersList.push(obj);
}
}
console.log(votersList);
console.log(votersList);
that.setData({
that.setData({
voterLists: votersList,
voterLists: votersList,
voterListShowModalStatus: true
voterListShowModalStatus: true
})
})
}
}
},
},
complete: function(res) {},
complete: function(res) {},
})
})
}
}
},
},
// deal with the clicking to pop up the box for inputing comment
// deal with the clicking to pop up the box for inputing comment
showCommentBox:function(e){
showCommentBox:function(e){
var currentStatu = e.currentTarget.dataset.statu;
var currentStatu = e.currentTarget.dataset.statu;
var detail = e.currentTarget.dataset.detail;
var detail = e.currentTarget.dataset.detail;
var animation = wx.createAnimation({
var animation = wx.createAnimation({
duration: 200, //Animation duration
duration: 200, //Animation duration
timingFunction: "linear", //linear
timingFunction: "linear", //linear
delay: 0 //0 means not delay
delay: 0 //0 means not delay
});
});
this.animation = animation;
this.animation = animation;
animation.opacity(0).rotateX(-100).step();
animation.opacity(0).rotateX(-100).step();
this.setData({
this.setData({
commentAnimationData: animation.export()
commentAnimationData: animation.export()
})
})
setTimeout(function () {
setTimeout(function () {
animation.opacity(1).rotateX(0).step();
animation.opacity(1).rotateX(0).step();
this.setData({
this.setData({
commentAnimationData: animation
commentAnimationData: animation
})
})
if (currentStatu == "close") {
if (currentStatu == "close") {
this.setData(
this.setData(
{
{
commentShowModalStatus: false
commentShowModalStatus: false
}
}
);
);
}
}
}.bind(this), 200)
}.bind(this), 200)
var payout = 0;
var payout = 0;
// show
// show
if (currentStatu == "open") {
if (currentStatu == "open") {
this.setData({
this.setData({
commentShowModalStatus: true,
commentShowModalStatus: true,
submitCommentAuthor:detail.author,
submitCommentAuthor:detail.author,
submitCommentPermlink: detail.permlink,
submitCommentPermlink: detail.permlink,
commentSubmitButton:true
commentSubmitButton:true
})
})
}
}
},
},
// dynamically get the content of the comment box
// dynamically get the content of the comment box
inputComment:function(e){
inputComment:function(e){
var content = e.detail.value;
var content = e.detail.value;
if(content){
if(content){
console.log(content);
console.log(content);
WxParse.wxParse('commentPreview', 'md', content, this, 5);
WxParse.wxParse('commentPreview', 'md', content, this, 5);
this.setData({ commentContent: content, commentSubmitButton:false})
this.setData({ commentContent: content, commentSubmitButton:false})
}
}
else{
else{
this.setData({ commentContent: content, commentSubmitButton: true })
this.setData({ commentContent: content, commentSubmitButton: true })
}
}
},
},
// cancel the comment box
// cancel the comment box
cancelComment:function(e){
cancelComment:function(e){
var animation = wx.createAnimation({
var animation = wx.createAnimation({
duration: 200, //Animation duration
duration: 200, //Animation duration
timingFunction: "linear", //linear
timingFunction: "linear", //linear
delay: 0 //0 means not delay
delay: 0 //0 means not delay
});
});
this.animation = animation;
this.animation = animation;
animation.opacity(0).rotateX(-100).step();
animation.opacity(0).rotateX(-100).step();
this.setData({
this.setData({
commentAnimationData: animation.export()
commentAnimationData: animation.export()
})
})
setTimeout(function () {
setTimeout(function () {
animation.opacity(1).rotateX(0).step();
animation.opacity(1).rotateX(0).step();
this.setData({
this.setData({
commentAnimationData: animation
commentAnimationData: animation
})
})
this.setData(
this.setData(
{
{
commentShowModalStatus: false
commentShowModalStatus: false
}
}
);
);
}.bind(this), 200)
}.bind(this), 200)
},
},
// submit the comment
// submit the comment
submitComment:function(e){
submitComment:function(e){
var commentContent = this.data.commentContent;
var commentContent = this.data.commentContent;
var name = wx.getStorageSync('name');
var name = wx.getStorageSync('name');
if (name){
if (name){
var key = wx.getStorageSync('pass');
var key = wx.getStorageSync('pass');
var author = this.data.submitCommentAuthor;
var author = this.data.submitCommentAuthor;
var permlink = this.data.submitCommentPermlink;
var permlink = this.data.submitCommentPermlink;
var that = this;
var that = this;
wx.request({
wx.request({
url: 'http://192.168.137.138:3000/operation/comment',
url: 'http://192.168.137.138:3000/operation/comment',
method: 'POST',
method: 'POST',
data:{
data:{
account:name,
account:name,
key:key,
key:key,
author:author,
author:author,
permlink:permlink,
permlink:permlink,
content: commentContent
content: commentContent
},
},
success: function (res) {
success: function (res) {
console.log(res);
console.log(res);
if (res.statusCode == '200' && res.data.message == 'success') {
if (res.statusCode == '200' && res.data.message == 'success') {
that.cancelComment();
that.cancelComment();
wx.showToast({
wx.showToast({
title: 'Reply Success',
title: 'Reply Success',
icon: 'success',
icon: 'success',
duration: 2000
duration: 2000
})
})
}
}
else {
else {
wx.showModal({
wx.showModal({
title: 'Error',
title: 'Error',
content: 'Something error with connection!',
content: 'Something error with connection!',
success: function (res) {
success: function (res) {
if (res.confirm) {
if (res.confirm) {
console.log('Something error with connection!')
console.log('Something error with connection!')
} else if (res.cancel) {
} else if (res.cancel) {
console.log('Something error with connection!')
console.log('Something error with connection!')
}
}
}
}
})
})
}
}
}
}
})
})
}
}
}
}
})
})