index.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  1. const app = getApp(), utils = require("../../utils/http");
  2. const util = require("../../utils/util");
  3. let casepage = 1, articlepage = 1, videopage = 1, evidencepage = 1, page = 1, time = 0, timer = null, showflag = true;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. top: app.globalData.statusBarHeight,
  10. hgt: app.globalData.titleBarHeight,
  11. loginFlag: true,
  12. phoneflag: false,
  13. share_user_id: '0',
  14. topname: '',
  15. toparea: '',
  16. imgUrl: app.globalData.imgUrl,
  17. personobj: {},
  18. casetype: [],
  19. nowcasebtn: '',
  20. caselist: [],
  21. guidetext: '',
  22. videolist: [],
  23. mobilephone: '',
  24. alertflag: false,
  25. loginform: false,
  26. canIUseGetUserProfile: false,
  27. weboffer: [],
  28. articlelist: [],
  29. type: '1',
  30. leftcaselist: [],
  31. rightcaselist: [],
  32. leftarticlelist: [],
  33. rightarticlelist: [],
  34. leftvideolist: [],
  35. rightvideolist: [],
  36. evidencelist: [],
  37. leftevidencelist: [],
  38. rightevidencelist: [],
  39. shareobj: {},
  40. passflag: false,
  41. indextitle: '微官网',
  42. type: 'updatetime',//hot 最热, updatetime最新
  43. indexlist: [],
  44. unfutureflag: false,
  45. companyobj: {},
  46. nowstate: 0,
  47. datashow: false,
  48. linkType: '',
  49. paramsId: '',
  50. firstload: false,
  51. officeType: '',
  52. curId: '',
  53. prelook: '',
  54. timeline: app.globalData.timeline,
  55. jumpType: '',
  56. jumpId: "",
  57. jumpPage: "",
  58. buildingId: "",
  59. apptype: '',
  60. isCollected: "",
  61. isAgree: false
  62. },
  63. /**
  64. * 生命周期函数--监听页面加载
  65. */
  66. onLoad: function (options) {
  67. var that = this;
  68. if (options.timeline == 'share') {
  69. this.setData({
  70. prelook: '125',
  71. timeline: app.globalData.timeline
  72. })
  73. }
  74. if (!!options.state) {
  75. this.setData({
  76. nowstate: options.state
  77. })
  78. }
  79. if (!!options.type) {
  80. this.setData({
  81. apptype: options.type
  82. })
  83. }
  84. time = 0;
  85. if (wx.getUserProfile) {
  86. this.setData({
  87. canIUseGetUserProfile: true
  88. })
  89. }
  90. that.setData({
  91. top: app.globalData.statusBarHeight,
  92. hgt: app.globalData.titleBarHeight,
  93. })
  94. if (!!options.clientype) {
  95. app.globalData.clientype = options.clientype;
  96. if (!!options.share_user_id) {
  97. that.setData({
  98. share_user_id: options.share_user_id
  99. })
  100. app.globalData.shareuserid = options.share_user_id;
  101. }
  102. if (options.office_type) {
  103. that.setData({
  104. officeType: options.office_type
  105. })
  106. }
  107. if (options.clg) {
  108. that.setData({
  109. isCollected: options.clg
  110. })
  111. }
  112. if (!!options.cid) {
  113. that.setData({
  114. curId: options.cid
  115. })
  116. }
  117. if (!!options.jump) {
  118. this.setData({
  119. jumpType: options.jump,
  120. jumpPage: options.page,
  121. jumpId: options.cid
  122. })
  123. }
  124. if (!!options.bid) {
  125. this.setData({
  126. buildingId: options.bid
  127. })
  128. }
  129. that.login();
  130. } else {
  131. if (!!options.scene) {
  132. let params = this.handleParams(decodeURIComponent(options.scene));
  133. if (!!params.cli) {
  134. app.globalData.clientype = params.cli;
  135. }
  136. if (!!params.t) {
  137. that.setData({
  138. linkType: params.t
  139. })
  140. }
  141. if (!!params.id) {
  142. that.setData({
  143. paramsId: params.id
  144. })
  145. }
  146. }
  147. if (!!options.share_user_id) {
  148. that.setData({
  149. share_user_id: options.share_user_id
  150. })
  151. app.globalData.shareuserid = options.share_user_id;
  152. }
  153. that.login();
  154. }
  155. },
  156. agreePrivacy() {
  157. this.setData({
  158. isAgree: true
  159. });
  160. },
  161. handleParams: function (params) {
  162. let data = {};
  163. let p = params.split('&');
  164. for (var i = 0; i < p.length; i++) {
  165. let p1 = p[i].split('=');
  166. data[p1[0]] = p1[1];
  167. }
  168. return data;
  169. },
  170. videodecoratetap: function (e) {
  171. // '/customer/pages/videodecorate/videodecorate'
  172. wx.navigateTo({
  173. url: '/customer/pages/designerlist/designerlist'
  174. })
  175. },
  176. toViewBuilding() {
  177. wx.navigateTo({
  178. url: '/share/pages/buildinglist/buildinglist?ctp=' + app.globalData.clientype + '&uid=' + app.globalData.shareuserid + '&type=3&index=1',
  179. })
  180. },
  181. prelookimgtap() {
  182. if (!app.globalData.sharepersonobj.qrcode) {
  183. wx.showToast({
  184. title: "当前专属客服的二维码为空!",
  185. icon: 'none',
  186. duration: 2000
  187. })
  188. return false;
  189. }
  190. wx.previewImage({
  191. current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  192. urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表
  193. })
  194. },
  195. sharecompany: function () {
  196. const that = this;
  197. utils.$post({
  198. url: app.globalData.webUrl + 'client/index/content_belong_company',
  199. header: {
  200. 'Authorization': 'bearer ' + app.globalData.token
  201. },
  202. data: {
  203. client_type: app.globalData.clientype,
  204. uid: app.globalData.shareuserid
  205. },
  206. success: function (res) {
  207. if (res.data.code == '0') {
  208. app.globalData.currentUserId = res.data.data.employee_id;
  209. }
  210. },
  211. complete(res) {
  212. wx.hideLoading()
  213. }
  214. })
  215. },
  216. login: function () {
  217. var that = this;
  218. wx.showLoading({
  219. title: '加载中...'
  220. });
  221. wx.login({
  222. success: function (data) {
  223. if (data.errMsg == 'login:ok') {
  224. utils.$post({
  225. url: app.globalData.webUrl + 'api/users/code2session',
  226. data: {
  227. code: data.code,
  228. share: app.globalData.shareuserid,
  229. client_type: app.globalData.clientype
  230. },
  231. success: function (r) {
  232. if (r.data.code == '0') {
  233. app.globalData.companyobj = r.data.company_data;
  234. app.globalData.companyname = r.data.company_data.company_name;
  235. app.globalData.token = r.data.token;
  236. app.globalData.official_openid = r.data.official_openid;
  237. app.globalData.agentEmployeEid = r.data.agent_employee_id;
  238. app.globalData.vrString = r.data.str || "";
  239. that.setData({
  240. companyobj: r.data.company_data
  241. })
  242. if (!!r.data.company_data && r.data.company_data.client_type) {
  243. app.globalData.clientype = r.data.company_data.client_type;
  244. }
  245. if (!!r.data.share) {
  246. app.globalData.shareperson = r.data.share;
  247. app.globalData.sharename = r.data.share.name;
  248. app.globalData.sharepersonobj = r.data.share;
  249. that.setData({
  250. mobilephone: r.data.share.phone,
  251. shareobj: r.data.share,
  252. indextitle: r.data.share.name ? r.data.share.name : r.data.share.nickname + '的微官网',
  253. share_user_id: r.data.share.id,
  254. })
  255. that.sharecompany();
  256. util.toolfun(6);
  257. } else {
  258. that.setData({
  259. indextitle: r.data.company + '微官网',
  260. })
  261. }
  262. that.getCurAgentName();
  263. that.indexfun();
  264. // phone有没有,有的话,不用授权,
  265. if (!!r.data.user.phone) {
  266. if (that.data.share_user_id) {
  267. that.setData({
  268. share_user_id: r.data.user.id,
  269. })
  270. }
  271. if (!r.data.share) {
  272. that.setData({
  273. indextitle: (!!r.data.user.binded ? !r.data.user.binded.name ? r.data.user.nickname + '的' : r.data.user.binded.name + '的' : '') + '微官网'
  274. })
  275. }
  276. if (!!r.data.user.binded && r.data.user.binded.state == '待审核') {
  277. that.setData({
  278. passflag: true
  279. })
  280. } else {
  281. that.setData({
  282. passflag: false
  283. })
  284. }
  285. app.globalData.personMsg = r.data.user;
  286. app.globalData.use_id = r.data.user.id;
  287. that.setData({
  288. personobj: r.data.user
  289. })
  290. that.setData({
  291. phoneflag: false
  292. })
  293. app.globalData.phone = true;//有手机号
  294. that.setData({
  295. firstload: true
  296. })
  297. if (!!r.data.user.binded && r.data.user.binded.state == '在职' && that.data.nowstate != 1) {
  298. app.globalData.currentUserId = r.data.user.binded.id;
  299. if (that.data.apptype == 1) {
  300. wx.reLaunch({
  301. url: '/index/pages/building/building'
  302. })
  303. } else if (that.data.apptype == 2) {
  304. wx.reLaunch({
  305. url: '/index/pages/morecontent/morecontent'
  306. })
  307. } else if (that.data.apptype == 3) {
  308. wx.reLaunch({
  309. url: '/index/pages/caselist/caselist'
  310. })
  311. } else if (that.data.apptype == 4) {
  312. wx.reLaunch({
  313. url: '/index/pages/friendcircle/friendcircle'
  314. })
  315. } else if (that.data.apptype == 5) {//谈单工具
  316. wx.reLaunch({
  317. url: '/pages/findcustomertool/findcustomertool?type=1'
  318. })
  319. } else if (that.data.apptype == 6) {//老客转介
  320. wx.reLaunch({
  321. url: '/pages/findcustomertool/findcustomertool?type=2'
  322. })
  323. } else if (that.data.apptype == 7) {
  324. wx.reLaunch({
  325. url: '/index/pages/school/school?type=121'
  326. })
  327. } else if (that.data.apptype == 8) {
  328. wx.reLaunch({
  329. url: '/index/pages/school/school?type=212'
  330. })
  331. } else if (that.data.apptype == 9) {
  332. wx.reLaunch({
  333. url: '/index/pages/school/school?type=313'
  334. })
  335. } else if (that.data.apptype == 10) {//客户报备
  336. wx.reLaunch({
  337. url: '/mycustomer/pages/addcustomerData/addcustomerData'
  338. })
  339. } else if (that.data.apptype == 11) {//工作汇报
  340. wx.reLaunch({
  341. url: "/pages/other/other?type=3"
  342. })
  343. } else if (that.data.apptype == 12) {
  344. wx.reLaunch({
  345. url: "/index/pages/activity/activity"
  346. })
  347. } else if (that.data.apptype == 13) {//每日学练
  348. wx.reLaunch({
  349. url: "/index/pages/school/school?type=11"
  350. })
  351. } else if (that.data.apptype == 14) {//活动扫码
  352. wx.reLaunch({
  353. url: "/mycustomer/pages/activitylist/activitylist"
  354. })
  355. } else if (that.data.apptype == 15) {
  356. wx.reLaunch({
  357. url: '/pages/other/other?type=9009'
  358. })
  359. } else if (that.data.apptype == 16) {//楼盘上传
  360. wx.reLaunch({
  361. url: "/pages/other/other?type=987&bType="
  362. })
  363. } else if (that.data.apptype == 17) {//在施工地
  364. wx.reLaunch({
  365. url: '/pages/other/other?type=8992'
  366. })
  367. } else if (that.data.apptype == 18) {
  368. wx.reLaunch({
  369. url: '/mycustomer/pages/dragontigerrank/dragontigerrank'
  370. })
  371. } else if (that.data.apptype == 19) {//团队管理
  372. wx.reLaunch({
  373. url: "/mycustomer/pages/managerdata/managerdata?type=1"
  374. })
  375. } else if (that.data.apptype == 20) {//员工邀请
  376. wx.reLaunch({
  377. url: "/mycustomer/pages/managerdata/managerdata?type=5"
  378. })
  379. } else if (that.data.apptype == 21) {//员工审核
  380. wx.reLaunch({
  381. url: "/mycustomer/pages/managerdata/managerdata?type=6"
  382. })
  383. } else if (that.data.apptype == 22) {//员工画像
  384. wx.reLaunch({
  385. url: "/mycustomer/pages/managerdata/managerdata?type=7"
  386. })
  387. } else if (that.data.apptype == 23) {//话术管理
  388. wx.reLaunch({
  389. url: "/mycustomer/pages/managerdata/managerdata?type=2"
  390. })
  391. } else if (that.data.apptype == 24) {//资源库管理
  392. wx.reLaunch({
  393. url: "/mycustomer/pages/managerdata/managerdata?type=3"
  394. })
  395. } else if (that.data.apptype == 25) {//汇报管理
  396. wx.reLaunch({
  397. url: "/pages/other/other?type=3&state=2"
  398. })
  399. } else if (that.data.apptype == 26) {//考核管理
  400. wx.reLaunch({
  401. url: "/index/pages/testapprove/testapprove"
  402. })
  403. } else if (that.data.apptype == 27) {//团队客户
  404. wx.reLaunch({
  405. url: "/pages/other/other?type=48"
  406. })
  407. } else if (that.data.apptype == 28) {//客户回收库
  408. wx.reLaunch({
  409. url: "/pages/other/other?type=77"
  410. })
  411. } else if (that.data.apptype == 29) {//内容触达
  412. wx.reLaunch({
  413. url: "/pages/other/other?type=13"
  414. })
  415. } else if (that.data.apptype == 30) {//楼盘管理
  416. wx.reLaunch({
  417. url: "/pages/other/other?type=987&bType=1"
  418. })
  419. } else if (that.data.apptype == 31) {//死单审核
  420. wx.reLaunch({
  421. url: "/pages/other/other?type=6060"
  422. })
  423. } else if (that.data.apptype == 32) {//数据统计
  424. wx.reLaunch({
  425. url: "/pages/other/other?type=6886"
  426. })
  427. } else if (that.data.jumpType == 'app') {
  428. if (that.data.jumpPage == 'building') {
  429. wx.reLaunch({
  430. url: '/index/pages/progressdetail/progressdetail?cid=' + that.data.jumpId,
  431. })
  432. } else if (that.data.jumpPage == 'housetype') {
  433. wx.reLaunch({
  434. url: '/index/pages/housetype/housetype?cid=' + that.data.jumpId + '&buildId=' + that.data.buildingId,
  435. })
  436. } else if (that.data.jumpPage == 'materialcase') {
  437. wx.reLaunch({
  438. url: '/index/pages/casemsg/casemsg?cid=' + that.data.jumpId,
  439. })
  440. } else if (that.data.jumpPage == 'construct') {
  441. wx.reLaunch({
  442. url: '/customer/pages/sitemsg/sitemsg?cid=' + that.data.jumpId + '&type=2',
  443. })
  444. }
  445. } else if (that.data.officeType) {
  446. if (that.data.officeType == 'allocation') {
  447. wx.reLaunch({
  448. url: '/pages/customer/customer?type=1',
  449. })
  450. } else if (that.data.officeType == 'cread') {
  451. wx.reLaunch({
  452. url: '/mycustomer/pages/customermsg/customermsg?cid=' + that.data.curId,
  453. })
  454. } else if (that.data.officeType == 'clue_radar') {
  455. wx.reLaunch({
  456. url: '/mycustomer/pages/guestclues/guestclues',
  457. })
  458. } else if (that.data.officeType == 'share_c') {
  459. wx.reLaunch({
  460. url: '/pages/other/other?type=22',
  461. })
  462. }
  463. } else if (r.data.camp == 1) {
  464. wx.reLaunch({
  465. url: '/pages/other/other?type=32',
  466. })
  467. } else if (!!that.data.linkType && !!that.data.paramsId) {
  468. setTimeout(() => {
  469. wx.navigateTo({
  470. url: '/pages/other/other?type=11' + '&tid=' + that.data.paramsId
  471. })
  472. }, 1000)
  473. } else if (that.data.isCollected) {
  474. that.collectJumpFun(that.data.isCollected);
  475. } else {
  476. wx.switchTab({
  477. url: '/pages/consoledesk/consoledesk',
  478. })
  479. }
  480. } else {
  481. if (r.data.isagent && !r.data.user.binded && that.data.nowstate != 1) {
  482. app.globalData.brokeruserId = r.data.isagent;
  483. wx.reLaunch({
  484. url: '/customer/pages/brokerindex/brokerindex',
  485. })
  486. }
  487. }
  488. wx.hideLoading();
  489. } else {
  490. wx.hideLoading();
  491. that.setData({
  492. loginFlag: false,
  493. phoneflag: true
  494. })
  495. app.globalData.phone = false;//没有手机号
  496. }
  497. }
  498. }
  499. })
  500. }
  501. }
  502. })
  503. },
  504. collectJumpFun(type) {
  505. switch(type) {
  506. case '1':
  507. wx.navigateTo({
  508. url: '/index/pages/casemsg/casemsg?cid=' + this.data.curId,
  509. })
  510. break;
  511. case '2':
  512. wx.navigateTo({
  513. url: "/index/pages/videoshare/videoshare?vid=" + this.data.curId,
  514. });
  515. break;
  516. case '3':
  517. wx.navigateTo({
  518. url: "/index/pages/articleshare/articleshare?aid=" + this.data.curId,
  519. });
  520. break;
  521. case '4':
  522. wx.navigateTo({
  523. url: '/index/pages/companystrengthmsg/companystrengthmsg?eid=' + this.data.curId,
  524. })
  525. break;
  526. case '5':
  527. wx.navigateTo({
  528. url: '/index/pages/publicpraisemsg/publicpraisemsg?eid=' + this.data.curId,
  529. })
  530. break;
  531. case '6':
  532. wx.navigateTo({
  533. url: '/index/pages/progressdetail/progressdetail?cid=' + this.data.curId,
  534. })
  535. break;
  536. case '7':
  537. wx.navigateTo({
  538. url: '/customer/pages/sitemsg/sitemsg?cid=' + this.data.curId + '&type=2&ty=',
  539. })
  540. break;
  541. case '8':
  542. wx.navigateTo({
  543. url: '/pages/decorateguidemsg/decorateguidemsg?cid=' + this.data.curId +"&type=1"
  544. })
  545. break;
  546. }
  547. },
  548. callcompanytap() {
  549. if (!app.globalData.companyobj.tel) {
  550. wx.showToast({
  551. title: '公司电话没有填写!',
  552. icon: 'none',
  553. duration: 2000
  554. })
  555. return false;
  556. }
  557. wx.makePhoneCall({
  558. phoneNumber: app.globalData.companyobj.tel
  559. })
  560. },
  561. closetap: function () {
  562. this.setData({
  563. passflag: false,
  564. unfutureflag: false
  565. })
  566. },
  567. setitletap: function (e) {
  568. this.setData({
  569. type: e.currentTarget.dataset.type
  570. })
  571. if (e.currentTarget.dataset.type == 1) {
  572. this.caselistfun();
  573. } else if (e.currentTarget.dataset.type == 2) {
  574. this.articlelist();
  575. } else if (e.currentTarget.dataset.type == 3) {
  576. // this.videofun();
  577. } else if (e.currentTarget.dataset.type == 4) {
  578. this.evidencefun();
  579. }
  580. },
  581. evidencefun: function () {
  582. const that = this;
  583. evidencepage = 1;
  584. utils.$get({
  585. url: app.globalData.webUrl + 'client/evidencelist',
  586. header: {
  587. 'Authorization': 'bearer ' + app.globalData.token
  588. },
  589. data: {
  590. uid: '',
  591. page: 1,
  592. cate: '',
  593. keyword: ''
  594. },
  595. success: function (res) {
  596. wx.stopPullDownRefresh();
  597. if (res.data.code == '0') {
  598. that.setData({
  599. evidencelist: res.data.data,
  600. leftevidencelist: [],
  601. rightevidencelist: [],
  602. })
  603. that.imgload();
  604. }
  605. }
  606. })
  607. },
  608. imgload: function () {
  609. var that = this;
  610. var leftlist = that.data.leftevidencelist;
  611. var rightlist = that.data.rightevidencelist;
  612. var indexlist = that.data.evidencelist;
  613. if (indexlist.length == 0) {
  614. return false;
  615. }
  616. if (leftlist.length == 0) {
  617. leftlist.push(indexlist[0]);
  618. indexlist.shift();
  619. that.setData({
  620. evidencelist: indexlist,
  621. leftevidencelist: leftlist,
  622. rightevidencelist: rightlist
  623. })
  624. } else {
  625. var leftheight, rightheight;
  626. const query = wx.createSelectorQuery()
  627. query.select('.leftcaselistbox').boundingClientRect();
  628. query.exec(function (res) {
  629. leftheight = res[0].height;
  630. const queryright = wx.createSelectorQuery()
  631. queryright.select('.rightcaselistbox').boundingClientRect();
  632. queryright.exec(function (rs) {
  633. leftlist = that.data.leftevidencelist;
  634. rightlist = that.data.rightevidencelist;
  635. indexlist = that.data.evidencelist;
  636. rightheight = rs[0].height;
  637. if (leftheight <= rightheight) {
  638. leftlist.push(indexlist[0]);
  639. indexlist.shift();
  640. } else {
  641. rightlist.push(indexlist[0]);
  642. indexlist.shift();
  643. }
  644. that.setData({
  645. evidencelist: indexlist,
  646. leftevidencelist: leftlist,
  647. rightevidencelist: rightlist
  648. })
  649. })
  650. })
  651. }
  652. },
  653. indextap: function () {
  654. wx.switchTab({
  655. url: '/pages/consoledesk/consoledesk',
  656. })
  657. },
  658. appointap: function () {
  659. wx.navigateTo({
  660. url: '/pages/appoint/appoint',
  661. })
  662. },
  663. housestyleBtn: function () {
  664. this.setData({
  665. unfutureflag: true
  666. })
  667. // wx.navigateTo({
  668. // url: "/pages/beforetest/beforetest?type=housestyle&share_user_id="+this.data.share_user_id
  669. // });
  670. },
  671. casetotap: function () {
  672. // '/customer/pages/decoratecase/decoratecase?share_user_id='+this.data.share_user_id,
  673. wx.navigateTo({
  674. url: '/customer/pages/site/site'
  675. })
  676. },
  677. findcustomertoolTap: function (e) {
  678. wx.navigateTo({
  679. url: '/pages/networktool/networktool?share_user_id=' + this.data.share_user_id,
  680. })
  681. },
  682. callphonetap: function () {
  683. wx.makePhoneCall({
  684. phoneNumber: this.data.shareobj.phone
  685. })
  686. },
  687. guidetotap: function () {
  688. wx.navigateTo({
  689. url: '/pages/decorateguide/decorateguide?share_user_id=' + this.data.share_user_id,
  690. })
  691. },
  692. casetap: function (e) {
  693. wx.navigateTo({
  694. url: '/pages/decorateguidemsg/decorateguidemsg?cid=' + e.currentTarget.dataset.cid,
  695. })
  696. },
  697. articletap: function (e) {
  698. wx.navigateTo({
  699. url: '/customer/pages/decoratecasemsg/decoratecasemsg?aid=' + e.currentTarget.dataset.cid
  700. })
  701. },
  702. figurepricetap: function () {
  703. wx.navigateTo({
  704. url: '/customer/pages/figureprice/figureprice?share_user_id=' + this.data.share_user_id,
  705. })
  706. },
  707. signtap: function () {
  708. wx.navigateTo({
  709. url: '/customer/pages/findesign/findesign?share_user_id=' + this.data.share_user_id,
  710. })
  711. },
  712. oldreform: function () {
  713. wx.navigateTo({
  714. url: '/customer/pages/reform/reform?share_user_id=' + this.data.share_user_id,
  715. })
  716. },
  717. /**
  718. * 生命周期函数--监听页面初次渲染完成
  719. */
  720. onReady: function (options) {
  721. },
  722. onPlay: function () {
  723. },
  724. onPlayNav: function () {
  725. },
  726. onShow: function () {
  727. this.setData({
  728. top: app.globalData.statusBarHeight,
  729. hgt: app.globalData.titleBarHeight,
  730. timeline: app.globalData.timeline
  731. })
  732. if (app.globalData.shareuserid) {
  733. timer = setInterval(function () {
  734. time = time * 1 + 1;
  735. }, 1000)
  736. }
  737. if (app.globalData.timeline == 2) {
  738. wx.hideLoading()
  739. }
  740. if (!showflag) {
  741. this.caseimgload();
  742. }
  743. showflag = true;
  744. },
  745. hotap: function () {
  746. this.setData({
  747. type: "updatetime"
  748. })
  749. wx.showLoading({
  750. title: '加载中...',
  751. })
  752. this.indexfun();
  753. },
  754. newtap: function () {
  755. this.setData({
  756. type: "hot"
  757. })
  758. wx.showLoading({
  759. title: '加载中...',
  760. })
  761. this.indexfun();
  762. },
  763. indexfun: function () {
  764. const that = this;
  765. page = 1;
  766. that.setData({
  767. firstload: true
  768. })
  769. utils.$get({
  770. url: app.globalData.webUrl + 'client/index/recommend',
  771. header: {
  772. 'Authorization': 'bearer ' + app.globalData.token
  773. },
  774. data: {
  775. page: 1,
  776. limit: 10,
  777. type: that.data.type,//hot 最热, updatetime最新
  778. },
  779. success: function (res) {
  780. that.setData({
  781. datashow: true
  782. })
  783. if (res.data.code == '0') {
  784. that.setData({
  785. indexlist: res.data.data,
  786. leftcaselist: [],
  787. rightcaselist: [],
  788. })
  789. }
  790. that.caseimgload();
  791. wx.hideLoading()
  792. }, fail() {
  793. wx.hideLoading()
  794. }
  795. })
  796. },
  797. getCurAgentName: function () {
  798. const that = this;
  799. utils.$get({
  800. url: app.globalData.webUrl + 'api/agents/get_agent_name',
  801. header: {
  802. 'Authorization': 'bearer ' + app.globalData.token
  803. },
  804. data: {},
  805. success: function (res) {
  806. if (res.data.code == '0') {
  807. app.globalData.agentName = res.data.name;
  808. }
  809. }
  810. })
  811. },
  812. caseimgload: function () {
  813. var that = this;
  814. var leftcaselist = that.data.leftcaselist;
  815. var rightcaselist = that.data.rightcaselist;
  816. var indexlist = that.data.indexlist;
  817. if (indexlist.length == 0) {
  818. return false;
  819. }
  820. let casemsg = indexlist[0];
  821. if (!casemsg) {
  822. that.setData({
  823. indexlist: [],
  824. })
  825. return false;
  826. }
  827. if (leftcaselist.length == 0) {
  828. leftcaselist.push(casemsg);
  829. indexlist.shift();
  830. that.setData({
  831. indexlist: indexlist,
  832. leftcaselist: leftcaselist,
  833. rightcaselist: rightcaselist
  834. })
  835. } else {
  836. var leftheight, rightheight;
  837. const query = wx.createSelectorQuery()
  838. query.select('.leftcaselistbox').boundingClientRect();
  839. query.exec(function (res) {
  840. if (!res[0]) {
  841. return false;
  842. }
  843. leftheight = res[0].height;
  844. const queryright = wx.createSelectorQuery()
  845. queryright.select('.rightcaselistbox').boundingClientRect();
  846. queryright.exec(function (rs) {
  847. leftcaselist = that.data.leftcaselist;
  848. rightcaselist = that.data.rightcaselist;
  849. rightheight = rs[0].height;
  850. if (leftheight <= rightheight) {
  851. leftcaselist.push(casemsg);
  852. indexlist.shift();
  853. } else {
  854. rightcaselist.push(casemsg);
  855. indexlist.shift();
  856. }
  857. that.setData({
  858. indexlist: indexlist,
  859. leftcaselist: leftcaselist,
  860. rightcaselist: rightcaselist
  861. })
  862. })
  863. })
  864. }
  865. },
  866. videofun: function () {
  867. var that = this;
  868. videopage = 1;
  869. utils.$post({
  870. url: app.globalData.webUrl + 'client/video/list',
  871. header: {
  872. 'Authorization': 'bearer ' + app.globalData.token
  873. },
  874. data: {
  875. type: '',
  876. page: 1,
  877. limit: "10",
  878. user_id: ''
  879. },
  880. success: function (res) {
  881. wx.hideLoading();
  882. if (res.data.code == '0') {
  883. that.setData({
  884. videolist: res.data.data,
  885. leftvideolist: [],
  886. rightvideolist: []
  887. })
  888. that.videoimgload();
  889. }
  890. }
  891. })
  892. },
  893. videoimgload: function () {
  894. var that = this;
  895. var leftvideolist = that.data.leftvideolist;
  896. var rightvideolist = that.data.rightvideolist;
  897. var videolist = that.data.videolist;
  898. if (videolist.length == 0) {
  899. return false;
  900. }
  901. let articlemsg = videolist[0];
  902. if (!articlemsg) {
  903. that.setData({
  904. videolist: [],
  905. })
  906. return false;
  907. }
  908. if (leftvideolist.length == 0) {
  909. leftvideolist.push(articlemsg);
  910. videolist.shift();
  911. that.setData({
  912. videolist: videolist,
  913. leftvideolist: leftvideolist,
  914. rightvideolist: rightvideolist
  915. })
  916. } else {
  917. var leftheight, rightheight;
  918. const query = wx.createSelectorQuery()
  919. query.select('.leftcaselistbox').boundingClientRect();
  920. query.exec(function (res) {
  921. leftheight = res[0].height;
  922. const queryright = wx.createSelectorQuery()
  923. queryright.select('.rightcaselistbox').boundingClientRect();
  924. queryright.exec(function (rs) {
  925. leftvideolist = that.data.leftvideolist;
  926. rightvideolist = that.data.rightvideolist;
  927. rightheight = rs[0].height;
  928. if (leftheight <= rightheight) {
  929. leftvideolist.push(articlemsg);
  930. videolist.shift();
  931. } else {
  932. rightvideolist.push(articlemsg);
  933. videolist.shift();
  934. }
  935. that.setData({
  936. videolist: videolist,
  937. leftvideolist: leftvideolist,
  938. rightvideolist: rightvideolist
  939. })
  940. })
  941. })
  942. }
  943. },
  944. guidetap: function (e) {
  945. this.setData({
  946. guidetext: e.currentTarget.dataset.type
  947. })
  948. this.caselistfun();
  949. },
  950. caselistfun: function () {
  951. var that = this;
  952. casepage = 1;
  953. utils.$get({
  954. url: app.globalData.webUrl + 'client/caselist',
  955. header: {
  956. 'Authorization': 'bearer ' + app.globalData.token
  957. },
  958. data: {
  959. uid: '',
  960. page: 1,
  961. commu_id: '',// 小区id
  962. style_id: '',//风格id
  963. square_start: '',//面积开始值
  964. square_end: '',//面积结束值
  965. keyword: ''
  966. },
  967. success: function (res) {
  968. that.setData({
  969. datashow: true
  970. })
  971. if (res.data.code == '0') {
  972. that.setData({
  973. caselist: res.data.data,
  974. leftcaselist: [],
  975. rightcaselist: [],
  976. })
  977. }
  978. that.caseimgload();
  979. wx.hideLoading()
  980. }, fail() {
  981. wx.hideLoading()
  982. }
  983. })
  984. },
  985. articlelist: function () {
  986. var that = this;
  987. articlepage = 1;
  988. utils.$post({
  989. url: app.globalData.webUrl + 'client/article/list',
  990. header: {
  991. 'Authorization': 'bearer ' + app.globalData.token
  992. },
  993. data: {
  994. type: "",
  995. label: '',
  996. page: 1,
  997. limit: "10",
  998. keyword: ''
  999. },
  1000. success: function (res) {
  1001. if (res.data.code == '0') {
  1002. that.setData({
  1003. articlelist: res.data.data,
  1004. leftarticlelist: [],
  1005. rightarticlelist: [],
  1006. })
  1007. that.articleimgload();
  1008. }
  1009. }
  1010. })
  1011. },
  1012. articleimgload: function () {
  1013. var that = this;
  1014. var leftarticlelist = that.data.leftarticlelist;
  1015. var rightarticlelist = that.data.rightarticlelist;
  1016. var articlelist = that.data.articlelist;
  1017. if (articlelist.length == 0) {
  1018. return false;
  1019. }
  1020. let articlemsg = articlelist[0];
  1021. if (!articlemsg) {
  1022. that.setData({
  1023. articlelist: [],
  1024. })
  1025. return false;
  1026. }
  1027. if (leftarticlelist.length == 0) {
  1028. leftarticlelist.push(articlemsg);
  1029. articlelist.shift();
  1030. that.setData({
  1031. articlelist: articlelist,
  1032. leftarticlelist: leftarticlelist,
  1033. rightarticlelist: rightarticlelist
  1034. })
  1035. } else {
  1036. var leftheight, rightheight;
  1037. const query = wx.createSelectorQuery()
  1038. query.select('.leftcaselistbox').boundingClientRect();
  1039. query.exec(function (res) {
  1040. leftheight = res[0].height;
  1041. const queryright = wx.createSelectorQuery()
  1042. queryright.select('.rightcaselistbox').boundingClientRect();
  1043. queryright.exec(function (rs) {
  1044. leftarticlelist = that.data.leftarticlelist;
  1045. rightarticlelist = that.data.rightarticlelist;
  1046. rightheight = rs[0].height;
  1047. if (leftheight <= rightheight) {
  1048. leftarticlelist.push(articlemsg);
  1049. articlelist.shift();
  1050. } else {
  1051. rightarticlelist.push(articlemsg);
  1052. articlelist.shift();
  1053. }
  1054. that.setData({
  1055. articlelist: articlelist,
  1056. leftarticlelist: leftarticlelist,
  1057. rightarticlelist: rightarticlelist
  1058. })
  1059. })
  1060. })
  1061. }
  1062. },
  1063. videomsgtap: function (e) {
  1064. wx.navigateTo({
  1065. url: '/pages/networkvideo/networkvideo?vid=' + e.currentTarget.dataset.vid
  1066. })
  1067. },
  1068. evitap: function (e) {
  1069. wx.navigateTo({
  1070. url: '/customer/pages/publicpraisemsg/publicpraisemsg?eid=' + e.currentTarget.dataset.cid
  1071. })
  1072. },
  1073. publicpraisetap: function (e) {
  1074. wx.navigateTo({
  1075. url: '/customer/pages/publicpraise/publicpraise'
  1076. })
  1077. },
  1078. submittap: function () {
  1079. var that = this;
  1080. if (that.data.loginform) {
  1081. wx.showToast({
  1082. title: '不能重复报名!',
  1083. icon: 'none',
  1084. duration: 2000
  1085. })
  1086. return false;
  1087. }
  1088. if (!that.data.topname) {
  1089. wx.showToast({
  1090. title: '姓名不能为空!',
  1091. icon: 'none',
  1092. duration: 2000
  1093. })
  1094. return false;
  1095. }
  1096. if (!that.data.toparea) {
  1097. wx.showToast({
  1098. title: '面积不能为空!',
  1099. icon: 'none',
  1100. duration: 2000
  1101. })
  1102. return false;
  1103. }
  1104. this.applyinput();
  1105. },
  1106. getUserProfile: function () {
  1107. var that = this;
  1108. if (!that.data.topname) {
  1109. wx.showToast({
  1110. title: '姓名不能为空!',
  1111. icon: 'none',
  1112. duration: 2000
  1113. })
  1114. return false;
  1115. }
  1116. if (!that.data.toparea) {
  1117. wx.showToast({
  1118. title: '面积不能为空!',
  1119. icon: 'none',
  1120. duration: 2000
  1121. })
  1122. return false;
  1123. }
  1124. wx.getUserProfile({
  1125. lang: 'zh_CN',
  1126. desc: '为了更好的体验申请获取以下信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  1127. success: (res) => {
  1128. if (res.errMsg == 'getUserProfile:ok') {
  1129. utils.$post({
  1130. url: app.globalData.webUrl + 'api/users/setUserInfo',
  1131. data: {
  1132. encryptedData: res.encryptedData,
  1133. iv: res.iv,
  1134. rawData: res.rawData,
  1135. signature: res.signature,
  1136. },
  1137. header: {
  1138. 'Authorization': 'bearer ' + app.globalData.token
  1139. },
  1140. success: function (r) {
  1141. if (r.data.code == '0') {
  1142. that.setData({
  1143. loginFlag: false
  1144. })
  1145. app.globalData.userflag = false;//有个人信息
  1146. wx.showToast({
  1147. title: '点击立即计算获取报价',
  1148. icon: 'none',
  1149. duration: 2000
  1150. })
  1151. } else {
  1152. that.setData({
  1153. loginFlag: true
  1154. })
  1155. }
  1156. }
  1157. })
  1158. } else {
  1159. that.setData({
  1160. loginFlag: true
  1161. })
  1162. }
  1163. }
  1164. })
  1165. },
  1166. getUserInfoTap: function (res) {
  1167. var that = this;
  1168. if (!that.data.topname) {
  1169. wx.showToast({
  1170. title: '姓名不能为空!',
  1171. icon: 'none',
  1172. duration: 2000
  1173. })
  1174. return false;
  1175. }
  1176. if (!that.data.toparea) {
  1177. wx.showToast({
  1178. title: '面积不能为空!',
  1179. icon: 'none',
  1180. duration: 2000
  1181. })
  1182. return false;
  1183. }
  1184. if (res.detail.errMsg == 'getUserInfo:ok') {
  1185. utils.$post({
  1186. url: app.globalData.webUrl + 'api/users/setUserInfo',
  1187. data: {
  1188. encryptedData: res.detail.encryptedData,
  1189. iv: res.detail.iv,
  1190. rawData: res.detail.rawData,
  1191. signature: res.detail.signature,
  1192. },
  1193. header: {
  1194. 'Authorization': 'bearer ' + app.globalData.token
  1195. },
  1196. success: function (r) {
  1197. if (r.data.code == '0') {
  1198. that.setData({
  1199. loginFlag: false,
  1200. })
  1201. app.globalData.userflag = false;//有个人信息
  1202. wx.showToast({
  1203. title: '点击立即计算获取报价',
  1204. icon: 'none',
  1205. duration: 2000
  1206. })
  1207. } else {
  1208. that.setData({
  1209. loginFlag: true
  1210. })
  1211. }
  1212. }
  1213. })
  1214. } else {
  1215. that.setData({
  1216. loginFlag: true
  1217. })
  1218. }
  1219. },
  1220. getPhoneNumberTap: function (res) {
  1221. var that = this;
  1222. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  1223. utils.$post({
  1224. url: app.globalData.webUrl + 'api/users/setUserMobile',
  1225. data: {
  1226. encryptedData: res.detail.encryptedData,
  1227. iv: res.detail.iv
  1228. },
  1229. header: {
  1230. 'Authorization': 'bearer ' + app.globalData.token
  1231. },
  1232. success: function (r) {
  1233. if (r.data.code == '0') {
  1234. that.login();
  1235. app.globalData.phone = true;
  1236. app.globalData.personMsg.phone = r.data.mobile;
  1237. that.applyinput();
  1238. }
  1239. }
  1240. })
  1241. }
  1242. },
  1243. /**
  1244. * 生命周期函数--监听页面隐藏
  1245. */
  1246. onHide: function () {
  1247. showflag = false;
  1248. if (app.globalData.shareuserid) {
  1249. if (timer) {
  1250. clearInterval(timer)
  1251. }
  1252. this.setimetap();
  1253. }
  1254. },
  1255. openVRLink(e) {
  1256. let vrlink = e.currentTarget.dataset.vrlink;
  1257. let id = e.currentTarget.dataset.id;
  1258. wx.navigateTo({
  1259. url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&aid=' + id,
  1260. })
  1261. },
  1262. setimetap() {
  1263. if (!this.data.isAgree) {
  1264. return false;
  1265. }
  1266. const that = this;
  1267. utils.$post({
  1268. url: app.globalData.webUrl + 'client/index/visit_due_time',
  1269. header: {
  1270. 'Authorization': 'bearer ' + app.globalData.token
  1271. },
  1272. data: {
  1273. id: app.globalData.currentUserId,
  1274. pipe_type: 'toolAll',
  1275. time: time,
  1276. },
  1277. success: function (res) {
  1278. }
  1279. })
  1280. },
  1281. /**
  1282. * 生命周期函数--监听页面卸载
  1283. */
  1284. onUnload: function () {
  1285. if (app.globalData.shareuserid) {
  1286. this.setimetap();
  1287. }
  1288. },
  1289. /**
  1290. * 页面相关事件处理函数--监听用户下拉动作
  1291. */
  1292. onPullDownRefresh: function () {
  1293. const that = this;
  1294. if (app.globalData.timeline == 2) {
  1295. return false;
  1296. }
  1297. page = 1;
  1298. this.login();
  1299. let time = setTimeout(function () {
  1300. wx.stopPullDownRefresh()
  1301. clearTimeout(time)
  1302. }, 1000)
  1303. },
  1304. /**
  1305. * 页面上拉触底事件的处理函数
  1306. */
  1307. onReachBottom: function () {
  1308. const that = this;
  1309. page = page + 1;
  1310. wx.showLoading({
  1311. title: '加载中...',
  1312. })
  1313. utils.$get({
  1314. url: app.globalData.webUrl + 'client/index/recommend',
  1315. header: {
  1316. 'Authorization': 'bearer ' + app.globalData.token
  1317. },
  1318. data: {
  1319. page: page,
  1320. limit: 10,
  1321. type: that.data.type,//hot 最热, updatetime最新
  1322. },
  1323. success: function (res) {
  1324. if (res.data.code == '0') {
  1325. let arrflag = false, indexlist = that.data.indexlist;
  1326. if (indexlist.length != 0) {
  1327. arrflag = true;
  1328. }
  1329. indexlist = indexlist.concat(res.data.data)
  1330. that.setData({
  1331. indexlist: indexlist,
  1332. })
  1333. if (!arrflag) {
  1334. that.caseimgload();
  1335. }
  1336. }
  1337. wx.hideLoading()
  1338. }, fail() {
  1339. wx.hideLoading()
  1340. }
  1341. })
  1342. },
  1343. addsharetap: function (type) {
  1344. let that = this;
  1345. utils.$post({
  1346. url: app.globalData.webUrl + 'api/share/addlog',
  1347. header: {
  1348. 'Authorization': 'bearer ' + app.globalData.token
  1349. },
  1350. data: {
  1351. id: '0',
  1352. type: type,
  1353. },
  1354. success: function (r) { }
  1355. })
  1356. },
  1357. /**
  1358. * 用户点击右上角分享
  1359. */
  1360. onShareAppMessage: function () {
  1361. let real = '';
  1362. wx.showShareMenu({
  1363. withShareTicket: true,
  1364. menus: ['shareAppMessage', 'shareTimeline']
  1365. })
  1366. if (!!app.globalData.personMsg.binded && !!app.globalData.personMsg.binded.name) {
  1367. real = app.globalData.personMsg.binded.name + '的微官网'
  1368. } else {
  1369. real = this.data.indextitle;
  1370. }
  1371. this.addsharetap('weiwang');
  1372. return {
  1373. title: real,
  1374. imageUrl: 'https://o.nczyzs.com/xcx/xcxweiw.jpg',
  1375. path: '/pages/index/index?type=share&share_user_id=' + (this.data.share_user_id ? this.data.share_user_id : app.globalData.personMsg.id) + '&clientype=' + app.globalData.clientype + "&state=1"
  1376. }
  1377. },
  1378. onShareTimeline: function () {
  1379. let real = '';
  1380. if (!!app.globalData.personMsg.binded && !!app.globalData.personMsg.binded.name) {
  1381. real = app.globalData.personMsg.binded.name + '的微官网'
  1382. } else {
  1383. real = this.data.indextitle;
  1384. }
  1385. this.addsharetap('weiwang');
  1386. return {
  1387. title: real,
  1388. imageUrl: app.globalData.imgUrl + 'xcx/xcxweiw.jpg',
  1389. query: 'type=share&share_user_id=' + (this.data.share_user_id ? this.data.share_user_id : app.globalData.personMsg.id) + '&clientype=' + app.globalData.clientype + "&state=1&timeline=share"
  1390. }
  1391. }
  1392. })