companystrengthmsg.js 18 KB

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