pp电子

登录
免费开通

微信小程序音乐播放器,音乐播放器小程序制作方法(页面渲染)

  页面渲染

  

  为相识决这个问题,,,,,,我们给图片添加一个渐变的遮罩,,,,,,就像图10-8那样,,,,,,这样抵达文字部分时,,,,,,配景就酿成了玄色,,,,,,不会影响文字的显示,,,,,,并且抵达了由图片究竟下列表颜色渐变的效果,,,,,,很是雅观。 。。。。

  这个效果主要靠pp电子名堂文件实现,,,,,,我们先写我们熟悉的部分。 。。。。

  1. .list-top {
  2.     position: relative;
  3.     height: 100%;
  4. }
  5. .list-top::after {         
  6.     content: " ";
  7.     display: block;
  8.     padding-top: 100%;
  9. }
  10. .top-info {
  11.     position: absolute;
  12.     bottom: 0;
  13.     width: 100%;
  14.     z-index: 3;
  15. }
  16. .top-img {
  17.     width: 100%;
  18.     height: 100%;
  19.     position: absolute;
  20. }
  21.  
  22. .top-info-inner {
  23.     display: -webkit-box;
  24.     -webkit-box-align: center;
  25.     margin: 0 15px 25px;
  26.     color: #fff;
  27. }
  28.  
  29. .top-info-text {
  30.     -webkit-box-flex: 1;
  31.     margin-right: 10px;
  32. }
  33. .top-info-title {
  34.     font-size: 24px;
  35.     line-height: 36px;
  36.     white-space: nowrap;
  37.     overflow: hidden;
  38. }
  39. .top-info-base {
  40.     font-size: 14px;
  41.     line-height: 20px;
  42. }
复制代码

 

  “::after”体现在“.list-top”后边添加,,,,,,为了是在不修改结构文件的情形下,,,,,,添加视图以抵达美化的效果。 。。。。

  

  我们需要添加的遮罩为结构里“top—back”这部分,,,,,,名堂文件为:

  1. .tl-top-b {
  2.     position: absolute;
  3.     bottom: 0;
  4.     width: 100%;
  5.     background-image: -webkit-linear-gradient(top,transparent,currentColor 80%);
  6. }
  7. .tl-top-b::after {
  8.     content: " ";
  9.     display: block;
  10.     padding-top: 60%;
  11. }
复制代码

 

  -webkit-linear-gradient(top,transparent,currentColor 80%)这行代码为我们建设了线性渐变的效果,,,,,,这样pp电子图片底部就会泛起渐变为玄色的效果了。 。。。。

  剩下播放按钮的样式,,,,,,这里由于用到了渐变的遮罩和配景图,,,,,,为了抵达最好的效果,,,,,,这个按钮就不可用图片来显示了,,,,,,我们使用代码来建设一个播放按钮。 。。。。

  1. .tl-top-play {
  2.     position: relative;
  3.     display: block;
  4.     width: 42px;
  5.     height: 42px;
  6.     margin-left: 10px;
  7.     border: solid 3px;
  8.     border-radius: 999px;
  9. }
  10. .tl-top-play::after {
  11.     content: " ";
  12.     position: absolute;
  13.     left: 50%;
  14.     top: 50%;
  15.     margin-top: -10px;
  16.     margin-left: -5px;
  17.     display: inline-block;
  18.     vertical-align: middle;
  19.     width: 0;
  20.     height: 0;
  21.     border-style: solid;
  22.     border-width: 10px 16px;
  23.     border-color: transparent transparent  transparent #fff;
  24. }
复制代码

 

  视图建设完毕,,,,,,最先为视图填充数据。 。。。。

  1. //加载网络请求函数
  2. var MusicService = require('../../services/music');
  3. //获取应用实例
  4. var app = getApp();
  5.  
  6. Page({
  7.     data: {
  8.         // text:"这是一个页面"
  9.         songList: [],
  10.         imgUrl: '',
  11.         id: 0,
  12.         topinfo: {},
  13.         update_time: '',
  14.     },
  15.     onLoad: function (options) {
  16.         // 页面初始化 options为页面跳转所带来的参数
  17.         var self = this;
  18.         var id = app.globalData.topListId;
  19.         this.setData({
  20.             id: id
  21.         });
  22.         MusicService.getTopListInfo(id, this.getTopListCallback)
  23.     },
  24. })
复制代码

 

  这里我们获取了生涯于全局变量里的topListId(即我们点击的排行分类的ID),,,,,,然后使用这个ID请求网络。 。。。。

  1. getTopListCallback: function (data) {
  2.         var imgUrl = data.topinfo.pic_album;
  3.         this.setData({
  4.             topinfo: data.topinfo,
  5.             update_time: data.update_time
  6.         });
  7.         this.setSongList(data.songlist);
  8.     },
复制代码

 

  使用回调函数为pp电子data赋值之后,,,,,,这里挪用了setSongList这个要领,,,,,,通过这个要领我们把返回数据里我们需要的内容生涯到songList里。 。。。。

  1. setSongList: function (songs) {
  2.         var list = [];
  3.         for (var i = 0; i < songs.length; i++) {
  4.             var item = songs[i];
  5.             var song = {};
  6.             var album = {};
  7.  
  8.             album.mid = item.data.albummid
  9.             album.id = item.data.albumid
  10.             album.name = item.data.albumname;
  11.             album.desc = item.data.albumdesc
  12.  
  13.             song.id = item.data.songid;
  14.             song.mid = item.data.songmid;
  15.             song.name = item.data.songname;
  16.             song.title = item.data.songorig;
  17.             song.subTitle = '';
  18.             song.singer = item.data.singer;
  19.             song.album = album;
  20.             song.time_public = item.time_public;
  21.             song.img = 'http://y.gtimg.cn/music/photo_new/T002R150x150M000' + album.mid + '.jpg?max_age=2592000'
  22.             list.push(song);
  23.         }
  24.         this.setData({
  25.             songList: list
  26.         })
  27.     }
复制代码

 

  最好完成此页面里的点击事务:

  1. mainTopTap: function (e) {
  2.         var list = this.data.songList;
  3.         app.setGlobalData({                //使用全局变量playList来生涯我们目今的list
  4.             playList: list,
  5.             playIndex: 0                    //体现从第一首歌曲最先播放
  6.         });
  7.         wx.navigateTo({
  8.             url: '../play/play'            //跳转到播放页
  9.         });
  10.     },
  11.     musicItemTap: function (e) {
  12.         var dataSet = e.currentTarget.dataset;
  13.         var index = dataSet.index;                //获取点击的item的序号
  14.         var list = this.data.songList;
  15.         app.setGlobalData({
  16.             playList: list,
  17.             playIndex: index                      //从点击歌曲最先播放
  18.         });
  19.         wx.navigateTo({
  20.             url: '../play/play'
  21.         });
  22.     },
复制代码

 

  上一节:微信小程序小白项目开发案例之音乐播放器-获取列表页数据

  下一节:微信小程序小白项目开发案例之音乐播放器-完成相似页面

  


【本站声明】
  1、本站文章中所选用的图片及文字泉源于网络以及用户投稿,,,,,,由于未联系到知识产权人或未发明有关知识产权的挂号,,,,,,若有知识产权人并不肯意我们使用,,,,,,若是有侵权请连忙联系。 。。。。
  2、本网站差池文章中所涉及的内容真实性、准确性、可靠性认真,,,,,,仅系客观性形貌,,,,,,如您需要相识该类商品/服务详细的资讯,,,,,,请您直接与该类商品/服务的提供者联系。 。。。。


KESION pp电子软件

KESION pp电子软件是海内领先的在线教育软件及私域社交电商软件服务提供商,,,,,,恒久专注于为企业提供在线教育软件及社交电商SaaS平台解决方案。 。。。。
公司焦点产品云开店SaaS社交电商服务平台、在线教育SaaS服务平台、教育企业数字化SaaS云平台、企微营销助手、私有化自力安排品牌网校和在线教育咨询等。 。。。。

KESION 一直通过手艺立异,,,,,,提供产品和服务,,,,,,助力企业向数字化转型,,,,,,通过科技驱动商业刷新,,,,,,让商业变得更智慧!



▼点击进入pp电子官网相识更多



热门标签
微信小程序
上/下篇
换一换相关推荐
精选内容
热门精选
pp电子·模拟器(试玩游戏)官方网站 pp电子·模拟器(试玩游戏)官方网站 pp电子·模拟器(试玩游戏)官方网站
【网站地图】
微信小程序音乐播放器,音乐播放器小程序制作方法(页面渲染)