web前端全系列 教程
1839个小节阅读:2242.9k
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
xxxxxxxxxx
<view class="container">
<view
data-id="{{ item.id }}"
data-name="{{ item.name }}"
data-poster="{{ item.artists[0].img1v1Url }}"
data-author="{{ item.artists[0].name }}"
class="item"
wx:for="{{ songs }}"
wx:key="index"
bindtap="bindgotoPlay"
>
<text class="name">{{ item.name }}</text>
<text class="author">{{ item.artists[0].name }}</text>
</view>
</view>
xxxxxxxxxx
const { request } = require("../../utils/request.js")
Page({
data: {
songs: [],
search: "",
limit: 20,
offset: 1
},
onLoad(options) {
this.setData({
search: options.search
})
this.http(options.search, this.data.limit, this.data.offset)
},
http(keywords, limit, offset) {
request("http://iwenwiki.com:3000/search", "GET", {
keywords,
limit,
offset
}).then(res => {
if (res.result.songs) {
this.setData({
songs: this.data.songs.concat(res.result.songs)
})
} else {
wx.showToast({
title: "暂无数据",
})
}
})
},
onReachBottom() {
this.setData({
offset: this.data.offset += 20
})
this.http(this.data.search, this.data.limit, this.data.offset)
},
bindgotoPlay(e){
let { id,name,author,poster } = e.currentTarget.dataset
wx.navigateTo({
url: '/pages/musicplay/musicplay?id=' + id +"&name=" + name + "&author=" + author +"&poster=" + poster
})
}
})
xxxxxxxxxx
<audio
poster="{{poster}}"
name="{{name}}"
author="{{author}}"
src="{{src}}"
id="myAudio"
controls>
</audio>
xxxxxxxxxx
Page({
data: {
src:"",
name:"",
poster:"",
author:""
},
onLoad(options) {
console.log(options);
this.setData({
src:"https://music.163.com/song/media/outer/url?id=" + options.id,
name:options.name,
poster:"https://p2.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",
author:options.author
})
}
})