微信音乐小程序实战(一):完成静态推荐歌曲页面的搭建

2021/6/11 20:21:21

本文主要是介绍微信音乐小程序实战(一):完成静态推荐歌曲页面的搭建,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

这次我们要完成的是推荐歌曲页面的搭建,页面效果如下:

 

完成此页面需要两个步骤:1. 搭建静态页面   2. 加入真实数据

搭建静态页面

1. 新建新项目

首先,让我们新建一个小程序项目(还不知道怎么新建的小伙伴就自行百度了唷),新建完的空白项目如下:

 

2. 新建文件夹

创建完后,我们开始新建一个文件夹recommendSong(由于只记录两个页面的学习,所以我就暂时不动index文件夹,而是选择新建一个文件夹;这也便于以后如果还有小程序的首页补充,可以再用这个index文件夹)

① 先新建文件夹 recommendSong

 

② 再在recommendSong文件夹上右键新建Page 

 

最终效果如下:

 

3. 完成静态页面的搭建

为了方便,我们让小程序最先展示recommendSong的页面,修改app.json,将recommendSong提到pages的最前面  【哦,前面我顺手删除了pages里的log文件夹,所以下面图示中的pages里就不包含log啦】

这时候小程序显示效果为:

 

现在我们要操作的就是recommendSong.wxml和recommendSong.wxss,完成最基本的静态页面

在此之前,我们先引入相关的图片和公共的css样式,首先在根目录新建一个文件夹static,

并在static里新建两个文件夹,分别为 iconfont 和 images

☞iconfont放置我们的和图标有关的css文件,image来存放我们的图片

A. 引入相关css文件

在iconfont中再新建两个文件,分别为 iconfont.wxss 和 myicon.wxss

iconfont.wxss的代码如下:

@font-face {
  font-family:"iconfont";
  src: url('//at.alicdn.com/t/font_1686339_sgjgtmoa3kj.eot?t=1601969873487');
  /* IE9 */
  src: url('//at.alicdn.com/t/font_1686339_sgjgtmoa3kj.eot?t=1601969873487#iefix') format('embedded-opentype'),
    /* IE6-IE8 */
  url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAB6cAAsAAAAANmQAAB5OAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCJEgrSdMIHATYCJAOBQAtiAAQgBYRtB4VzG8osVQQ2DgBE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V3SmLshE3syaKh0CEWsdq+TU5aQjWHTxac3z/nyAtsYAXrPQ2+TfIC+jUjymlgYTvucRSK82KORjThiIinWOiecIZ8jNMkNXKxLGe39wIakQlE0DrPVChjXWyUpm87PqcBFrfKtW0RCEUCAZMWLDhgPEr91cRGh58BOmtMjJbt8lq2659h46dOnfJzsnNy+9a0K17j6N6FvbqfXRRH4vWDonHKyMC1jXSSiM2OS6uS8EANyYtWUoZeMWcUHo2w40JgUyoKN5In5cCgm/MskmUk2SIzi2WW0JxBNroNObCA98S6834Sj3FREdDsd4DmZgh2WCDaxpMDdWikw8F2GYNS/cqCwYz7WMTl5wRAZo8pAvPEQ8hQccYJk1ZL2psgZdeTLXYQwq4PAWO7vGlYPHld45az2eRzoRZklY+G9UC4ySe5aXF8DYFajI6Apbu5uRHSh8s5DcU4qX4R/vQeuwR4nvGk7P06bC5pyfuzyZ1ncVNlz9hI84ht+jXfsjUNCBZ0lINxZffF1NrGj3y1KSM2xorArJgtS+5rJF1m2SFWqrtOklyIDHVGE/UTamnJjbxgqVbbNLhU+B9MjXIzafvTnnFU0LpBcNVR0oB') format('woff2'), url('//at.alicdn.com/t/font_1686339_sgjgtmoa3kj.woff?t=1601969873487') format('woff'), url('//at.alicdn.com/t/font_1686339_sgjgtmoa3kj.ttf?t=1601969873487') format('truetype'),
    /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
  url('//at.alicdn.com/t/font_1686339_sgjgtmoa3kj.svg?t=1601969873487#iconfont') format('svg');
  /* iOS 4.1- */
}
.iconfont {
  font-family:"iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.icon-meinv:before {
  content:"\e619";
}
.icon-jiangbei:before {
  content:"\e617";
}
.icon-column-4:before {
  content:"\e664";
}
.icon-shanchu:before {
  content:"\e61a";
}
.icon-liuyan:before {
  content:"\e650";
}
.icon-shanchu1:before {
  content:"\e719";
}
.icon-shanchu2:before {
  content:"\e771";
}
.icon-xiaoxi--copy:before {
  content:"\e614";
}
.icon-search:before {
  content:"\e615";
}
.icon-search1:before {
  content:"\e616";
}
.icon-huiyuan:before {
  content:"\e682";
}
.icon-huiyuan-:before {
  content:"\e613";
}
.icon-diantai:before {
  content:"\e6f4";
}
.icon-icon-ranking:before {
  content:"\e605";
}
.icon-meirituijian-:before {
  content:"\e64b";
}
/*.icon-paihangbang:before {*/
/*  content:"\e606";*/
/*}*/

.icon-meirituijian:before {
  content:"\e607";
}
.icon-zhiboguankanliangbofangsheyingshexiangjixianxing:before {
  content:"\e609";
}
.icon-zhibobofangshexiangjitianxianxianxing:before {
  content:"\e69b";
}
.icon-gedan:before {
  content:"\e60c";
}
.icon-gedan1:before {
  content:"\e610";
}
.icon-pause:before {
  content:"\e603";
}
.icon-zanting:before {
  content:"\e774";
}
.icon-bofang:before {
  content:"\e68b";
}
.icon-bofang1:before {
  content:"\e601";
}
.icon-shangyishou:before {
  content:"\e608";
}
.icon-zanting1:before {
  content:"\e60b";
}
.icon-next:before {
  content:"\e604";
}
.icon-iconsMusicyemianbofangmoshiPlayList:before {
  content:"\e677";
}
.icon-iconsMusicyemianbofangmoshiAlrepeatOne:before {
  content:"\e676";
}
.icon-iconsMusicyemianbofangmoshiRepeat:before {
  content:"\e678";
}
.icon-iconsMusicyemianbofangmoshiShuffle:before {
  content:"\e679";
}
.icon-myRecommender:before {
  content:"\e602";
}
.icon-wodehaoyou:before {
  content:"\e70b";
}
.icon-xiaoxi:before {
  content:"\e60d";
}
.icon-xiaoxi1:before {
  content:"\e60f";
}
.icon-gerenzhuye:before {
  content:"\e7ef";
}
.icon-gexingzhuangban:before {
  content:"\e653";
}
.icon-gengduo:before {
  content:"\e704";
}
.icon-gengduo1:before {
  content:"\e611";
}
.icon-buoumaotubiao15:before {
  content:"\e60e";
}
.icon-pinglun:before {
  content:"\e61b";
}
.icon-like:before {
  content:"\e692";
}
.icon-dianzan:before {
  content:"\e644";
}
.icon-iconzhengli_dianzan:before {
  content:"\e643";
}
.icon-pinglun1:before {
  content:"\e612";
}
.icon-pinglun2:before {
  content:"\e60a";
}
.icon-pinglun11:before {
  content:"\e600";
}



.icon-order:before {
  content: "\e623";
}

.icon-repeat:before {
  content: "\e607";
}

.icon-shuffle:before {
  content:"\e679";
}

 

myicon.wxss的代码如下:

@font-face {
  font-family: "iconfont"; /* Project id 2543123 */
  src: url('//at.alicdn.com/t/font_2543123_uk616l4ydjs.woff2?t=1623249546092') format('woff2'),
  url('//at.alicdn.com/t/font_2543123_uk616l4ydjs.woff?t=1623249546092') format('woff'),
  url('//at.alicdn.com/t/font_2543123_uk616l4ydjs.ttf?t=1623249546092') format('truetype');
}

.iconfont {
  font-family: "iconfont" !important;
  font-size: 16px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.icon-yinpin:before {
  content: "\e61b";
}

.icon-delete:before {
  content: "\e602";
}

.icon-huishou:before {
  content: "\e628";
}

.icon-shoucang-copy:before {
  content: "\e60b";
}

.icon-liebiaoxunhuan:before {
  content: "\e623";
}

.icon-danquxunhuan:before {
  content: "\e607";
}

.icon-_mars_bfang:before {
  content: "\e62c";
}

.icon-liebiao:before {
  content: "\e610";
}

.icon-bofang2:before {
  content: "\e601";
}

.icon-bofang1:before {
  content: "\e648";
}

.icon-shipin:before {
  content: "\e62e";
}

.icon-quanxuan:before {
  content: "\e600";
}

.icon-bofang_huaban1:before {
  content: "\e65c";
}

.icon-sousuo:before {
  content: "\e62f";
}

.icon-paihangbang:before {
  content: "\e782";
}

.icon-bofang:before {
  content: "\e7be";
}

 

以上这两个代码呢,都是阿里巴巴图库自动生成的,在之后你们也可以引入你们喜欢的图标,具体步骤可以百度,如果还是不明白,欢迎来找我呀(*^▽^*)

 

B. 引入相关静态图片

在images文件夹中新建recommendSong文件夹,来存放和推荐歌曲页面相关的图片,图片如下,将其保存到recommendSong文件夹下,命名为arc(这张图片有点白,你可能看不清楚,但是它确实在!)

 

C. 最终文件结构展示

 

引入完相关样式后,我们就可以真正开始写静态页面啦

代码如下:(静态页面均不做说明,相信想研究的小伙伴完全可以靠自己研究,都是基本的样式,不会困难的)

recommendSong.wxml

<view class="recommendSongContainer">
    <!-- 头部 -->
    <view class="header">
        <image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201203%2F30%2F105749xaf898vvl39813ls.jpg&refer=http%3A%2F%2Fattach.bbs.miui.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1625999721&t=ffda5c3f0753768ac029910b6e135fa2"></image>
        <view class="date">
            <text class="day">11</text>
            <text class="divider">/</text>
            <text class="month">06</text>
        </view>
        <image class="arc" src="/static/images/recommendSong/arc.png"></image>
    </view>
    <!-- 列表区域 -->
    <view class="ListContainer">
        <view class="listHeader">
            <text class="iconfont icon-_mars_bfang bofang_all"></text>
            <text class="bofang_font">播放全部</text>
            <text class="changeMore iconfont icon-quanxuan"></text>
        </view>
        <!-- 内容区 -->
        <scroll-view scroll-y class="listScroll">
            <view class="scrollItem">
                <image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201203%2F30%2F105749xaf898vvl39813ls.jpg&refer=http%3A%2F%2Fattach.bbs.miui.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1625999721&t=ffda5c3f0753768ac029910b6e135fa2"></image>
                <view class="music">
                    <view class="musicName">
                        <text class="name">明天,你好</text>
                        <text class="alias" wx:if="{{item.alias.length!==0}}">(《明天》的主题曲)</text>
                    </view>
                    <view class="musicInfo">
<!--                        <text class="tags">独家</text>-->
                        <text class="composer">牛奶咖啡</text>
                        <text class="connect">-</text>
                        <text class="album">牛奶咖啡</text>
                    </view>
                </view>
                <view class="opration">
                    <text class="iconfont icon-shipin movie"></text>
                    <text class="iconfont icon-gengduo more"></text>
                </view>

            </view>
            <view class="scrollItem">
                <image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201203%2F30%2F105749xaf898vvl39813ls.jpg&refer=http%3A%2F%2Fattach.bbs.miui.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1625999721&t=ffda5c3f0753768ac029910b6e135fa2"></image>
                <view class="music">
                    <view class="musicName">
                        <text class="name">明天,你好</text>
                        <text class="alias" wx:if="{{item.alias.length!==0}}">(《明天》的主题曲)</text>
                    </view>
                    <view class="musicInfo">
<!--                        <text class="tags">独家</text>-->
                        <text class="composer">牛奶咖啡</text>
                        <text class="connect">-</text>
                        <text class="album">牛奶咖啡</text>
                    </view>
                </view>
                <view class="opration">
                    <text class="iconfont icon-shipin movie"></text>
                    <text class="iconfont icon-gengduo more"></text>
                </view>

            </view>
            <view class="scrollItem">
                <image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201203%2F30%2F105749xaf898vvl39813ls.jpg&refer=http%3A%2F%2Fattach.bbs.miui.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1625999721&t=ffda5c3f0753768ac029910b6e135fa2"></image>
                <view class="music">
                    <view class="musicName">
                        <text class="name">明天,你好</text>
                        <text class="alias" wx:if="{{item.alias.length!==0}}">(《明天》的主题曲)</text>
                    </view>
                    <view class="musicInfo">
<!--                        <text class="tags">独家</text>-->
                        <text class="composer">牛奶咖啡</text>
                        <text class="connect">-</text>
                        <text class="album">牛奶咖啡</text>
                    </view>
                </view>
                <view class="opration">
                    <text class="iconfont icon-shipin movie"></text>
                    <text class="iconfont icon-gengduo more"></text>
                </view>

            </view>
            <view class="scrollItem">
                <image src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fattach.bbs.miui.com%2Fforum%2F201203%2F30%2F105749xaf898vvl39813ls.jpg&refer=http%3A%2F%2Fattach.bbs.miui.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1625999721&t=ffda5c3f0753768ac029910b6e135fa2"></image>
                <view class="music">
                    <view class="musicName">
                        <text class="name">明天,你好</text>
                        <text class="alias" wx:if="{{item.alias.length!==0}}">(《明天》的主题曲)</text>
                    </view>
                    <view class="musicInfo">
<!--                        <text class="tags">独家</text>-->
                        <text class="composer">牛奶咖啡</text>
                        <text class="connect">-</text>
                        <text class="album">牛奶咖啡</text>
                    </view>
                </view>
                <view class="opration">
                    <text class="iconfont icon-shipin movie"></text>
                    <text class="iconfont icon-gengduo more"></text>
                </view>

            </view>
        </scroll-view>
    </view>

</view>

 

recommendSong.wxss

/* 头部区域 */
.recommendSongContainer .header {
  width: 100%;
  height: 400rpx;
  position: relative;
}

.recommendSongContainer .header image {
  width: 100%;
  height: 100%;
}

.recommendSongContainer .header .date{
  position: absolute;
  left: 0;
  bottom: 0;
  padding: 20rpx;
  color: white;

}

.recommendSongContainer .header .date .day{
 font-size: 30px;
  font-weight: 600;
}
.recommendSongContainer .header .date .divider{
  font-weight: lighter;
  padding: 0 4rpx;
}

.recommendSongContainer .header .date .month{
  font-size: 14px;
  /*font-weight: bolder;*/
}

.recommendSongContainer .header .arc {
  position: absolute;
  bottom: 0;
  left: 0;
  /*height: 100%;*/
  width: 100%;
  height: 20rpx;
}

/* 列表区域 */

.listHeader {
  display: flex;
  /*height: 80rpx;*/
  /*line-height: 80rpx;*/
  /*background-color: pink;*/
  margin-bottom: 10rpx;
  padding: 20rpx;
}

.listHeader .bofang_all {
  color: rgb(254,47,34);
  font-size: 44rpx;
  margin-right: 30rpx;
}

.listHeader .bofang_font {
  /*font-size: 28rpx;*/
  font-weight: 600;
}

.ListContainer .fixed {
  position: fixed;
  width: 100%;
  top: 0;
  z-index: 999;
  background-color: #fff;
}

.ListContainer .fixed .changeMore {
  padding-right: 40rpx;
}

.listHeader .changeMore {
  margin-left:auto;
  /*float: right;*/
  font-size: 44rpx;
}

/* 内容区 */
.listScroll {
  padding: 0 20rpx;
}

.scrollItem {
  position: relative;
  display: flex;
  margin-bottom: 30rpx;
}


.scrollItem image {
  width: 80rpx;
  height: 80rpx;
  border-radius: 8rpx;
  margin-right: 20rpx;
}


.music .musicName {
  font-size: 28rpx;
  max-width: 500rpx;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.music .musicName .name {
  color: black;
}

.music .musicInfo {
  font-size: 24rpx;
  color: #666;
  max-width: 500rpx;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*.music .musicInfo .tags {*/
/*    font-size: 20rpx;*/
/*    font-weight: bold;*/
/*    color: #d43c33;*/
/*    padding: 0 4rpx;*/
/*    border: 1px solid rgba(206,58,36,0.35);*/
/*    border-radius: 10rpx;*/
/*}*/

/*.music .musicInfo .composer {*/
/*    margin-left: 6rpx;*/
/*}*/

.scrollItem .opration {
  position: absolute;
  color: #888;
  right: 0;
  /*width: 80rpx;*/
  /*height: 80rpx;*/
  line-height: 80rpx;
  text-align: right;
  padding-right: 45rpx;
}

.scrollItem .opration .movie {
  /*font-size: 18rpx;*/
  float: left;
  margin-right: 20rpx;

}
/*.scrollItem .opration .more {*/
/*    !*text-align: center;*!*/
/*    width: 80rpx;*/
/*    height: 80rpx;*/
/*}*/

 

现在页面的样子变成如图所示:

看着还是挺好看是不是,嘿嘿,不过仔细一看,会发现我们的图标都没有出来,这是为什么呢?我们明明已经在static文件夹里引入了相关的图标css文件啦

这是因为我们还没有引入这些css文件呢,现在就让我们在全局引入吧

修改根目录下的app.wxss: 

@import "/static/iconfont/iconfont.wxss";
@import "/static/iconfont/myicon.wxss";
.container {
  height: 100%;
} 

 

保存一下,然后再看页面,发现图标都出现啦,我们的页面更美观了!!

 

到目前为止,我们已经完成了推荐歌曲页面的静态搭建,下一篇我们开始为它加入真实的数据吧



这篇关于微信音乐小程序实战(一):完成静态推荐歌曲页面的搭建的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程