- 视频组件,第一个不暂停的话下一个就无法正常播放
- 当前 Bug 的[图片] 表现(可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo 视频组件,第一个不暂停的话下一个就无法正常播放 Page({ data: { items: [], allspurl: [], currentTab: '0', id:'', fspurl:'', fspid:'', keyy: '0', allspid:[], plr:[], plsj:[], plnr:[], plhf:[], fsdpl:'' }, onLoad: function () { this.setData({ id: wx.getStorageSync('id') }) this.setData({ fspid: wx.getStorageSync('fspid') }) this.getfspurl() this.getallspm() this.getallspurl() this.getallspid() this.getplr(this.data.fspid) this.getplsj(this.data.fspid) this.getplnr(this.data.fspid) this.getplhf(this.data.fspid) wx.setNavigationBarTitle({ title: getApp().globalData.gbkcm//页面标题为路由参数 }) }, xzsp:function(e){ var index = parseInt(e.currentTarget.dataset.index); this.setData({ fspurl: this.data.allspurl[index] }) this.setData({ fspid: this.data.allspid[index] }) this.setData({ keyy: index }) this.videoContext = wx.createVideoContext('{{keyy}}') this.getplr(this.data.fspid) this.getplsj(this.data.fspid) this.getplnr(this.data.fspid) this.getplhf(this.data.fspid) }, plf: function (e) { this.data.fsdpl = e.detail.value}, anfspl:function(){ if (this.data.fsdpl.length==0){ wx.showToast({ title: '请输入评论内容', icon: 'none', duration: 2000//持续的时间 }) }else{ var that = this wx.request({ url: getApp().globalData.gburl +"fspl/" +that.data.id +'?index='+this.data.fspid+'&&plnr='+that.data.fsdpl+'&&num='+getApp().globalData.gbnum, method: 'POST', success: function (res) { if (res.data == 1) { wx.showToast({ title: '发送成功', icon: 'none', duration: 2000//持续的时间 })} } }) } }, getallspid: function () { var that = this wx.request({ url: "http://m.cn/allspid/" + that.data.id, method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.allspid[i] = res.data[i]; that.setData({ allspid: that.data.allspid }) } } }) }, getallspurl: function () { var that = this wx.request({ url: "http://m.cn/allspurl/" + that.data.id, method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.allspurl[i] = res.data[i]; that.setData({ allspurl: that.data.allspurl }) } } }) }, getplr: function (spid) { var that = this wx.request({ url: "http://m.cn/plr/" + that.data.id +'?index='+spid, method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.plr[i] = res.data[i]; that.setData({ plr: that.data.plr }) } } }) }, getplsj: function (spid) { var that = this wx.request({ url: "http://m.cn/plsj/" + that.data.id + '?index='+spid , method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.plsj[i] = res.data[i]; that.setData({ plsj: that.data.plsj }) } } }) }, getplnr: function (spid) { var that = this wx.request({ url: "http://m.cn/plnr/" + that.data.id + '?index='+spid, method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.plnr[i] = res.data[i]; that.setData({ plnr: that.data.plnr }) } } }) }, getplhf: function (spid) { var that = this wx.request({ url: "http://m.cn/plhf/" + that.data.id + '?index=' + spid, method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.plhf[i] = res.data[i]; that.setData({ plhf: that.data.plhf }) } } }) }, getallspm: function () { var that = this; wx.request({ url: "http://m.cn/allspm/"+that.data.id, method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.items[i] = res.data[i]; that.setData({ items: that.data.items }) } } }) }, bindChange: function (e) { var that = this; that.setData({ currentTab: e.detail.current }); }, switchNav: function (e) { var page = this; var index = e.target.dataset.current; if (this.data.currentTab == index) { return false; } else { page.setData({ currentTab: index }); } }, onReady: function (res) { this.videoContext = wx.createVideoContext('{{keyy}}') }, videoErrorCallback: function (e) { console.log('视频错误信息:'); console.log(e.detail.errMsg); }, onPullDownRefresh: function () { wx.showNavigationBarLoading() //在标题栏中显示加载 this.setData({keyy:0}) this.onLoad() //模拟加载 setTimeout(function () {// complete wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 }, 800); }, getfspurl:function(){ var that=this wx.request({ url: 'http://m.cn/fspurl/' + this.data.id, method: 'GET', success: function (res) { if (res.data) { that.setData({ fspurl: res.data }) } else { wx.showToast({ title: '该课程暂无视频', icon: 'none', duration: 2000 }) wx.setStorage({ key: "fspurl", data: null }) } } }) } }) wxml <view class="videorq"> <video id="{{keyy}}" src="{{fspurl}}" binderror="videoErrorCallback" custom-cache="{{false}}"></video> </view> <view class="menu"> <view class="{{currentTab==0?'select':'default'}}" data-current="0" bindtap="switchNav">视频列表</view> <view class="{{currentTab==1?'select':'default'}}" data-current="1" bindtap="switchNav">评论</view> </view> <view class="line"> </view> <swiper current="{{currentTab}}" style="height:1800px;" bindchange="bindChange"> <swiper-item> <include src="shipin.wxml" /> </swiper-item> <swiper-item> <include src="pinglun.wxml" /> </swiper-item> </swiper> shipin.wxml <view class="tr" wx:for = "{{items}}" wx:for-index="index" wx:for-item="item" wx:key="" data-index='{{index}}' style='{{keyy==index?"color:#05CF8C;":""}}'bindtap='xzsp'> <text class="td" >{{item.name}}</text> </view >
2019-05-17 - 列表循环渲染
- 当前 Bug 的表现([图片] 可附上截图) - 预期表现 - 复现路径 - 提供一个最简复现 Demo 列表循环渲染出的MySQL里的数据删除一条,之后最后一条会重复显示,数据库的信息确实删掉了,刷新函数里写onload onshow函数都没有,提前写了onunload也没有,但是退出后再进入该页面就对了,重复的就没了,类似图中最后两栏重复 Page({ data: { currentTab: '0', alltz: [], alltzsj: [], allzy:[], allzysj: [] }, onLoad: function () { getApp().getstatus() wx.setNavigationBarTitle({ title: getApp().globalData.gbkcm//页面标题为路由参数 }) }, onShow: function () { this.getalltz() this.getalltzsj() this.getallzy() this.getallzysj() }, getalltz: function () { var that = this; wx.request({ url: getApp().globalData.gburl +"tz/" + getApp().globalData.gbkcm, method: 'GET', header: { 'Accept': 'application/json' }, success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.alltz[i] = res.data[i]; that.setData({ alltz: that.data.alltz }) } } }) }, getalltzsj: function () { var that = this; wx.request({ url: getApp().globalData.gburl +"tzsj/" + getApp().globalData.gbkcm, method: 'GET', header: { 'Accept': 'application/json' }, success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.alltzsj[i] = res.data[i]; that.setData({ alltzsj: that.data.alltzsj }) } } }) }, getallzy: function () { var that = this; wx.request({ url: getApp().globalData.gburl +"zy/" + getApp().globalData.gbkcm, method: 'GET', success: function (res) { for (var i = 0, len = res.data.length; i < len; i++) { that.data.allzy[i] = res.data[i]; that.setData({ allzy: that.data.allzy }) } } }) }, getallzysj: function () { var that = this; wx.request({ url: getApp().globalData.gburl +"zysj/" + getApp().globalData.gbkcm, method: 'GET', success: function (res) { for (var i =res.data.length; i>=0; i--) { that.data.allzysj[i] = res.data[i]; that.setData({ allzysj: that.data.allzysj }) } } }) }, fbtz:function(){ if (getApp().globalData.gbstatus == 2) { wx.showToast({ title: '暂无该权限', icon: 'none', duration: 2000 }) } else { wx.navigateTo({ url: '../fbtz/fbtz' })} }, fbzy: function () { if (getApp().globalData.gbstatus == 2) { wx.showToast({ title: '暂无该权限', icon: 'none', duration: 2000 }) } else { wx.navigateTo({ url: '../fbzy/fbzy' }) } }, sctz: function (e) { var that=this var index = parseInt(e.currentTarget.dataset.index); var time = this.data.alltzsj[index] wx.showModal({ //使用模态框提示用户进行操作 title: '', content: '删除此通知?', success: function (res) { if (res.confirm) { //判断用户是否点击了确定 if (getApp().globalData.gbstatus== 2) { wx.showToast({ title: '暂无该权限', icon: 'none', duration: 2000 })} else { wx.request({ url: getApp().globalData.gburl +"sctz/" + time, method: 'POST', success: function (res) { if(res.data==1){ wx.showToast({ title: '删除成功', icon: 'none', duration: 2000 }) } } }) } } } }) }, sczy: function (e) { var that = this var index = parseInt(e.currentTarget.dataset.index); var time = this.data.allzysj[index] wx.showModal({ //使用模态框提示用户进行操作 title: '', content: '删除此项作业?', success: function (res) { if (res.confirm) { //判断用户是否点击了确定 if (getApp().globalData.gbstatus == 2) { wx.showToast({ title: '暂无该权限', icon: 'none', duration: 2000 }) } else { wx.request({ url: getApp().globalData.gburl +"sczy/" + time, method: 'POST', success: function (res) { if (res.data == 1) { that.onReady(); wx.showToast({ title: '删除成功', icon: 'none', duration: 2000 }) } } }) } } } }) }, bindChange: function (e) { var that = this; that.setData({ currentTab: e.detail.current }); }, switchNav: function (e) { var page = this; var index = e.target.dataset.current; if (this.data.currentTab == index) { return false; } else { page.setData({ currentTab: index }); } }, onPullDownRefresh: function () { wx.showNavigationBarLoading() //在标题栏中显示加载 this.onShow() //模拟加载 setTimeout(function () {// complete wx.hideNavigationBarLoading() //完成停止加载 wx.stopPullDownRefresh() //停止下拉刷新 }, 1500); } }) <button class="bto" bindtap="fbzy">+</button> <view class="txh" wx:for = "{{allzy}}" wx:for-item="item" wx:key="" wx:for-index="index" data-index='{{index}}'bindlongpress='sczy'> <text class="tsj">{{allzysj[index]}}</text> <text class="tnr">{{item}}</text> <view class="line"></view> </view>
2019-05-17