<scroll-view
scroll-y // 纵向滚动
style="height:" //高度
refresher-enabled // 开启自定义下拉刷新
refresher-background="" // 自定义下拉刷新背景颜色
refresher-triggered="{{}}" // 下拉刷新触发状态 true为 触发 false为 没触发
bindrefresherrefresh="" // 下拉触发事件
bindscrolltolower=""> // 上拉触底引发事件
</scroll-view>
2.音频对象
// sub_Customer/pages/down_project/down_project.js
const innerAudioContext = wx.createInnerAudioContext()
Page({
/**
* 页面的初始数据
*/
data: {
srsss: '',
names: '',
showTime1: '00:00',
showTime2: '00:00',
audioDuration: 0, //音频的总时间
playSrc: '../../images/bo.png', //播放,暂停图标路径
isPlayAudio: false, //播放状态
audioSeek: 0, //此刻所在的时间
audioTime: 0, //进度条百分比
durationIntval: 0
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {},
bindFileDown(e) {
that.setData({
srsss: item.AttachmentURL,
names: item.AttachmentName
})
innerAudioContext.src = item.AttachmentURL;
//innerAudioContext.onEnded(() => {
//console.log("播放结束");
//that.setData({
//isPlayAudio: false
//})
//})
//innerAudioContext.onCanplay(() => {
//console.log(innerAudioContext.paused);
//})
innerAudioContext.onTimeUpdate(() => {
console.log("volumn:", innerAudioContext.volume);
that.setData({
showTime1: that.formatTime(innerAudioContext.currentTime),
showTime2: that.formatTime(innerAudioContext.duration),
audioTime: Math.floor(100 * innerAudioContext.currentTime /
innerAudioContext.duration)
})
})
},
bindProjectClose() { //关闭
innerAudioContext.stop();
this.setData({
playSrc: '../../images/bo.png',
audioTime: 0,
showTime1: '00:00',
showProjectPop: false,
})
},
sliderChange(e) {
let position = Math.floor(innerAudioContext.duration * e.detail.value / 100);
innerAudioContext.seek(position);
},
click() {
this.setData({
isPlayAudio: !this.data.isPlayAudio,
})
if (this.data.isPlayAudio) {
innerAudioContext.play();
this.setData({
playSrc: '../../images/zan.png',
})
} else {
innerAudioContext.pause();
this.setData({
playSrc: '../../images/bo.png',
})
}
},
formatTime(time) {
let minute = Math.floor(time / 60);
let second = Math.floor(time % 60);
minute = minute < 10 ? ("0" + minute) : minute;
second = second < 10 ? ("0" + second) : second;
let res = minute + ":" + second;
return res;
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
innerAudioContext.stop();
},
})
4.获取组件属性(高度,宽度)
let query = wx.createSelectorQuery()
let clas = "#" + 'mines';
query.select(clas).boundingClientRect()
query.exec(res => {
console.log(res);
})