var app=getApp(); var utils=require("../../../utils/http"); const util=require("../../../utils/util") let videoContext=null; var customerflag=false,stoptime=0; Page({ /** * 页面的初始数据 */ data: { imgUrl: app.globalData.imgUrl, videoUrl:'', video_id:'', title:'', btflag:false, loginFlag:false, phoneFlag:false, errorText:'请求错误!', oneButton: [{text: '确定'}], ght:'100%', customers_num: "", hot: "", video_url: "", headimgurl: "", nickname: "", vid: "", star_num: "", editVideoFlag: true, shareuserid: "", videoflag:false, playBtn:true, collectflag:0, startY:0, endY:0, type:'', videoObj:{}, mobileflag:false, autoplay:true, covercustomerFlag:true, alertFlag:false, alerText:'', footflag:false, personMsg:app.globalData.personMsg, companyobj:app.globalData.companyobj, nowflag:false, wshareshow:false, showDsc: false, priceflag: false, controlShow: false, playflag: 2,//1是播放中,2是暂停,3是加载中 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that=this; that.setData({ video_id:options.vid }) wx.showLoading({ title: '加载中...', }) that.sharemsg(); }, setpostertap: function () { wx.navigateTo({ url: '/index/pages/setposter/setposter?type=video&aid='+this.data.video_id+"&listshare=", }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 弹出报价弹窗 */ priceshowtap() { this.setData({ priceflag: true }) }, /** * 关闭报价弹窗 */ closepricetap() { this.setData({ priceflag: false }) }, showdscMsg: function () { if (this.data.videoObj.description.length > 28) { this.data.showDsc = !this.data.showDsc; this.setData({ showDsc: this.data.showDsc }) } }, wsharetap:function(e){ var that=this; that.setData({ wshareshow:true, }) }, shareurltap:function(e){ var that=this; wx.showLoading({ title: '加载中...', }) util.schemefun('/share/pages/videoshare/videoshare','vid='+that.data.video_id +'&userid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype,that.data.video_id,'video',''); this.sharelogtap(); }, sendfriendtap(){ this.sharelogtap(); }, sharelogtap:function(){ var that=this; this.setData({ nowflag:false, }) utils.$post({ url: app.globalData.webUrl + 'api/share/addlog', header: { 'Authorization':'bearer '+app.globalData.token }, data: { id:that.data.video_id, type:'video' }, success: function (r) { } }) }, collecTap:function(){ var that=this; var vurl=''; var videoObj=that.data.videoObj; if(videoObj.collect=='0'){ vurl="api/video/collect" }else{ vurl="api/video/collectCancel" } utils.$post({ url: app.globalData.webUrl + vurl, header: { 'Authorization':'bearer '+app.globalData.token }, data:{ id: that.data.video_id, }, success: function (res) { if (res.data.code == "0") { if(videoObj.collect=='0'){ videoObj.collect=1; that.setData({ videoObj:videoObj, alertFlag:true, alerText:res.data.msg }) setTimeout(function(){ that.setData({ alertFlag:false, }) },1000) }else{ videoObj.collect=0; that.setData({ videoObj:videoObj, alertFlag:true, alerText:res.data.msg }) setTimeout(function(){ that.setData({ alertFlag:false, }) },1000) } } else { if(res.data.msg=='您已收藏'){ videoObj.collect=1; that.setData({ videoObj:videoObj }) } } } }) }, sharemsg:function(){ var that=this; utils.$post({ url: app.globalData.webUrl + 'api/video/info', header: { 'Authorization':'bearer '+app.globalData.token }, data: { video_id:that.data.video_id }, success: function (r) { if(r.data.code=='0'){ r.data.data.video_url=r.data.data.video_url; r.data.data.description = r.data.data.title + '#' + r.data.data.description + '#'; that.setData({ title:r.data.data.title, videoObj:r.data.data, autoplay:true }) wx.setNavigationBarTitle({ title: r.data.data.title }) const videoContext = that.selectComponent('#myVideo'); videoContext.play(); } wx.hideLoading() } }) }, signpricetap(){ wx.showToast({ title: "您是员工无需报价!", icon: 'none', duration: 2000 }) }, prelooktap(){ if(!app.globalData.personMsg.binded.qrcode){ wx.showToast({ title: "您的二维码为空,请上传二维码!", icon: 'none', duration: 2000 }) return false; } wx.previewImage({ current: app.globalData.imgUrl+app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接 urls: [app.globalData.imgUrl+app.globalData.personMsg.binded.qrcode]// 需要预览的图片http链接列表 }) }, callphonetap:function(){ wx.makePhoneCall({ phoneNumber: app.globalData.personMsg.phone }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.setData({ personMsg:app.globalData.personMsg, companyobj:app.globalData.companyobj, }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, onShareAppMessage: function () { this.sharelogtap(); var img=this.data.videoObj.cover?this.data.videoObj.cover:(this.data.videoObj.video_url+'?x-oss-process=video/snapshot,t_100,f_jpg,w_500,m_fast'); return { title: this.data.videoObj.title, imageUrl: img, path: '/share/pages/videoshare/videoshare?vid='+this.data.video_id+'&userid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype } } })