buildprogress.js 37 KB

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