Skip to content

Commit

Permalink
update the reply page
Browse files Browse the repository at this point in the history
1.add showing payout  detail
2.add showing voters
  • Loading branch information
Cha0s0000 committed May 1, 2018
1 parent 0c5d098 commit cdae85e
Show file tree
Hide file tree
Showing 3 changed files with 344 additions and 7 deletions.
138 changes: 137 additions & 1 deletion pages/replyHistory/replyHistory.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Page({
for (var content in data) {
var obj = new Object();
obj.author = data[content].author;
obj.permlink = data[content].permlink;
obj.root_author = data[content].root_author;
obj.avatar = "https://steemitimages.com/u/" + obj.author + "/avatar/small";
obj.root_permlink = data[content].root_permlink;
Expand All @@ -63,6 +64,9 @@ Page({
obj.comment_num = data[content].children;
var payout = parseFloat(data[content].pending_payout_value) + parseFloat(data[content].total_payout_value) + parseFloat(data[content].curator_payout_value);
obj.pending_payout_value = "$" + payout.toFixed(2);
obj.total_payout_value = "$" + data[content].total_payout_value.replace("SBD", "");
obj.curator_payout_value = "$" + data[content].curator_payout_value.replace("SBD", "");
obj.promoted = "$" + data[content].promoted.replace("SBD", "");
obj.reputation = that.getReputation(data[content].author_reputation)
authorPosts.push(obj);
}
Expand Down Expand Up @@ -205,5 +209,137 @@ Page({
url: '../detail/detail?author=' + author + '&permlink=' + permlink,
})

}
},

// click to show all payout detail
showPayout: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
var time = e.currentTarget.dataset.time;
var detail = e.currentTarget.dataset.detail;
/* create thte animation */
// Step 1:setup an animation instance
var animation = wx.createAnimation({
duration: 200, //Animation duration
timingFunction: "linear", //linear
delay: 0 //0 means not delay
});

// Step 2: this animation instance is assigned to the current animation instance.
this.animation = animation;

// Step 3: perform the first set of animations.
animation.opacity(0).rotateX(-100).step();

// Step 4: export the animation object to the data object store.
this.setData({
animationData: animation.export()
})

// Step 5: set the timer to the specified time and execute the second set of animations.
setTimeout(function () {
// Execute the second set of animations.
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.
this.setData({
animationData: animation
})

//hide
if (currentStatu == "close") {
this.setData(
{
showModalStatus: false
}
);
}
}.bind(this), 200)
var payout = 0;
// show
if (currentStatu == "open") {
if ((detail.time.indexOf("天") != -1)) {
if (parseInt((detail.time.split('天')[0])) > 7) {
payout = parseInt((detail.time.split('天')[0])) - 7;
payout = payout + "天前";
}
else {
payout = 7 - parseInt((detail.time.split('天')[0]));
payout = payout + "天后";
}

}
else {
payout = "7天后";
}
this.setData(
{
PotentialPayout: detail.pending_payout_value,
PromotedPayout: detail.promoted,
AuthorPayout: detail.total_payout_value,
CurationPayout: detail.curator_payout_value,
Payout: payout,
showModalStatus: true
}
);
}
},

// click to show voter list
showVoters: function (e) {
var currentStatu = e.currentTarget.dataset.statu;
var detail = e.currentTarget.dataset.detail;
var animation = wx.createAnimation({
duration: 200, //Animation duration
timingFunction: "linear", //linear
delay: 0 //0 means not delay
});
this.animation = animation;
animation.opacity(0).rotateX(-100).step();
this.setData({
voterListAnimationData: animation.export()
})
setTimeout(function () {
animation.opacity(1).rotateX(0).step();
this.setData({
voterListAnimationData: animation
})
if (currentStatu == "close") {
this.setData(
{
voterListShowModalStatus: false
}
);
}
}.bind(this), 200)
var payout = 0;
// show
if (currentStatu == "open") {
var that = this;
var votersList = [];
wx: wx.request({
url: 'https://api.steemjs.com/get_active_votes?author=' + detail.author + '&permlink=' + detail.permlink,
method: 'GET',
success: function (res) {
if (res.statusCode == '200') {
var voterDatas = res.data;
for (var voterData in voterDatas) {
var obj = new Object();
obj.voter = voterDatas[voterData].voter;
obj.percent = String(voterDatas[voterData].percent / 100) + '%';
obj.reputation = that.getReputation(voterDatas[voterData].reputation);
obj.time = that.getTime(voterDatas[voterData].time);
obj.weight = voterDatas[voterData].weight;
votersList.push(obj);
}
console.log(votersList);
that.setData({
voterLists: votersList,
voterListShowModalStatus: true
})

}
},
complete: function (res) { },
})
}
},
})
62 changes: 56 additions & 6 deletions pages/replyHistory/replyHistory.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</view>
<view class="content">
<block wx:for="{{postsData}}" wx:for-item="item">
<view class="post-container" bindtap='click' data-block='{{item}}'>
<view class="post-container">
<view class="post-author-data">
<image class="post-avatar" src="{{item.avatar}}"></image>
<text class="post-author">{{item.author}}</text>
Expand All @@ -29,20 +29,20 @@
<view class ="dot"></view>
<text class="time">{{item.time}}</text>
</view>
<text class="post-title">REPLY TO - {{item.title}}</text>
<text class="post-title" bindtap='click' data-block='{{item}}'>REPLY TO - {{item.title}}</text>
<view class="img-content">
<text class="post-content">{{item.body}}</text>
<text class="post-content" bindtap='click' data-block='{{item}}'>{{item.body}}</text>
</view>
<view class= "foot-data">
<view class="post-like">
<!-- <icon type="success_circle" size="18"/> -->
<image mode="aspectFill" class="icon" src="../../images/icon/good.png"></image>
<!-- <icon type="success" size="18"/> -->
<text class="post-like-font"> {{item.pending_payout_value}}</text>
<text class="post-like-font" bindtap="showPayout" data-statu="open" data-detail="{{item}}"> {{item.pending_payout_value}}</text>
</view>
<view class="like-num">
<image mode="aspectFill" class="icon" src="../../images/icon/selected.png"></image>
<text class="like-num-font">{{item.like_num}}</text>
<text class="like-num-font" bindtap="showVoters" data-statu="open" data-detail="{{item}}">{{item.like_num}}</text>
</view>
<view class="comment-num">
<image mode="aspectFill" class="icon" src="../../images/icon/comments.png"></image>
Expand All @@ -57,4 +57,54 @@
<loading hidden="{{hidden}}">
Loading...
</loading>

<view class="drawer_screen" bindtap="showPayout" data-statu="close" wx:if="{{showModalStatus}}"></view>
<!--content-->
<!--Use the animation attribute to specify the animation that needs to be executed.-->
<view animation="{{animationData}}" class="drawer_box" wx:if="{{showModalStatus}}">

<!--drawer content-->
<view class="drawer_title">Total payout</view>
<view class="drawer_content">

<view class="top grid">
<text class="payout-type">Potential Payout</text>
<text class="payout-text">{{PotentialPayout}}</text>
</view>
<view class="top grid">
<text class="payout-type">Promoted</text>
<text class="payout-text">{{PromotedPayout}}</text>
</view>
<view class="top grid">
<text class="payout-type">Author Payout</text>
<text class="payout-text">{{AuthorPayout}}</text>
</view>
<view class="top grid">
<text class="payout-type">Curation Payout</text>
<text class="payout-text">{{CurationPayout}}</text>
</view>
<view class="top bottom grid">
<text class="payout-type">Payout</text>
<text class="payout-text">{{Payout}}</text>
</view>
</view>
<view class="btn_ok" bindtap="showPayout" data-statu="close">OK</view>
</view>
<view animation="{{voterListAnimationData}}" class="voterList-drawer_box" wx:if="{{voterListShowModalStatus}}">
<scroll-view scroll-y="true" style="height: 400px">
<view class="voterList-drawer_title">Voters List</view>
<view class="voters-list">
<block wx:for="{{voterLists}}" wx:for-item="voterList">
<view class="voters-item">
<view class="item">
<view class="voter-dot"></view>
<text class="voterList-voter">{{voterList.voter}}({{voterList.reputation}})</text>
<text class="voterList-percent">{{voterList.percent}}</text>
<text class="voterList-time">{{voterList.time}}</text>
</view>
</view>
</block>
</view>
<view class="btn_ok" bindtap="showVoters" data-statu="close">OK</view>
</scroll-view>
</view>
<view class="drawer_screen" bindtap="showVoters" data-statu="close" wx:if="{{voterListShowModalStatus}}"></view>
Loading

0 comments on commit cdae85e

Please sign in to comment.