yuminge-app/yun-min-program-plugin-master/packageH/circleCommunity/videoDetails/videoDetails.js

1655 lines
46 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// packageH/circleCommunity/videoDetails/videoDetails.js
// packageC/video_goods/VideoDetail/VideoDetail.js
var app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
language: "",
amount_id: "",
isLoadMore: true,
page: 1,
total_page: 0,
popularVideo: [],
heightauto: "auto",
widthauto: "auto",
showVideo: {},
myvideo: "",
show: false,
screeheight: 0,
minStyle: true,
firstcontent: false,
cleartime: null,
realIndex: 0,
kFootshow: true,
is_plugins: 0,
//答题
// AnswerID:0,
// showVideoAnswer:false,
// successShow:false,
// errorShow:false,
// subject:null,
// integral:0,
// vid:0,
// integral_name:'积分',
//短视频红包
// reward_type:0,//奖励类型( 1观看累计时长 2看完视频发放奖励
// logID:0,//视频已观看记录的视频id
// maxTime:0,//视频总时长
// activity_reward_id:0,
// redpack_info:{
// amount:0
// },//红包设置展示信息
// is_openRedpack:false,
// openRedpackData:[],//短视频红包活动数组
// openRedpackTimes:[],//观看时长集合数组
// showVerification: false,//绑定手机
// showRedpack: false, //红包
// openRedpack: false,
// currentDuration: 0,//当前视频播放时长重播时复位为0
// cumulativeDuration: 0,//累计时长
//绑定手机
// start1: false,
// codetext: '获取验证码',
// bind_mobile:false,
// imgcode: "", //图形验证码
// cationCode: false,
// count: "",
// form: {
// mobile: "",
// //验证码
// code: "",
// captcha: ""
// },
timer: null,
circleId: 0,
// getCommentFlag:true,
commentsShow: false,
mainCommentShow: false,
maincomment: "",
comment_total: 0,
comment_page: 1,
comment_loading: false,
comment_total_count: 0,
StickCommentData: [],
replyName: "",
replyContent: "",
host_comment_id: "",
second_comment_id: "",
is_own: false,
commentManagement: false,
replyshow: false,
//--------
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.data.myvideo = wx.createVideoContext("myvideo");
this.getinformation();
if (options.circleId) {
this.setData({
circleId: options.circleId,
});
}
if (options.vid) {
this.setData({
amount_id: options.vid,
});
}
if (options.mid) {
app._setMid(options.mid);
}
if (options.status) {
this.setData({
cardFrom: "my",
sta: options.status,
});
}
if (options.card_id) {
this.setData({
card_id: options.card_id,
});
}
if (options.from) {
this.setData({
cardFrom: options.from,
});
}
wx.setStorageSync("circle_invitation_id", this.data.amount_id);
if (options.page) {
this.setData({
page: Number(options.page) ? Number(options.page) : 0,
});
}
// 判断是否有page和vid 没有vid就是会员中心进入的样式二 有page的肯定是从列表进入
if (options.page || !options.vid) {
this.getData();
} else {
// 有vid就是分享视频详情 任务编号: 42332
this.getDetail();
}
},
gofabu() {
wx.navigateTo({
url: "/packageC/video_goods/videoAgreement/videoAgreement",
});
},
gomy() {
wx.navigateTo({
url: "/packageC/video_goods/myVideo/myVideo",
});
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
let language = wx.getStorageSync("langIndex");
this.setData({
language: language.en,
});
},
subMainCommentBtn() {
this.setData({
maincomment: "",
mainCommentShow: !this.data.mainCommentShow,
});
},
replyBtn() {
this.setData({
replyshow: true,
commentManagement: false,
});
},
replyshowClose() {
this.setData({
replyshow: false,
});
},
commentManagementClose() {
this.setData({
commentManagement: false,
});
},
replySubmitBtn() {
if (!this.data.replyContent) {
wx.showToast({
icon: "none",
title: "请输入回复内容",
duration: 1500,
});
return;
}
this.setData({
replyshow: false,
});
this.getReplyComments("reply");
},
praiseBtn(e) {
let host_comment_id = e.currentTarget.dataset.hostcommentid;
let second_comment_id = e.currentTarget.dataset.secondcommentid;
let index = e.currentTarget.dataset.index;
let chilindex = e.currentTarget.dataset.chilindex;
let is_praise = e.currentTarget.dataset.ispraise;
if (is_praise == 1) {
return app.tips("你已赞过该贴");
}
this.getPraiseData(host_comment_id, second_comment_id, index, chilindex);
},
getPraiseData(host_comment_id, second_comment_id, index, chilindex) {
let dataJson = {};
let urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.comment-like");
dataJson.invitation_id = this.data.amount_id;
if (host_comment_id && second_comment_id) {
dataJson.comment_id = second_comment_id;
} else {
dataJson.comment_id = host_comment_id;
}
app._postNetWork({
url: urlStr,
showToastIn: false,
data: dataJson,
success: (resdata) => {
var res = resdata.data;
app.tips(res.msg);
if (res.result != 1) return;
if (host_comment_id && second_comment_id) {
this.setData({
["StickCommentData.[" + index + "].has_many_comment[" + chilindex + "].is_like"]: 1,
["StickCommentData.[" + index + "].has_many_comment[" + chilindex + "].link_count"]: this.data.StickCommentData[index].has_many_comment[chilindex].link_count
? this.data.StickCommentData[index].has_many_comment[chilindex].link_count + 1
: 1,
});
} else {
this.setData({
["StickCommentData[" + index + "].is_like"]: 1,
["StickCommentData[" + index + "].link_count"]: this.data.StickCommentData[index].link_count ? this.data.StickCommentData[index].link_count + 1 : 1,
});
}
},
fail: function (res) {},
});
},
delBtn() {
if (this.data.host_comment_id && this.data.second_comment_id) {
this.setData({
commend_id: this.data.second_comment_id,
});
} else {
this.setData({
commend_id: this.data.host_comment_id,
});
}
this.setData({
commentManagement: false,
});
this.delReply();
},
delReply() {
let that = this;
let dataJson = {};
let urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.delete-comment");
dataJson.comment_id = this.data.commend_id;
app._postNetWork({
url: urlStr,
showToastIn: false,
data: dataJson,
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
that.getStickComment();
wx.showToast({
icon: "none",
title: res.msg,
duration: 1500,
});
} else {
wx.showToast({
icon: "none",
title: res.msg,
duration: 1500,
});
}
},
fail: function (res) {},
});
},
subMainBtn() {
if (!this.data.maincomment) {
wx.showToast({
icon: "none",
title: "请输入你的精彩评论",
duration: 1500,
});
return;
}
this.setData({
mainCommentShow: false,
});
this.getReplyComments("main");
},
getReplyComments(getType) {
let that = this;
let dataJson = {};
let urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.comment");
dataJson.invitation_id = that.data.amount_id;
if (getType == "main") {
dataJson.comment = that.data.maincomment;
} else {
dataJson.comment = that.data.replyContent;
}
if (getType == "reply") {
if (this.data.host_comment_id) {
dataJson.parent_id = this.data.host_comment_id;
}
if (this.data.second_comment_id) {
dataJson.subordinate_id = this.data.second_comment_id;
}
}
app._postNetWork({
url: urlStr,
showToastIn: false,
data: dataJson,
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
that.getStickComment();
wx.showToast({
icon: "none",
title: res.msg,
duration: 1500,
});
} else {
wx.showToast({
icon: "none",
title: res.msg,
duration: 1500,
});
}
},
fail: function (res) {},
});
},
getStickComment() {
this.setData({
comment_page: 1,
comment_total: 0,
});
let dataJson = {
invitation_id: this.data.amount_id,
};
let urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.get-comment-list");
app._postNetWork({
url: urlStr,
showToastIn: false,
data: dataJson,
success: (resdata) => {
var res = resdata.data;
if (res.result == 1) {
this.setData({
comment_total: res.data.last_page,
StickCommentData: res.data.data,
comment_total_count: res.data.total,
});
} else {
wx.showToast({
icon: "none",
title: res.msg,
duration: 1500,
});
}
},
fail: function (res) {},
});
},
replyCommentsBtn(e) {
let host_comment_id = e.currentTarget.dataset.hostcommentid;
let second_comment_id = e.currentTarget.dataset.secondcommentid;
let uname = e.currentTarget.dataset.uname;
let content = e.currentTarget.dataset.content;
let is_own = e.currentTarget.dataset.isown;
this.setData({
host_comment_id: host_comment_id,
second_comment_id: second_comment_id,
replyContent: "",
replyName: uname,
replyshowcontent: content,
});
console.log(this.data.replyContent);
if (is_own == 1) {
this.setData({
is_own: true,
});
} else {
this.setData({
is_own: false,
});
}
this.setData({
commentManagement: true,
});
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {},
// getSubject() {
// if (this.data.is_plugins==1) {
// if(this.data.AnswerID == this.data.amount_id){
// //防止重复一直请求答题
// this.includeRedpackID('vid');
// return;
// }
// this.data.AnswerID = this.data.amount_id;
// var urlStr = app.getNetAddresss("plugin.answer-reward.api.index.get-subject");
// app._getNetWork({
// url: urlStr,
// data: {
// vid: this.data.amount_id
// },
// success: (resdata) => {
// var res = resdata.data;
// if (res.result == 1) {
// if (res.data.status != 1) {
// wx.showToast({
// title: res.msg,
// icon: 'none',
// duration: 1500
// })
// this.data.myvideo.play();
// } else {
// if (res.data.subject != null) {
// // wx.navigateTo({
// // url: '/packageC/video_goods/videoAnswer/videoAnswer?vid=' + this.data.amount_id,
// // })
// this.data.myvideo.pause()
// let answerfilter = res.data.subject.has_many_answer.filter(function (item) {
// return item.content != '';
// });
// this.setData({
// integral_name:res.data.integral_name,
// subject:res.data.subject,
// ['subject.has_many_answer']:answerfilter,
// showVideoAnswer:true
// })
// }else{
// this.includeRedpackID('vid');
// }
// }
// } else {
// this.data.myvideo.play();
// this.includeRedpackID('vid',0,'fail',res.msg);
// }
// },
// fail: function (res) {
// console.log(res);
// }
// });
// }else{
// this.includeRedpackID('vid');
// return
// }
// },
// reward(evt){
// //短视频红包开启,设置观看完指定的视频后获得,
// //如果该视频开启了短视频答题,则需要先 答对 题目才可以获得红包奖励,
// //并且和原短视频答题设置的积分奖励同时获得,弹窗 只 弹出红包领取弹窗,不在显示获得积分弹窗!!
// let id = evt.currentTarget.dataset.id;
// console.log(evt);
// let urlStr = app.getNetAddresss("plugin.answer-reward.api.index.index");
// app._getNetWork({
// url: urlStr,
// data: {
// vid: this.data.amount_id,
// subject_id: this.data.subject.id,
// answer_id:id },
// success: (resdata)=> {
// let res = resdata.data;
// if(res.result!=1){
// this.setData({errorShow:true,showVideoAnswer:false});
// }else {
// if(res.data.status==0){
// wx.showToast({
// title: res.msg,
// icon: 'none',
// duration: 1500
// })
// }else if(res.data.status==1){
// this.setData({
// integral:res.data.integral
// });
// this.includeRedpackID('vid',0,'success');
// }
// }
// }
// });
// },
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {},
aaaa() {
console.log("执行加载更多");
},
getMoreStickComment() {
console.log("执行加载更多");
let json = {
invitation_id: this.data.amount_id,
};
console.log("执行加载更多", this.data.comment_loading);
if (this.data.comment_loading) return;
this.setData({
comment_loading: true,
});
let urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.get-comment-list");
if (this.data.comment_page >= this.data.comment_total) {
this.setData({
loading: true,
});
return;
} else {
this.setData({
comment_page: this.data.comment_page + 1,
});
json.page = this.data.comment_page;
app._postNetWork({
url: urlStr,
showToastIn: false,
data: json,
success: (resdata) => {
var res = resdata.data;
if (res.result == 1) {
var myData = res.data.data;
this.setData({
StickCommentData: this.data.StickCommentData.concat(myData),
comment_loading: false,
});
} else {
this.setData({
comment_page: this.data.comment_page - 1,
comment_loading: false,
});
}
},
fail: function (res) {},
});
}
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {},
/**
* 用户点击右上角分享
*/
onShareTimeline: function () {
var value = wx.getStorageSync("yz_uid");
var mid = "";
if (value) {
mid = value;
}
let json = {};
let shareImg = "";
if (this.data.popularVideo[this.data.realIndex] && this.data.popularVideo[this.data.realIndex].img) {
shareImg = this.data.popularVideo[this.data.realIndex].img;
}
json = {
title: this.data.showVideo.title ? this.data.showVideo.title : "",
query: "vid=" + this.data.amount_id + "&page=" + this.page + "&mid=" + mid + "&circleId=" + this.data.circleId,
};
if (shareImg) {
json.imageUrl = shareImg;
}
console.log(json);
return json;
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function (res) {
console.log(res);
var value = wx.getStorageSync("yz_uid");
var mid = "";
if (value) {
mid = value;
}
let json = {};
let shareImg = "";
if (this.data.popularVideo[this.data.realIndex] && this.data.popularVideo[this.data.realIndex].img) {
shareImg = this.data.popularVideo[this.data.realIndex].img;
}
// if (res.from == 'button') { 跟下面的一样 先注释
// console.log(this.data.amount_id,this.data.page,mid)
// if(this.data.cardFrom != 'card' && hat.data.cardFrom != 'my'){
// json = {
// title: this.data.showVideo.title ? this.data.showVideo.title : '',
// path: '/packageC/video_goods/VideoDetail/VideoDetail?vid=' + this.data.amount_id + '&mid=' + mid
// }
// }else {
// json = {
// title: this.data.showVideo.title ? this.data.showVideo.title : '',
// path: '/packageC/video_goods/VideoDetail/VideoDetail?vid=' + this.data.amount_id + '&page=' + this.data.page + '&mid=' + mid
// }
// }
// if(shareImg){
// json.imageUrl = shareImg;
// }
// return json
// }
json = {
title: this.data.showVideo.title ? this.data.showVideo.title : "",
path: "/packageH/circleCommunity/videoDetails/videoDetails?vid=" + this.data.amount_id + "&page=" + this.data.page + "&mid=" + mid + "&circleId=" + this.data.circleId,
};
if (shareImg) {
json.imageUrl = shareImg;
}
return json;
},
getDetail() {
let that = this;
var urlStr = app.getNetAddresss("plugin.video-share.frontend.video.getVideoGoods");
urlStr += "&video_goods_id=" + this.data.amount_id;
app._getNetWork({
url: urlStr,
// data: {
// json
// },
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
that.setData({
showVideo: res.data.video_goods,
});
that.getData(true);
} else {
wx.showToast({
title: res.msg,
icon: "none",
duration: 1500,
});
}
},
fail: function (res) {
console.log(res);
},
});
},
getData(flag) {
let that = this;
let urlStr;
if (this.data.cardFrom == "card") {
// var json = { page: this.data.page, card_id: this.data.card_id };
urlStr = app.getNetAddresss("plugin.business-card.frontend.controllers.card.paging.videos");
urlStr += "&page=" + this.data.page;
urlStr += "&card_id=" + this.data.card_id;
} else if (that.data.cardFrom == "my") {
urlStr = app.getNetAddresss("plugin.video-share.frontend.video.my-video");
urlStr += "&page=" + this.data.page;
urlStr += "&vid=" + this.data.amount_id;
urlStr += "&status=" + this.data.sta;
} else {
// var json = { page: this.data.page };
urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.get-circle-invitation-list");
urlStr += "&page=" + this.data.page;
urlStr += "&invitation_status=" + 2;
urlStr += "&circle_id=" + this.data.circleId;
}
app._getNetWork({
url: urlStr,
// data: {
// json
// },
success: function (resdata) {
var res = resdata.data;
if (res.result == 1) {
that.data.isLoadMore = true;
// 判断有没有开启 短视频答题奖励积分 插件
that.setData({
is_plugins: res.data.is_plugins,
});
//短视频红包
try {
// 判断有没有开启 短视频答题奖励积分 插件
that.setData({
is_plugins: res.data.is_plugins,
});
} catch (e) {
console.log(e);
}
//短视频红包
try {
if (res.data.video_redpack && res.data.video_redpack.is_open === 1) {
console.log("短视频红包================");
that.setData({
is_openRedpack: true,
openRedpackData: res.data.video_redpack.data,
});
for (let i = 0; i < that.data.openRedpackData.length; i++) {
if (that.data.openRedpackData[i].view_time_open_state === "1") {
that.data.openRedpackTimes.push(that.data.openRedpackData[i].view_time_data);
}
}
that.data.openRedpackTimes = that.data.openRedpackTimes.sort(function (a, b) {
return a - b;
});
console.log("短视频红包累计观看时长数组", that.data.openRedpackTimes);
}
} catch (error) {
console.log("error", error);
}
if (that.data.cardFrom == "card") {
that.data.total_page = res.data.last_page;
if (!that.data.total_page) {
that.data.total_page = 0;
}
that.setData({
popularVideo: res.data.data,
});
let popularVideoData = res.data.data;
if (that.data.amount_id) {
for (let i = 0; i < res.data.data.length; i++) {
if (res.data.data[i].id == that.data.amount_id) {
that.setData({
showVideo: res.data.data[i],
});
popularVideoData.splice(0, i);
that.setData({
popularVideo: popularVideoData,
});
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
that.setData({
firstcontent: true,
});
that.clickSwiperbtn(0);
return;
}
}
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
} else {
that.setData({
showVideo: that.data.popularVideo[0],
});
that.clickSwiperbtn(0);
}
} else if (that.data.cardFrom == "my") {
that.data.total_page = res.data.video.last_page;
if (!that.data.total_page) {
that.data.total_page = 0;
}
that.setData({
popularVideo: res.data.video.data,
});
let popularVideoData = res.data.video.data;
if (that.data.amount_id) {
for (let i = 0; i < res.data.video.data.length; i++) {
if (res.data.video.data[i].id == that.data.amount_id) {
that.setData({
showVideo: res.data.video.data[i],
});
popularVideoData.splice(0, i);
that.setData({
popularVideo: popularVideoData,
});
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
that.setData({
firstcontent: true,
});
that.clickSwiperbtn(0);
return;
}
}
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
} else {
that.setData({
showVideo: that.data.popularVideo[0],
});
that.clickSwiperbtn(0);
}
} else {
that.data.total_page = res.data.last_page;
if (!that.data.total_page) {
that.data.total_page = 0;
}
that.setData({
popularVideo: res.data.data,
});
let popularVideoData = res.data.data;
if (!flag) {
if (that.data.amount_id) {
for (let i = 0; i < res.data.data.length; i++) {
if (res.data.data[i].id == that.data.amount_id) {
that.setData({
showVideo: res.data.data[i],
});
popularVideoData.splice(0, i);
that.setData({
popularVideo: popularVideoData,
});
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
that.setData({
firstcontent: true,
});
that.clickSwiperbtn(0);
return;
}
}
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
} else {
that.setData({
showVideo: that.data.popularVideo[0],
});
that.clickSwiperbtn(0);
}
} else {
if (that.data.amount_id) {
for (let i = 0; i < res.data.list.data.length; i++) {
if (res.data.list.data[i].id == that.data.amount_id) {
popularVideoData.splice(i, 1);
break;
}
}
popularVideoData.unshift(that.data.showVideo);
that.setData({
popularVideo: popularVideoData,
});
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
that.clickSwiperbtn(0);
}
}
}
that.setData({
firstcontent: true,
});
} else {
wx.showToast({
title: res.msg,
icon: "none",
duration: 1500,
});
}
},
fail: function (res) {
console.log(res);
},
});
},
getinformation() {
try {
const res = wx.getSystemInfoSync();
let windowHeight = res.windowHeight;
let windowWidth = res.windowWidth;
this.setData({
heightauto: windowHeight + "px",
widthauto: windowWidth + "px",
});
this.data.screeheight = windowHeight;
} catch (e) {
// Do something when catch error
}
},
clickSwiperbtn(e) {
console.log(e);
let index = 0;
if (e.currentTarget) {
index = e.currentTarget.dataset.index;
} else {
index = e;
}
this.clickSwiper(index);
},
clickSwiper(e) {
let index = e;
console.log("zhixing");
if (this.data.popularVideo[index].show && this.data.amount_id === this.data.popularVideo[index].id) {
this.setData({
show: false,
["popularVideo[" + index + "].show"]: false,
});
this.data.myvideo.pause();
return;
}
this.judgmentpic(index);
this.setData({
show: true,
amount_id: this.data.popularVideo[index].id,
["popularVideo[" + index + "].show"]: true,
});
this.data.logID = 0;
this.data.myvideo.play();
this.getStickComment();
//this.data.getCommentFlag=true;
},
popularVideoChange(e) {
clearTimeout(this.data.cleartime);
let realIndex = e.detail.current;
let that = this;
that.data.realIndex = realIndex;
that.data.AnswerID = 0;
that.data.cumulativeDuration = parseInt(that.data.cumulativeDuration + that.data.currentDuration); //切换视频时计算累计
that.data.currentDuration = 0;
that.judgmentpic_2(realIndex);
},
judgmentpic_2(index) {
let realIndex = index;
let that = this;
try {
if (that.data.popularVideo[realIndex] && that.data.popularVideo[realIndex].cover) {
const query = wx.createSelectorQuery();
query.select("#pic_" + realIndex).boundingClientRect();
query.exec(function (res) {
let screeheight = that.data.screeheight;
if (res[0] && res[0].height) {
let imgheight = res[0].height;
if (imgheight > Math.ceil(screeheight * (7 / 8))) {
that.setData({
minStyle: false,
});
that.getvideomessage(realIndex);
} else {
that.setData({
minStyle: true,
});
that.getvideomessage(realIndex);
}
} else {
that.setData({
minStyle: true,
});
that.getvideomessage(realIndex);
}
});
} else {
that.setData({
minStyle: true,
});
that.getvideomessage(realIndex);
}
} catch (e) {
that.setData({
minStyle: true,
});
that.getvideomessage(realIndex);
//TODO handle the exception
}
},
getvideomessage(realIndex) {
let that = this;
if (realIndex == that.data.popularVideo.length - 2) {
that.getMoreData();
}
this.data.myvideo.pause();
that.setData({
show: false,
showVideo: that.data.popularVideo[realIndex],
});
if (realIndex === 0) {
this.setData({
["popularVideo[" + realIndex + "].show"]: false,
["popularVideo[" + (realIndex + 1) + "].show"]: false,
});
} else {
this.setData({
["popularVideo[" + (realIndex - 1) + "].show"]: false,
["popularVideo[" + realIndex + "].show"]: false,
});
if (that.data.popularVideo[realIndex + 1]) {
this.setData({
["popularVideo[" + (realIndex + 1) + "].show"]: false,
});
}
}
wx.setNavigationBarTitle({
title: that.data.showVideo.title,
});
wx.setStorageSync("circle_invitation_id", this.data.showVideo.id);
this.data.cleartime = setTimeout(() => {
that.clickSwiper(realIndex);
}, 300);
//切换结束时
},
getMoreData() {
const that = this;
that.data.isLoadMore = false; // 防止多次请求分页数据
if (this.data.page >= this.data.total_page) {
return;
} else {
this.data.page = this.data.page + 1;
let urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.get-circle-invitation-list");
app._getNetWork({
url: urlStr,
data: {
page: this.data.page,
},
success: function (resdata) {
that.data.isLoadMore = true;
var res = resdata.data;
if (res.result == 1) {
let myData = res.data.list.data;
that.setData({
popularVideo: that.data.popularVideo.concat(myData),
});
} else {
that.data.page = that.data.page - 1;
that.data.isLoadMore = false;
}
},
fail: function (res) {
console.log(res);
},
});
}
},
chooseUser(e) {
let item = e.currentTarget.dataset.item;
if (item.member.business_card != 0) {
wx.navigateTo({
url: "/packageB/member/business_card/BusinessCard/BusinessCard?card_id=" + item.member.business_card + "&mark=card",
});
}
},
toggleLike(e) {
let index = e.currentTarget.dataset.index;
// let item = e.currentTarget.dataset.item;
if (this.data.popularVideo[index].is_like == 0) {
this.setData({
["popularVideo[" + index + "].link_count"]: this.data.popularVideo[index].link_count + 1,
});
} else {
// if (this.data.popularVideo[index].link_count > 0) {
// this.setData({
// ['popularVideo[' + index + '].link_count']: this.data.popularVideo[index].link_count - 1
// })
// }
}
this.setData({
["popularVideo[" + index + "].is_like"]: true,
// ['popularVideo[' + index + '].is_like']: (this.data.popularVideo[index].is_like==0 ? 1 : 0)
});
// let that = this;
let urlStr = app.getNetAddresss("plugin.circle.frontend.circle-invitation.like");
let json = {
invitation_id: this.data.amount_id,
};
app._postNetWork({
url: urlStr,
showToastIn: false,
data: json,
success: (resdata) => {
var res = resdata.data;
app.tips(res.msg);
},
fail: function (res) {},
});
},
shareVideo() {
// this.setData({
// showShare: true
// })
},
close() {
this.setData({
showShare: false,
});
},
openComments() {
this.setData({
commentsShow: !this.data.commentsShow,
});
},
toGood(e) {
let item = e.currentTarget.dataset.item;
wx.navigateTo({
url: "/packageA/detail_v2/detail_v2?id=" + item.goods_id + "&circle_invitation_id=" + item.id,
});
},
judgmentpic(index) {
let realIndex = index;
let that = this;
const query = wx.createSelectorQuery();
query.select("#pic_" + realIndex).boundingClientRect();
query.exec(function (res) {
let screeheight = that.data.screeheight;
let imgheight = res[0].height;
if (imgheight > Math.ceil(screeheight * (7 / 8))) {
that.setData({
minStyle: false,
});
} else {
that.setData({
minStyle: true,
});
}
});
},
// onLoadedmetadata(event){
// // console.log("bindloadedmetadata---------------",event)
// if(this.data.maxTime == 0&&this.data.is_openRedpack){
// this.data.maxTime = parseInt(event.detail.duration)
// this.getViewTimelog();
// }else{
// this.data.maxTime = parseInt(event.detail.duration)
// }
// console.log('视频总时长',this.data.maxTime)
// },
// onTimeupdate(event){
// //注意video 使用wx:if="{{show}}"时在电脑端模拟器1.03.2101150版本上每暂停播放后会出现递增video实例但真机正常
// this.data.currentDuration = event.detail.currentTime
// let minute = parseInt((this.data.cumulativeDuration + this.data.currentDuration)/60);
// // console.log(event.detail.currentTime,"累计秒", parseInt((this.data.cumulativeDuration + this.data.currentDuration)), "累计分钟", minute);
// if(this.data.openRedpackTimes.indexOf(minute)>-1){
// //达到累计获奖时长
// this.data.openRedpackTimes.splice(0,1);
// console.log("删除一个累计时长条件",this.data.openRedpackTimes);
// this.includeRedpackID('time',minute);
// }
// return;
// },
endedPlay() {
console.log("播放结束");
// this.data.cumulativeDuration = parseInt(this.data.cumulativeDuration + this.data.currentDuration);//结束视频时计算累计
// this.data.currentDuration = 0;
//this.getSubject();
},
onPlaying() {
console.log("onPlaying=================");
// if(this.data.maxTime != 0&&this.data.is_openRedpack){
// this.getViewTimelog();
// }
},
// getViewTimelog(){
// if(this.data.logID == this.data.amount_id){
// return;
// }
// // console.log("1111111111111=========",this.data.logID,this.data.amount_id,this.data.maxTime)
// this.data.logID = this.data.amount_id;
// let urlStr = app.getNetAddresss('plugin.video-redpack.frontend.activity.logViewTime');
// let json = {
// video_id: this.data.amount_id,
// video_length:this.data.maxTime
// };
// app._postNetWork({
// url: urlStr,
// showToastIn: false,
// data: json,
// success: function (resdata) {},
// fail: function (res) {}
// });
// },
// includeRedpackID(type,value,status,text){
// if(this.data.is_openRedpack){
// if(status === 'success'){
// this.setData({
// showVideoAnswer:false,
// logID:0
// })
// }
// if(type=='time'){
// //累计时长获取活动id
// for (let i = 0; i < this.data.openRedpackData.length; i++) {
// if (this.data.openRedpackData[i].view_time_data === value) {
// this.data.activity_reward_id = this.data.openRedpackData[i].activity_id;
// console.log("达到红包累计时长",this.data.amount_id,this.data.activity_reward_id);
// this.getRedpackReward(1,1);
// return;
// }
// }
// }else if(type=='vid'){
// //判断当前视频id是否为短视频红包指定视频
// for (let i = 0; i < this.data.openRedpackData.length; i++) {
// if (this.data.openRedpackData[i].view_finish_ids.indexOf(this.data.amount_id)>-1) {
// this.data.activity_reward_id = this.data.openRedpackData[i].activity_id;
// console.log("短视频红包指定视频",this.data.amount_id,this.data.activity_reward_id);
// this.getRedpackReward(2,1);
// return;
// }
// }
// }
// if(status === 'success'){
// this.setData({
// showVideoAnswer:false,
// successShow:true
// })
// }
// if(status === 'fail'){
// wx.showToast({
// title: text,
// icon: 'none',
// duration: 1500
// })
// }
// this.data.myvideo.play();
// this.getViewTimelog();
// }else{
// if(status === 'success'){
// this.setData({
// showVideoAnswer:false,
// successShow:true
// })
// }
// if(status === 'fail'){
// wx.showToast({
// title: text,
// icon: 'none',
// duration: 1500
// })
// }
// }
// },
// getRedpackReward(reward_type,request_type){
// let that = this
// this.data.reward_type = reward_type
// let urlStr = app.getNetAddresss('plugin.video-redpack.frontend.activity.reward');
// let json = {
// video_id: this.data.amount_id,
// activity_id:this.data.activity_reward_id,
// reward_type:reward_type,
// request_type:request_type,
// video_length:this.data.maxTime
// };
// app._postNetWork({
// url: urlStr,
// showToastIn: false,
// data: json,
// success: function (resdata) {
// var res = resdata.data;
// if (res.result == 1) {
// if(request_type == 1){
// that.data.myvideo.pause()
// console.log("红包=================",that.data.myvideo)
// that.setData({
// redpack_info: res.data,
// showRedpack: true
// })
// if(res.data.bind_mobile==1&&res.data.member_bind_mobile==0){
// //开启绑定,但用户未绑定手机
// that.setData({
// bind_mobile: true
// })
// }
// }else{
// that.setData({
// ['redpack_info.amount']: res.data.amount,
// openRedpack: true
// })
// }
// } else {
// // that.data.myvideo.play();
// // that.getViewTimelog();
// wx.showToast({
// icon: 'none',
// title: res.msg,
// duration: 1500
// })
// }
// },
// fail: function (res) {}
// });
// },
// openRedpackM(){
// if(this.data.redpack_info.bind_mobile==1&&this.data.redpack_info.member_bind_mobile==0){
// //开启绑定,但用户未绑定手机
// this.getimgdata()
// this.setData({
// showVerification: true
// })
// return
// }else{
// this.getRedpackReward(this.data.reward_type,2)
// }
// },
//获取图片验证码
// getimgdata(data) {
// let that = this;
// let urlStr = app.getNetAddresss("home-page.getCaptcha");
// if(data) {
// if (data.captcha) {
// that.setData({
// imgcode: data.captcha.img
// })
// }
// }else {
// app._getNetWork({
// url: urlStr,
// validateBol:2,
// success: function(resdata) {
// var res = resdata.data;
// if (res.result == 1) {
// if (res.data.captcha) {
// that.setData({
// imgcode: res.data.captcha.img
// })
// }
// }
// },
// fail: function(res) {
// console.log(res);
// }
// });
// }
// },
// getPhoneNumber(e){
// let info = e.detail;
// if(e.detail.errMsg=='getPhoneNumber:ok'){
// this.getPhoneM(info)
// }else{
// this.setData({
// showVerification: true
// })
// }
// },
// getPhoneM(info){
// let that = this;
// wx.checkSession({
// success: (res) => {
// console.log(res,'checkSession')
// that.getSessionKey(info)
// },
// })
// },
// getSessionKey(info){
// let key = wx.getStorageSync('session');
// console.log(key,'缓存的session')
// let that = this;
// let urlStr = app.getNetAddresss('member.mini-decrypt.getSessionKey');
// app._postNetWork({
// url: urlStr,
// data:{
// session_key_id:key,
// not_validate_page:'0'
// },
// showToastIn: false,
// success: function(resdata) {
// var res = resdata.data;
// if (res.result == 1) {
// console.log(res,'获取session_key')
// if(res.result == 1){
// let keys = res.data.session_key_data.session_key;
// that.getPhone_index(info,keys)
// }
// } else {
// wx.showToast({
// icon: 'none',
// title: res.msg,
// duration: 1500
// });
// }
// },
// fail: function(res) {}
// });
// },
// getPhone_index(info,keys){
// console.log(info,keys)
// wx.showLoading({
// title: '加载中',
// })
// let arr ={
// info:info,
// session_key:keys
// }
// let that = this;
// let urlStr = app.getNetAddresss('member.mini-decrypt.index');
// app._postNetWork({
// url: urlStr,
// showToastIn: false,
// data: {
// para_arr:arr,
// not_validate_page:'0'
// },
// success: function(resdata) {
// var res = resdata.data;
// if (res.result == 1) {
// console.log(res)
// that.setData({
// 'form.mobile':res.data.purePhoneNumber,
// showVerification:true
// })
// wx.hideLoading({
// success: (res) => {},
// })
// } else {
// wx.hideLoading({
// success: (res) => {},
// })
// wx.showToast({
// icon: 'none',
// title: res.msg,
// duration: 1500
// });
// }
// },
// fail: function(res) {}
// });
// },
//绑定手机号的值
// mobileinp(e) {
// let val = e.detail.value;
// this.setData({
// "form.mobile": val.trim()
// })
// },
//绑定图形验证码的值
// captchainp(e) {
// let val = e.detail.value;
// this.setData({
// "form.captcha": val.trim()
// })
// },
//绑定验证码的值
// codeinp(e) {
// let val = e.detail.value;
// this.setData({
// "form.code": val.trim()
// })
// },
// sendCode(e) {
// if (this.data.start1) {
// return false
// }
// let time = 60;
// let that = this;
// that.setData({
// "start1": true,
// "codetext": "(" + time + ")秒后重新获取"
// })
// let set = setInterval(function() {
// that.setData({
// codetext: "(" + --time + ")秒后重新获取",
// })
// }, 1000);
// setTimeout(function() {
// that.setData({
// codetext: "获取短信验证码",
// start1: false
// })
// clearInterval(set);
// }, 60000);
// that.verificationCode(set);
// },
//发送验证码
// verificationCode(set) {
// let that = this;
// if (app._isTextEmpty(this.data.form.mobile)) {
// wx.showToast({
// icon: 'none',
// title: '请填写手机号',
// duration: 1500
// })
// that.setData({
// codetext: "获取短信验证码",
// start1: false
// })
// clearInterval(set);
// return;
// }
// if (app._isMoblie(this.data.form.mobile)) {
// wx.showToast({
// icon: 'none',
// title: '请填写正确的手机号',
// duration: 1500
// })
// return;
// }
// if (app._isTextEmpty(this.data.form.captcha) && this.data.imgcode) {
// wx.showToast({
// icon: 'none',
// title: '请填图形验证码',
// duration: 1500
// })
// that.setData({
// codetext: "获取短信验证码",
// start1: false
// })
// clearInterval(set);
// return
// } else {
// let urlStr = app.getNetAddresss("member.register.sendCodeV2");
// urlStr += '&mobile=' + this.data.form.mobile;
// urlStr += '&captcha=' + this.data.form.captcha;
// urlStr += '&code=' + this.data.form.code;
// // 发送获取验证码的请求
// app._getNetWork({
// url: urlStr,
// validateBol:2,
// success: function(resdata) {
// var res = resdata.data;
// if (res.result == 1) {
// wx.showToast({
// icon: 'none',
// title: '已发送',
// duration: 1500
// })
// } else {
// wx.showToast({
// icon: 'none',
// title: res.msg,
// duration: 1500
// })
// //刷新图形验证码
// that.setData({
// 'form.captcha': '',
// start1:false,
// codetext: "获取短信验证码",
// })
// clearTimeout(set)
// that.getimgdata();
// }
// },
// fail: function(res) {
// console.log(res);
// }
// });
// }
// },
// alterAction(){
// if (app._isTextEmpty(this.data.form.mobile)) {
// wx.showToast({
// icon: 'none',
// title: '请填写手机号',
// duration: 1500
// })
// return;
// }
// if (app._isMoblie(this.data.form.mobile)) {
// wx.showToast({
// icon: 'none',
// title: '请填写正确的手机号',
// duration: 1500
// })
// return;
// }
// if (app._isTextEmpty(this.data.form.code)) {
// wx.showToast({
// icon: 'none',
// title: '请填验证码',
// duration: 1500
// })
// return;
// }
// let urlStr = app.getNetAddresss("plugin.video-redpack.frontend.activity.bindMobile");
// app._postNetWork({
// url: urlStr,
// showToastIn: false,
// data: that.data.form,
// validateBol:2,
// success: function(resdata) {
// var res = resdata.data;
// if (res.result == 1) {
// console.log(that.data)
// that.getRedpackReward(that.data.reward_type,2)
// that.setData({
// showVerification:false,
// showRedpack:true
// })
// } else {
// wx.showToast({
// icon: 'none',
// title: res.msg,
// duration: 1500
// })
// }
// },
// fail: function(res) {}
// });
// },
// cloneVerification(){
// this.setData({
// showVerification:false,
// ['form.captcha']:'',
// ['form.code']:''
// })
// },
// cloneAnswer(){
// this.setData({
// errorShow:false,
// successShow:false,
// logID: 0,
// AnswerID:0
// })
// this.data.myvideo.play();
// this.getViewTimelog();
// },
// cloneRedpack(){
// this.setData({
// logID: 0,
// AnswerID:0,
// showRedpack: false,
// openRedpack:false
// })
// if(this.data.reward_type == 2){
// this.getViewTimelog();
// }
// this.data.myvideo.play();
// },
});