const util = require( '../../utils/util.js' );
Page( {
data: {
// text:"这是一个页面"
data: [],
databody: null,
comments : [], // 评论
winHeight: 0, // 设备高度
// 弹窗
modalHidden: true,
modalValue: null,
/**
* 分享配置
*/
shareShow: 'none',
shareOpacity: {},
shareBottom: {},
},
onLoad: function( options ) {
// 页面初始化 options 为页面跳转所带来的参数
var that = this
var id = options.id;
// 请求内容数据
util.AJAX( "news/" + id, function( res ) {
var arr = res.data;
var body = arr.body;
body = body.match( /<p>.*?<\/p>/g );
var ss = [];
for( var i = 0, len = body.length; i < len;i++ ) {
ss[ i ] = /<img.*?>/.test( body[ i ] );
if( ss[ i ] ) {
body[ i ] = body[ i ].match( /(http:|https:).*?\.(jpg|jpeg|gif|png)/ );
} else {
body[ i ] = body[ i ].replace( /<p>/g, '' )
.replace( /<\/p>/g, '' )
.replace( /<strong>/g, '' )
.replace( /<\/strong>/g, '' )
.replace( /<a.*?\/a>/g, '' )
.replace( / /g, ' ' )
.replace( /“/g, '"' )
.replace( /”/g, '"' );
}
}
// 重新写入数据
that.setData( {
data: arr,
databody: body
});
});
// 请求评论
util.AJAX( "story/" + id + "/short-comments", function( res ) {
var arr = res.data.comments;
for ( var i = 0, len = arr.length; i < len; i++ ){
arr[i]['times'] = util.getTime( arr[i].time );
}
// 重新写入数据
that.setData( {
comments: arr
});
});
/**
* 获取系统信息
*/
wx.getSystemInfo( {
success: function( res ) {
that.setData( {
winWidth: res.windowWidth,
winHeight: res.windowHeight
});
}
});
},
/**
* 显示分享
*/
showShare: function( e ) {
// 创建动画
var animation = wx.createAnimation( {
duration: 100,
timingFunction: "ease",
})
this.animation = animation;
var that = this;
that.setData( {
shareShow: "block",
});
setTimeout( function() {
that.animation.bottom( 0 ).step();
that.setData( {
shareBottom: animation.export()
});
}.bind( this ), 400 );
// 遮罩层
setTimeout( function() {
that.animation.opacity( 0.3 ).step();
that.setData( {
shareOpacity: animation.export()
});
}.bind( this ), 400 );
},
/**
* 关闭分享
*/
shareClose: function() {
// 创建动画
var animation = wx.createAnimation( {
duration: 0,
timingFunction: "ease"
})
this.animation = animation;
var that = this;
setTimeout( function() {
that.animation.bottom( -210 ).step();
that.setData( {
shareBottom: animation.export()
});
}.bind( this ), 500 );
setTimeout( function() {
that.animation.opacity( 0 ).step();
that.setData( {
shareOpacity: animation.export()
});
}.bind( this ), 500 );
setTimeout( function() {
that.setData( {
shareShow: "none",
});
}.bind( this ), 1500 );
},
/**
* 点击分享图标弹出层
*/
modalTap: function( e ) {
var that = this;
that.setData( {
modalHidden: false,
modalValue: e.target.dataset.share
})
},
/**
* 关闭弹出层
*/
modalChange: function( e ) {
var that = this;
that.setData( {
modalHidden: true
})
},
onReady: function() {
// 页面渲染完成
// 修改页面标题
wx.setNavigationBarTitle( {
title: this.data.data.title
})
},
onShow: function() {
// 页面显示
},
onHide: function() {
// 页面隐藏
},
onUnload: function() {
// 页面关闭
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码)微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码) 微信小程序练手项目-知乎日报(完整代码)微信小程序练手项目-知乎日报(完整代码)微信小程序练手项目-知乎日报(完整代码
资源推荐
资源详情
资源评论
收起资源包目录
微信小程序练手项目-知乎日报(完整代码).zip (38个子文件)
微信小程序练手项目-知乎日报(完整代码)
pages
detail
detail.json 37B
detail.js 5KB
detail.wxml 3KB
detail.wxss 3KB
index
index.wxml 5KB
index.js 5KB
index.json 39B
index.wxss 3KB
themes
themes.json 37B
themes.js 785B
themes.wxss 1KB
themes.wxml 713B
app.json 307B
app.js 911B
template
itemlist.wxml 0B
utils
util.js 2KB
app.wxss 225B
效果截图
demo2.png 169KB
QQ20161009-5@2x.png 35KB
QQ20161009-6@2x.png 78KB
demo4 (1).png 63KB
QQ20161009-4@2x.png 54KB
demo4 (2).png 75KB
demo.gif 3.45MB
config.js 89B
static
pengyou.png 31KB
arrowright.png 1KB
loading.gif 2KB
weixin.png 28KB
share.png 17KB
weibo.png 35KB
qq.png 25KB
loading.svg 498B
wechat.png 1KB
zan.png 26KB
wechatHL.png 1KB
001.jpg 359KB
comments.png 23KB
共 38 条
- 1
资源评论
张飞的猪大数据
- 粉丝: 3318
- 资源: 41
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功