buildprogress.js 37 KB

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