publicpraisemsg.js 16 KB

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