1
0

videoshare.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. var app = getApp();
  2. var utils = require("../../../utils/http");
  3. const util = require("../../../utils/util")
  4. let videoContext = null;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. imgUrl: app.globalData.imgUrl,
  11. videoUrl: '',
  12. video_id: '',
  13. title: '',
  14. btflag: false,
  15. loginFlag: false,
  16. phoneFlag: false,
  17. showTask: true,
  18. datashow: false,
  19. errorText: '请求错误!',
  20. oneButton: [{ text: '确定' }],
  21. ght: '100%',
  22. customers_num: "",
  23. hot: "",
  24. video_url: "",
  25. headimgurl: "",
  26. nickname: "",
  27. vid: "",
  28. star_num: "",
  29. editVideoFlag: true,
  30. shareuserid: "",
  31. videoflag: false,
  32. playBtn: true,
  33. collectflag: 0,
  34. startY: 0,
  35. endY: 0,
  36. type: '',
  37. videoObj: {},
  38. mobileflag: false,
  39. autoplay: true,
  40. covercustomerFlag: true,
  41. alertFlag: false,
  42. alerText: '',
  43. bType: "",
  44. pType: "",
  45. footflag: false,
  46. personMsg: app.globalData.personMsg,
  47. companyobj: app.globalData.companyobj,
  48. nowflag: false,
  49. wshareshow: false,
  50. showDsc: false,
  51. priceflag: false,
  52. controlShow: false,
  53. playflag: 2,//1是播放中,2是暂停
  54. isBroker: false,
  55. loading: false,
  56. showApproval: false,
  57. isfullScreen: false,
  58. remark: "",
  59. trackimgarr: [],
  60. nowimagearr: [],
  61. shareApprovallist: []
  62. },
  63. /**
  64. * 生命周期函数--监听页面加载
  65. */
  66. onLoad: function (options) {
  67. if (!!options.clg && options.clg == 2) {
  68. wx.reLaunch({
  69. url: '/pages/index/index?clientype=' + options.cty + "&cid=" + options.cid + "&clg=2",
  70. })
  71. return false;
  72. }
  73. var that = this;
  74. that.setData({
  75. video_id: options.vid
  76. })
  77. if (!!options.ty) {
  78. this.setData({
  79. bType: options.ty,
  80. showTask: false
  81. })
  82. }
  83. if (!!options.tp) {
  84. this.setData({
  85. pType: options.tp
  86. })
  87. }
  88. if (app.globalData.brokeruserId) {
  89. that.setData({
  90. isBroker: true
  91. })
  92. } else {
  93. that.setData({
  94. isBroker: false
  95. })
  96. }
  97. wx.showLoading({
  98. title: '加载中...',
  99. })
  100. that.sharemsg();
  101. },
  102. getPhoneNumberTap: function (res) {
  103. var that = this;
  104. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  105. that.setData({
  106. loading: true,
  107. })
  108. utils.$post({
  109. url: app.globalData.webUrl + 'api/users/setUserMobile',
  110. data: {
  111. encryptedData: res.detail.encryptedData,
  112. iv: res.detail.iv
  113. },
  114. header: {
  115. 'Authorization': 'bearer ' + app.globalData.token
  116. },
  117. success: function (r) {
  118. if (r.data.code == '0') {
  119. that.submitMsg(r.data.mobile);
  120. }
  121. }
  122. })
  123. }
  124. },
  125. /**
  126. * 提交注册数据
  127. */
  128. submitMsg(mobile) {
  129. var that = this;
  130. utils.$post({
  131. url: app.globalData.webUrl + 'api/agents/add_agents',
  132. header: {
  133. 'Authorization': 'bearer ' + app.globalData.token
  134. },
  135. data: {
  136. name: '',
  137. phone: mobile,
  138. employee_id: app.globalData.brokerEmployeeId,
  139. wechat: '',
  140. type: app.globalData.brokerType
  141. },
  142. success: function (res) {
  143. if (res.data.code == '0') {
  144. app.globalData.brokeruserId = res.data.data;
  145. that.setData({
  146. isBroker: true,
  147. loading: false,
  148. wshareshow: true
  149. })
  150. }
  151. }
  152. })
  153. },
  154. onFullScreenChange(e) {
  155. let isBol = e.detail.detail.fullScreen;
  156. this.setData({
  157. isfullScreen: isBol
  158. })
  159. },
  160. setpostertap: function () {
  161. if (this.data.bType == 'b') {
  162. wx.navigateTo({
  163. url: '/index/pages/setposter/setposter?type=video&aid=' + this.data.video_id + "&ty=b&listshare=",
  164. })
  165. } else {
  166. wx.navigateTo({
  167. url: '/index/pages/setposter/setposter?type=video&aid=' + this.data.video_id + "&listshare=",
  168. })
  169. }
  170. },
  171. /**
  172. * 生命周期函数--监听页面初次渲染完成
  173. */
  174. onReady: function () {
  175. },
  176. /**
  177. * 弹出报价弹窗
  178. */
  179. priceshowtap() {
  180. videoContext.pause();
  181. this.setData({
  182. priceflag: true
  183. })
  184. },
  185. /**
  186. * 关闭报价弹窗
  187. */
  188. closepricetap() {
  189. this.setData({
  190. priceflag: false
  191. })
  192. },
  193. showdscMsg: function () {
  194. if (this.data.videoObj.description.length > 28) {
  195. this.data.showDsc = !this.data.showDsc;
  196. this.setData({
  197. showDsc: this.data.showDsc
  198. })
  199. }
  200. },
  201. wsharetap: function (e) {
  202. var that = this;
  203. that.setData({
  204. wshareshow: true,
  205. })
  206. },
  207. videotap() {
  208. videoContext.play();
  209. wx.showLoading()
  210. },
  211. bindprogress() {
  212. setTimeout(() => {
  213. wx.hideLoading();
  214. },2000)
  215. this.setData({
  216. playflag: 1
  217. })
  218. },
  219. shareurltap: function (e) {
  220. var that = this;
  221. wx.showLoading({
  222. title: '加载中...',
  223. })
  224. if (this.data.bType == 'b') {
  225. util.schemefun('/share/pages/videoshare/videoshare', 'vid=' + that.data.video_id + '&userid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, that.data.video_id, 'video', '');
  226. } else {
  227. 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', '');
  228. }
  229. this.sharelogtap();
  230. },
  231. sendfriendtap() {
  232. this.sharelogtap();
  233. },
  234. sharelogtap: function () {
  235. var that = this;
  236. this.setData({
  237. nowflag: false,
  238. })
  239. utils.$post({
  240. url: app.globalData.webUrl + 'api/share/addlog',
  241. header: {
  242. 'Authorization': 'bearer ' + app.globalData.token
  243. },
  244. data: {
  245. id: that.data.video_id,
  246. type: 'video'
  247. },
  248. success: function (r) {
  249. }
  250. })
  251. },
  252. collecTap: function () {
  253. var that = this;
  254. var vurl = '';
  255. var videoObj = that.data.videoObj;
  256. if (videoObj.collect == '0') {
  257. vurl = "api/video/collect"
  258. } else {
  259. vurl = "api/video/collectCancel"
  260. }
  261. utils.$post({
  262. url: app.globalData.webUrl + vurl,
  263. header: {
  264. 'Authorization': 'bearer ' + app.globalData.token
  265. },
  266. data: {
  267. id: that.data.video_id,
  268. },
  269. success: function (res) {
  270. if (res.data.code == "0") {
  271. if (videoObj.collect == '0') {
  272. videoObj.collect = 1;
  273. that.setData({
  274. videoObj: videoObj,
  275. alertFlag: true,
  276. alerText: res.data.msg
  277. })
  278. setTimeout(function () {
  279. that.setData({
  280. alertFlag: false,
  281. })
  282. }, 1000)
  283. } else {
  284. videoObj.collect = 0;
  285. that.setData({
  286. videoObj: videoObj,
  287. alertFlag: true,
  288. alerText: res.data.msg
  289. })
  290. setTimeout(function () {
  291. that.setData({
  292. alertFlag: false,
  293. })
  294. }, 1000)
  295. }
  296. } else {
  297. if (res.data.msg == '您已收藏') {
  298. videoObj.collect = 1;
  299. that.setData({
  300. videoObj: videoObj
  301. })
  302. }
  303. }
  304. }
  305. })
  306. },
  307. sharemsg: function () {
  308. var that = this;
  309. utils.$post({
  310. url: app.globalData.webUrl + 'api/video/info',
  311. header: {
  312. 'Authorization': 'bearer ' + app.globalData.token
  313. },
  314. data: {
  315. video_id: that.data.video_id
  316. },
  317. success: function (r) {
  318. if (r.data.code == '0') {
  319. r.data.data.video_url = r.data.data.video_url;
  320. r.data.data.description = r.data.data.title + '#' + r.data.data.description + '#';
  321. that.setData({
  322. title: r.data.data.title,
  323. videoObj: r.data.data,
  324. autoplay: true
  325. })
  326. wx.setNavigationBarTitle({
  327. title: r.data.data.title
  328. })
  329. videoContext = that.selectComponent('#myVideo');
  330. videoContext.play();
  331. }
  332. setTimeout(() => {
  333. wx.hideLoading()
  334. },2000)
  335. }
  336. })
  337. },
  338. signpricetap() {
  339. wx.showToast({
  340. title: "您是员工无需报价!",
  341. icon: 'none',
  342. duration: 2000
  343. })
  344. },
  345. prelooktap() {
  346. if (!app.globalData.personMsg.binded.qrcode) {
  347. wx.showToast({
  348. title: "您的二维码为空,请上传二维码!",
  349. icon: 'none',
  350. duration: 2000
  351. })
  352. return false;
  353. }
  354. wx.previewImage({
  355. current: app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
  356. urls: [app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode]// 需要预览的图片http链接列表
  357. })
  358. },
  359. callphonetap: function () {
  360. wx.makePhoneCall({
  361. phoneNumber: app.globalData.personMsg.phone
  362. })
  363. },
  364. /**
  365. * 生命周期函数--监听页面显示
  366. */
  367. onShow: function () {
  368. this.setData({
  369. personMsg: app.globalData.personMsg,
  370. companyobj: app.globalData.companyobj,
  371. })
  372. },
  373. /**
  374. * 生命周期函数--监听页面隐藏
  375. */
  376. onHide: function () {
  377. },
  378. /**
  379. * 生命周期函数--监听页面卸载
  380. */
  381. onUnload: function () {
  382. },
  383. /**
  384. * 页面相关事件处理函数--监听用户下拉动作
  385. */
  386. onPullDownRefresh: function () {
  387. },
  388. /**
  389. * 页面上拉触底事件的处理函数
  390. */
  391. onReachBottom: function () {
  392. },
  393. onShareAppMessage: function () {
  394. var img = this.data.videoObj.cover_share_img?this.data.videoObj.cover_share_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');
  395. if (this.data.bType == 'b') {
  396. this.sharelogtap();
  397. return {
  398. title: this.data.videoObj.title,
  399. imageUrl: img,
  400. path: '/share/pages/videoshare/videoshare?vid=' + this.data.video_id + '&userid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
  401. }
  402. } else {
  403. this.sharelogtap();
  404. return {
  405. title: this.data.videoObj.title,
  406. imageUrl: img,
  407. path: '/share/pages/videoshare/videoshare?vid=' + this.data.video_id + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
  408. }
  409. }
  410. },
  411. onAddToFavorites(res) {
  412. var img = this.data.videoObj.cover_share_img?this.data.videoObj.cover_share_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');
  413. return {
  414. title: this.data.videoObj.title,
  415. imageUrl: img,
  416. query: 'cid=' + this.data.video_id + '&cty=' + app.globalData.clientype + '&clg=2',
  417. }
  418. }
  419. })