publicpraisemsg.js 18 KB

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