diff --git a/mus/app.js b/mus/app.js new file mode 100644 index 0000000..1ed57c4 --- /dev/null +++ b/mus/app.js @@ -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 + } +}) diff --git a/mus/app.json b/mus/app.json new file mode 100644 index 0000000..9c5d2cc --- /dev/null +++ b/mus/app.json @@ -0,0 +1,12 @@ +{ + "pages":[ + "pages/index/index", + "pages/test/test" + ], + "window":{ + "backgroundTextStyle":"light", + "navigationBarBackgroundColor": "#fff", + "navigationBarTitleText": "音乐", + "navigationBarTextStyle":"black" + } +} diff --git a/mus/app.wxss b/mus/app.wxss new file mode 100644 index 0000000..e69de29 diff --git a/mus/image/01.png b/mus/image/01.png new file mode 100644 index 0000000..0939fe6 Binary files /dev/null and b/mus/image/01.png differ diff --git a/mus/image/02.png b/mus/image/02.png new file mode 100644 index 0000000..ab554db Binary files /dev/null and b/mus/image/02.png differ diff --git a/mus/image/02stop.png b/mus/image/02stop.png new file mode 100644 index 0000000..be984cd Binary files /dev/null and b/mus/image/02stop.png differ diff --git a/mus/image/03.png b/mus/image/03.png new file mode 100644 index 0000000..9402bfa Binary files /dev/null and b/mus/image/03.png differ diff --git a/mus/image/04.png b/mus/image/04.png new file mode 100644 index 0000000..c446705 Binary files /dev/null and b/mus/image/04.png differ diff --git a/mus/image/05.png b/mus/image/05.png new file mode 100644 index 0000000..6dfd030 Binary files /dev/null and b/mus/image/05.png differ diff --git a/mus/image/06.png b/mus/image/06.png new file mode 100644 index 0000000..51340c3 Binary files /dev/null and b/mus/image/06.png differ diff --git a/mus/image/banner.jpg b/mus/image/banner.jpg new file mode 100644 index 0000000..51b93a3 Binary files /dev/null and b/mus/image/banner.jpg differ diff --git a/mus/image/cover.jpg b/mus/image/cover.jpg new file mode 100644 index 0000000..ceaac4a Binary files /dev/null and b/mus/image/cover.jpg differ diff --git a/mus/image/test.jpg b/mus/image/test.jpg new file mode 100644 index 0000000..ceaac4a Binary files /dev/null and b/mus/image/test.jpg differ diff --git a/mus/image/鸡你太美.mp3 b/mus/image/鸡你太美.mp3 new file mode 100644 index 0000000..574c177 Binary files /dev/null and b/mus/image/鸡你太美.mp3 differ diff --git a/mus/pages/index/index.js b/mus/pages/index/index.js new file mode 100644 index 0000000..f1fe16b --- /dev/null +++ b/mus/pages/index/index.js @@ -0,0 +1,118 @@ +// pages/index/index.js +Page({ + data: { + item: 0, + tab: 0, + playlist: [{ + id: 1, + title: '钢琴演奏曲', + singer: '肖邦', + src: 'http://localhost:3000/1.mp3', + coverImgUrl: '/image/cover.jpg' + }, { + id: 2, + title: '奏鸣曲', + singer: '莫扎特', + src: 'http://localhost:3000/2.mp3', + coverImgUrl: '/image/cover.jpg' + }, { + id: 3, + title: '欢乐颂', + singer: '贝多芬', + src: 'http://localhost:3000/1.mp3', + coverImgUrl: '/image/cover.jpg' + }, { + id: 4, + title: '爱之梦', + singer: '李斯特', + src: 'http://localhost:3000/1.mp3', + coverImgUrl: '/image/cover.jpg' + }], + state: 'paused', + playIndex: 0, + play: { + currentTime: '00:00', + duration: '00:00', + percent: 0, + title: '', + singer: '', + coverImgUrl: '/image/cover.jpg' + }, + }, + changeItem(e) { + this.setData({ + item: e.target.dataset.item + }) + }, + changeTab(e) { + this.setData({ + tab: e.detail.current + }) + }, + audioCtx: null, + onReady() { + this.audioCtx = wx.createInnerAudioContext() + var that = this + this.audioCtx.onError(function () { + console.log('播放失败' + that.audioCtx.src) + }) + this.audioCtx.onEnded(function () { + that.next() + }) + this.audioCtx.onPlay(function () {}) + this.audioCtx.onTimeUpdate(function () { + that.setData({ + 'play.duration': fromatTime(that.audioCtx.duration), + 'play.currentTime': fromatTime(that.audioCtx.currentTime), + 'play.percent': that.audioCtx.currentTime / that.audioCtx.duration * 100 + }) + }) + this.setMusic(0) + + function fromatTime(time) { + var minute = Math.floor(time / 60) % 60; + var second = Math.floor(time) % 60; + return (minute < 10 ? '0' + minute : minute) + ':' + (second < 10 ? '0' + second : second) + } + }, + 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 + }) + }, + play() { + this.audioCtx.play() + this.setData({ + state: 'running' + }) + }, + pause() { + this.audioCtx.pause() + this.setData({ + state: 'paused' + }) + }, + next() { + 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() + } + }, + sliderChange(e) { + var second = e.detail.value * this.audioCtx.duration / 100 + this.audioCtx.seek(second) + }, + change(e) { + this.setMusic(e.currentTarget.dataset.index) + this.play() + } +}) \ No newline at end of file diff --git a/mus/pages/index/index.wxml b/mus/pages/index/index.wxml new file mode 100644 index 0000000..8d05ad3 --- /dev/null +++ b/mus/pages/index/index.wxml @@ -0,0 +1,33 @@ + + 音乐推荐 + 播放器 + 播放列表 + + + + + + + + + + + + + + + + + + + {{play.title}} + {{play.singer}} + + + + + + + + + \ No newline at end of file diff --git a/mus/pages/index/index.wxss b/mus/pages/index/index.wxss new file mode 100644 index 0000000..6da07d3 --- /dev/null +++ b/mus/pages/index/index.wxss @@ -0,0 +1,217 @@ +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; +} + +.tab-item.active { + color: #c25b5b; + border-bottom: #c25b5b; +} + +.content { + flex: 1; +} + +.content>swiper { + height: 100%; +} + +.player { + background: #222; + border-top: 1px solid #252525; + height: 112rpx; +} + +.content-info { + height: 100%; +} + +::-webkit-scrollbar { + width: 0; + height: 0; + color: transparent; +} + +.content-info-slide { + height: 302rpx; + margin-bottom: 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; +} + +.content-info-list { + font-size: 11pt; + margin-bottom: 20rpx; + +} + +.content-info-list>.list-title { + margin: 20px 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: 1px 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-color: #222; + border-top: 1px solid #252525; + height: 112rpx; +} + +.player-cover { + width: 80rpx; + height: 80rpx; + margin-left: 20rpx; + border-radius: 8rpx; + border: 1px solid #333; +} + +.player-info { + flex: 1; + font-size: 10pt; + line-height: 38rpx; + margin-left: 20rpx; + padding-bottom: 8rpx; +} + +.player-controls image { + width: 80rpx; + height: 80rpx; + margin-right: 15rpx; +} + +.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-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: center; + margin: 0 35rpx; + font-size: 9pt; + text-align: center; +} + +.content-play-progress>view { + flex: 1; +} + +.playlist-item { + display: flex; + align-items: center; + border-bottom: 1rpx solid #333; + height: 122rpx; +} + +.playlist-cover { + width: 80rpx; + 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; +} + +.playlist-controls { + font-size: 10pt; + margin-right: 20rpx; + color: #c25b5b; +} \ No newline at end of file diff --git a/mus/pages/index/info.wxml b/mus/pages/index/info.wxml new file mode 100644 index 0000000..65be672 --- /dev/null +++ b/mus/pages/index/info.wxml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + 私人FM + + + + 每日歌曲推荐 + + + + 云音乐新歌榜 + + + + 推荐歌曲 + + + + 紫罗兰 + + + + 五月之歌 + + + + 菩提树 + + + + 欢乐颂 + + + + 安魂曲 + + + + 摇篮曲 + + + + \ No newline at end of file diff --git a/mus/pages/index/play.wxml b/mus/pages/index/play.wxml new file mode 100644 index 0000000..731e878 --- /dev/null +++ b/mus/pages/index/play.wxml @@ -0,0 +1,16 @@ + + + {{play.title}} + -{{play.singer}}- + + + + + + {{play.currentTime}} + + + + {{play.duration}} + + \ No newline at end of file diff --git a/mus/pages/index/playlist.wxml b/mus/pages/index/playlist.wxml new file mode 100644 index 0000000..36a2ee2 --- /dev/null +++ b/mus/pages/index/playlist.wxml @@ -0,0 +1,14 @@ + + + + + + {{item.title}} + {{item.singer}} + + + + 正在播放 + + + \ No newline at end of file diff --git a/mus/pages/test/test.js b/mus/pages/test/test.js new file mode 100644 index 0000000..86dacc3 --- /dev/null +++ b/mus/pages/test/test.js @@ -0,0 +1,7 @@ +// pages/test/test.js +Page({ + scroll(e) + { + console.log(e.detail) + }, +}) \ No newline at end of file diff --git a/mus/pages/test/test.json b/mus/pages/test/test.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/mus/pages/test/test.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/mus/pages/test/test.wxml b/mus/pages/test/test.wxml new file mode 100644 index 0000000..7a1546d --- /dev/null +++ b/mus/pages/test/test.wxml @@ -0,0 +1,7 @@ + + + +缩放模式测试 + +裁剪模式测试 + \ No newline at end of file diff --git a/mus/pages/test/test.wxss b/mus/pages/test/test.wxss new file mode 100644 index 0000000..3ee2480 --- /dev/null +++ b/mus/pages/test/test.wxss @@ -0,0 +1 @@ +/* pages/test/test.wxss */ \ No newline at end of file diff --git a/mus/project.config.json b/mus/project.config.json new file mode 100644 index 0000000..c256fd6 --- /dev/null +++ b/mus/project.config.json @@ -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": "wx5815e4d0b33a2993", + "projectname": "miniprogram-92", + "condition": {}, + "editorSetting": { + "tabIndent": "insertSpaces", + "tabSize": 2 + } +} \ No newline at end of file diff --git a/mus/project.private.config.json b/mus/project.private.config.json new file mode 100644 index 0000000..dd50eb3 --- /dev/null +++ b/mus/project.private.config.json @@ -0,0 +1,7 @@ +{ + "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html", + "projectname": "music", + "setting": { + "compileHotReLoad": true + } +} \ No newline at end of file diff --git a/mus/sitemap.json b/mus/sitemap.json new file mode 100644 index 0000000..ca02add --- /dev/null +++ b/mus/sitemap.json @@ -0,0 +1,7 @@ +{ + "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html", + "rules": [{ + "action": "allow", + "page": "*" + }] +} \ No newline at end of file