buildprogress.js 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  1. // share/pages/buildprogress/buildprogress.js
  2. const app = getApp();
  3. var utils = require("../../../utils/http");
  4. let time = 0;
  5. var timer = null, page = 1;
  6. var casepage = 1;
  7. var designTimer = null;
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. showAction: false,
  14. loginFlag: false,
  15. canIUseGetUserProfile: false,
  16. showContent: false,
  17. datashow: false,
  18. showAddress: false,
  19. dialog: false,
  20. showCaseStyle: false,
  21. showArea: false,
  22. showInput: false,
  23. cid: '',
  24. clientype: '',
  25. dscTitle: '',
  26. dscDataMsg: {},
  27. nowCaseStyleName: '',
  28. nowCaseStyleId: '',
  29. nowAreaName: '',
  30. nowAreaId: '',
  31. nowAreaStart: '',
  32. nowAreaEnd: '',
  33. casekeytext: '',
  34. scrollTop: 0,
  35. detail: {},
  36. companyobj: {},
  37. progresslist: [],
  38. sharepersonMsg: {},
  39. personMsg:app.globalData.personMsg,
  40. type: 3,
  41. constructlist: [],
  42. constructnum: 0,
  43. imgUrl: app.globalData.imgUrl,
  44. caselist: [],
  45. caseTypelist: [],
  46. imageArr: [],
  47. VRlinklist: [],
  48. videolink: {},
  49. allDataCount: 1,
  50. caseTypeActive: '',
  51. showVrOrVideo: false,
  52. devCaseShow: false,
  53. showArticle: '',
  54. activeType: '',
  55. showSortNum: 1,
  56. showType: 'vr',
  57. houseTypeActive: 0,
  58. swiperIndex: 0,
  59. showVideoNum: 1,
  60. currentVideoIndex: 0,
  61. tab: [{
  62. name: '楼盘实景',
  63. type: '',
  64. count: 1
  65. }, {
  66. name: '效果图',
  67. type: 'img',
  68. count: 0
  69. }, {
  70. name: '楼盘VR',
  71. type: 'vr',
  72. count: 0
  73. }, {
  74. name: '楼盘视频',
  75. type: 'video',
  76. count: 0
  77. }],
  78. square: [
  79. { id: '', name: '全部', start: '', end: '' },
  80. { id: 1, name: '60㎡以下', start: 0, end: 60 },
  81. { id: 2, name: '60㎡—90㎡', start: 60, end: 90 },
  82. { id: 3, name: '90㎡—110㎡', start: 90, end: 110 },
  83. { id: 4, name: '110㎡—140㎡', start: 110, end: 140 },
  84. { id: 5, name: '140㎡—170㎡', start: 140, end: 170 },
  85. { id: 6, name: '170㎡—210㎡', start: 170, end: 210 },
  86. { id: 7, name: '210㎡—240㎡', start: 210, end: 240 },
  87. { id: 8, name: '240㎡—270㎡', start: 240, end: 270 },
  88. { id: 9, name: '270㎡以上', start: 270, end: '' }
  89. ],
  90. houseTypeTab: [],
  91. houseTypeArr: ['全部', '一居', '二居', '三居', '四居', '五居', '六居', '七居', '八居', '别墅'],
  92. houseTypelists: [],
  93. houseTypeItemlist: [],
  94. devCaselist: [],
  95. designPlan: false,
  96. viewMore: 3,
  97. devCaseData: []
  98. },
  99. /**
  100. * 生命周期函数--监听页面加载
  101. */
  102. onLoad(options) {
  103. time = 0;
  104. if (!options.type) {
  105. wx.hideHomeButton();
  106. }
  107. if (wx.getUserProfile) {
  108. this.setData({
  109. canIUseGetUserProfile: true
  110. })
  111. }
  112. if (!!options.scene) {
  113. options = unescape(options.scene);
  114. let arr = options.split('&');
  115. let obj = {};
  116. for (let i = 0; i < arr.length; i++) {
  117. let arr1 = arr[i].split('=');
  118. obj[arr1[0]] = arr1[1];
  119. }
  120. this.setData({
  121. cid: obj.c,
  122. clientype: obj.t
  123. })
  124. app.globalData.clientype = obj.t;
  125. app.globalData.shareuserid = obj.u;
  126. app.globalData.sharempid = obj.e;
  127. } else {
  128. if (!!options.cid) {
  129. this.setData({
  130. cid: options.cid
  131. })
  132. }
  133. if (!!options.ctp) {
  134. this.setData({
  135. clientype: options.ctp
  136. })
  137. app.globalData.clientype = options.ctp;
  138. }
  139. if (!!options.uid) {
  140. app.globalData.shareuserid = options.uid;
  141. }
  142. if (!!options.empid) {
  143. app.globalData.sharempid = options.empid;
  144. }
  145. }
  146. this.logindata()
  147. },
  148. logindata: function () {
  149. var that = this;
  150. wx.showLoading();
  151. wx.login({
  152. success: function (data) {
  153. if (data.errMsg == 'login:ok') {
  154. utils.$post({
  155. url: app.globalData.webUrl + 'api/users/code2session',
  156. data: {
  157. client_type: that.data.clientype,
  158. code: data.code,
  159. share: app.globalData.shareuserid
  160. },
  161. success: function (r) {
  162. if (r.data.code == '0') {
  163. app.globalData.sharepersonobj = r.data.share;
  164. app.globalData.token = r.data.token;
  165. that.sharecompany();
  166. that.getBuildingProgressDetail();
  167. that.setData({
  168. sharepersonMsg: app.globalData.sharepersonobj,
  169. })
  170. 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 != '游客')) {
  171. app.globalData.use_id = r.data.user.id;
  172. app.globalData.personMsg = r.data.user;
  173. app.globalData.userflag = false; //有个人信息
  174. var nickname = r.data.user.nickname;
  175. var phone = r.data.user.phone;
  176. that.setData({
  177. loginFlag: false,
  178. datashow: true,
  179. personMsg:r.data.user
  180. })
  181. if (r.data.user.phone != '') {
  182. app.globalData.personMsg = r.data.user;
  183. that.setData({
  184. mobileflag: false,
  185. phoneFlag: false
  186. })
  187. } else {
  188. that.setData({
  189. mobileflag: true,
  190. phoneFlag: true
  191. })
  192. }
  193. } else {
  194. wx.hideLoading();
  195. that.setData({
  196. articlelogin: false,
  197. loginFlag: true
  198. })
  199. }
  200. } else {
  201. wx.hideLoading();
  202. that.setData({
  203. articlelogin: false,
  204. loginFlag: true
  205. })
  206. }
  207. }
  208. })
  209. } else {
  210. wx.hideLoading();
  211. that.setData({
  212. articlelogin: false,
  213. loginFlag: true
  214. })
  215. }
  216. }
  217. })
  218. },
  219. cancelGetPhone() {
  220. designTimer = setTimeout(() => {
  221. this.setData({
  222. designPlan: true
  223. })
  224. },4000)
  225. },
  226. sharecompany: function () {
  227. const that = this;
  228. utils.$post({
  229. url: app.globalData.webUrl + 'client/index/content_belong_company',
  230. header: {
  231. 'Authorization': 'bearer ' + app.globalData.token
  232. },
  233. data: {
  234. client_type: app.globalData.clientype,
  235. uid: app.globalData.shareuserid
  236. },
  237. success: function (res) {
  238. if (res.data.code == '0') {
  239. app.globalData.companyobj=res.data.data;
  240. app.globalData.currentUserId = res.data.data.employee_id;
  241. that.setData({
  242. companyobj: res.data.data
  243. })
  244. }
  245. },
  246. complete(res) {
  247. wx.hideLoading()
  248. }
  249. })
  250. },
  251. getImageAndVRAndVideo(type) {
  252. var that = this;
  253. utils.$post({
  254. url: app.globalData.webUrl + 'client/building/progress',
  255. header: {
  256. 'Authorization': 'bearer ' + app.globalData.token
  257. },
  258. data: {
  259. id: that.data.cid,
  260. type: type,
  261. },
  262. success: function (res) {
  263. if (res.data.code == '0') {
  264. if (type == 'img') {
  265. let imgs = [];
  266. res.data.data.forEach(v => {
  267. if (v.img && v.img.length > 0) {
  268. imgs.push(...v.img);
  269. }
  270. })
  271. that.data.tab[1].count = imgs.length;
  272. that.setData({
  273. imageArr: imgs,
  274. tab: that.data.tab
  275. })
  276. } else if (type == 'vr') {
  277. let vrlist = [];
  278. res.data.data.forEach(v => {
  279. if (v.vr && v.vr.length > 0) {
  280. vrlist.push(...v.vr);
  281. }
  282. })
  283. that.data.tab[2].count = vrlist.length;
  284. that.setData({
  285. VRlinklist: vrlist,
  286. tab: that.data.tab
  287. })
  288. } else {
  289. let videoArr = res.data.data.map(v => {
  290. return { video: v.video, cover: v.img.length ? v.img[0] : '' }
  291. });
  292. that.data.tab[3].count = res.data.data.length;
  293. that.setData({
  294. videolink: videoArr,
  295. tab: that.data.tab
  296. })
  297. }
  298. }
  299. }
  300. })
  301. },
  302. /**
  303. * 获取案例数据
  304. */
  305. caselistfun: function (e) {
  306. var that = this;
  307. casepage = 1;
  308. utils.$get({
  309. url: app.globalData.webUrl + 'api/building/material_case',
  310. header: {
  311. 'Authorization': 'bearer ' + app.globalData.token
  312. },
  313. data: {
  314. page: 1,
  315. room: that.data.caseTypeActive,
  316. building_id: that.data.cid,
  317. // style_id: that.data.nowCaseStyleId,
  318. // square_start: that.data.nowAreaStart,
  319. // square_end: that.data.nowAreaEnd,
  320. // keyword: that.data.casekeytext
  321. },
  322. success: function (res) {
  323. that.setData({
  324. datashow: true
  325. })
  326. if (res.data.code == '0') {
  327. let caseType = res.data.data.housetype_list.map(v => {
  328. return { name: that.data.houseTypeArr[v.room], id: v.room, count: v.count }
  329. });
  330. that.setData({
  331. caselist: res.data.data.list,
  332. caseTypelist: caseType.length ? caseType.sort(that.compare("id")) : []
  333. })
  334. }
  335. setTimeout(function () {
  336. wx.hideLoading()
  337. }, 1000)
  338. },
  339. fail() {
  340. wx.hideLoading()
  341. }
  342. })
  343. },
  344. closeDesigntap(e) {
  345. if (designTimer) {
  346. clearTimeout(designTimer);
  347. }
  348. if (e.detail.type == 'success') {
  349. this.setData({
  350. designPlan: false
  351. })
  352. } else {
  353. this.setData({
  354. designPlan: false
  355. })
  356. }
  357. },
  358. /**
  359. * 排序
  360. */
  361. compare(property) {
  362. return function (a, b) {
  363. var value1 = a[property];
  364. var value2 = b[property];
  365. return value1 - value2;
  366. }
  367. },
  368. viewDevCase(e) {
  369. let id = e.currentTarget.dataset.id;
  370. var that = this;
  371. utils.$get({
  372. url: app.globalData.webUrl + 'client/building/dev_case_list',
  373. header: {
  374. 'Authorization': 'bearer ' + app.globalData.token
  375. },
  376. data: {
  377. id: id,
  378. },
  379. success: function (res) {
  380. if (res.data.code == '0') {
  381. that.setData({
  382. devCaselist: res.data.data,
  383. devCaseShow: true
  384. })
  385. } else {
  386. wx.showToast({
  387. title: res.data.msg,
  388. icon: 'none',
  389. duration: 1500
  390. })
  391. }
  392. }
  393. })
  394. },
  395. devCaseDetail(e) {
  396. let id = e.currentTarget.dataset.id;
  397. let type = e.currentTarget.dataset.type;
  398. if (type == 1) {
  399. var that = this;
  400. utils.$get({
  401. url: app.globalData.webUrl + 'client/building/dev_case_detail',
  402. header: {
  403. 'Authorization': 'bearer ' + app.globalData.token
  404. },
  405. data: {
  406. id: id,
  407. },
  408. success: function (res) {
  409. if (res.data.code == '0') {
  410. let vrlink = res.data.data.vr_link;
  411. if (vrlink) {
  412. wx.navigateTo({
  413. url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&uid=' + app.globalData.shareuserid + '&cty=building' + '&ctp=' + app.globalData.clientype + '&aid=' + that.data.detail.id,
  414. })
  415. } else {
  416. wx.showToast({
  417. title: '未上传VR链接',
  418. icon: 'none',
  419. duration: 1500
  420. })
  421. }
  422. } else {
  423. wx.showToast({
  424. title: res.data.msg,
  425. icon: 'none',
  426. duration: 1500
  427. })
  428. }
  429. }
  430. })
  431. } else {
  432. wx.navigateTo({
  433. url: '/index/pages/viewcase/viewcase?cid=' + id + '&type=2' + '&ctp=' + app.globalData.clientype + '&uid=' + app.globalData.shareuserid,
  434. })
  435. }
  436. },
  437. /**
  438. * 搜索案例
  439. */
  440. searchCaselist(e) {
  441. let id = e.currentTarget.dataset.type;
  442. this.setData({
  443. caseTypeActive: id
  444. })
  445. this.caselistfun();
  446. },
  447. /**
  448. * 前往案例详情
  449. */
  450. casemsgtap: function (e) {
  451. wx.navigateTo({
  452. url: '/share/pages/materialcase/materialcase?type=3&cid=' + e.currentTarget.dataset.cid + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype
  453. })
  454. },
  455. /**
  456. * 前往个人名片
  457. */
  458. toPageNameCard() {
  459. wx.navigateTo({
  460. url: '/share/pages/shareCard/shareCard?uid=' + app.globalData.shareuserid + '&empid=' + app.globalData.currentUserId + '&ctp=' + app.globalData.clientype + '&ftype=share',
  461. })
  462. },
  463. callphonetap: function () {
  464. console.log()
  465. wx.makePhoneCall({
  466. phoneNumber: app.globalData.sharepersonobj.phone //仅为示例,并非真实的电话号码
  467. })
  468. },
  469. swiperChange(e) {
  470. let currentItemId = e.detail.currentItemId;
  471. if (currentItemId.indexOf('img') > -1) {
  472. let index = currentItemId.split('-')[1];
  473. let type = currentItemId.split('-')[0];
  474. this.setData({
  475. activeType: type,
  476. showSortNum: parseInt(index) + 1,
  477. allDataCount: this.data.imageArr.length
  478. })
  479. }
  480. if (currentItemId.indexOf('vr') > -1) {
  481. let index = currentItemId.split('-')[1];
  482. let type = currentItemId.split('-')[0];
  483. this.setData({
  484. activeType: type,
  485. showSortNum: parseInt(index) + 1,
  486. allDataCount: this.data.VRlinklist.length
  487. })
  488. }
  489. if (currentItemId.indexOf('video') > -1) {
  490. let index = currentItemId.split('-')[1];
  491. let type = currentItemId.split('-')[0];
  492. this.setData({
  493. activeType: type,
  494. showSortNum: parseInt(index) + 1,
  495. allDataCount: this.data.videolink.length
  496. })
  497. }
  498. if (currentItemId.indexOf('cover') > -1) {
  499. this.setData({
  500. activeType: '',
  501. showSortNum: 1,
  502. allDataCount: 1
  503. })
  504. }
  505. },
  506. swiperVideoChange(e) {
  507. this.setData({
  508. showVideoNum: parseInt(e.detail.current) + 1
  509. })
  510. },
  511. /**
  512. * 风格类型获取
  513. */
  514. casestylefun: function () {
  515. var that = this;
  516. utils.$get({
  517. url: app.globalData.webUrl + 'api/stylelist',
  518. header: {
  519. 'Authorization': 'bearer ' + app.globalData.token
  520. },
  521. data: {},
  522. success: function (res) {
  523. if (res.data.code == '0') {
  524. res.data.data.unshift({ name: '全部', id: '' })
  525. that.setData({
  526. casestylelist: res.data.data
  527. })
  528. }
  529. }
  530. })
  531. },
  532. chooseCaseStyle(e) {
  533. let id = e.currentTarget.dataset.id;
  534. let name = e.currentTarget.dataset.name;
  535. this.setData({
  536. nowCaseStyleName: name,
  537. nowCaseStyleId: id,
  538. showCaseStyle: false
  539. })
  540. this.caselistfun();
  541. },
  542. chooseArea(e) {
  543. let id = e.currentTarget.dataset.id;
  544. let name = e.currentTarget.dataset.name;
  545. let start = e.currentTarget.dataset.start;
  546. let end = e.currentTarget.dataset.end;
  547. this.setData({
  548. nowAreaName: name,
  549. nowAreaId: id,
  550. nowAreaStart: start,
  551. nowAreaEnd: end,
  552. showArea: false
  553. })
  554. this.caselistfun();
  555. },
  556. setcasekeywordtap: function (e) {
  557. this.setData({
  558. casekeytext: e.detail.value
  559. })
  560. },
  561. closeMask() {
  562. this.setData({
  563. showVrOrVideo: false,
  564. dialog: false,
  565. showArea: false,
  566. showCaseStyle: false,
  567. showInput: false,
  568. devCaseShow: false
  569. })
  570. },
  571. handleCaseStyle() {
  572. this.setData({
  573. showCaseStyle: true
  574. })
  575. },
  576. handleShowArea() {
  577. this.setData({
  578. showArea: true
  579. })
  580. },
  581. handleShowInput() {
  582. this.data.showInput = !this.data.showInput;
  583. this.setData({
  584. showInput: this.data.showInput
  585. })
  586. },
  587. handleMore() {
  588. if (this.data.viewMore == this.data.progresslist.length) {
  589. this.setData({
  590. viewMore: 3
  591. })
  592. } else {
  593. this.setData({
  594. viewMore: this.data.progresslist.length
  595. })
  596. }
  597. },
  598. searchCase() {
  599. this.setData({
  600. showInput: false
  601. })
  602. this.caselistfun();
  603. },
  604. dothis() { },
  605. prelooktap() {
  606. if (!app.globalData.sharepersonobj.qrcode) {
  607. wx.showToast({
  608. title: "当前专属客服的二维码为空!",
  609. icon: 'none',
  610. duration: 2000
  611. })
  612. return false;
  613. }
  614. wx.previewImage({
  615. current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
  616. urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表
  617. })
  618. },
  619. setypetap(e) {
  620. this.setData({
  621. type: e.currentTarget.dataset.type
  622. })
  623. },
  624. getBuildingProgressDetail(e) {
  625. var that = this;
  626. utils.$post({
  627. url: app.globalData.webUrl + 'client/building/view',
  628. header: {
  629. 'Authorization': 'bearer ' + app.globalData.token
  630. },
  631. data: {
  632. id: that.data.cid
  633. },
  634. success: function (res) {
  635. if (res.data.code == 0) {
  636. wx.hideLoading();
  637. let dataMsg = res.data.data;
  638. dataMsg.update_time = dataMsg.update_time ? dataMsg.update_time.split(' ')[0] : '';
  639. dataMsg.areastr = dataMsg.area_list.map(v => `${v}㎡`).join('/');
  640. dataMsg.content = dataMsg.content.replace(/\r|\n/ig, "");
  641. let houseTypeArry = [];
  642. let devCaselist = [];
  643. if (dataMsg.housetype && Object.keys(dataMsg.housetype).length > 0) {
  644. Object.keys(dataMsg.housetype).forEach(v => {
  645. houseTypeArry.push({ name: that.data.houseTypeArr[v], id: v, count: dataMsg.housetype[v].length, list: dataMsg.housetype[v] })
  646. })
  647. if (houseTypeArry.length) {
  648. houseTypeArry[0].list.forEach(v => {
  649. if (v.devcase && v.devcase.length) {
  650. devCaselist.push(...v.devcase)
  651. }
  652. })
  653. }
  654. }
  655. that.data.tab[1].count = dataMsg.cover.length;
  656. that.setData({
  657. detail: dataMsg,
  658. imageArr: dataMsg.cover,
  659. tab: that.data.tab,
  660. houseTypelists: houseTypeArry.length ? houseTypeArry.sort(that.compare("id")) : [],
  661. houseTypeItemlist: houseTypeArry.length ? houseTypeArry[0].list : [],
  662. devCaseData: devCaselist
  663. })
  664. if (that.data.detail.name) {
  665. wx.setNavigationBarTitle({
  666. title: that.data.detail.name,
  667. })
  668. }
  669. } else {
  670. setTimeout(() => {
  671. wx.hideLoading();
  672. }, 1500)
  673. }
  674. }
  675. })
  676. this.buildingProgress();
  677. // this.getImageAndVRAndVideo('img');
  678. this.getImageAndVRAndVideo('vr');
  679. this.getImageAndVRAndVideo('video');
  680. this.caselistfun();
  681. this.constructfun();
  682. // this.casestylefun();
  683. },
  684. houseTypeDsc(e) {
  685. let index = e.currentTarget.dataset.index;
  686. let title = e.currentTarget.dataset.title;
  687. let room = e.currentTarget.dataset.room;
  688. this.setData({
  689. dscDataMsg: this.data.houseTypeItemlist[index],
  690. dscTitle: room == 9 ? '别墅' : title,
  691. dialog: true
  692. })
  693. },
  694. constructfun() {
  695. const that = this;
  696. page = 1;
  697. utils.$post({
  698. url: app.globalData.webUrl + 'client/building/construction',
  699. header: {
  700. 'Authorization': 'bearer ' + app.globalData.token
  701. },
  702. data: {
  703. building_id: that.data.cid,
  704. page: 1
  705. },
  706. success: function (res) {
  707. that.setData({
  708. constructlist: res.data.data,
  709. constructnum: res.data.count
  710. })
  711. }
  712. })
  713. },
  714. sitetap(e) {
  715. wx.navigateTo({
  716. url: '/share/pages/constructsite/constructsite?type=3&cid=' + e.currentTarget.dataset.cid + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype,
  717. })
  718. },
  719. getPhoneNumberTap(res) {
  720. let type = res.currentTarget.dataset.type;
  721. let that = this;
  722. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  723. utils.$post({
  724. url: app.globalData.webUrl + 'api/users/setUserMobile',
  725. data: {
  726. encryptedData: res.detail.encryptedData,
  727. iv: res.detail.iv
  728. },
  729. header: {
  730. 'Authorization': 'bearer ' + app.globalData.token
  731. },
  732. success: function (r) {
  733. if (r.data.code == '0') {
  734. if (type == "update") {
  735. that.urgeUpdateData();
  736. } else {
  737. that.signUpClient(r.data.mobile);
  738. }
  739. } else {
  740. wx.showToast({
  741. title: r.data.msg,
  742. icon: "none",
  743. duration: 2000
  744. });
  745. }
  746. }
  747. })
  748. }
  749. },
  750. urgeUpdateData() {
  751. var that = this;
  752. utils.$post({
  753. url: app.globalData.webUrl + 'client/building/urge',
  754. header: {
  755. 'Authorization': 'bearer ' + app.globalData.token
  756. },
  757. data: {
  758. employee_id: app.globalData.sharempid,
  759. building_id: that.data.cid
  760. },
  761. success: function (res) {
  762. if (res.data.code == 0) {
  763. wx.showToast({
  764. title: '催更成功',
  765. icon: 'success',
  766. duration: 1500
  767. })
  768. }
  769. }
  770. })
  771. },
  772. signUpClient(phone) {
  773. var that = this;
  774. utils.$post({
  775. url: app.globalData.webUrl + 'client/index/signUp',
  776. header: {
  777. 'Authorization': 'bearer ' + app.globalData.token
  778. },
  779. data: {
  780. mobile: phone,
  781. type: 'building',
  782. id: that.data.cid,
  783. },
  784. success: function (res) {
  785. if (res.data.code == 0) {
  786. wx.showToast({
  787. title: '恭喜您报名成功,稍后会有服务顾问跟您联系',
  788. icon: 'none',
  789. duration: 1500
  790. })
  791. }
  792. }
  793. })
  794. },
  795. /**
  796. * 切换
  797. */
  798. handleSwitch(e) {
  799. let type = e.currentTarget.dataset.type;
  800. let count = e.currentTarget.dataset.count;
  801. let swiperIndex = 0;
  802. if (type == 'img') {
  803. swiperIndex = 1;
  804. } else if (type == 'vr') {
  805. swiperIndex = this.data.imageArr.length + 1;
  806. } else if (type == 'video') {
  807. swiperIndex = this.data.imageArr.length + this.data.VRlinklist.length + 1;
  808. } else {
  809. swiperIndex = 0;
  810. }
  811. this.setData({
  812. swiperIndex: swiperIndex,
  813. activeType: type,
  814. allDataCount: count,
  815. showSortNum: 1,
  816. })
  817. },
  818. toggleClass(e) {
  819. let id = e.currentTarget.dataset.cid;
  820. if (id == this.data.showArticle) {
  821. this.setData({
  822. showArticle: ''
  823. })
  824. } else {
  825. this.setData({
  826. showArticle: id
  827. })
  828. }
  829. },
  830. handleFullPlay(e) {
  831. let videoId = e.currentTarget.dataset.id;
  832. var videoContext = this.selectComponent(`#${videoId}`);
  833. videoContext.requestFullScreen({ direction: 0 })
  834. },
  835. /**
  836. * 户型切换
  837. */
  838. handlelist(e) {
  839. let type = e.currentTarget.dataset.type;
  840. let idx = e.currentTarget.dataset.index;
  841. let devCaselist = [];
  842. this.data.houseTypelists[idx].list.forEach(v => {
  843. if (v.devcase && v.devcase.length) {
  844. devCaselist.push(...v.devcase);
  845. }
  846. })
  847. this.setData({
  848. houseTypeActive: type,
  849. houseTypeItemlist: this.data.houseTypelists[idx].list,
  850. devCaseData: devCaselist
  851. })
  852. },
  853. /**
  854. * 放大图片
  855. * @param {*} e
  856. */
  857. previewImage(e) {
  858. let type = e.currentTarget.dataset.type;
  859. if (type == 'cover') {
  860. let imgUrl = e.currentTarget.dataset.img;
  861. if (imgUrl) {
  862. wx.previewImage({
  863. current: imgUrl,
  864. urls: [imgUrl]
  865. })
  866. } else {
  867. wx.showToast({
  868. title: '暂无图片展示',
  869. icon: 'none',
  870. })
  871. }
  872. } else if (type == 'image') {
  873. let imgUrl = e.currentTarget.dataset.img;
  874. wx.previewImage({
  875. current: imgUrl,
  876. urls: this.data.imageArr
  877. })
  878. } else if (type == 'vr') {
  879. this.setData({
  880. showVrOrVideo: true,
  881. showType: 'vr'
  882. })
  883. } else if (type == 'video') {
  884. this.setData({
  885. showVrOrVideo: true,
  886. showType: 'video',
  887. currentVideoIndex: this.data.showSortNum - 1 < 0 ? 0 : (this.data.showSortNum - 1),
  888. showVideoNum: this.data.showSortNum
  889. })
  890. } else if (type == 'himg') {
  891. let idx = e.currentTarget.dataset.index;
  892. let imgUrl = e.currentTarget.dataset.img;
  893. wx.previewImage({
  894. current: imgUrl,
  895. urls: this.data.houseTypeItemlist[idx].house_img,
  896. })
  897. } else {
  898. let imgUrl = e.currentTarget.dataset.img;
  899. let index = e.currentTarget.dataset.index;
  900. var arr = this.data.progresslist[index].img;
  901. wx.previewImage({
  902. current: imgUrl,
  903. urls: arr,
  904. })
  905. }
  906. },
  907. openVRLink(e) {
  908. let type = e.currentTarget.dataset.type;
  909. if (type == 2) {
  910. let vrlink = e.currentTarget.dataset.vr;
  911. wx.navigateTo({
  912. url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&uid=' + app.globalData.shareuserid + '&cty=building' + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.detail.id,
  913. })
  914. } else {
  915. let aid = e.currentTarget.dataset.id;
  916. let vrlink = e.currentTarget.dataset.vrlink;
  917. wx.navigateTo({
  918. url: '/pages/other/other?type=vr&vrurl=' + escape(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&aid=' + aid,
  919. })
  920. }
  921. },
  922. showAllContent() {
  923. let showContent = !this.data.showContent;
  924. this.setData({
  925. showContent: showContent
  926. })
  927. },
  928. buildingProgress() {
  929. var that = this;
  930. utils.$post({
  931. url: app.globalData.webUrl + 'client/building/progress',
  932. header: {
  933. 'Authorization': 'bearer ' + app.globalData.token
  934. },
  935. data: {
  936. id: that.data.cid
  937. },
  938. success: function (res) {
  939. let progress = res.data.data;
  940. that.setData({
  941. progresslist: progress,
  942. datashow: true,
  943. })
  944. }
  945. })
  946. },
  947. /**
  948. * 展示地址
  949. */
  950. showAddressName(e) {
  951. let type = e.currentTarget.dataset.type;
  952. if (type == 'hide') {
  953. this.setData({
  954. showAddress: false
  955. })
  956. } else {
  957. this.setData({
  958. showAddress: true
  959. })
  960. }
  961. },
  962. operateBtn() {
  963. this.setData({
  964. showAction: false
  965. })
  966. },
  967. sharelogtap: function () {
  968. var that = this;
  969. utils.$post({
  970. url: app.globalData.webUrl + 'api/share/addlog',
  971. header: {
  972. 'Authorization': 'bearer ' + app.globalData.token
  973. },
  974. data: {
  975. id: that.data.cid,
  976. type: 'building'
  977. },
  978. success: function (r) {
  979. }
  980. })
  981. },
  982. /**
  983. * 生命周期函数--监听页面初次渲染完成
  984. */
  985. onReady() {
  986. },
  987. /**
  988. * 生命周期函数--监听页面显示
  989. */
  990. onShow() {
  991. this.setData({
  992. imgUrl: app.globalData.imgUrl,
  993. })
  994. timer = setInterval(function () {
  995. time = time * 1 + 1;
  996. }, 1000)
  997. },
  998. /**
  999. * 生命周期函数--监听页面隐藏
  1000. */
  1001. onHide() {
  1002. if (timer) {
  1003. clearInterval(timer)
  1004. }
  1005. this.visitimefun();
  1006. },
  1007. visitimefun() {
  1008. const that = this;
  1009. utils.$post({
  1010. url: app.globalData.webUrl + 'client/index/visit_due_time',
  1011. header: {
  1012. 'Authorization': 'bearer ' + app.globalData.token
  1013. },
  1014. data: {
  1015. id: that.data.cid,
  1016. pipe_type: 'building',
  1017. time: time,
  1018. },
  1019. success: function (res) {
  1020. }
  1021. })
  1022. },
  1023. /**
  1024. * 生命周期函数--监听页面卸载
  1025. */
  1026. onUnload() {
  1027. this.visitimefun();
  1028. },
  1029. /**
  1030. * 页面相关事件处理函数--监听用户下拉动作
  1031. */
  1032. onPullDownRefresh() {
  1033. },
  1034. /**
  1035. * 页面上拉触底事件的处理函数
  1036. */
  1037. onReachBottom() {
  1038. const that = this;
  1039. if (!!app.globalData.token) {
  1040. page = page * 1 + 1;
  1041. utils.$post({
  1042. url: app.globalData.webUrl + 'client/building/construction',
  1043. header: {
  1044. 'Authorization': 'bearer ' + app.globalData.token
  1045. },
  1046. data: {
  1047. building_id: that.data.cid,
  1048. page: page
  1049. },
  1050. success: function (res) {
  1051. let constructlist = that.data.constructlist;
  1052. if (res.data.code == 0) {
  1053. constructlist = constructlist.concat(res.data.data);
  1054. that.setData({
  1055. constructlist: constructlist,
  1056. })
  1057. }
  1058. }
  1059. })
  1060. }
  1061. },
  1062. /**
  1063. * 用户点击右上角分享
  1064. */
  1065. onShareAppMessage(e) {
  1066. const that = this;
  1067. let type = e.target ? e.target.dataset.type : '';
  1068. let id = e.target ? e.target.dataset.id : '';
  1069. if (type == "progress") {
  1070. return {
  1071. title: that.data.detail.name + '-楼盘进度',
  1072. imageUrl: that.data.detail.cover[0],
  1073. path: '/share/pages/buildShare/buildShare?cid=' + id + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id
  1074. }
  1075. } else {
  1076. this.sharelogtap();
  1077. return {
  1078. title: this.data.detail.name,
  1079. imageUrl: this.data.detail.cover[0],
  1080. path: '/share/pages/buildprogress/buildprogress?cid=' + this.data.cid + '&uid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.sharempid
  1081. }
  1082. }
  1083. }
  1084. })