- wx.getLocation接口获取不同位置的坐标数居都是相同的?
我们的项目需要实时获取用的位置提交给后台,wx.getLocation我代码设置的是每30秒获取一次,每隔2分钟提交给后台,经线上版本测试得到的位置信息都是一样的,是什么原因。 这是后台返回的位置数居, [图片]
2022-09-14 - 流量主结算每月结算两次,邮箱每月会收到两次结算单,实际付款为啥每月只付半个月的结算?
[图片][图片][图片]
2022-04-01 - 调用wx.checkIsSoterEnrolledInDevice如果手机中没有指纹,怎么录入指纹?
如题目,如何手机中没有指纹,通过小程序能实现录入指纹吗?如果有指纹,忘记了想更改指纹,怎么更改?
2021-01-05 - 求兼容型较好的音乐播放器代码
最近在做一个音乐播放的小程序,用wx.createInnerAudioContext()接口。 目前安卓6.0及以下版本不能播放,网上找了很多例子的代码,都不尽人意,不是这问题都是那问题,基本都是兼容型不好。有做的音乐播放的朋友,并且已经兼容大多手机的代码。能共享出来供参考,让我们这种新手少走弯路。也可有偿共享。
2019-07-24 - 播放音乐onTimeUpdate不会自动执行,必须点击后才执行
需要实现一个播放器加载后自动播放音乐。开发工具模拟器上,可以自动播放出声音,时间和进度条不会变化。但是点击播放按钮后可以。真机测试,安卓有些手机可以,有些不行。苹果手机都不可以。 [图片] [图片] [图片] bgMusic.onTimeUpdate()方法为什点击事件会执行,onload事件不能自动执行,开发工具模拟器的效果是这样的。 [代码]var[代码] [代码]config = require([代码][代码]'../../config.js'[代码][代码]);[代码][代码]const bgMusic = wx.createInnerAudioContext()[代码][代码]const app = getApp()[代码][代码]//动画[代码][代码]var[代码] [代码]audioAnimation;[代码][代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]index: [代码][代码]'2'[代码][代码],[代码][代码] [代码][代码]title_list: [{[代码][代码] [代码][代码]src: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]title: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]id: 0,[代码][代码] [代码][代码]img: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]}],[代码][代码] [代码][代码]show: [代码][代码]'none'[代码][代码], [代码][代码]//列表弹窗显隐[代码][代码] [代码][代码]isOpen: [代码][代码]true[代码][代码], [代码][代码]//播放开关[代码][代码] [代码][代码]starttime: [代码][代码]'00:00'[代码][代码], [代码][代码]//正在播放时长[代码][代码] [代码][代码]duration: [代码][代码]'00:00'[代码][代码], [代码][代码]//总时长[代码][代码] [代码][代码]music_on: [代码][代码]true[代码][代码],[代码][代码]//音乐是不是在播放 [代码][代码] [代码][代码]music_playing: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码](options) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]var[代码] [代码]classid = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]id = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]id: options.id,[代码][代码] [代码][代码]classid: options.classid,[代码][代码] [代码][代码]})[代码][代码] [代码][代码]// 获取应的音频[代码][代码] [代码][代码]that.s_p();[代码][代码] [代码] [代码] [代码][代码]},[代码][代码] [代码][代码]//获取数据[代码][代码] [代码][代码]s_p: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]classid = that.data.classid;[代码][代码] [代码][代码]var[代码] [代码]id = that.data.id;[代码][代码] [代码][代码]var[代码] [代码]network = require([代码][代码]'../../utils/network.js'[代码][代码]); [代码][代码]//引用加载提示效果[代码][代码] [代码][代码]network.request({[代码][代码] [代码][代码]url: config.apiurl + [代码][代码]'/?api=listenStory/detail&id='[代码] [代码]+ id + [代码][代码]'&classid='[代码] [代码]+ classid, [代码][代码]//调用接口[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]'appid'[代码][代码]: config.appid, [代码][代码]// 传递appid[代码][代码] [代码][代码]'timestamp'[代码][代码]: config.timestamp, [代码][代码]// timestamp[代码][代码] [代码][代码]'signature'[代码][代码]: config.signature, [代码][代码]// signature[代码][代码] [代码][代码]},[代码][代码] [代码][代码]method: [代码][代码]'POST'[代码][代码],[代码][代码] [代码][代码]header: {[代码][代码] [代码][代码]'content-type'[代码][代码]: [代码][代码]'application/json'[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res.data);[代码][代码] [代码][代码]var[代码] [代码]audiolist = that.data.audiolist;[代码][代码] [代码][代码]that.data.title_list[0].src = res.data.data.content.mp3link;[代码][代码] [代码][代码]//that.data.title_list[2].img = res.data.data.content.titlepic;[代码][代码] [代码][代码]var[代码] [代码]src = res.data.data.content.mp3link;[代码][代码] [代码][代码]var[代码] [代码]img = res.data.data.content.titlepic;[代码][代码] [代码][代码]var[代码] [代码]title = res.data.data.content.title;[代码][代码] [代码][代码]var[代码] [代码]clickId = res.data.data.content.id;[代码][代码] [代码][代码]var[代码] [代码]classname=res.data.data.content.classname;[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]newsdata: res.data.data.content,[代码][代码] [代码][代码]'color'[代码][代码]: [代码][代码]'#0b68f3'[代码][代码],[代码][代码] [代码][代码]'clickId'[代码][代码]: clickId,[代码][代码] [代码][代码]'src'[代码][代码]:src,[代码][代码] [代码][代码]'img'[代码][代码]:img,[代码][代码] [代码][代码]'title'[代码][代码]:title,[代码][代码] [代码][代码]'classname'[代码][代码]:classname,[代码][代码] [代码][代码]});[代码][代码] [代码][代码]//播放音频[代码][代码] [代码][代码]that.listenerButtonPlay();[代码][代码] [代码][代码]//设置页面标题//[代码][代码] [代码][代码]wx.setNavigationBarTitle({[代码][代码] [代码][代码]title:classname,[代码][代码] [代码][代码]})[代码] [代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]// 播放[代码][代码] [代码][代码]listenerButtonPlay: [代码][代码]function[代码] [代码](e) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]//bug ios 播放时必须加title 不然会报错导致音乐不播放 [代码][代码] [代码][代码]var[代码] [代码]sec = [代码][代码]this[代码][代码].data.src[代码][代码] [代码][代码]bgMusic.title = that.data.title;[代码][代码] [代码][代码]bgMusic.epname = that.data.classname;[代码][代码] [代码][代码]bgMusic.src = that.data.src;[代码][代码] [代码][代码]this[代码][代码].data.music_on = [代码][代码]true[代码][代码];[代码][代码] [代码][代码]this[代码][代码].data.music_playing = [代码][代码]true[代码][代码];[代码][代码] [代码][代码]bgMusic.play(); [代码][代码]//图片添加css样式,旋转样式 [代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]music_on: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]music_playing: [代码][代码]this[代码][代码].data.music_playing,[代码][代码] [代码][代码]})[代码][代码] [代码][代码]bgMusic.onTimeUpdate(() => {[代码][代码] [代码][代码]var[代码] [代码]duration = bgMusic.duration;[代码][代码] [代码][代码]var[代码] [代码]offset = bgMusic.currentTime;[代码][代码] [代码][代码]var[代码] [代码]currentTime = parseInt(bgMusic.currentTime);[代码][代码] [代码][代码]var[代码] [代码]min = [代码][代码]"0"[代码] [代码]+ parseInt(currentTime / 60);[代码][代码] [代码][代码]var[代码] [代码]max = parseInt(bgMusic.duration);[代码][代码] [代码][代码]var[代码] [代码]sec = currentTime % 60;[代码][代码] [代码][代码]var[代码] [代码]maxtime = max / 60[代码][代码] [代码][代码]var[代码] [代码]max_time = parseInt(maxtime);[代码][代码] [代码][代码]var[代码] [代码]x_maxtime = maxtime - max_time;[代码][代码] [代码][代码]var[代码] [代码]yu_time = parseInt(x_maxtime * 60)[代码][代码] [代码][代码]if[代码] [代码](sec < 10) {[代码][代码] [代码][代码]sec = [代码][代码]"0"[代码] [代码]+ sec;[代码][代码] [代码][代码]};[代码][代码] [代码][代码]var[代码] [代码]starttime = min + [代码][代码]':'[代码] [代码]+ sec; [代码][代码]/* 00:00 */[代码][代码] [代码][代码]var[代码] [代码]time_time = max_time + [代码][代码]':'[代码] [代码]+ yu_time[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]isOpen: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]duration: time_time,[代码][代码] [代码][代码]offset: currentTime,[代码][代码] [代码][代码]starttime: starttime,[代码][代码] [代码][代码]max: max,[代码][代码] [代码][代码]changePlay: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]})[代码][代码] [代码][代码]// 播放出错[代码][代码] [代码][代码]bgMusic.onError((res) => {[代码][代码] [代码][代码]that.prompt.message([代码][代码]'网络出错,稍后再试'[代码][代码])[代码][代码] [代码][代码]})[代码][代码] [代码][代码]// 播放结束[代码][代码] [代码][代码]bgMusic.onEnded((res) => {[代码][代码] [代码][代码]// console.log('录音播放结束');[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]var[代码] [代码]id = parseInt([代码][代码]this[代码][代码].data.index)[代码][代码] [代码][代码]var[代码] [代码]num = id + 1[代码] [代码] [代码][代码]if[代码] [代码](id + 1 > [代码][代码]this[代码][代码].data.title_list.length - 1) {[代码][代码] [代码][代码]wx.showToast({[代码][代码] [代码][代码]title: [代码][代码]'已是最后一个'[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]music_on: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]index: num,[代码][代码] [代码][代码]'color'[代码][代码]: [代码][代码]'#0b68f3'[代码][代码],[代码][代码] [代码][代码]'clickId'[代码][代码]: num,[代码][代码] [代码][代码]src: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]duration: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]that.s_p()[代码][代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//暂停播放[代码][代码] [代码][代码]listenerButtonPause() {[代码][代码] [代码][代码]this[代码][代码].data.music_on = [代码][代码]true[代码][代码];[代码][代码] [代码][代码]this[代码][代码].data.music_playing = [代码][代码]false[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]bgMusic.pause()[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]isOpen: [代码][代码]false[代码][代码],[代码][代码] [代码][代码]music_on: [代码][代码]this[代码][代码].data.music_on,[代码][代码] [代码][代码]music_playing: [代码][代码]this[代码][代码].data.music_playing,[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]// 进度条拖拽[代码][代码] [代码][代码]sliderChange(e) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码] [代码][代码]var[代码] [代码]offset = parseInt(e.detail.value);[代码][代码] [代码][代码]bgMusic.play();[代码][代码] [代码][代码]bgMusic.seek(offset);[代码][代码] [代码][代码]that.setData({[代码][代码] [代码][代码]isOpen: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码] [代码]})[代码]
2019-07-22 - 下拉加载更多显示数据重复
[图片] [图片] [图片] 下拉到第二页,也展示的第一页的数据,
2019-06-18 - wx.createInnerAudioContext()自动播放问题
打开播放音乐,时间在走,进度条不动,默认不自动播放音乐,只有点击暂停,再点击播放才能播放音乐,想要的效果是打开后自动播放音乐,点暂停后停止播放。 [图片] 下面js代码。 [代码]var[代码] [代码]config = require([代码][代码]'../../config.js'[代码][代码]);[代码][代码]const app = getApp()[代码][代码]const innerAudioContext = wx.createInnerAudioContext();[代码][代码]Page({[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]siteurl: config.siteurl, [代码][代码]//传递网址[代码] [代码] [代码][代码]audiolist: [[代码][代码] [代码][代码]{[代码][代码] [代码][代码]audiosrc: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]coverimg: [代码][代码]''[代码][代码],[代码][代码] [代码][代码]}[代码][代码] [代码][代码]],[代码][代码] [代码][代码]isPlayAudio: [代码][代码]true[代码][代码],[代码][代码] [代码][代码]audioSeek: 0,[代码][代码] [代码][代码]audioDuration: 0,[代码][代码] [代码][代码]showTime1: [代码][代码]'00:00'[代码][代码],[代码][代码] [代码][代码]showTime2: [代码][代码]'00:00'[代码][代码],[代码][代码] [代码][代码]audioTime: 0[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onLoad: [代码][代码]function[代码] [代码](options) {[代码][代码] [代码][代码]var[代码] [代码]classid = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]id = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]this[代码][代码].setData({[代码][代码] [代码][代码]id: options.id,[代码][代码] [代码][代码]classid:options.classid,[代码][代码] [代码][代码]})[代码][代码] [代码][代码]this[代码][代码].gainLoadingListData();[代码][代码] [代码][代码]//innerAudioContext.play();[代码][代码] [代码][代码]this[代码][代码].innerAudioContext.play();[代码][代码] [代码] [代码] [代码] [代码] [代码][代码]},[代码][代码]//获取数据[代码][代码] [代码][代码]gainLoadingListData: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]classid = that.data.classid;[代码][代码] [代码][代码]var[代码] [代码]id = that.data.id;[代码][代码] [代码][代码]wx.request({[代码][代码] [代码][代码]url: config.apiurl + [代码][代码]'/?api=listenStory/detail&id='[代码] [代码]+ id + [代码][代码]'&classid='[代码] [代码]+ classid, [代码][代码]//调用接口[代码][代码] [代码][代码]data: {[代码][代码] [代码][代码]'appid'[代码][代码]: config.appid, [代码][代码]// 传递appid[代码][代码] [代码][代码]'timestamp'[代码][代码]: config.timestamp, [代码][代码]// timestamp[代码][代码] [代码][代码]'signature'[代码][代码]: config.signature, [代码][代码]// signature[代码][代码] [代码][代码]},[代码][代码] [代码][代码]method: [代码][代码]'GET'[代码][代码],[代码][代码] [代码][代码]header: {[代码][代码] [代码][代码]'content-type'[代码][代码]: [代码][代码]'application/json'[代码][代码],[代码][代码] [代码][代码]},[代码][代码] [代码][代码]success: [代码][代码]function[代码] [代码](res) {[代码][代码] [代码][代码]console.log(res.data);[代码][代码] [代码][代码]var[代码] [代码]audiolist = that.data.audiolist;[代码][代码] [代码][代码]that.data.audiolist[0].audiosrc = res.data.data.content.mp3link;[代码][代码] [代码] [代码] [代码][代码]that.setData({[代码][代码] [代码][代码]newsdata: res.data.data.content,[代码][代码] [代码][代码]});[代码][代码] [代码][代码]var[代码] [代码]audiosrc = res.data.data.content.mp3link;[代码][代码] [代码][代码]var[代码] [代码]coverimg = res.data.data.content.titlepic;[代码][代码] [代码][代码]//设置页面标题//[代码][代码] [代码][代码]wx.setNavigationBarTitle({[代码][代码] [代码][代码]title: res.data.data.content.title[代码][代码] [代码][代码]})[代码][代码] [代码] [代码] [代码] [代码] [代码][代码]}[代码][代码] [代码][代码]})[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onShow: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]this[代码][代码].Initialization();[代码][代码] [代码][代码]this[代码][代码].loadaudio();[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//初始化播放器,获取duration[代码][代码] [代码][代码]Initialization() {[代码][代码] [代码][代码]this[代码][代码].gainLoadingListData();[代码][代码] [代码][代码]var[代码] [代码]t = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]if[代码] [代码]([代码][代码]this[代码][代码].data.audiolist[0].audiosrc.length != 0) {[代码][代码] [代码][代码]//设置src[代码][代码] [代码][代码]innerAudioContext.src = [代码][代码]this[代码][代码].data.audiolist[0].audiosrc;[代码][代码] [代码][代码]//运行一次[代码][代码] [代码][代码]innerAudioContext.play();[代码][代码] [代码][代码]innerAudioContext.pause();[代码][代码] [代码][代码]innerAudioContext.onCanplay(() => {[代码][代码] [代码][代码]//初始化duration[代码][代码] [代码][代码]innerAudioContext.duration[代码][代码] [代码][代码]setTimeout([代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]//延时获取音频真正的duration[代码][代码] [代码][代码]var[代码] [代码]duration = innerAudioContext.duration;[代码][代码] [代码][代码]var[代码] [代码]min = parseInt(duration / 60);[代码][代码] [代码][代码]var[代码] [代码]sec = parseInt(duration % 60);[代码][代码] [代码][代码]if[代码] [代码](min.toString().length == 1) {[代码][代码] [代码][代码]min = `0${min}`;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](sec.toString().length == 1) {[代码][代码] [代码][代码]sec = `0${sec}`;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]t.setData({ audioDuration: innerAudioContext.duration, showTime2: `${min}:${sec}` });[代码][代码] [代码][代码]}, 1000)[代码][代码] [代码][代码]})[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//拖动进度条事件[代码][代码] [代码][代码]sliderChange(e) {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]innerAudioContext.src = [代码][代码]this[代码][代码].data.audiolist[0].audiosrc;[代码][代码] [代码][代码]//获取进度条百分比[代码][代码] [代码][代码]var[代码] [代码]value = e.detail.value;[代码][代码] [代码][代码]this[代码][代码].setData({ audioTime: value });[代码][代码] [代码][代码]var[代码] [代码]duration = [代码][代码]this[代码][代码].data.audioDuration;[代码][代码] [代码][代码]//根据进度条百分比及歌曲总时间,计算拖动位置的时间[代码][代码] [代码][代码]value = parseInt(value * duration / 100);[代码][代码] [代码][代码]//更改状态[代码][代码] [代码][代码]this[代码][代码].setData({ audioSeek: value, isPlayAudio: [代码][代码]true[代码] [代码]});[代码][代码] [代码][代码]//调用seek方法跳转歌曲时间[代码][代码] [代码][代码]innerAudioContext.seek(value);[代码][代码] [代码][代码]//播放歌曲[代码][代码] [代码][代码]innerAudioContext.play();[代码][代码] [代码][代码]},[代码][代码] [代码][代码]//播放、暂停按钮[代码][代码] [代码][代码]playAudio() {[代码][代码] [代码][代码]//获取播放状态和当前播放时间[代码][代码] [代码][代码]var[代码] [代码]isPlayAudio = [代码][代码]this[代码][代码].data.isPlayAudio;[代码][代码] [代码][代码]var[代码] [代码]seek = [代码][代码]this[代码][代码].data.audioSeek;[代码][代码] [代码] [代码] [代码][代码]innerAudioContext.play();[代码][代码] [代码] [代码] [代码][代码]//更改播放状态[代码][代码] [代码][代码]this[代码][代码].setData({ isPlayAudio: !isPlayAudio })[代码][代码] [代码][代码]if[代码] [代码](isPlayAudio) {[代码][代码] [代码][代码]//如果在播放则记录播放的时间seek,暂停[代码][代码] [代码][代码]this[代码][代码].setData({ audioSeek: innerAudioContext.currentTime });[代码][代码] [代码][代码]} [代码][代码]else[代码] [代码]{[代码][代码] [代码][代码]//如果在暂停,获取播放时间并继续播放[代码][代码] [代码][代码]innerAudioContext.src = [代码][代码]this[代码][代码].data.audiolist[0].audiosrc;[代码][代码] [代码][代码]if[代码] [代码](innerAudioContext.duration != 0) {[代码][代码] [代码][代码]this[代码][代码].setData({ audioDuration: innerAudioContext.duration });[代码][代码] [代码][代码]}[代码][代码] [代码][代码]//跳转到指定时间播放[代码][代码] [代码][代码]innerAudioContext.seek(seek);[代码][代码] [代码][代码]innerAudioContext.play();[代码][代码] [代码][代码]}[代码][代码] [代码][代码]},[代码][代码] [代码][代码]loadaudio() {[代码][代码] [代码][代码]var[代码] [代码]that = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]//设置一个计步器[代码][代码] [代码][代码]this[代码][代码].data.durationIntval = setInterval([代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]//当歌曲在播放时执行[代码][代码] [代码][代码]if[代码] [代码](that.data.isPlayAudio == [代码][代码]true[代码][代码]) {[代码][代码] [代码][代码]//获取歌曲的播放时间,进度百分比[代码][代码] [代码][代码]var[代码] [代码]seek = that.data.audioSeek;[代码][代码] [代码][代码]var[代码] [代码]duration = innerAudioContext.duration;[代码][代码] [代码][代码]var[代码] [代码]time = that.data.audioTime;[代码][代码] [代码][代码]time = parseInt(100 * seek / duration);[代码][代码] [代码][代码]//当歌曲在播放时,每隔一秒歌曲播放时间+1,并计算分钟数与秒数[代码][代码] [代码][代码]var[代码] [代码]min = parseInt((seek + 1) / 60);[代码][代码] [代码][代码]var[代码] [代码]sec = parseInt((seek + 1) % 60);[代码][代码] [代码][代码]//填充字符串,使3:1这种呈现出 03:01 的样式[代码][代码] [代码][代码]if[代码] [代码](min.toString().length == 1) {[代码][代码] [代码][代码]min = `0${min}`;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](sec.toString().length == 1) {[代码][代码] [代码][代码]sec = `0${sec}`;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]var[代码] [代码]min1 = parseInt(duration / 60);[代码][代码] [代码][代码]var[代码] [代码]sec1 = parseInt(duration % 60);[代码][代码] [代码][代码]if[代码] [代码](min1.toString().length == 1) {[代码][代码] [代码][代码]min1 = `0${min1}`;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]if[代码] [代码](sec1.toString().length == 1) {[代码][代码] [代码][代码]sec1 = `0${sec1}`;[代码][代码] [代码][代码]}[代码][代码] [代码][代码]//当进度条完成,停止播放,并重设播放时间和进度条[代码][代码] [代码][代码]if[代码] [代码](time >= 100) {[代码][代码] [代码][代码]innerAudioContext.stop();[代码][代码] [代码][代码]that.setData({ audioSeek: 0, audioTime: 0, audioDuration: duration, isPlayAudio: [代码][代码]false[代码][代码], showTime1: `00:00` });[代码][代码] [代码][代码]return[代码] [代码]false[代码][代码];[代码][代码] [代码][代码]}[代码][代码] [代码][代码]//正常播放,更改进度信息,更改播放时间信息[代码][代码] [代码][代码]that.setData({ audioSeek: seek + 1, audioTime: time, audioDuration: duration, showTime1: `${min}:${sec}`, showTime2: `${min1}:${sec1}` });[代码][代码] [代码][代码]}[代码][代码] [代码][代码]}, 1000);[代码][代码] [代码][代码]},[代码][代码] [代码][代码]onUnload: [代码][代码]function[代码] [代码]() {[代码][代码] [代码][代码]//卸载页面,清除计步器[代码][代码] [代码][代码]clearInterval([代码][代码]this[代码][代码].data.durationIntval);[代码][代码] [代码][代码]}[代码][代码]})[代码] WXML代码 [代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'audioPlayer'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'player'[代码][代码]>[代码][代码] [代码][代码]<!-- <image src='{{audiolist[0].coverimg}}' class='audioBack'></image>-->[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]src[代码][代码]=[代码][代码]'../../images/pay_img.png'[代码] [代码]class[代码][代码]=[代码][代码]'audioBack'[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码][代码]>{{newsdata.title}}</[代码][代码]view[代码][代码]>[代码][代码] [代码] [代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'audioControls'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'flex'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'bottom'[代码] [代码]catchtap[代码][代码]=[代码][代码]'playAudio'[代码][代码]>[代码][代码] [代码][代码]<!-- 按钮 -->[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]wx:if[代码][代码]=[代码][代码]"{{isPlayAudio}}"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]src[代码][代码]=[代码][代码]'../../images/pause.png'[代码] [代码]/>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]wx:else>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]src[代码][代码]=[代码][代码]'../../images/play.png'[代码] [代码]/>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'slider'[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]slider[代码] [代码]bindchange[代码][代码]=[代码][代码]'sliderChange'[代码] [代码]activeColor[代码][代码]=[代码][代码]'red'[代码] [代码]block-size[代码][代码]=[代码][代码]"12"[代码] [代码]value[代码][代码]=[代码][代码]'{{audioTime}}'[代码] [代码]/>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]'time'[代码][代码]>[代码][代码] [代码][代码]{{showTime1}}/{{showTime2}}[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码][代码] [代码][代码]</[代码][代码]view[代码][代码]>[代码]
2019-05-27 - 列表页上拉加载更多的数据的问题
我要实现的是点击某类新闻列表页下拉加载更多新闻,现在下拉加载的不是这个类别的新闻,在上拉加载第二页时classid值失效。请问如何设置能让classid的值一直有效。 [图片] [图片] [图片]
2019-04-10 - 小程序获取到了接口数据,视图界面view中却不能显示出来
一个项目的新闻详细页获取到了接口数据,视图界面view中却不显示数据,分类和列表页正常显示,网上查一些资料还是没有解决,同样的方式和代码在另一个项目中新闻详细可以正常显示。 js代码: [图片] wxml代码 [图片] API接口获取数据提示 [图片]
2019-04-03