publicpraisemsg.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. const app = getApp();
  2. var utils = require("../../../utils/http");
  3. let time = 0;
  4. var timer = null,
  5. videoContext = null;
  6. var designTimer = null;
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. imgUrl: app.globalData.imgUrl,
  13. eid: '',
  14. scrollTop: 0,
  15. evidencemsg: {},
  16. showAddress: false,
  17. showAction: false,
  18. loginFlag: false,
  19. mobileflag: false,
  20. canIUseGetUserProfile: false,
  21. lastId: '',
  22. nextId: '',
  23. companyName: '',
  24. articlelogin: true,
  25. datashow: false,
  26. shareobj: {},
  27. top: app.globalData.statusBarHeight,
  28. hgt: app.globalData.titleBarHeight,
  29. employeeflag: false, //false是用户,true是员工
  30. customerFlag: true,
  31. companyobj: {},
  32. type: '',
  33. priceflag: false,
  34. showDsc: false,
  35. designPlan: false,
  36. playflag: 2,//1是播放中,2是暂停
  37. isBroker: false,
  38. showMask: false,
  39. isfullScreen: false,
  40. fPhone: "",
  41. agid: "",
  42. isAgree: false
  43. },
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */
  47. onLoad: function (options) {
  48. var that = this;
  49. time = 0;
  50. that.setData({
  51. top: app.globalData.statusBarHeight,
  52. hgt: app.globalData.titleBarHeight,
  53. })
  54. wx.hideHomeButton();
  55. if (wx.getUserProfile) {
  56. this.setData({
  57. canIUseGetUserProfile: true
  58. })
  59. }
  60. if (options.type) {
  61. this.setData({
  62. type: options.type
  63. })
  64. }
  65. if (!!options.scene) {
  66. options = unescape(options.scene);
  67. let arr = options.split('&');
  68. let obj = {};
  69. for (let i = 0; i < arr.length; i++) {
  70. let arr1 = arr[i].split('=');
  71. obj[arr1[0]] = arr1[1];
  72. }
  73. if (obj.g) {
  74. app.globalData.shareuserid = obj.u;
  75. that.setData({
  76. eid: obj.e,
  77. isBroker: true,
  78. agid: obj.g
  79. })
  80. app.globalData.clientype = obj.c;
  81. app.globalData.brokeruserId = obj.g;
  82. } else {
  83. app.globalData.shareuserid = obj.uid;
  84. that.setData({
  85. eid: obj.eid
  86. })
  87. app.globalData.clientype = obj.ctp;
  88. }
  89. } else {
  90. app.globalData.shareuserid = options.uid;
  91. that.setData({
  92. eid: options.eid
  93. })
  94. app.globalData.clientype = options.ctp;
  95. if (!!options.agid) {
  96. that.setData({
  97. isBroker: true,
  98. agid: options.agid
  99. })
  100. app.globalData.brokeruserId = options.agid;
  101. }
  102. }
  103. },
  104. //用户同意隐私协议
  105. agreePrivacy() {
  106. this.setData({
  107. isAgree: true
  108. })
  109. wx.showLoading({
  110. title: '加载中...',
  111. })
  112. this.logindata();
  113. },
  114. showDscContent: function () {
  115. if (this.data.evidencemsg.desc.length > 29) {
  116. this.data.showDsc = !this.data.showDsc;
  117. this.setData({
  118. showDsc: this.data.showDsc
  119. })
  120. }
  121. },
  122. onFullScreenChange(e) {
  123. let isBol = e.detail.detail.fullScreen;
  124. this.setData({
  125. isfullScreen: isBol
  126. })
  127. },
  128. golastap: function () {
  129. wx.navigateBack({
  130. delta: 1,
  131. success:function(r){
  132. },
  133. fail:function(r){
  134. wx.reLaunch({
  135. url: '/pages/index/index?state=1',
  136. })
  137. },
  138. })
  139. },
  140. goindextap: function () {
  141. if(!this.data.employeeflag){
  142. wx.reLaunch({
  143. url: '/pages/index/index',
  144. })
  145. }else{
  146. wx.reLaunch({
  147. url: '/pages/consoledesk/consoledesk',
  148. })
  149. }
  150. },
  151. sharecompany: function () {
  152. const that = this;
  153. utils.$post({
  154. url: app.globalData.webUrl + 'client/index/content_belong_company',
  155. header: {
  156. 'Authorization': 'bearer ' + app.globalData.token
  157. },
  158. data: {
  159. client_type: app.globalData.clientype,
  160. uid: app.globalData.shareuserid
  161. },
  162. success: function (res) {
  163. if (res.data.code == '0') {
  164. app.globalData.companyobj = res.data.data;
  165. app.globalData.currentUserId = res.data.data.employee_id || '';
  166. that.setData({
  167. companyobj: res.data.data
  168. })
  169. }
  170. },
  171. complete(res) {
  172. wx.hideLoading()
  173. }
  174. })
  175. },
  176. logindata: function () {
  177. var that = this;
  178. wx.showLoading();
  179. wx.login({
  180. success: function (data) {
  181. if (data.errMsg == 'login:ok') {
  182. utils.$post({
  183. url: app.globalData.webUrl + 'api/users/code2session',
  184. data: {
  185. code: data.code,
  186. share: app.globalData.shareuserid,
  187. client_type: app.globalData.clientype,
  188. share_agent_id: app.globalData.brokeruserId
  189. },
  190. success: function (r) {
  191. if (r.data.code == '0') {
  192. app.globalData.token = r.data.token;
  193. app.globalData.sharepersonobj = r.data.share;
  194. that.setData({
  195. shareobj: app.globalData.sharepersonobj,
  196. companyName: r.data.company
  197. })
  198. that.sharecompany();
  199. app.globalData.companyname = r.data.company;
  200. app.globalData.official_openid = r.data.official_openid;
  201. app.globalData.agentEmployeEid = r.data.agent_employee_id;
  202. app.globalData.personMsg = r.data.user;
  203. if (!!r.data.user.phone) {
  204. app.globalData.sharename = !!r.data.share ? r.data.share.nickname : r.data.user.nickname;
  205. app.globalData.use_id = r.data.user.id;
  206. app.globalData.userflag = false; //有个人信息
  207. var nickname = r.data.user.nickname;
  208. var phone = r.data.user.phone;
  209. that.setData({
  210. fPhone: phone,
  211. loginFlag: false,
  212. employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false,
  213. articlelogin: true,
  214. mobileflag: false,
  215. articlelogin: true
  216. })
  217. if (!!r.data.user.binded && r.data.user.binded.state == '在职') {
  218. app.globalData.currentUserId = r.data.user.binded.id;
  219. }
  220. var obj = {
  221. detail: 1
  222. }
  223. that.evidencefun(obj);
  224. } else {
  225. that.evidencefun();
  226. wx.hideLoading();
  227. that.setData({
  228. articlelogin: false,
  229. loginFlag: false,
  230. mobileflag: true
  231. })
  232. }
  233. }
  234. wx.hideLoading();
  235. }
  236. })
  237. }
  238. }
  239. })
  240. },
  241. cancelGetPhone() {
  242. designTimer = setTimeout(() => {
  243. this.setData({
  244. designPlan: true
  245. })
  246. }, 4000)
  247. },
  248. priceshowtap() {
  249. if (videoContext) {
  250. videoContext.pause();
  251. }
  252. this.setData({
  253. priceflag: true
  254. })
  255. },
  256. closepricetap() {
  257. this.setData({
  258. priceflag: false
  259. })
  260. },
  261. closeDesigntap(e) {
  262. if (designTimer) {
  263. clearTimeout(designTimer);
  264. }
  265. if (e.detail.type == 'success') {
  266. this.setData({
  267. designPlan: false
  268. })
  269. } else {
  270. this.setData({
  271. designPlan: false
  272. })
  273. }
  274. },
  275. /**
  276. * 生命周期函数--监听页面初次渲染完成
  277. */
  278. onReady: function () { },
  279. prelooktap() {
  280. if (!app.globalData.sharepersonobj.qrcode) {
  281. wx.showToast({
  282. title: "当前专属客服的二维码为空!",
  283. icon: 'none',
  284. duration: 2000
  285. })
  286. return false;
  287. }
  288. wx.previewImage({
  289. current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  290. urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode] // 需要预览的图片http链接列表
  291. })
  292. },
  293. /**
  294. * 前往个人名片
  295. */
  296. toPageNameCard() {
  297. wx.navigateTo({
  298. url: '/share/pages/shareCard/shareCard?uid=' + app.globalData.shareuserid + '&empid=' + app.globalData.currentUserId + '&ctp=' + app.globalData.clientype + '&ftype=share',
  299. })
  300. },
  301. operateBtn() {
  302. this.setData({
  303. showAction: false
  304. })
  305. },
  306. callphonetap: function () {
  307. wx.makePhoneCall({
  308. phoneNumber: app.globalData.sharepersonobj.phone
  309. })
  310. },
  311. evidencefun: function (type) {
  312. var that = this;
  313. utils.$get({
  314. url: app.globalData.webUrl + 'client/evidencedetail',
  315. header: {
  316. 'Authorization': 'bearer ' + app.globalData.token
  317. },
  318. data: {
  319. id: that.data.eid,
  320. uid: !!app.globalData.personMsg.id ? app.globalData.personMsg.id : app.globalData.shareuserid,
  321. },
  322. success: function (res) {
  323. setTimeout(function () {
  324. wx.hideLoading()
  325. }, 400)
  326. if (res.data.code == '0') {
  327. res.data.data.desc = res.data.data.title + '#' + res.data.data.desc + '#';
  328. that.setData({
  329. evidencemsg: res.data.data,
  330. lastId: res.data.lastId,
  331. nextId: res.data.nextId,
  332. })
  333. // wx.setNavigationBarTitle({
  334. // title: res.data.data.title
  335. // })
  336. if (res.data.data.difference == 1) {
  337. videoContext = that.selectComponent("#myVideo1");
  338. if (!!type && type.detail == '1') {
  339. that.setData({
  340. articlelogin: true,
  341. phoneFlag: false,
  342. autoplay: true
  343. })
  344. videoContext.play();
  345. }
  346. } else {
  347. if (!!type && type.detail == '1') {
  348. that.setData({
  349. articlelogin: true,
  350. phoneFlag: false,
  351. })
  352. }
  353. }
  354. }
  355. },
  356. fail() {
  357. setTimeout(function () {
  358. wx.hideLoading()
  359. }, 400)
  360. }
  361. })
  362. },
  363. lookevidencefun() { },
  364. evidencesharetap: function () {
  365. var that = this;
  366. utils.$post({
  367. url: app.globalData.webUrl + 'api/share/addlog',
  368. header: {
  369. 'Authorization': 'bearer ' + app.globalData.token
  370. },
  371. data: {
  372. id: that.data.eid,
  373. type: 'materialEvidence'
  374. },
  375. success: function (r) { }
  376. })
  377. },
  378. hiddenMaskFunc() {
  379. this.setData({
  380. showMask: false
  381. })
  382. },
  383. getPhoneNumberTap: function (res) {
  384. var that = this;
  385. let type = res.currentTarget.dataset.type;
  386. that.setData({
  387. articlelogin: true,
  388. phoneFlag: false,
  389. })
  390. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  391. utils.$post({
  392. url: app.globalData.webUrl + 'api/users/setUserMobile',
  393. data: {
  394. encryptedData: res.detail.encryptedData,
  395. iv: res.detail.iv
  396. },
  397. header: {
  398. 'Authorization': 'bearer ' + app.globalData.token
  399. },
  400. success: function (r) {
  401. if (r.data.code == '0') {
  402. app.globalData.phone = true;
  403. that.setData({
  404. phoneFlag: false,
  405. articlelogin: true,
  406. fPhone: r.data.mobile,
  407. })
  408. if (type == 'broker') {
  409. that.setData({
  410. showMask: true
  411. })
  412. return false;
  413. }
  414. videoContext.play();
  415. } else {
  416. that.setData({
  417. errorText: r.data.msg,
  418. errorflag: true
  419. })
  420. }
  421. }
  422. })
  423. } else {
  424. this.setData({
  425. showMask: true
  426. })
  427. }
  428. },
  429. videotap() {
  430. videoContext.play();
  431. wx.showLoading()
  432. },
  433. bindprogress() {
  434. wx.hideLoading();
  435. this.setData({
  436. playflag: 1
  437. })
  438. },
  439. pretap: function () {
  440. if (!!this.data.lastId) {
  441. wx.redirectTo({
  442. url: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.lastId,
  443. })
  444. }
  445. },
  446. nextap: function () {
  447. if (!!this.data.nextId) {
  448. wx.redirectTo({
  449. url: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.nextId,
  450. })
  451. }
  452. },
  453. /**
  454. * 展示地址
  455. */
  456. showAddressName(e) {
  457. let type = e.currentTarget.dataset.type;
  458. if (type == 'hide') {
  459. this.setData({
  460. showAddress: false
  461. })
  462. } else {
  463. this.setData({
  464. showAddress: true
  465. })
  466. }
  467. },
  468. /**
  469. * 生命周期函数--监听页面显示
  470. */
  471. onShow: function () {
  472. this.setData({
  473. top: app.globalData.statusBarHeight,
  474. hgt: app.globalData.titleBarHeight,
  475. })
  476. timer = setInterval(function () {
  477. time = time * 1 + 1;
  478. }, 1000)
  479. },
  480. /**
  481. * 生命周期函数--监听页面隐藏
  482. */
  483. onHide: function () {
  484. if (designTimer) {
  485. clearTimeout(designTimer);
  486. }
  487. if (timer) {
  488. clearInterval(timer)
  489. }
  490. this.visitimefun();
  491. },
  492. visitimefun() {
  493. if (!this.data.isAgree) {
  494. return false;
  495. }
  496. const that = this;
  497. utils.$post({
  498. url: app.globalData.webUrl + 'client/index/visit_due_time',
  499. header: {
  500. 'Authorization': 'bearer ' + app.globalData.token
  501. },
  502. data: {
  503. id: that.data.eid,
  504. pipe_type: 'materialEvidence',
  505. time: time,
  506. },
  507. success: function (res) { }
  508. })
  509. },
  510. /**
  511. * 生命周期函数--监听页面卸载
  512. */
  513. onUnload: function () {
  514. if (designTimer) {
  515. clearTimeout(designTimer);
  516. }
  517. this.visitimefun();
  518. },
  519. /**
  520. * 页面相关事件处理函数--监听用户下拉动作
  521. */
  522. onPullDownRefresh: function () {
  523. },
  524. /**
  525. /**
  526. * 页面上拉触底事件的处理函数
  527. */
  528. onReachBottom: function () {
  529. },
  530. /**
  531. * 用户点击右上角分享
  532. */
  533. onShareAppMessage: function () {
  534. var img = this.data.evidencemsg.cover_share_img?this.data.evidencemsg.cover_share_img:this.data.evidencemsg.difference == 1 ? (this.data.evidencemsg.cover ? this.data.evidencemsg.cover : (this.data.evidencemsg.pics[0] + '?x-oss-process=video/snapshot,t_100,f_jpg,w_375,m_fast')) : this.data.evidencemsg.pics[0];
  535. img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
  536. if (app.globalData.brokeruserId) {
  537. this.evidencesharetap();
  538. let uid = (app.globalData.shareuserid) ? app.globalData.shareuserid : app.globalData.personMsg.id;
  539. return {
  540. title: this.data.evidencemsg.title,
  541. imageUrl: img,
  542. path: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + uid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId,
  543. };
  544. } else {
  545. this.evidencesharetap();
  546. let uid = (app.globalData.shareuserid) ? app.globalData.shareuserid : app.globalData.personMsg.id;
  547. return {
  548. title: this.data.evidencemsg.title,
  549. imageUrl: img,
  550. path: '/share/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.eid + '&uid=' + uid + '&ctp=' + app.globalData.clientype,
  551. };
  552. }
  553. }
  554. })