123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343 |
- var app=getApp();
- var utils=require("../../utils/http");
- var customerflag=false;
- var stoptime=0;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- 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: "",
- customerFlag: true,
- videoflag:false,
- playBtn:true,
- collectflag:0,
- startY:0,
- endY:0,
- type:'',
- videoObj:{},
- mobileflag:false,
- autoplay:false,
- covercustomerFlag:true,
- share_user_id:'',
- sharepersonobj:app.globalData.sharepersonobj,
- companyobj:app.globalData.companyobj
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that=this;
-
- wx.getSystemInfo({
- success: (res) => {
- that.setData({
- videoHeight:res.windowHeight
- })
- }
- })
- app.globalData.sharevid=options.vid;
- that.setData({
- video_id:options.vid,
- share_user_id:options.share_user_id,
- companyobj:app.globalData.companyobj
- })
- wx.showLoading({
- title: '加载中',
- })
- // app.globalData.shareuserid=app.globalData.personMsg.id;
- that.sharemsg();
- wx.hideLoading();
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- movestart:function(e){
- var that=this;
- console.log(e)
- that.setData({
- startY:e.changedTouches[0].pageY
- })
- },
- moveTap:function(e){
- var that=this;
- },
- touchend:function(e){
- var that=this;
- console.log(e)
- that.setData({
- endY:e.changedTouches[0].pageY
- })
- var move=that.data.endY-that.data.startY;
- if(move>=50&&!!app.globalData.token){
- that.setData({
- type:'last'
- })
- const videoContext = that.selectComponent('#myVideo');
- videoContext.stop();
- that.decoratemsg();
- }else if(move<=-50&&!!app.globalData.token){
- that.setData({
- type:'next'
- })
- const videoContext = that.selectComponent('#myVideo');
- videoContext.stop();
- that.decoratemsg();
- }
-
-
- },
- // 装修端翻页视频详情
- decoratemsg:function(){
- var that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/video/videoPage',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data: {
- video_id:that.data.video_id,
- desc:that.data.type,
- user_id:app.globalData.personMsg.id
- },
- success: function (r) {
- wx.hideLoading();
- if(r.data.code=='0'){
- r.data.data.video_url=app.globalData.imgUrl+r.data.data.video_url;
- that.setData({
- title:r.data.data.title,
- videoObj:r.data.data,
- customerFlag:true,
- autoplay:true,
- video_id:r.data.data.id
- })
- wx.setNavigationBarTitle({
- title: r.data.data.title
- })
- const videoContext = that.selectComponent('#myVideo');
- videoContext.play();
- }else{
- that.setData({
- title:'视频转发'
- })
- }
- }
- })
- },
- minefun:function(){
- },
- 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;
- wx.showToast({
- title: res.data.msg,
- icon: "none",
- duration:2000
- });
- that.setData({
- videoObj:videoObj
- })
- }else{
- videoObj.collect=0;
- wx.showToast({
- title: res.data.msg,
- icon: "none",
- duration:2000
- });
- that.setData({
- videoObj:videoObj
- })
- }
- } else {
- if(res.data.msg=='您已收藏'){
- videoObj.collect=1;
- that.setData({
- videoObj:videoObj
- })
- }
- }
- }
- })
- },
- clickzanTap:function(){
- var that=this;
- var videoObj=that.data.videoObj;
- utils.$post({
- url: app.globalData.webUrl + 'api/video/star',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- video_id: that.data.video_id,
- },
- success: function (res) {
- wx.showToast({
- title: res.data.msg,
- icon: "none",
- duration:2000
- });
- if (res.data.code == '0') {
- if(res.data.msg=='点赞成功'){
- videoObj.star_num = videoObj.star_num * 1 + 1;
-
- videoObj.stared=1;
- }else{
- videoObj.star_num = videoObj.star_num * 1 - 1;
- videoObj.stared=0;
- }
- that.setData({
- videoObj:videoObj
- })
- }
- }
- })
- },
- editTap:function(){
- const videoContext = this.selectComponent('#myVideo');
- videoContext.pause()
- wx.navigateTo({
- url: "/pages/videoreprint/videoreprint?vid="+this.data.video_id,
- });
- },
- sharemsg:function(){
- var that=this;
- utils.$post({
- url: app.globalData.webUrl + 'client/video/info',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data: {
- video_id:that.data.video_id
- },
- success: function (r) {
- wx.hideLoading();
- if(r.data.code=='0'){
- r.data.data.video_url=r.data.data.video_url;
- that.setData({
- title:r.data.data.title,
- videoObj:r.data.data,
- customerFlag:true,
- autoplay:true
- })
- wx.setNavigationBarTitle({
- title: r.data.data.title
- })
- const videoContext = that.selectComponent('#myVideo');
- videoContext.play();
- }else{
- that.setData({
- title:'视频转发'
- })
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- // wx.hideHomeButton();
- this.setData({
- companyobj:app.globalData.companyobj
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- var timearr=app.globalData.timearr,flag=false;
- for(var i=0;i<timearr.length;i++){
- if(timearr[i].type=='smallnetvideomsg'){
- timearr[i].time=timearr[i].time*1+stoptime*1;
- flag=true;
- }
- }
- if(!flag){
- var obj={
- type:'smallnetvideomsg',
- time:stoptime
- };
- app.globalData.timearr.push(obj);
- }else{
- app.globalData.timearr=timearr;
- }
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- // onShareAppMessage: function () {
- // return {
- // title: '我是'+app.globalData.sharename+",这是我的个人微网。",
- // imageUrl:"../../img/weiw.png",
- // path: '/pages/microgrid/microgrid?share_user_id='+this.data.share_user_id+"&sharename="+app.globalData.sharename
- // }
- // }
- })
|