index.js 41 KB

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