companystrengthmsg.js 17 KB

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