networkvideo.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. var app=getApp();
  2. var utils=require("../../utils/http");
  3. var customerflag=false;
  4. var stoptime=0;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. videoUrl:'',
  11. video_id:'',
  12. title:'',
  13. btflag:false,
  14. loginFlag:false,
  15. phoneFlag:false,
  16. errorText:'请求错误!',
  17. oneButton: [{text: '确定'}],
  18. ght:'100%',
  19. customers_num: "",
  20. hot: "",
  21. video_url: "",
  22. headimgurl: "",
  23. nickname: "",
  24. vid: "",
  25. star_num: "",
  26. editVideoFlag: true,
  27. shareuserid: "",
  28. customerFlag: true,
  29. videoflag:false,
  30. playBtn:true,
  31. collectflag:0,
  32. startY:0,
  33. endY:0,
  34. type:'',
  35. videoObj:{},
  36. mobileflag:false,
  37. autoplay:false,
  38. covercustomerFlag:true,
  39. share_user_id:'',
  40. sharepersonobj:app.globalData.sharepersonobj,
  41. companyobj:app.globalData.companyobj
  42. },
  43. /**
  44. * 生命周期函数--监听页面加载
  45. */
  46. onLoad: function (options) {
  47. var that=this;
  48. wx.getSystemInfo({
  49. success: (res) => {
  50. that.setData({
  51. videoHeight:res.windowHeight
  52. })
  53. }
  54. })
  55. app.globalData.sharevid=options.vid;
  56. that.setData({
  57. video_id:options.vid,
  58. share_user_id:options.share_user_id,
  59. companyobj:app.globalData.companyobj
  60. })
  61. wx.showLoading({
  62. title: '加载中',
  63. })
  64. // app.globalData.shareuserid=app.globalData.personMsg.id;
  65. that.sharemsg();
  66. wx.hideLoading();
  67. },
  68. /**
  69. * 生命周期函数--监听页面初次渲染完成
  70. */
  71. onReady: function () {
  72. },
  73. movestart:function(e){
  74. var that=this;
  75. console.log(e)
  76. that.setData({
  77. startY:e.changedTouches[0].pageY
  78. })
  79. },
  80. moveTap:function(e){
  81. var that=this;
  82. },
  83. touchend:function(e){
  84. var that=this;
  85. console.log(e)
  86. that.setData({
  87. endY:e.changedTouches[0].pageY
  88. })
  89. var move=that.data.endY-that.data.startY;
  90. if(move>=50&&!!app.globalData.token){
  91. that.setData({
  92. type:'last'
  93. })
  94. const videoContext = that.selectComponent('#myVideo');
  95. videoContext.stop();
  96. that.decoratemsg();
  97. }else if(move<=-50&&!!app.globalData.token){
  98. that.setData({
  99. type:'next'
  100. })
  101. const videoContext = that.selectComponent('#myVideo');
  102. videoContext.stop();
  103. that.decoratemsg();
  104. }
  105. },
  106. // 装修端翻页视频详情
  107. decoratemsg:function(){
  108. var that=this;
  109. utils.$post({
  110. url: app.globalData.webUrl + 'api/video/videoPage',
  111. header: {
  112. 'Authorization':'bearer '+app.globalData.token
  113. },
  114. data: {
  115. video_id:that.data.video_id,
  116. desc:that.data.type,
  117. user_id:app.globalData.personMsg.id
  118. },
  119. success: function (r) {
  120. wx.hideLoading();
  121. if(r.data.code=='0'){
  122. r.data.data.video_url=app.globalData.imgUrl+r.data.data.video_url;
  123. that.setData({
  124. title:r.data.data.title,
  125. videoObj:r.data.data,
  126. customerFlag:true,
  127. autoplay:true,
  128. video_id:r.data.data.id
  129. })
  130. wx.setNavigationBarTitle({
  131. title: r.data.data.title
  132. })
  133. const videoContext = that.selectComponent('#myVideo');
  134. videoContext.play();
  135. }else{
  136. that.setData({
  137. title:'视频转发'
  138. })
  139. }
  140. }
  141. })
  142. },
  143. minefun:function(){
  144. },
  145. collecTap:function(){
  146. var that=this;
  147. var vurl='';
  148. var videoObj=that.data.videoObj;
  149. if(videoObj.collect=='0'){
  150. vurl="api/video/collect"
  151. }else{
  152. vurl="api/video/collectCancel"
  153. }
  154. utils.$post({
  155. url: app.globalData.webUrl + vurl,
  156. header: {
  157. 'Authorization':'bearer '+app.globalData.token
  158. },
  159. data:{
  160. id: that.data.video_id,
  161. },
  162. success: function (res) {
  163. if (res.data.code == "0") {
  164. if(videoObj.collect=='0'){
  165. videoObj.collect=1;
  166. wx.showToast({
  167. title: res.data.msg,
  168. icon: "none",
  169. duration:2000
  170. });
  171. that.setData({
  172. videoObj:videoObj
  173. })
  174. }else{
  175. videoObj.collect=0;
  176. wx.showToast({
  177. title: res.data.msg,
  178. icon: "none",
  179. duration:2000
  180. });
  181. that.setData({
  182. videoObj:videoObj
  183. })
  184. }
  185. } else {
  186. if(res.data.msg=='您已收藏'){
  187. videoObj.collect=1;
  188. that.setData({
  189. videoObj:videoObj
  190. })
  191. }
  192. }
  193. }
  194. })
  195. },
  196. clickzanTap:function(){
  197. var that=this;
  198. var videoObj=that.data.videoObj;
  199. utils.$post({
  200. url: app.globalData.webUrl + 'api/video/star',
  201. header: {
  202. 'Authorization':'bearer '+app.globalData.token
  203. },
  204. data:{
  205. video_id: that.data.video_id,
  206. },
  207. success: function (res) {
  208. wx.showToast({
  209. title: res.data.msg,
  210. icon: "none",
  211. duration:2000
  212. });
  213. if (res.data.code == '0') {
  214. if(res.data.msg=='点赞成功'){
  215. videoObj.star_num = videoObj.star_num * 1 + 1;
  216. videoObj.stared=1;
  217. }else{
  218. videoObj.star_num = videoObj.star_num * 1 - 1;
  219. videoObj.stared=0;
  220. }
  221. that.setData({
  222. videoObj:videoObj
  223. })
  224. }
  225. }
  226. })
  227. },
  228. editTap:function(){
  229. const videoContext = this.selectComponent('#myVideo');
  230. videoContext.pause()
  231. wx.navigateTo({
  232. url: "/pages/videoreprint/videoreprint?vid="+this.data.video_id,
  233. });
  234. },
  235. sharemsg:function(){
  236. var that=this;
  237. utils.$post({
  238. url: app.globalData.webUrl + 'client/video/info',
  239. header: {
  240. 'Authorization':'bearer '+app.globalData.token
  241. },
  242. data: {
  243. video_id:that.data.video_id
  244. },
  245. success: function (r) {
  246. wx.hideLoading();
  247. if(r.data.code=='0'){
  248. r.data.data.video_url=r.data.data.video_url;
  249. that.setData({
  250. title:r.data.data.title,
  251. videoObj:r.data.data,
  252. customerFlag:true,
  253. autoplay:true
  254. })
  255. wx.setNavigationBarTitle({
  256. title: r.data.data.title
  257. })
  258. const videoContext = that.selectComponent('#myVideo');
  259. videoContext.play();
  260. }else{
  261. that.setData({
  262. title:'视频转发'
  263. })
  264. }
  265. }
  266. })
  267. },
  268. /**
  269. * 生命周期函数--监听页面显示
  270. */
  271. onShow: function () {
  272. // wx.hideHomeButton();
  273. this.setData({
  274. companyobj:app.globalData.companyobj
  275. })
  276. },
  277. /**
  278. * 生命周期函数--监听页面隐藏
  279. */
  280. onHide: function () {
  281. var timearr=app.globalData.timearr,flag=false;
  282. for(var i=0;i<timearr.length;i++){
  283. if(timearr[i].type=='smallnetvideomsg'){
  284. timearr[i].time=timearr[i].time*1+stoptime*1;
  285. flag=true;
  286. }
  287. }
  288. if(!flag){
  289. var obj={
  290. type:'smallnetvideomsg',
  291. time:stoptime
  292. };
  293. app.globalData.timearr.push(obj);
  294. }else{
  295. app.globalData.timearr=timearr;
  296. }
  297. },
  298. /**
  299. * 生命周期函数--监听页面卸载
  300. */
  301. onUnload: function () {
  302. },
  303. /**
  304. * 页面相关事件处理函数--监听用户下拉动作
  305. */
  306. onPullDownRefresh: function () {
  307. },
  308. /**
  309. * 页面上拉触底事件的处理函数
  310. */
  311. onReachBottom: function () {
  312. },
  313. /**
  314. * 用户点击右上角分享
  315. */
  316. // onShareAppMessage: function () {
  317. // return {
  318. // title: '我是'+app.globalData.sharename+",这是我的个人微网。",
  319. // imageUrl:"../../img/weiw.png",
  320. // path: '/pages/microgrid/microgrid?share_user_id='+this.data.share_user_id+"&sharename="+app.globalData.sharename
  321. // }
  322. // }
  323. })