2018/1/5 0:00:00
泉源:不详
作者:未知
页面渲染
为相识决这个问题,,,,,,我们给图片添加一个渐变的遮罩,,,,,,就像图10-8那样,,,,,,这样抵达文字部分时,,,,,,配景就酿成了玄色,,,,,,不会影响文字的显示,,,,,,并且抵达了由图片究竟下列表颜色渐变的效果,,,,,,很是雅观。。。。
这个效果主要靠pp电子名堂文件实现,,,,,,我们先写我们熟悉的部分。。。。
-
.list-top {
-
position: relative;
-
height: 100%;
-
}
-
.list-top::after {
-
content: " ";
-
display: block;
-
padding-top: 100%;
-
}
-
.top-info {
-
position: absolute;
-
bottom: 0;
-
width: 100%;
-
z-index: 3;
-
}
-
.top-img {
-
width: 100%;
-
height: 100%;
-
position: absolute;
-
}
-
-
.top-info-inner {
-
display: -webkit-box;
-
-webkit-box-align: center;
-
margin: 0 15px 25px;
-
color: #fff;
-
}
-
-
.top-info-text {
-
-webkit-box-flex: 1;
-
margin-right: 10px;
-
}
-
.top-info-title {
-
font-size: 24px;
-
line-height: 36px;
-
white-space: nowrap;
-
overflow: hidden;
-
}
-
.top-info-base {
-
font-size: 14px;
-
line-height: 20px;
-
}
复制代码
“::after”体现在“.list-top”后边添加,,,,,,为了是在不修改结构文件的情形下,,,,,,添加视图以抵达美化的效果。。。。
我们需要添加的遮罩为结构里“top—back”这部分,,,,,,名堂文件为:
-
.tl-top-b {
-
position: absolute;
-
bottom: 0;
-
width: 100%;
-
background-image: -webkit-linear-gradient(top,transparent,currentColor 80%);
-
}
-
.tl-top-b::after {
-
content: " ";
-
display: block;
-
padding-top: 60%;
-
}
复制代码
-webkit-linear-gradient(top,transparent,currentColor 80%)这行代码为我们建设了线性渐变的效果,,,,,,这样pp电子图片底部就会泛起渐变为玄色的效果了。。。。
剩下播放按钮的样式,,,,,,这里由于用到了渐变的遮罩和配景图,,,,,,为了抵达最好的效果,,,,,,这个按钮就不可用图片来显示了,,,,,,我们使用代码来建设一个播放按钮。。。。
-
.tl-top-play {
-
position: relative;
-
display: block;
-
width: 42px;
-
height: 42px;
-
margin-left: 10px;
-
border: solid 3px;
-
border-radius: 999px;
-
}
-
.tl-top-play::after {
-
content: " ";
-
position: absolute;
-
left: 50%;
-
top: 50%;
-
margin-top: -10px;
-
margin-left: -5px;
-
display: inline-block;
-
vertical-align: middle;
-
width: 0;
-
height: 0;
-
border-style: solid;
-
border-width: 10px 16px;
-
border-color: transparent transparent transparent #fff;
-
}
复制代码
视图建设完毕,,,,,,最先为视图填充数据。。。。
-
//加载网络请求函数
-
var MusicService = require('../../services/music');
-
//获取应用实例
-
var app = getApp();
-
-
Page({
-
data: {
-
// text:"这是一个页面"
-
songList: [],
-
imgUrl: '',
-
id: 0,
-
topinfo: {},
-
update_time: '',
-
},
-
onLoad: function (options) {
-
// 页面初始化 options为页面跳转所带来的参数
-
var self = this;
-
var id = app.globalData.topListId;
-
this.setData({
-
id: id
-
});
-
MusicService.getTopListInfo(id, this.getTopListCallback)
-
},
-
})
复制代码
这里我们获取了生涯于全局变量里的topListId(即我们点击的排行分类的ID),,,,,,然后使用这个ID请求网络。。。。
-
getTopListCallback: function (data) {
-
var imgUrl = data.topinfo.pic_album;
-
this.setData({
-
topinfo: data.topinfo,
-
update_time: data.update_time
-
});
-
this.setSongList(data.songlist);
-
},
复制代码
使用回调函数为pp电子data赋值之后,,,,,,这里挪用了setSongList这个要领,,,,,,通过这个要领我们把返回数据里我们需要的内容生涯到songList里。。。。
-
setSongList: function (songs) {
-
var list = [];
-
for (var i = 0; i < songs.length; i++) {
-
var item = songs[i];
-
var song = {};
-
var album = {};
-
-
album.mid = item.data.albummid
-
album.id = item.data.albumid
-
album.name = item.data.albumname;
-
album.desc = item.data.albumdesc
-
-
song.id = item.data.songid;
-
song.mid = item.data.songmid;
-
song.name = item.data.songname;
-
song.title = item.data.songorig;
-
song.subTitle = '';
-
song.singer = item.data.singer;
-
song.album = album;
-
song.time_public = item.time_public;
-
song.img = 'http://y.gtimg.cn/music/photo_new/T002R150x150M000' + album.mid + '.jpg?max_age=2592000'
-
list.push(song);
-
}
-
this.setData({
-
songList: list
-
})
-
}
复制代码
最好完成此页面里的点击事务:
-
mainTopTap: function (e) {
-
var list = this.data.songList;
-
app.setGlobalData({ //使用全局变量playList来生涯我们目今的list
-
playList: list,
-
playIndex: 0 //体现从第一首歌曲最先播放
-
});
-
wx.navigateTo({
-
url: '../play/play' //跳转到播放页
-
});
-
},
-
musicItemTap: function (e) {
-
var dataSet = e.currentTarget.dataset;
-
var index = dataSet.index; //获取点击的item的序号
-
var list = this.data.songList;
-
app.setGlobalData({
-
playList: list,
-
playIndex: index //从点击歌曲最先播放
-
});
-
wx.navigateTo({
-
url: '../play/play'
-
});
-
},
复制代码
上一节:微信小程序小白项目开发案例之音乐播放器-获取列表页数据
下一节:微信小程序小白项目开发案例之音乐播放器-完成相似页面
【本站声明】
1、本站文章中所选用的图片及文字泉源于网络以及用户投稿,,,,,,由于未联系到知识产权人或未发明有关知识产权的挂号,,,,,,若有知识产权人并不肯意我们使用,,,,,,若是有侵权请连忙联系。。。。
2、本网站差池文章中所涉及的内容真实性、准确性、可靠性认真,,,,,,仅系客观性形貌,,,,,,如您需要相识该类商品/服务详细的资讯,,,,,,请您直接与该类商品/服务的提供者联系。。。。
KESION pp电子软件
KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,,,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。。。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。。。。KESION 一直通过手艺立异,,,,,,提供产品和服务,,,,,,助力企业向数字化转型,,,,,,通过科技驱动商业刷新,,,,,,让商业变得更智慧!