master
laptoy 2 years ago
parent 9778628324
commit f70351fc73

@ -1,31 +0,0 @@
/*
* Eslint config file
* Documentation: https://eslint.org/docs/user-guide/configuring/
* Install the Eslint extension before using this feature.
*/
module.exports = {
env: {
es6: true,
browser: true,
node: true,
},
ecmaFeatures: {
modules: true,
},
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
},
globals: {
wx: true,
App: true,
Page: true,
getCurrentPages: true,
getApp: true,
Component: true,
requirePlugin: true,
requireMiniProgram: true,
},
// extends: 'eslint:recommended',
rules: {},
}

@ -1,4 +1,5 @@
# music
![](截图1.png)
![](截图2.png)
![](截图3.png)
# music1
![](1.png)
![](2.png)
![](3.png)

@ -1,19 +0,0 @@
// app.js
App({
onLaunch() {
// 展示本地存储能力
const logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
},
globalData: {
userInfo: null
}
})

@ -1,13 +1,7 @@
{
"pages":[
"pages/index/index",
"pages/logs/logs"
],
"window":{
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "音乐",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
"pages/test/test"
]
}

@ -1,10 +0,0 @@
/* *app.wxss*
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
} */

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 5.4 KiB

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Before

Width:  |  Height:  |  Size: 65 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

@ -1,11 +1,74 @@
// index.js
// 获取应用实例
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
item:0,
tab:0,
// 播放器列表数据
playlist:[{
id:1,
title:"晴天",
singer:'周杰伦',
src:'http://localhost:3000/1.mp3',
converImgUrl:'../images/yhm.png'
},{
id:2,
title:"反方向的钟",
singer:'周杰伦',
src:'http://localhost:3000/2.mp3',
converImgUrl:'../images/yhm.png'
},{
id:3,
title:"兰亭序",
singer:'周杰伦',
src:'http://localhost:3000/3.mp3',
converImgUrl:'../images/yhm.png'
},{
id:4,
title:"青花瓷",
singer:'周杰伦',
src:'http://localhost:3000/4.mp3',
converImgUrl:'../images/yhm.png'
},{
id:5,
title:"本草纲目",
singer:'周杰伦',
src:'http://localhost:3000/4.mp3',
converImgUrl:'../images/yhm.png'
},{
id:6,
title:"爱在西元前",
singer:'周杰伦',
src:'http://localhost:3000/4.mp3',
converImgUrl:'../images/yhm.png'
},{
id:7,
title:"花海",
singer:'周杰伦',
src:'http://localhost:3000/4.mp3',
converImgUrl:'../images/yhm.png'
},{
id:8,
title:"半岛铁盒",
singer:'周杰伦',
src:'http://localhost:3000/4.mp3',
converImgUrl:'../images/yhm.png'
},{
id:9,
title:"轨迹",
singer:'周杰伦',
src:'http://localhost:3000/4.mp3',
converImgUrl:'../images/yhm.png'
},{
id:10,
title:"搁浅",
singer:'周杰伦',
src:'http://localhost:3000/4.mp3',
converImgUrl:'../images/yhm.png'
}
],
state:'paused',
playIndex:0,
play:{
@ -14,85 +77,112 @@ Page({
percent:0,
title:'',
singer:'',
coverImgUrl:'./images/cover.jpg',
// converImgUrl:'../images/cover.jpg'
coverImgUrl:'../images/yhm.png'
}
},
changeItem:function(e){
audioCtx:null,
changeItem(e){
this.setData({
item : e.target.dataset.item
})
},
changeTab:function(e){
changeTab(e){
this.setData({
tab:e.detail.current
})
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
playlist:[{
id:1,title:'钢琴协奏曲',singer:'肖邦',
src:'',coverImgUrl:'./images/cover.jpg'
},{
id:2,title:'奏鸣曲',singer:'莫扎特',
src:'',coverImgUrl:'./images/cover.jpg'
},{
id:2,title:'奏鸣曲',singer:'莫扎特',
src:'',coverImgUrl:'./images/cover.jpg'
},{
id:2,title:'欢乐颂',singer:'贝多芬',
src:'',coverImgUrl:'./images/cover.jpg'
},{
id:2,title:'爱之梦',singer:'李斯特',
src:'',coverImgUrl:'./images/cover.jpg'
}],
audioCtx:null,
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
this.audioCtx=wx.cteateInnerAudioContext()
this.setMusic(0)
this.audioCtx = wx.createInnerAudioContext();
this.setMusic(0);
},
setMusic:function(index){
var music=this.data.playlist[index]
this.audioCtx.src=music.src
setMusic(index){
var music = this .data.playlist[index];
this.audioCtx.src = music.src;
this.setData({
playIndex: index,
'play.title': music.title,
'play.singer': music.singer,
'play.coverImgUrl': music.coverImgUrl,
'play.currentTime': '00:00',
'play.duration': '00:00',
'play.percent': 0
})
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
// 播放
play: function() {
this.audioCtx.play();
this.setData({state: 'running'})
},
// 暂停
pause: function () {
this.audioCtx.pause();
this.setData({state: 'paused'});
},
// 下一曲
next: function() {
var index = this.data.playIndex >= this.data.playlist.length - 1 ? 0 : this.data.playIndex + 1
this. setMusic(index)
if (this .data.state == 'running') {
this.play()
}
})
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息预计自2021年4月13日起getUserInfo将不再弹出弹窗并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

@ -1,6 +1,5 @@
{
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "音乐",
"navigationBarTextStyle": "black",
"usingComponents": {}
"navigationBarTextStyle": "black"
}

@ -1,17 +1,12 @@
<!--index.wxml-->
<!-- <swiper current-item-id="c">
<swiper item-id="a" style="background-color: #ccc">0</swiper>
<swiper item-id="b" style="background-color: #ddd">0</swiper>
<swiper item-id="c" style="background-color:#eee">0</swiper>
</swiper> -->
<!-- 顶部 -->
<view class="tab">
<view class="tab-item {{tab == 0 ? 'active' : ''}}" bindtap="changeItem" data-item="0">音乐推荐</view>
<view class="tab-item {{tab == 1 ? 'active' : ''}}" bindtap="changeItem" data-item="1">播放器</view>
<view class="tab-item {{tab == 2 ? 'active' : ''}}" bindtap="changeItem" data-item="2">播放列表</view>
</view>
<!-- 播放器 -->
<view class="content">
<swiper current="{{item}}" bindtap="changeTab">
<swiper current="{{item}}" bindchange="changeTab">
<swiper-item>
<include src="info.wxml"/>
</swiper-item>
@ -23,17 +18,20 @@
</swiper-item>
</swiper>
</view>
<!-- 底部播放器 -->
<view class="player">
<image class="player-cover" src="{{play.coverImgUrl}}" />
<view class="play-info">
<view class="play-info-title">{{play.title}}</view>
<view class="play-info-singer">{{play.singer}}</view>
<view class="player-info">
<view class="player-info-title">{{play.title}}</view>
<view class="player-info-singer">{{play.singer}}</view>
</view>
<view class="player-controls">
<image src="./images/01.png" bindtap="changePage" data-page='2'/>
<image src="./images/02.png"/>
<image src="./images/03.png"/>
<!--切换到播放列表-->
<image src="../images/01.png" bindtap="changePage" data-page="2" />
<!--播放或暂停-->
<image wx:if="{{state == 'paused'}}" src="../images/02.png" bindtap="play" />
<image wx:else src="../images/02stop.png" bindtap="pause" />
<!--下一曲-->
<image src="../images/03.png" bindtap="next" />
</view>
</view>

@ -1,4 +1,3 @@
page {
display: flex;
flex-direction: column;
@ -6,7 +5,6 @@ page{
color: #ccc;
height: 100%;
}
.tab{
display: flex;
}
@ -17,6 +15,10 @@ page{
line-height: 72rpx;
border-bottom: 6rpx solid #eee;
}
.tab-item.active{
color: #c25b5b;
border-bottom-color: #c25b5b;
}
.content {
flex: 1;
}
@ -28,10 +30,6 @@ page{
border-top:1px solid #252525;
height: 112rpx;
}
.tab-item.active{
color:#c25b5b;
border-bottom-color: #c25b5b;
}
.content-info{
height: 100%;
}
@ -42,12 +40,14 @@ page{
}
.content-info-slide{
height: 302rpx;
margin-top: 20px;
margin-bottom: 20px;
}
.content-info-slide image{
width: 100%;
height: 100%;
}
/* 功能按钮 */
.content-info-portal{
display: flex;
margin-bottom: 15px;
@ -63,11 +63,8 @@ height: 100%;
display: block;
margin: 20rpx auto;
}
::-webkit-scrollbar{
width:0;
height:0;
color:transparent;
}
/* 热门音乐 */
.content-info-list{
font-size: 11pt;
margin-bottom: 20rpx;
@ -96,6 +93,59 @@ margin:0 20rpx;
margin: 10rpx auto;
font-size: 10pt;
}
/*播放器*/
.content-play {
display: flex;
justify-content: space-around;
flex-direction: column;
height: 100%;
text-align: center ;
}
.content-play-info > view{
color: #888;
font-size: 11pt;
}
/*操放进度和时间*/
.content-play-progress{
display: flex;
align-items: center;
margin:0 35rpx;
font-size: 9pt;
text-align: center;
}
.content-play-progress > view {
flex: 1;
}
/*显示专辑页面样式*/
.content-play-cover image {
animation: rotateImage 10s linear infinite;
width: 400rpx;
height: 400rpx;
border-radius: 50%;
border: 1px solid #333 ;
}
@keyframes rotateImage {
from {
transform: rotate(0deg);
}
to{
transform: rotate(360deg);
}
}
/* 播放进度和时间 */
.content-play-progress{
display: flex;
align-items: flex;
margin: 0 35rpx;
font-size: 9pt;
text-align: center;
}
.content-play-progress > view {
flex: 1;
}
/* 底部播放器 */
.player {
display: flex;
align-items: center;
@ -110,14 +160,14 @@ margin:0 20rpx;
border-radius: 8rpx;
border: 1px solid #333 ;
}
.play-info{
.player-info {
flex: 1;
font-size: 10pt;
line-height: 38rpx;
margin-left: 20rpx;
padding-bottom: 8rpx;
}
.play-info-singer{
.player-info-singer {
color: #888;
}
.player-controls image {
@ -125,3 +175,30 @@ margin:0 20rpx;
height: 80rpx;
margin-right: 15rpx;
}
.content-playlist{
height: 100%;
}
/* 播放列表 */
.playlist-item {
display: flex;
align-items: center;
border-bottom: 1rpx solid #333 ;
height: 112rpx;
}
.playlist-cover {
width: 20rpx;
height: 80rpx;
margin-left:15rpx;
border-radius: 8rpx;
border: 1px solid#333 ;
}
.playlist-info {
flex: 1;
font-size: 10pt;
line-height: 38rpx;
margin-left: 20rpx;
padding-bottom: 8rpx;
}
.playlist-info-singer {
color:#888;
}

@ -1,55 +1,58 @@
<!-- 轮播图 -->
<scroll-view class="content-info" scroll-y>
<view style="background: rgb(17, 17, 17);height: 1000px;">
<swiper class="content-info-slide" indicator-color="rgba(255,255,255)" indicator-active-color="#fff" indicator-dots circular autoplay>
<swiper class="content-info-slide" indicator-color="rgba(255,255,255,.5)" indicator-active-color="#fff" indicator-dots circular autoplay>
<swiper-item>
<image src="./images/banner.jpg"/>
<image src="../images/banner1.jpg"/>
</swiper-item>
<swiper-item>
<image src="./images/banner.jpg"/>
<image src="../images/banner2.jpg"/>
</swiper-item>
<swiper-item>
<image src="./images/banner.jpg"/>
<image src="../images/banner3.jpg"/>
</swiper-item>
</swiper>
<!-- 功能按钮 -->
<view class="content-info-portal">
<view>
<image src="./images/04.png"/>
<image src="../images/04.png"/>
<text>私人FM</text>
</view>
<view>
<image src="./images/05.png"/>
<image src="../images/05.png"/>
<text>每日歌曲推荐</text>
</view>
<view>
<image src="./images/06.png"/>
<text>云音乐听歌榜</text>
<image src="../images/06.png"/>
<text>云音乐新歌榜</text>
</view>
</view>
<view class="content-info-list">
<view class="list-title">推荐歌曲</view>
<view class="list-inner">
<view class="list-item">
<image src="./images/cover.jpg"/><view>紫罗兰</view>
<image src="../images/mjz.png"/>
<view>稻香</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>菩提树</view>
<image src="../images/qlx.png"/>
<view>七里香</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>五月之歌</view>
<image src="../images/syydxb.png"/>
<view>夜曲</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>欢乐颂</view>
<image src="../images/mjz.png"/>
<view>花海</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>安魂曲</view>
<image src="../images/ylxb.png"/>
<view>一路向北</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>摇篮曲</view>
<image src="../images/yhm.png"/>
<view>以父之名</view>
</view>
</view>
</view>
</view>
<view>已到达底部</view>
</scroll-view>

@ -1,3 +1,20 @@
<view style="background: #ddd; color: #000;height: 100%;">
play
<!-- 播放器 -->
<view class="content-play">
<!--显示音乐信息-->
<view class="content-play-info">
<text>{{play.title}}</text>
<view>—— {{play.singer}} ——</view>
</view>
<!-- 显示专辑封面 -->
<view class="content-play-cover">
<image src="{{play.coverImgUrl}}" sty1e="animation-play-state:{{state}}" />
</view>
<!--显示播放进度和时间-->
<view class="content-play-progress">
<text>{{play.currentTime}}</text>
<view>
<slider bindchange="sliderChange" activeColor="#d33a31" block-size="12" backgroundColor="#dadada" value="{{play. percent}}" />
</view>
<text>{{play.duration}}</text>
</view>
</view>

@ -1,3 +1,12 @@
<view style="background: #eee; color: #000;height: 100%;">
playllist
<scroll-view cclass="content-playlist" scroll-y>
<view class="playlist-item" wx:for="{{playlist}}" wx:key="id" bindtap="change" data-index="{{index}}">
<image class="playlist-cover" src="{{item.converImgUrl}}" />
<view class="playlist-info">
<view class="playlist-info-title">{{item.title}}</view>
<view cclass="playlist-info-singer">{{item.singer}}</view>
</view>
<view class="playlist-controls">
<text wx:if="{{index==playIndex}}">正在播放</text>
</view>
</view>
</scroll-view>

@ -1,18 +0,0 @@
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})

@ -1,4 +0,0 @@
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}

@ -1,6 +0,0 @@
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log.date}}</text>
</block>
</view>

@ -1,8 +0,0 @@
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}

@ -1,27 +0,0 @@
// pages/swiper.js
Component({
/**
* 组件的属性列表
*/
properties: {
imgUrls:Array,
},
/**
* 组件的初始数据
*/
data: {
currentIndex:0,
},
/**
* 组件的方法列表
*/
methods: {
swiperChange(e){
this.setData({
currentIndex:e.detail.cuurrent
});
}
}
})

@ -1,2 +0,0 @@
<!--pages/swiper.wxml-->
<text>pages/swiper.wxml</text>

@ -1 +0,0 @@
/* pages/swiper.wxss */

@ -0,0 +1,68 @@
// pages/test/test.js
Page({
/**
* 页面的初始数据
*/
data: {
},
scroll:function(e){
console.log(e.detail)
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -1,4 +1,3 @@
{
"component": true,
"usingComponents": {}
}

@ -0,0 +1,11 @@
<scroll-view scroll-x scroll-y style="height:200px" bindscroll="srcll">
<view style="width:200%;height:400px;background: #ccc"></view>
</scroll-view>
<view>缩放模式测试</view>
<image style="width:200px;height:200px;background-color:#eee;"
mode="scaleToFill" src="/image/test.jpj">
</image>
<view>裁剪模式测试</view>
<image style="width:200px;height:200px;background-color:#eee;"
mode="scaleToFill" src="/image/test.jpg">
</image>

@ -0,0 +1 @@
/* pages/test/test.wxss */

@ -42,7 +42,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
"appid": "wx1f22c2b8f0b59fc1",
"appid": "wx43b4be9b6b720b57",
"projectname": "miniprogram-92",
"condition": {},
"editorSetting": {

@ -1,6 +1,6 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "miniprogram-5",
"projectname": "miniprogram-6",
"setting": {
"compileHotReLoad": true
}

@ -1,7 +0,0 @@
{
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
"rules": [{
"action": "allow",
"page": "*"
}]
}

@ -1,19 +0,0 @@
const formatTime = date => {
const year = date.getFullYear()
const month = date.getMonth() + 1
const day = date.getDate()
const hour = date.getHours()
const minute = date.getMinutes()
const second = date.getSeconds()
return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}`
}
const formatNumber = n => {
n = n.toString()
return n[1] ? n : `0${n}`
}
module.exports = {
formatTime
}
Loading…
Cancel
Save