companystrengthmsg.js 15 KB

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