master
laptoy 2 years ago
parent 05100b986d
commit 7d303ed676

@ -0,0 +1,31 @@
/*
* 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: {},
}

@ -0,0 +1,19 @@
// 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
}
})

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

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

@ -0,0 +1,98 @@
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
item:0,
tab:0,
state:'paused',
playIndex:0,
play:{
currentTime:'00:00',
duration:'00:00',
percent:0,
title:'',
singer:'',
coverImgUrl:'./images/cover.jpg',
}
},
changeItem:function(e){
this.setData({
item:e.target.dataset.item
})
},
changeTab:function(e){
this.setData({
tab:e.detail.current
})
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs'
})
},
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
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)
} ,
setMusic:function(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.percent':0
})
},
getUserProfile(e) {
// 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息预计自2021年4月13日起getUserInfo将不再弹出弹窗并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

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

@ -0,0 +1,39 @@
<!--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-item>
<include src="info.wxml"/>
</swiper-item>
<swiper-item>
<include src="play.wxml"/>
</swiper-item>
<swiper-item>
<include src="playlist.wxml"/>
</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>
<view class="player-controls">
<image src="./images/01.png" bindtap="changePage" data-page='2'/>
<image src="./images/02.png"/>
<image src="./images/03.png"/>
</view>
</view>

@ -0,0 +1,127 @@
page{
display: flex;
flex-direction: column;
background: #17181a;
color: #ccc;
height: 100%;
}
.tab{
display: flex;
}
.tab-item{
flex: 1;
font-size: 10pt;
text-align: center;
line-height: 72rpx;
border-bottom: 6rpx solid #eee;
}
.content{
flex: 1;
}
.content>swiper{
height: 100%;
}
.player{
background: #222;
border-top: 1px solid #252525;
height: 112rpx;
}
.tab-item.active{
color:#c25b5b;
border-bottom-color: #c25b5b;
}
.content-info{
height: 100%;
}
::-webkit-scrollbar{
width: 0;
height: 0;
color: transparent;
}
.content-info-slide {
height: 302rpx;
margin-top: 20px;
}
.content-info-slide image{
width: 100%;
height: 100%;
}
.content-info-portal{
display: flex;
margin-bottom: 15px;
}
.content-info-portal>view{
flex: 1;
font-size: 11pt;
text-align: center;
}
.content-info-portal image{
width: 120rpx;
height: 120rpx;
display: block;
margin: 20rpx auto;
}
::-webkit-scrollbar{
width:0;
height:0;
color:transparent;
}
.content-info-list{
font-size: 11pt;
margin-bottom:20rpx;
}
.content-info-list>.list-title{
margin: 20rpx 35rpx;
}
.content-info-list>.list-inner{
display:flex;
flex-wrap: wrap;
margin:0 20rpx;
}
.content-info-list>.list-inner>.list-item{
flex: 1;
}
.content-info-list>.list-inner>.list-item>image{
display: block;
width:200rpx;
height:200rpx;
margin:0 auto;
border-radius: 10rpx;
border:1rpx solid #555;
}
.content-info-list>.list-inner>.list-item>view{
width:200rpx;
margin:10rpx auto;
font-size: 10pt;
}
.player{
display:flex;
align-items: center;
background: #222;
border-top: 1px solid #252525;
height: 112rpx;
}
.player-cover{
width:80rpx;
height:80rpx;
margin-left: 15rpx;
border-radius: 8rpx;
border: 1px solid #333;
}
.play-info{
flex:1;
font-size: 10pt;
line-height: 38rpx;
margin-left: 20rpx;
padding-bottom: 8rpx;
}
.play-info-singer{
color:#888;
}
.player-controls image{
width:80rpx;
height: 80rpx;
margin-right:15rpx ;
}

@ -0,0 +1,55 @@
<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-item>
<image src="./images/banner.jpg"/>
</swiper-item>
<swiper-item>
<image src="./images/banner.jpg"/>
</swiper-item>
<swiper-item>
<image src="./images/banner.jpg"/>
</swiper-item>
</swiper>
<view class="content-info-portal">
<view>
<image src="./images/04.png"/>
<text>私人FM</text>
</view>
<view>
<image src="./images/05.png"/>
<text>每日歌曲推荐</text>
</view>
<view>
<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>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>菩提树</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>五月之歌</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>欢乐颂</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>安魂曲</view>
</view>
<view class="list-item">
<image src="./images/cover.jpg"/><view>摇篮曲</view>
</view>
</view>
</view>
</view>
<view>已到达底部</view>
</scroll-view>

@ -0,0 +1,3 @@
<view style="background: #ddd; color: #000;height: 100%;">
play
</view>

@ -0,0 +1,3 @@
<view style="background: #eee; color: #000;height: 100%;">
playllist
</view>

@ -0,0 +1,18 @@
// 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
}
})
})
}
})

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

@ -0,0 +1,6 @@
<!--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>

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

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

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

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

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

@ -0,0 +1,52 @@
{
"description": "项目配置文件",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"bundle": false,
"userConfirmedBundleSwitch": false,
"urlCheck": true,
"scopeDataCheck": false,
"coverView": true,
"es6": true,
"postcss": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"preloadBackgroundData": false,
"minified": true,
"autoAudits": false,
"newFeature": false,
"uglifyFileName": false,
"uploadWithSourceMap": true,
"useIsolateContext": true,
"nodeModules": false,
"enhance": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"showShadowRootInWxmlPanel": true,
"packNpmManually": false,
"enableEngineNative": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"showES6CompileOption": false,
"minifyWXML": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false
},
"compileType": "miniprogram",
"libVersion": "2.19.4",
"appid": "wx1f22c2b8f0b59fc1",
"projectname": "miniprogram-92",
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}

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

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

@ -0,0 +1,19 @@
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