|
@@ -72,6 +72,8 @@ Page({
|
|
|
userInfo: {},
|
|
|
loading:false,
|
|
|
loading_more:false,
|
|
|
+ loading_show:false,
|
|
|
+ users_count:0,
|
|
|
next_data:true,
|
|
|
busy:false,
|
|
|
posts:[]
|
|
@@ -83,14 +85,10 @@ Page({
|
|
|
}
|
|
|
self.setData({
|
|
|
loading:true,
|
|
|
+ posts:[],
|
|
|
busy:true
|
|
|
});
|
|
|
- var url;
|
|
|
- if(self.data.next_page_url==null){
|
|
|
- url=config.service.apiUrl+'timeline';
|
|
|
- }else{
|
|
|
- url=self.data.next_page_url
|
|
|
- }
|
|
|
+ var url=config.service.apiUrl+'timeline';
|
|
|
qcloud.request({
|
|
|
// 要请求的地址
|
|
|
url: url,
|
|
@@ -136,6 +134,88 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ user_list(){
|
|
|
+ var self=this;
|
|
|
+ var url=config.service.apiUrl+'followers';
|
|
|
+ qcloud.request({
|
|
|
+ // 要请求的地址
|
|
|
+ url: url,
|
|
|
+ success(result) {
|
|
|
+ if(result.data.success==true){
|
|
|
+ self.setData({
|
|
|
+ users_count:result.data.followers.total
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log('request success', result);
|
|
|
+ },
|
|
|
+
|
|
|
+ fail(error) {
|
|
|
+ console.log('request fail', error);
|
|
|
+ },
|
|
|
+
|
|
|
+ complete() {
|
|
|
+ console.log('request complete');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ refresh(){
|
|
|
+ var self = this;
|
|
|
+ if(self.data.busy){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ self.setData({
|
|
|
+ loading:true,
|
|
|
+ posts:[],
|
|
|
+ busy:true
|
|
|
+ });
|
|
|
+ // wx.showNavigationBarLoading();
|
|
|
+ var url=config.service.apiUrl+'timeline';
|
|
|
+ qcloud.request({
|
|
|
+ // 要请求的地址
|
|
|
+ url: url,
|
|
|
+ success(result) {
|
|
|
+ if(result.data.success==true){
|
|
|
+ for (var i=0;i<result.data.posts.data.length;i++){
|
|
|
+ var datestr=Date.parse((result.data.posts.data[i]['created_at']).toString().replace(/-/g, "/"));
|
|
|
+ if(datestr){
|
|
|
+ result.data.posts.data[i]['created_at']=new Date(datestr).format("hh:mm");
|
|
|
+ }else{
|
|
|
+ result.data.posts.data[i]['created_at']= '--:--'
|
|
|
+ }
|
|
|
+ }
|
|
|
+ self.setData({
|
|
|
+ posts:result.data.posts.data
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(result.data.posts.next_page_url!==null){
|
|
|
+ self.setData({
|
|
|
+ next_data:true,
|
|
|
+ next_page_url:result.data.posts.next_page_url
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ self.setData({
|
|
|
+ next_data:false,
|
|
|
+ next_page_url:null
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log('request success', result);
|
|
|
+ },
|
|
|
+
|
|
|
+ fail(error) {
|
|
|
+ console.log('request fail', error);
|
|
|
+ },
|
|
|
+
|
|
|
+ complete() {
|
|
|
+ self.setData({
|
|
|
+ loading:false,
|
|
|
+ busy:false
|
|
|
+ });
|
|
|
+ // wx.hideNavigationBarLoading();
|
|
|
+ wx.stopPullDownRefresh();
|
|
|
+ console.log('request complete');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
load_more(){
|
|
|
var self = this;
|
|
|
var request_url=self.data.next_page_url;
|
|
@@ -196,29 +276,91 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ formSubmit:function(e){
|
|
|
+ var self = this;
|
|
|
+ if(self.data.busy1){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var data={};
|
|
|
+ data.image_url="http://upload-1251348966.image.myqcloud.com/upload/2017-04-21/b1ba2fd7b035f7db742bf76e2af7be96.png?imageMogr2/auto-orient/strip/thumbnail/1000x1000/quality/80/format/jpg";
|
|
|
+ if(e.detail.formId!='the formId is a mock one'){
|
|
|
+ data.form_id=e.detail.formId;
|
|
|
+ }
|
|
|
+ data.can_read_times=-1
|
|
|
+ data.type==1
|
|
|
+ data.expire_in=-1;
|
|
|
+ self.setData({
|
|
|
+ 'busy1':true
|
|
|
+ })
|
|
|
+ qcloud.request({
|
|
|
+ // 要请求的地址
|
|
|
+ url: config.service.messageAddUrl,
|
|
|
+ method:"POST",
|
|
|
+ data: data,
|
|
|
+ success(result) {
|
|
|
+ console.log(result);
|
|
|
+ if(result.data.success==true){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/channel/invitation/invitation?hash_key='+result.data.id
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ showMsg("提示信息","新建邀请失败,"+result.data.message);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ fail(error) {
|
|
|
+ console.log('request fail', error);
|
|
|
+ showMsg("提示信息","新建邀请失败");
|
|
|
+ },
|
|
|
+
|
|
|
+ complete() {
|
|
|
+ self.setData({
|
|
|
+ 'busy1':false
|
|
|
+ })
|
|
|
+ console.log('request complete');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
onReachBottom: function() {
|
|
|
var self = this;
|
|
|
self.load_more();
|
|
|
},
|
|
|
- onShareAppMessage: function () {
|
|
|
- return {
|
|
|
- title: '密频',
|
|
|
- path: 'pages/channel/index/index',
|
|
|
- success: function(res) {
|
|
|
- showSuccess('分享成功');
|
|
|
- console.log(res);
|
|
|
- // 分享成功
|
|
|
- },
|
|
|
- fail: function(res) {
|
|
|
- // 分享失败
|
|
|
- console.log(res);
|
|
|
- },
|
|
|
- complete:function(res){
|
|
|
- console.log(res);
|
|
|
- }
|
|
|
- }
|
|
|
+ onPullDownRefresh: function() {
|
|
|
+ var self = this;
|
|
|
+ self.refresh();
|
|
|
},
|
|
|
- onLoad:function(options){
|
|
|
+ onLoad:function(e){
|
|
|
+ console.log(e);
|
|
|
+ if(e.hash_key){
|
|
|
+ this.setData({
|
|
|
+ hash_key:e.hash_key
|
|
|
+ })
|
|
|
+ var self=this;
|
|
|
+ qcloud.request({
|
|
|
+ // 要请求的地址
|
|
|
+ url: config.service.apiUrl+'messages/'+self.data.hash_key,
|
|
|
+ success(result) {
|
|
|
+ console.log(result);
|
|
|
+ if(result.data.success==true){
|
|
|
+ if(result.data.is_mine==false){
|
|
|
+ var ncikname=result.data.message_data.user.nickname;
|
|
|
+ showMsg("提示信息","您成功关注了"+ncikname+'的密频');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
+ fail(error) {
|
|
|
+ console.log('request fail', error);
|
|
|
+ },
|
|
|
+
|
|
|
+ complete() {
|
|
|
+ console.log('request complete');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }else{
|
|
|
+ console.log('123')
|
|
|
+ }
|
|
|
// 页面初始化 options为页面跳转所带来的参数
|
|
|
},
|
|
|
onReady:function(){
|
|
@@ -239,6 +381,7 @@ Page({
|
|
|
var self=this;
|
|
|
app.getUserInfo(function(userInfo){
|
|
|
self.post_list();
|
|
|
+ self.user_list();
|
|
|
});
|
|
|
},
|
|
|
onHide:function(){
|