videoshare.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. var app=getApp();
  2. var utils=require("../../../utils/http");
  3. const util=require("../../../utils/util")
  4. let videoContext=null;
  5. var customerflag=false,stoptime=0;
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. imgUrl: app.globalData.imgUrl,
  12. videoUrl:'',
  13. video_id:'',
  14. title:'',
  15. btflag:false,
  16. loginFlag:false,
  17. phoneFlag:false,
  18. errorText:'请求错误!',
  19. oneButton: [{text: '确定'}],
  20. ght:'100%',
  21. customers_num: "",
  22. hot: "",
  23. video_url: "",
  24. headimgurl: "",
  25. nickname: "",
  26. vid: "",
  27. star_num: "",
  28. editVideoFlag: true,
  29. shareuserid: "",
  30. videoflag:false,
  31. playBtn:true,
  32. collectflag:0,
  33. startY:0,
  34. endY:0,
  35. type:'',
  36. videoObj:{},
  37. mobileflag:false,
  38. autoplay:true,
  39. covercustomerFlag:true,
  40. alertFlag:false,
  41. alerText:'',
  42. footflag:false,
  43. personMsg:app.globalData.personMsg,
  44. companyobj:app.globalData.companyobj,
  45. nowflag:false,
  46. wshareshow:false,
  47. showDsc: false,
  48. priceflag: false,
  49. controlShow: false,
  50. playflag: 2,//1是播放中,2是暂停,3是加载中
  51. },
  52. /**
  53. * 生命周期函数--监听页面加载
  54. */
  55. onLoad: function (options) {
  56. var that=this;
  57. that.setData({
  58. video_id:options.vid
  59. })
  60. wx.showLoading({
  61. title: '加载中...',
  62. })
  63. that.sharemsg();
  64. },
  65. setpostertap: function () {
  66. wx.navigateTo({
  67. url: '/index/pages/setposter/setposter?type=video&aid='+this.data.video_id+"&listshare=",
  68. })
  69. },
  70. /**
  71. * 生命周期函数--监听页面初次渲染完成
  72. */
  73. onReady: function () {
  74. },
  75. /**
  76. * 弹出报价弹窗
  77. */
  78. priceshowtap() {
  79. this.setData({
  80. priceflag: true
  81. })
  82. },
  83. /**
  84. * 关闭报价弹窗
  85. */
  86. closepricetap() {
  87. this.setData({
  88. priceflag: false
  89. })
  90. },
  91. showdscMsg: function () {
  92. if (this.data.videoObj.description.length > 28) {
  93. this.data.showDsc = !this.data.showDsc;
  94. this.setData({
  95. showDsc: this.data.showDsc
  96. })
  97. }
  98. },
  99. wsharetap:function(e){
  100. var that=this;
  101. that.setData({
  102. wshareshow:true,
  103. })
  104. },
  105. shareurltap:function(e){
  106. var that=this;
  107. wx.showLoading({
  108. title: '加载中...',
  109. })
  110. 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','');
  111. this.sharelogtap();
  112. },
  113. sendfriendtap(){
  114. this.sharelogtap();
  115. },
  116. sharelogtap:function(){
  117. var that=this;
  118. this.setData({
  119. nowflag:false,
  120. })
  121. utils.$post({
  122. url: app.globalData.webUrl + 'api/share/addlog',
  123. header: {
  124. 'Authorization':'bearer '+app.globalData.token
  125. },
  126. data: {
  127. id:that.data.video_id,
  128. type:'video'
  129. },
  130. success: function (r) {
  131. }
  132. })
  133. },
  134. collecTap:function(){
  135. var that=this;
  136. var vurl='';
  137. var videoObj=that.data.videoObj;
  138. if(videoObj.collect=='0'){
  139. vurl="api/video/collect"
  140. }else{
  141. vurl="api/video/collectCancel"
  142. }
  143. utils.$post({
  144. url: app.globalData.webUrl + vurl,
  145. header: {
  146. 'Authorization':'bearer '+app.globalData.token
  147. },
  148. data:{
  149. id: that.data.video_id,
  150. },
  151. success: function (res) {
  152. if (res.data.code == "0") {
  153. if(videoObj.collect=='0'){
  154. videoObj.collect=1;
  155. that.setData({
  156. videoObj:videoObj,
  157. alertFlag:true,
  158. alerText:res.data.msg
  159. })
  160. setTimeout(function(){
  161. that.setData({
  162. alertFlag:false,
  163. })
  164. },1000)
  165. }else{
  166. videoObj.collect=0;
  167. that.setData({
  168. videoObj:videoObj,
  169. alertFlag:true,
  170. alerText:res.data.msg
  171. })
  172. setTimeout(function(){
  173. that.setData({
  174. alertFlag:false,
  175. })
  176. },1000)
  177. }
  178. } else {
  179. if(res.data.msg=='您已收藏'){
  180. videoObj.collect=1;
  181. that.setData({
  182. videoObj:videoObj
  183. })
  184. }
  185. }
  186. }
  187. })
  188. },
  189. sharemsg:function(){
  190. var that=this;
  191. utils.$post({
  192. url: app.globalData.webUrl + 'api/video/info',
  193. header: {
  194. 'Authorization':'bearer '+app.globalData.token
  195. },
  196. data: {
  197. video_id:that.data.video_id
  198. },
  199. success: function (r) {
  200. if(r.data.code=='0'){
  201. r.data.data.video_url=r.data.data.video_url;
  202. r.data.data.description = r.data.data.title + '#' + r.data.data.description + '#';
  203. that.setData({
  204. title:r.data.data.title,
  205. videoObj:r.data.data,
  206. autoplay:true
  207. })
  208. wx.setNavigationBarTitle({
  209. title: r.data.data.title
  210. })
  211. const videoContext = that.selectComponent('#myVideo');
  212. videoContext.play();
  213. }
  214. wx.hideLoading()
  215. }
  216. })
  217. },
  218. signpricetap(){
  219. wx.showToast({
  220. title: "您是员工无需报价!",
  221. icon: 'none',
  222. duration: 2000
  223. })
  224. },
  225. prelooktap(){
  226. if(!app.globalData.personMsg.binded.qrcode){
  227. wx.showToast({
  228. title: "您的二维码为空,请上传二维码!",
  229. icon: 'none',
  230. duration: 2000
  231. })
  232. return false;
  233. }
  234. wx.previewImage({
  235. current: app.globalData.imgUrl+app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
  236. urls: [app.globalData.imgUrl+app.globalData.personMsg.binded.qrcode]// 需要预览的图片http链接列表
  237. })
  238. },
  239. callphonetap:function(){
  240. wx.makePhoneCall({
  241. phoneNumber: app.globalData.personMsg.phone
  242. })
  243. },
  244. /**
  245. * 生命周期函数--监听页面显示
  246. */
  247. onShow: function () {
  248. this.setData({
  249. personMsg:app.globalData.personMsg,
  250. companyobj:app.globalData.companyobj,
  251. })
  252. },
  253. /**
  254. * 生命周期函数--监听页面隐藏
  255. */
  256. onHide: function () {
  257. },
  258. /**
  259. * 生命周期函数--监听页面卸载
  260. */
  261. onUnload: function () {
  262. },
  263. /**
  264. * 页面相关事件处理函数--监听用户下拉动作
  265. */
  266. onPullDownRefresh: function () {
  267. },
  268. /**
  269. * 页面上拉触底事件的处理函数
  270. */
  271. onReachBottom: function () {
  272. },
  273. onShareAppMessage: function () {
  274. this.sharelogtap();
  275. 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');
  276. return {
  277. title: this.data.videoObj.title,
  278. imageUrl: img,
  279. path: '/share/pages/videoshare/videoshare?vid='+this.data.video_id+'&userid='+app.globalData.personMsg.id+'&ctp='+app.globalData.clientype
  280. }
  281. }
  282. })