Skip to content

Commit

Permalink
update the info page
Browse files Browse the repository at this point in the history
1. check if have logined  or not before loading the data

2. add function of clicking the avatar to log out
  • Loading branch information
Cha0s0000 committed Apr 16, 2018
1 parent ac3a172 commit 92111f3
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 61 deletions.
142 changes: 84 additions & 58 deletions pages/info/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,69 +40,76 @@ Page({
* Life cycle function - listen to page load.
*/
onLoad: function (options) {
// this.steem_per_mvests();
var that = this;
wx.request({
// testing the hostname
url: 'https://steemit.com/@cha0s0000.json',
method: 'GET',
success: function (res) {
console.log(res);
if(res.data.status == '200')
{
that.vests_to_sp(parseFloat(res.data.user.vesting_shares), parseFloat(res.data.user.delegated_vesting_shares));
that.get_follower_following();
that.setData({
avatar: res.data.user.json_metadata.profile.profile_image,
balance: res.data.user.balance,
created: res.data.user.created,
post_count : res.data.user.post_count,
sbd_balance: res.data.user.sbd_balance,
vesting_shares: parseInt(res.data.user.vesting_shares),
voting_power: String(res.data.user.voting_power).substr(0,2),
reputation: that.getReputation(res.data.user.reputation),
average_market_bandwidth: res.data.user.average_market_bandwidth,
author:res.data.user.name,
steemitname: res.data.user.json_metadata.profile.name,
about: res.data.user.json_metadata.profile.about,
location: res.data.user.json_metadata.profile.location,
postkey: res.data.user.posting.key_auths[0][0],
activekey: res.data.user.active.key_auths[0][0],
ownerkey: res.data.user.owner.key_auths[0][0],
memokey: res.data.user.memo_key,
account_auths: res.data.user.posting.account_auths,
witness_votes: res.data.user.witness_votes,
hidden:true
var account = wx.getStorageSync('name')
if(account == ''){
wx.redirectTo({
url: '../login/login',
})
}
else{
var that = this;
wx.request({
// testing the hostname
url: 'https://steemit.com/@' + account+'.json',
method: 'GET',
success: function (res) {
console.log(res);
if (res.data.status == '200') {
that.vests_to_sp(parseFloat(res.data.user.vesting_shares), parseFloat(res.data.user.delegated_vesting_shares));
that.get_follower_following();
that.setData({
avatar: res.data.user.json_metadata.profile.profile_image,
balance: res.data.user.balance,
created: res.data.user.created,
post_count: res.data.user.post_count,
sbd_balance: res.data.user.sbd_balance,
vesting_shares: parseInt(res.data.user.vesting_shares),
voting_power: String(res.data.user.voting_power).substr(0, 2),
reputation: that.getReputation(res.data.user.reputation),
average_market_bandwidth: res.data.user.average_market_bandwidth,
author: res.data.user.name,
steemitname: res.data.user.json_metadata.profile.name,
about: res.data.user.json_metadata.profile.about,
location: res.data.user.json_metadata.profile.location,
postkey: res.data.user.posting.key_auths[0][0],
activekey: res.data.user.active.key_auths[0][0],
ownerkey: res.data.user.owner.key_auths[0][0],
memokey: res.data.user.memo_key,
account_auths: res.data.user.posting.account_auths,
witness_votes: res.data.user.witness_votes,
hidden: true



})
}
that.calc_bandwidth();
},
complete: function (res) {
var transactionHistory = [];
wx.request({
url: 'https://uploadbeta.com/api/steemit/transfer-history/?id=cha0s0000',
method:'GET',
success:function(res){
if (res.statusCode == '200') {
var transactionDatas = res.data;
for (var transactionData in transactionDatas){
var obj = new Object();
obj.time = transactionDatas[transactionData].time_desc;
obj.transaction = transactionDatas[transactionData].transaction;
obj.memo = transactionDatas[transactionData].memo;
transactionHistory.push(obj);
})
}
that.calc_bandwidth();
},
complete: function (res) {
var transactionHistory = [];
wx.request({
url: 'https://uploadbeta.com/api/steemit/transfer-history/?id=' + account,
method: 'GET',
success: function (res) {
if (res.statusCode == '200') {
var transactionDatas = res.data;
for (var transactionData in transactionDatas) {
var obj = new Object();
obj.time = transactionDatas[transactionData].time_desc;
obj.transaction = transactionDatas[transactionData].transaction;
obj.memo = transactionDatas[transactionData].memo;
transactionHistory.push(obj);
}
}
console.log(transactionHistory);
that.setData({ transactions: transactionHistory })
}
console.log(transactionHistory);
that.setData({ transactions: transactionHistory})
}
})
}
})

})
}
})

}

},

/**
Expand Down Expand Up @@ -137,6 +144,8 @@ Page({
* Page correlation event handler - listen to the user to pull.
*/
onPullDownRefresh: function () {
this.setData({ hidden: false})
this.onLoad();

},

Expand Down Expand Up @@ -299,4 +308,21 @@ Page({
})
},

clickAvatar:function(){
var that =this;
wx.showModal({
title: 'LogOut',
content: 'Are you sure to log out',
success: function (res) {
if (res.confirm) {
console.log('confirm log out')
wx.removeStorageSync('name')
that.onLoad();
} else if (res.cancel) {
console.log('cancel the log out ')
}
}
})
}

})
2 changes: 1 addition & 1 deletion pages/info/info.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<image class="info-header-bg" src="../../static/images/info_head.png" />
<view class="none-work">
<view class="info-avatar-bg"></view>
<image class="info-avatar" src="{{avatar}}" />
<image class="info-avatar" bindtap='clickAvatar' src="{{avatar}}" />
</view>
</view>
<view class="info-content">
Expand Down
9 changes: 7 additions & 2 deletions pages/info/info.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@
}
.about{
display: flex;
flex-direction: row;
margin-top:10rpx;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
width: 100%;
}
.intro{
font-size: 15px;
font-size: 13px;
font-family:'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif;
text-align:center;
margin:auto;
Expand Down Expand Up @@ -286,6 +288,7 @@
vertical-align: middle;
margin-right: 5px;
margin-left:5px;
font-size:11px
}
.post-view{
display: flex;
Expand All @@ -306,12 +309,14 @@
vertical-align: middle;
margin-right: 5px;
margin-left:5px;
font-size:11px
}

.following-text{
vertical-align: middle;
margin-right: 5px;
margin-left:5px;
font-size:11px
}
.split{
margin-bottom: 30rpx;
Expand Down

0 comments on commit 92111f3

Please sign in to comment.