index.js 43 KB

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