master
qingxiangting 1 year ago
parent 3231462c67
commit 23d2892202

@ -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: {},
}

BIN
1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

@ -1,2 +1,2 @@
# medicine
# music

@ -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,14 @@
{
"pages": [
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "Weixin",
"navigationBarTextStyle": "black"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}

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

@ -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: 340 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 272 KiB

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: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 364 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

@ -0,0 +1,140 @@
// index.js
// 获取应用实例
const app = getApp()
Page({
data: {
item:0,
tab:0,
state:'paused',
playIndex:0,
play:{
currenTime:'00:00',
duration:'00:00',
percent:0,
title:'',
singer:'',
coverImgUrl:'/images/cover.jpg',
},
playlist:[{
id:1,title:'钢琴协奏曲',singer:'肖邦',
src:'http://localhost:3000/1.mp3',coverImgUrl:'/images/cover.jpg'
},{
id:2,title:'奏鸣曲',singer:'莫扎特',
src:'http://localhost:3000/1.mp3',coverImgUrl:'/images/cover.jpg'
},{
id:3,title:'欢乐颂',singer:'贝多芬',
src:'http://localhost:3000/2.mp3',coverImgUrl:'/images/cover.jpg'
},{
id:4,title:'爱之梦',singer:'李斯特',
src:'h',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'
})
},
audioCtx:null,
onReady:function() {
  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':formatTime(that.audioCtx.duration),
      'play.currentTime':formatTime(that.audioCtx.currentTime),
      'play.percent':that.audioCtx.currentTime /
      that.audioCtx.duration*100
    })
  })
  this.setMusic(0)
  function formatTime(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)
  }
},
sliderChange:function(e){
var second=e.detail.value*this.audioCtx.duration/100
this.audioCtx.seek(second)
},
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.duration':0
})
},
onLoad() {
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
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()
}
},
change:function(e){
this.setMusic(e.currentTarget.dataset.index)
this.play()
},
getUserInfo(e) {
// 不推荐使用getUserInfo获取用户信息预计自2021年4月13日起getUserInfo将不再弹出弹窗并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

@ -0,0 +1,5 @@
{
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "中医药目录",
"navigationBarTextStyle": "black"
}

@ -0,0 +1,49 @@
// index.ts
// 获取应用实例
const app = getApp<IAppOption>()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo'),
canIUseGetUserProfile: false,
canIUseOpenData: wx.canIUse('open-data.type.userAvatarUrl') && wx.canIUse('open-data.type.userNickName') // 如需尝试获取用户信息可改为false
},
// 事件处理函数
bindViewTap() {
wx.navigateTo({
url: '../logs/logs',
})
},
onLoad() {
// @ts-ignore
if (wx.getUserProfile) {
this.setData({
canIUseGetUserProfile: true
})
}
},
getUserProfile() {
// 推荐使用wx.getUserProfile获取用户信息开发者每次通过该接口获取用户个人信息均需用户确认开发者妥善保管用户快速填写的头像昵称避免重复弹窗
wx.getUserProfile({
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
success: (res) => {
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
},
getUserInfo(e: any) {
// 不推荐使用getUserInfo获取用户信息预计自2021年4月13日起getUserInfo将不再弹出弹窗并直接返回匿名的用户个人信息
console.log(e)
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})

@ -0,0 +1,19 @@
<view class="tab">
<view class="tab-item {{tab==0?'active':''}}" bindtap="changeItem" data-item="0">中医药推荐</view>
<view class="tab-item {{tab==0?'active':''}}" bindtap="changeItem" data-item="1">中药材大全</view>
<view class="tab-item {{tab==0?'active':''}}" bindtap="changeItem" data-item="2">药材集</view>
</view>
<!-- 内容 -->
<view class="content">
<swiper current="{{item}}" bindchange="changeTab">
<swiper-item>
<include src="info.wxml"></include>
</swiper-item>
<swiper-item>
<include src="play.wxml"></include>
</swiper-item>
<swiper-item>
<include src="playlist.wxml"></include>
</swiper-item>
</swiper>
</view>

@ -0,0 +1,177 @@
page{
display: flex;
flex-direction: column;
background: #17181a;
color: #ccc;
height: 100%;
}
.tab{
display: flex;
}
.tab-item.active{
color: #c25b5b;
border-bottom-color:#c25b5b;
}
.tab-item{
flex: 1;
font-size: 10pt;
text-align: center;
line-height: 72px;
border-bottom:6rpx solid #eee;
}
.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{
flex: 1;
}
.content >swiper{
height: 100%;
}
.content-info{
height: 100%;
}
.content-info-slide{
height: 302rpx;
margin-bottom:20px ;
}
.content-info-slide image{
width: 100%;
height: 100%;
}
.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{
background: #222;
border-top: 1px solid #252525;
height: 112rpx;
display: flex;
align-items: center;
background: #222;
border-top:1px solid #252525;
}
.player-cover{
width: 80rpx;
height: 80rpx;
margin-left: 15rpx;
border-radius: 8rpx;
border:1px solid #333;
}
.player-info{
flex: 1;
font-size: 10pt;
line-height: 38rpx;
margin-left:20rpx;
padding-bottom:8rpx;
}
.player-info-singer{
color: #888;
}
.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;
}
.playlist-cover{
width: 80rpx;
height: 80rpx;
margin-left: 15rpx;
border-radius: 8rpx;
border: 1rpx 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;
}

@ -0,0 +1,56 @@
<scroll-view class="content-info" scroll-y>
<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/banner1.jpeg" mode=""/>
</swiper-item>
<swiper-item>
<image src="/images/banner2.jpg" mode=""/>
</swiper-item>
<swiper-item>
<image src="/images/banner3.jpg" mode=""/>
</swiper-item>
</swiper>
<view class="content-info-portal">
<view>
<image src="/images/04.jpg" />
<text>解表药</text>
</view>
<view>
<image src="/images/05.jpg"/>
<text>清热药</text>
</view>
<view>
<image src="/images/06.jpg"/>
<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/cover1.jpg" /> <view>麻黄
</view>
</view>
<view class="list-item">
<image src="/images/cover2.jpg" /> <view>生地</view>
</view>
<view class="list-item">
<image src="/images/cover3.jpeg" /> <view>丹皮
</view>
</view>
<view class="list-item">
<image src="/images/cover4.jpeg" /> <view>半夏
</view>
</view>
<view class="list-item">
<image src="/images/cover5.jpeg" /> <view>昆布
</view>
</view>
<view class="list-item">
<image src="/images/cover6.jpg" /> <view>胖大海
</view>
</view>
</view>
</view>
</scroll-view>

@ -0,0 +1,28 @@
<view class="content-play-list">
<view class="list-inner">
<view class="list-item">
<image src="/images/cover1.jpg" /> <view>薄荷
</view>
</view>
<view class="list-item">
<image src="/images/cover2.jpg" /> <view>菊花</view>
</view>
<view class="list-item">
<image src="/images/cover3.jpeg" /> <view>决明子
</view>
</view>
<view class="list-item">
<image src="/images/cover4.jpeg" /> <view>半夏
</view>
</view>
<view class="list-item">
<image src="/images/cover5.jpeg" /> <view>昆布
</view>
</view>
<view class="list-item">
<image src="/images/cover6.jpg" /> <view>胖大海
</view>
</view>
</view>
</view>

@ -0,0 +1,27 @@
<view class="content-playlist-list">
<view class="list-inner">
<view class="list-item">
<image src="/images/cover3.jpeg" /> <view>决明子
</view>
</view>
<view class="list-item">
<image src="/images/cover4.jpeg" /> <view>半夏</view>
</view>
<view class="list-item">
<image src="/images/cover3.jpeg" /> <view>决明子
</view>
</view>
<view class="list-item">
<image src="/images/cover4.jpeg" /> <view>半夏
</view>
</view>
<view class="list-item">
<image src="/images/cover5.jpeg" /> <view>昆布
</view>
</view>
<view class="list-item">
<image src="/images/cover6.jpg" /> <view>胖大海
</view>
</view>
</view>
</view>

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

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

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

@ -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,66 @@
// pages/test/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

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

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

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

@ -0,0 +1,77 @@
// pages/test.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady:function() {
var audioCtx=wx.createInnerAudioContext()
audioCtx.src='http://localhoost:3000/1.mp3'
audioCtx.onPlay(function(){
console.log('开始播放')
})
audioCtx.onError(function(res){
console.log(res.errMsg)
console.log(res.errCode)
})
audioCtx.play()
},
sliderChanging:function(e){
console.log(e.detail.value)
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})

@ -0,0 +1,3 @@
{
"usingComponents": {}
}

@ -0,0 +1,3 @@
<!--pages/test.wxml-->
<text>pages/test.wxml</text>
<slider bindchanging="sliderChanging" show-value />

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

@ -0,0 +1,29 @@
{
"appid": "wx7912c734562a817d",
"compileType": "miniprogram",
"libVersion": "2.32.3",
"packOptions": {
"ignore": [],
"include": []
},
"setting": {
"coverView": true,
"es6": true,
"postcss": true,
"minified": true,
"enhance": true,
"showShadowRootInWxmlPanel": true,
"packNpmRelationList": [],
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"condition": false
},
"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": "music",
"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
}

@ -0,0 +1,19 @@
export const formatTime = (date: 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: number) => {
const s = n.toString()
return s[1] ? s : '0' + s
}
Loading…
Cancel
Save