progressdetail.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. // index/pages/progressdetail/progressdetail.js
  2. const app = getApp();
  3. var utils = require("../../../utils/http");
  4. const util = require("../../../utils/util")
  5. let page = 1;
  6. let vrpage = 1;
  7. let videopage = 1;
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. cid: '',
  14. detail: {},
  15. companyobj: {},
  16. personMsg: {},
  17. progresslist: [],
  18. showContent: false,
  19. datashow: false,
  20. dialog: false,
  21. showCaseStyle: false,
  22. showArea: false,
  23. showInput: false,
  24. moreVrBol: false,
  25. moreVideoBol: false,
  26. type: 3,
  27. labelArr: [],
  28. constructlist: [],
  29. caselist: [],
  30. imageArr: [],
  31. VRlinklist: [],
  32. caseTypelist: [],
  33. videolink: {},
  34. constructnum: 0,
  35. allDataCount: 1,
  36. imgUrl: app.globalData.imgUrl,
  37. wshareshow: false,
  38. showVrOrVideo: false,
  39. showTask: true,
  40. showArticle: '',
  41. activeType: '',
  42. caseTypeActive: '',
  43. dscTitle: '',
  44. dscDataMsg: {},
  45. nowCaseStyleName: '',
  46. nowCaseStyleId: '',
  47. nowAreaName: '',
  48. nowAreaId: '',
  49. nowAreaStart: '',
  50. nowAreaEnd: '',
  51. casekeytext: '',
  52. showSortNum: 1,
  53. showType: 'vr',
  54. houseTypeActive: 0,
  55. showVideoNum: 1,
  56. currentVideoIndex: 0,
  57. tab: [{
  58. name: '实景',
  59. type: '',
  60. count: 1
  61. }, {
  62. name: '效果图',
  63. type: 'img',
  64. count: 0
  65. }, {
  66. name: 'VR',
  67. type: 'vr',
  68. count: 0
  69. }, {
  70. name: '视频',
  71. type: 'video',
  72. count: 0
  73. }],
  74. houseTypeTab: [],
  75. houseTypeArr: ['全部', '一居', '二居', '三居', '四居', '五居', '六居', '七居', '八居', '别墅'],
  76. houseTypelists: [],
  77. houseTypeItemlist: [],
  78. devCaselist: [],
  79. ltype: '',
  80. bType: "",
  81. pType: "",
  82. labelId: "",
  83. viewMore: 3,
  84. devCaseData: [],
  85. showCutImage: false,
  86. loading: false,
  87. showApproval: false,
  88. remark: "",
  89. trackimgarr: [],
  90. nowimagearr: [],
  91. shareApprovallist: [],
  92. shareUrl: '',
  93. shareTitle: '',
  94. shareImage: '',
  95. shareType: '',
  96. shareId: '',
  97. shareQuery: ''
  98. },
  99. /**
  100. * 生命周期函数--监听页面加载
  101. */
  102. onLoad(options) {
  103. page = 1;
  104. vrpage = 1;
  105. videopage = 1;
  106. if (!!options.cid) {
  107. wx.showLoading({
  108. title: '加载中...',
  109. })
  110. this.setData({
  111. companyobj: app.globalData.companyobj,
  112. cid: options.cid,
  113. personMsg: app.globalData.personMsg,
  114. })
  115. if (this.data.companyobj.company_name) {
  116. if (this.data.companyobj.company_name.length > 6) {
  117. this.data.companyobj.company_name = this.data.companyobj.company_name.substring(0, 6);
  118. this.setData({
  119. companyobj: this.data.companyobj
  120. })
  121. }
  122. }
  123. this.getBuildingProgressDetail();
  124. }
  125. if (!!options.ty) {
  126. this.setData({
  127. bType: options.ty,
  128. showTask: false
  129. })
  130. }
  131. if (!!options.tp) {
  132. this.setData({
  133. pType: options.tp
  134. })
  135. }
  136. if (options.type) {
  137. this.setData({
  138. ltype: options.type
  139. })
  140. }
  141. },
  142. handShowUpload: function () {
  143. this.setData({
  144. trackimgarr: [],
  145. nowimagearr: [],
  146. remark: "",
  147. showCutImage: true
  148. })
  149. },
  150. handleShowApproval() {
  151. this.setData({
  152. showApproval: true
  153. })
  154. wx.showLoading({
  155. title: '加载中...',
  156. })
  157. this.getBrokerApprovallist();
  158. },
  159. //获取审核列表
  160. getBrokerApprovallist() {
  161. const that = this;
  162. utils.$post({
  163. url: app.globalData.webUrl + 'api/agentEmp/share_list',
  164. header: {
  165. 'Authorization': 'bearer ' + app.globalData.token
  166. },
  167. data: {
  168. id: that.data.cid,
  169. type: "Building"
  170. },
  171. success: function (res) {
  172. wx.hideLoading();
  173. if (res.data.code == 0) {
  174. that.setData({
  175. shareApprovallist: res.data.data
  176. })
  177. }
  178. }
  179. })
  180. },
  181. getBuildingProgresslabel() {
  182. const that = this;
  183. utils.$post({
  184. url: app.globalData.webUrl + 'api/buildingLabel/index',
  185. header: {
  186. 'Authorization': 'bearer ' + app.globalData.token
  187. },
  188. data: {},
  189. success: function (res) {
  190. if (res.data.code == 0) {
  191. that.setData({
  192. labelArr: res.data.data
  193. })
  194. }
  195. }
  196. })
  197. },
  198. switchlabelFun(e) {
  199. page = 1;
  200. this.setData({
  201. labelId: e.currentTarget.dataset.id
  202. })
  203. wx.showLoading({
  204. title: '加载中...',
  205. })
  206. this.buildingProgress();
  207. },
  208. previewImageEvent(e) {
  209. let index = parseInt(e.currentTarget.dataset.index);
  210. let idx = parseInt(e.currentTarget.dataset.idx);
  211. wx.previewImage({
  212. urls: this.data.shareApprovallist[index].img,
  213. current: this.data.shareApprovallist[index].img[idx]
  214. })
  215. },
  216. closeDialog: function () {
  217. this.setData({
  218. showCutImage: false,
  219. showApproval: false
  220. })
  221. },
  222. getTextarea(e) {
  223. this.setData({
  224. remark: e.detail.value
  225. })
  226. },
  227. //审核通过
  228. confirmApproval(e) {
  229. let id = e.currentTarget.dataset.id;
  230. const that = this;
  231. wx.showModal({
  232. title: '审核提醒',
  233. content: '您确认通过审核吗?',
  234. complete: (res) => {
  235. if (res.confirm) {
  236. utils.$post({
  237. url: app.globalData.webUrl + 'api/agentEmp/validate_share',
  238. header: {
  239. 'Authorization': 'bearer ' + app.globalData.token
  240. },
  241. data: {
  242. share_id: id,
  243. status: 1
  244. },
  245. success: function (res) {
  246. if (res.data.code == 0) {
  247. wx.showToast({
  248. title: '已通过审核',
  249. icon: "none",
  250. duration: 1500,
  251. success: function () {
  252. setTimeout(() => {
  253. that.getBrokerApprovallist();
  254. }, 1000)
  255. }
  256. })
  257. }
  258. }
  259. })
  260. }
  261. }
  262. })
  263. },
  264. //审核拒绝
  265. rejectApproval(e) {
  266. let id = e.currentTarget.dataset.id;
  267. const that = this;
  268. wx.showModal({
  269. title: '审核提醒',
  270. content: '您确认驳回审核吗?',
  271. complete: (res) => {
  272. if (res.confirm) {
  273. utils.$post({
  274. url: app.globalData.webUrl + 'api/agentEmp/validate_share',
  275. header: {
  276. 'Authorization': 'bearer ' + app.globalData.token
  277. },
  278. data: {
  279. share_id: id,
  280. status: 2
  281. },
  282. success: function (res) {
  283. if (res.data.code == 0) {
  284. wx.showToast({
  285. title: '已驳回审核',
  286. icon: "none",
  287. duration: 1500,
  288. success: function () {
  289. setTimeout(() => {
  290. that.getBrokerApprovallist();
  291. }, 1000)
  292. }
  293. })
  294. }
  295. }
  296. })
  297. }
  298. }
  299. })
  300. },
  301. //上传分享截图
  302. submitData() {
  303. if (!this.data.trackimgarr.length) {
  304. wx.showToast({
  305. title: '请上传分享截图!',
  306. icon: "none",
  307. duration: 1500,
  308. })
  309. return false;
  310. }
  311. this.setData({
  312. loading: true
  313. })
  314. this.ossuploadimg();
  315. },
  316. uploadImage() {
  317. let _this = this;
  318. wx.chooseMedia({
  319. count: 9,
  320. mediaType: ["image"],
  321. sourceType: ["album", "camera"],
  322. sizeType: ['original', 'compressed'],
  323. success: function (res) {
  324. if (res.errMsg == "chooseMedia:ok") {
  325. _this.createImagePayment(res.tempFiles);
  326. }
  327. }
  328. })
  329. },
  330. //删除图片
  331. imageDel(e) {
  332. let index = e.currentTarget.dataset.index;
  333. this.data.trackimgarr.splice(index, 1);
  334. this.setData({
  335. trackimgarr: this.data.trackimgarr
  336. })
  337. },
  338. //选择添加图片
  339. createImagePayment: function (imgUrl) {
  340. var that = this;
  341. if (imgUrl.length == 0) return;
  342. var lent = that.data.trackimgarr.length + imgUrl.length;
  343. if (lent > 9) {
  344. lent = 9
  345. } else {
  346. lent = lent;
  347. }
  348. let trackimgarr = that.data.trackimgarr;
  349. let len = imgUrl.length;
  350. if ((trackimgarr.length + len) > 9) {
  351. for (let j = 0; j < len; j++) {
  352. if (trackimgarr.length < 9) {
  353. trackimgarr.push(imgUrl[j]);
  354. }
  355. }
  356. } else {
  357. trackimgarr = trackimgarr.concat(imgUrl);
  358. }
  359. that.setData({
  360. trackimgarr: trackimgarr
  361. })
  362. },
  363. //oss上传图片到阿里云
  364. ossuploadimg: function (e) {
  365. let that = this;
  366. let trackimgarr = that.data.trackimgarr;
  367. var arr = [];
  368. for (let i = 0; i < trackimgarr.length; i++) {
  369. //获取文件后缀
  370. // 随机生成文件名称
  371. let rstr = trackimgarr[i].tempFilePath.split('.');
  372. var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
  373. var imgName = fileRandName + '.' + 'png';
  374. // var fileName = that.data.;
  375. var date = new Date();
  376. var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
  377. var imgstr = 'broker/' + time + '/' + imgName;
  378. var nowimagearr = that.data.nowimagearr;
  379. nowimagearr.push(imgstr);
  380. that.setData({
  381. nowimagearr: nowimagearr
  382. })
  383. wx.uploadFile({
  384. url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
  385. filePath: trackimgarr[i].tempFilePath,
  386. name: 'file',
  387. formData: {
  388. // name: that.data.imgSrc[0],
  389. key: 'broker/' + time + '/' + imgName,
  390. policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
  391. OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
  392. success_action_status: "200",
  393. signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
  394. },
  395. header: {
  396. "Content-Type": "multipart/form-data",
  397. 'accept': 'application/json',
  398. },
  399. success: function (rs) {
  400. if (rs.errMsg == 'uploadFile:ok') {
  401. arr.push('0');
  402. if (arr.length == trackimgarr.length) {
  403. that.requestUploadImageApi();
  404. }
  405. }
  406. },
  407. fail(res) {
  408. wx.hideLoading()
  409. }
  410. })
  411. }
  412. },
  413. //提交数据
  414. requestUploadImageApi() {
  415. let that = this;
  416. let imgs = that.data.nowimagearr.map(v => {
  417. return { serverId: "", img: v, };
  418. })
  419. utils.$post({
  420. url: app.globalData.webUrl + 'api/agentsWork/upload_share_log',
  421. header: {
  422. 'Authorization': 'bearer ' + app.globalData.token
  423. },
  424. data: {
  425. article_id: that.data.cid,
  426. file_media_id: imgs,
  427. remarks: that.data.remark,
  428. type: "Building"
  429. },
  430. success: function (res) {
  431. that.setData({
  432. loading: false
  433. })
  434. if (res.data.code == '0') {
  435. wx.showToast({
  436. title: '上传成功',
  437. icon: "success",
  438. duration: 1500
  439. })
  440. that.setData({
  441. showCutImage: false
  442. })
  443. }
  444. }
  445. })
  446. },
  447. viewHouseType(e) {
  448. let cid = e.currentTarget.dataset.cid;
  449. wx.navigateTo({
  450. url: '/index/pages/housetype/housetype?cid=' + cid + '&buildId=' + this.data.cid + '&ty=' + this.data.bType,
  451. })
  452. },
  453. /**
  454. * 排序
  455. */
  456. compare(property) {
  457. return function (a, b) {
  458. var value1 = a[property];
  459. var value2 = b[property];
  460. return value1 - value2;
  461. }
  462. },
  463. toggleClass(e) {
  464. let id = e.currentTarget.dataset.cid;
  465. if (id == this.data.showArticle) {
  466. this.setData({
  467. showArticle: ''
  468. })
  469. } else {
  470. this.setData({
  471. showArticle: id
  472. })
  473. }
  474. },
  475. jumpNameCard() {
  476. wx.navigateTo({
  477. url: '/index/pages/namecard/namecard'
  478. })
  479. },
  480. devCaseDetail(e) {
  481. let id = e.currentTarget.dataset.id;
  482. let type = e.currentTarget.dataset.type;
  483. if (type == 1) {
  484. var that = this;
  485. utils.$get({
  486. url: app.globalData.webUrl + 'api/building/dev_case_detail',
  487. header: {
  488. 'Authorization': 'bearer ' + app.globalData.token
  489. },
  490. data: {
  491. id: id,
  492. },
  493. success: function (res) {
  494. if (res.data.code == '0') {
  495. let vrlink = res.data.data.vr_link;
  496. if (vrlink) {
  497. wx.navigateTo({
  498. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&uid=' + (app.globalData.shareuserid ? app.globalData.shareuserid : app.globalData.personMsg.id) + '&cty=building' + '&ctp=' + app.globalData.clientype + '&aid=' + that.data.detail.id,
  499. })
  500. } else {
  501. wx.showToast({
  502. title: '未上传VR链接',
  503. icon: 'none',
  504. duration: 1500
  505. })
  506. }
  507. } else {
  508. wx.showToast({
  509. title: res.data.msg,
  510. icon: 'none',
  511. duration: 1500
  512. })
  513. }
  514. }
  515. })
  516. } else {
  517. wx.navigateTo({
  518. url: '/index/pages/viewcase/viewcase?cid=' + id + '&type=1',
  519. })
  520. }
  521. },
  522. handleSwitch(e) {
  523. let type = e.currentTarget.dataset.type;
  524. let count = e.currentTarget.dataset.count;
  525. let swiperIndex = 0;
  526. if (type == 'img') {
  527. swiperIndex = 1;
  528. } else if (type == 'vr') {
  529. swiperIndex = this.data.imageArr.length + 1;
  530. } else if (type == 'video') {
  531. swiperIndex = this.data.imageArr.length + this.data.VRlinklist.length + 1;
  532. } else {
  533. swiperIndex = 0;
  534. }
  535. this.setData({
  536. swiperIndex: swiperIndex,
  537. activeType: type,
  538. allDataCount: count,
  539. showSortNum: 1,
  540. })
  541. },
  542. /**
  543. * 户型剖析
  544. */
  545. houseTypeDsc(e) {
  546. let index = e.currentTarget.dataset.index;
  547. let title = e.currentTarget.dataset.title;
  548. let room = e.currentTarget.dataset.room;
  549. this.setData({
  550. dscDataMsg: this.data.houseTypeItemlist[index],
  551. dscTitle: room == 9 ? '别墅' : title,
  552. dialog: true
  553. })
  554. },
  555. /**
  556. * 询问报价
  557. */
  558. inquiry() {
  559. if (this.data.bType == 'b') {
  560. wx.showToast({
  561. title: '装修推荐官无需询问',
  562. icon: 'none',
  563. duration: 1500
  564. })
  565. } else {
  566. wx.showToast({
  567. title: '员工无需询问',
  568. icon: 'none',
  569. duration: 1500
  570. })
  571. }
  572. },
  573. getImageAndVRAndVideo(type) {
  574. var that = this;
  575. let dataObj = {};
  576. if (type == 'vr') {
  577. dataObj = {
  578. id: that.data.cid,
  579. type: type,
  580. page: vrpage,
  581. };
  582. } else {
  583. dataObj = {
  584. id: that.data.cid,
  585. type: type,
  586. page: videopage,
  587. };
  588. }
  589. utils.$post({
  590. url: app.globalData.webUrl + 'api/building/progress',
  591. header: {
  592. 'Authorization': 'bearer ' + app.globalData.token
  593. },
  594. data: dataObj,
  595. success: function (res) {
  596. if (videopage > 1 || vrpage > 1) {
  597. setTimeout(() => { wx.hideLoading(); }, 1000)
  598. }
  599. if (res.data.code == '0') {
  600. if (type == 'vr') {
  601. that.getImageAndVRAndVideo('video');
  602. if (dataObj.page == 1) {
  603. that.data.VRlinklist = [];
  604. }
  605. if (res.data.data.length == 0) {
  606. that.setData({
  607. moreVrBol: true
  608. })
  609. }
  610. let vrlist = [];
  611. res.data.data.forEach(v => {
  612. if (v.vr && v.vr.length > 0) {
  613. vrlist.push(...v.vr);
  614. }
  615. })
  616. that.data.VRlinklist = that.data.VRlinklist.concat(vrlist);
  617. that.data.tab[2].count = that.data.VRlinklist.length;
  618. that.setData({
  619. VRlinklist: that.data.VRlinklist,
  620. tab: that.data.tab
  621. })
  622. if (dataObj.page > 1) {
  623. that.setData({
  624. allDataCount: that.data.VRlinklist.length
  625. })
  626. }
  627. } else {
  628. that.buildingProgress();
  629. if (dataObj.page == 1) {
  630. that.data.videolink = [];
  631. }
  632. if (res.data.data.length == 0) {
  633. that.setData({
  634. moreVideoBol: true
  635. })
  636. }
  637. let videoArr = res.data.data.map(v => {
  638. return { video: v.video, cover: v.img.length ? v.img[0] : '' }
  639. });
  640. that.data.videolink = that.data.videolink.concat(videoArr);
  641. that.data.tab[3].count = that.data.videolink.length;
  642. that.setData({
  643. videolink: that.data.videolink,
  644. tab: that.data.tab,
  645. })
  646. if (dataObj.page > 1) {
  647. that.setData({
  648. allDataCount: that.data.videolink.length
  649. })
  650. }
  651. }
  652. }
  653. }
  654. })
  655. },
  656. handlelist(e) {
  657. let type = e.currentTarget.dataset.type;
  658. let idx = e.currentTarget.dataset.index;
  659. let devCaselist = [];
  660. this.data.houseTypelists[idx].list.forEach(v => {
  661. if (v.devcase && v.devcase.length) {
  662. devCaselist.push(...v.devcase);
  663. }
  664. })
  665. this.setData({
  666. houseTypeActive: type,
  667. houseTypeItemlist: this.data.houseTypelists[idx].list,
  668. devCaseData: devCaselist
  669. })
  670. },
  671. /**
  672. * 进入案例详情
  673. */
  674. casemsgtap: function (e) {
  675. wx.navigateTo({
  676. url: '/index/pages/casemsg/casemsg?cid=' + e.currentTarget.dataset.cid,
  677. })
  678. },
  679. sitetap(e) {
  680. if (!this.data.ltype) {
  681. wx.navigateTo({
  682. url: '/index/pages/constructsite/constructsite?cid=' + e.currentTarget.dataset.cid,
  683. })
  684. } else {
  685. wx.navigateTo({
  686. url: '/customer/pages/sitemsg/sitemsg?cid=' + e.currentTarget.dataset.cid + '&type=' + this.data.ltype,
  687. })
  688. }
  689. },
  690. previewWechat() {
  691. if (this.data.personMsg.binded && this.data.personMsg.binded.qrcode) {
  692. if (this.data.personMsg.binded.qrcode.indexOf("https") < 0) {
  693. wx.previewImage({
  694. urls: [this.data.imgUrl + this.data.personMsg.binded.qrcode],
  695. })
  696. } else {
  697. wx.previewImage({
  698. urls: [this.data.personMsg.binded.qrcode],
  699. })
  700. }
  701. } else {
  702. wx.showToast({
  703. title: '暂未设置二维码',
  704. icon: "none"
  705. })
  706. }
  707. },
  708. mobileAction() {
  709. wx.makePhoneCall({
  710. phoneNumber: this.data.personMsg.phone,
  711. })
  712. },
  713. getBuildingProgressDetail() {
  714. var that = this;
  715. utils.$post({
  716. url: app.globalData.webUrl + 'api/building/view',
  717. header: {
  718. 'Authorization': 'bearer ' + app.globalData.token
  719. },
  720. data: {
  721. id: that.data.cid
  722. },
  723. success: function (res) {
  724. if (res.data.code == 0) {
  725. that.getBuildingProgresslabel();
  726. that.getImageAndVRAndVideo('vr');
  727. let dataMsg = res.data.data;
  728. dataMsg.update_time = dataMsg.update_time.split(' ')[0];
  729. dataMsg.areastr = dataMsg.area_list.map(v => `${v}㎡`).join('/');
  730. dataMsg.content = dataMsg.content.replace(/\r|\n/ig, "");
  731. let houseTypeArry = [];
  732. let devCaselist = [];
  733. if (dataMsg.housetype && Object.keys(dataMsg.housetype).length > 0) {
  734. Object.keys(dataMsg.housetype).forEach(v => {
  735. houseTypeArry.push({ name: that.data.houseTypeArr[v], id: v, count: dataMsg.housetype[v].length, list: dataMsg.housetype[v] })
  736. })
  737. if (houseTypeArry.length) {
  738. houseTypeArry[0].list.forEach(v => {
  739. if (v.devcase && v.devcase.length) {
  740. devCaselist.push(...v.devcase)
  741. }
  742. })
  743. }
  744. }
  745. that.data.tab[1].count = dataMsg.cover.length;
  746. that.setData({
  747. detail: dataMsg,
  748. imageArr: dataMsg.cover,
  749. tab: that.data.tab,
  750. houseTypelists: houseTypeArry.length ? houseTypeArry.sort(that.compare("id")) : [],
  751. houseTypeItemlist: houseTypeArry.length ? houseTypeArry[0].list : [],
  752. devCaseData: devCaselist
  753. })
  754. wx.setNavigationBarTitle({
  755. title: dataMsg.name,
  756. })
  757. }
  758. }
  759. })
  760. },
  761. openVRLink(e) {
  762. let type = e.currentTarget.dataset.type;
  763. if (type == 2) {
  764. let vrlink = e.currentTarget.dataset.vr;
  765. wx.navigateTo({
  766. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&uid=' + (app.globalData.shareuserid ? app.globalData.shareuserid : app.globalData.personMsg.id) + '&cty=building' + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.detail.id,
  767. })
  768. } else {
  769. let id = e.currentTarget.dataset.id;
  770. let vrlink = e.currentTarget.dataset.vrlink;
  771. wx.navigateTo({
  772. url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + id,
  773. })
  774. }
  775. },
  776. setcasekeywordtap: function (e) {
  777. this.setData({
  778. casekeytext: e.detail.value
  779. })
  780. },
  781. closeMask() {
  782. this.setData({
  783. showVrOrVideo: false,
  784. dialog: false,
  785. showArea: false,
  786. showCaseStyle: false,
  787. showInput: false,
  788. })
  789. },
  790. handleCaseStyle() {
  791. this.setData({
  792. showCaseStyle: true
  793. })
  794. },
  795. handleShowArea() {
  796. this.setData({
  797. showArea: true
  798. })
  799. },
  800. handleShowInput() {
  801. this.data.showInput = !this.data.showInput;
  802. this.setData({
  803. showInput: this.data.showInput
  804. })
  805. },
  806. dothis() { },
  807. showAllContent() {
  808. let showContent = !this.data.showContent;
  809. this.setData({
  810. showContent: showContent
  811. })
  812. },
  813. handleMore() {
  814. if (this.data.viewMore == this.data.progresslist.length) {
  815. this.setData({
  816. viewMore: 3
  817. })
  818. } else {
  819. this.setData({
  820. viewMore: this.data.progresslist.length
  821. })
  822. }
  823. },
  824. handleTips() {
  825. if (this.data.bType == 'b') {
  826. wx.showToast({
  827. title: '装修推荐官不可催更新',
  828. icon: 'none',
  829. duration: 1500
  830. })
  831. } else {
  832. wx.showToast({
  833. title: '员工不可催更新',
  834. icon: 'none',
  835. duration: 1500
  836. })
  837. }
  838. },
  839. /**
  840. * 放大图片
  841. * @param {*} e
  842. */
  843. previewImage(e) {
  844. let type = e.currentTarget.dataset.type;
  845. if (type == 'cover') {
  846. let imgUrl = e.currentTarget.dataset.img;
  847. if (imgUrl) {
  848. wx.previewImage({
  849. current: imgUrl,
  850. urls: [imgUrl]
  851. })
  852. } else {
  853. wx.showToast({
  854. title: '暂无图片展示',
  855. icon: 'none',
  856. })
  857. }
  858. } else if (type == 'image') {
  859. let imgUrl = e.currentTarget.dataset.img;
  860. wx.previewImage({
  861. current: imgUrl,
  862. urls: this.data.imageArr
  863. })
  864. } else if (type == 'vr') {
  865. this.setData({
  866. showVrOrVideo: true,
  867. showType: 'vr'
  868. })
  869. } else if (type == 'video') {
  870. this.setData({
  871. showVrOrVideo: true,
  872. showType: 'video',
  873. currentVideoIndex: this.data.showSortNum - 1 < 0 ? 0 : (this.data.showSortNum - 1),
  874. showVideoNum: this.data.showSortNum
  875. })
  876. } else if (type == 'himg') {
  877. let idx = e.currentTarget.dataset.index;
  878. let imgUrl = e.currentTarget.dataset.img;
  879. wx.previewImage({
  880. current: imgUrl,
  881. urls: this.data.houseTypeItemlist[idx].house_img,
  882. })
  883. } else {
  884. let imgUrl = e.currentTarget.dataset.img;
  885. let index = e.currentTarget.dataset.index;
  886. var arr = this.data.progresslist[index].img;
  887. wx.previewImage({
  888. current: imgUrl,
  889. urls: arr,
  890. })
  891. }
  892. },
  893. /**
  894. * 顶部轮播切换
  895. */
  896. swiperChange(e) {
  897. let currentItemId = e.detail.currentItemId;
  898. if (currentItemId.indexOf('img') > -1) {
  899. let index = currentItemId.split('-')[1];
  900. let type = currentItemId.split('-')[0];
  901. this.setData({
  902. activeType: type,
  903. showSortNum: parseInt(index) + 1,
  904. allDataCount: this.data.imageArr.length
  905. })
  906. }
  907. if (currentItemId.indexOf('vr') > -1) {
  908. let index = currentItemId.split('-')[1];
  909. let type = currentItemId.split('-')[0];
  910. this.setData({
  911. activeType: type,
  912. showSortNum: parseInt(index) + 1,
  913. allDataCount: this.data.VRlinklist.length
  914. })
  915. if (!this.data.moreVrBol && (index == (this.data.VRlinklist.length - 1))) {
  916. wx.showLoading({
  917. title: '正在加载数据...',
  918. })
  919. vrpage = vrpage * 1 + 1;
  920. this.getImageAndVRAndVideo('vr');
  921. }
  922. }
  923. if (currentItemId.indexOf('video') > -1) {
  924. let index = currentItemId.split('-')[1];
  925. let type = currentItemId.split('-')[0];
  926. this.setData({
  927. activeType: type,
  928. showSortNum: parseInt(index) + 1,
  929. allDataCount: this.data.videolink.length
  930. })
  931. for (let i = 0; i < this.data.videolink.length; i++) {
  932. let videoEle = this.selectComponent(`#videolink${i}`);
  933. videoEle.pause();
  934. }
  935. if (!this.data.moreVideoBol && (index == (this.data.videolink.length - 1))) {
  936. wx.showLoading({
  937. title: '正在加载数据...',
  938. })
  939. videopage = videopage * 1 + 1;
  940. this.getImageAndVRAndVideo('video');
  941. }
  942. }
  943. if (currentItemId.indexOf('cover') > -1) {
  944. this.setData({
  945. activeType: '',
  946. showSortNum: 1,
  947. allDataCount: 1
  948. })
  949. }
  950. },
  951. /**
  952. * 视频放大滑动切换
  953. */
  954. swiperVideoChange(e) {
  955. this.setData({
  956. showVideoNum: parseInt(e.detail.current) + 1
  957. })
  958. },
  959. handleFullPlay(e) {
  960. let videoId = e.currentTarget.dataset.id;
  961. var videoContext = this.selectComponent(`#${videoId}`);
  962. videoContext.requestFullScreen({ direction: 0 })
  963. },
  964. buildingProgress() {
  965. var that = this;
  966. utils.$post({
  967. url: app.globalData.webUrl + 'api/building/progress',
  968. header: {
  969. 'Authorization': 'bearer ' + app.globalData.token
  970. },
  971. data: {
  972. id: that.data.cid,
  973. page: page,
  974. label_id: that.data.labelId
  975. },
  976. success: function (res) {
  977. wx.hideLoading();
  978. if (res.data.code == '0') {
  979. let progress = res.data.data;
  980. that.setData({
  981. progresslist: progress,
  982. datashow: true
  983. })
  984. }
  985. }
  986. })
  987. },
  988. handleCollect(e) {
  989. const that = this;
  990. let detail = this.data.detail;
  991. let collect = that.data.detail.collected;
  992. let urllink = !collect ? app.globalData.webUrl + 'api/building/collect' : app.globalData.webUrl + 'api/building/collectCancel';
  993. utils.$post({
  994. url: urllink,
  995. header: {
  996. 'Authorization': 'bearer ' + app.globalData.token
  997. },
  998. data: {
  999. id: that.data.cid,
  1000. },
  1001. success: (res) => {
  1002. if (res.data.code == 0) {
  1003. detail.collected = !collect;
  1004. this.setData({
  1005. detail: detail
  1006. })
  1007. wx.showToast({
  1008. title: res.data.msg,
  1009. icon: 'none',
  1010. duration: 1000
  1011. })
  1012. }
  1013. }
  1014. })
  1015. },
  1016. shareProgress(e) {
  1017. let id = e.currentTarget.dataset.id;
  1018. this.setData({
  1019. shareId: id,
  1020. shareType: 'buildingProgress',
  1021. shareUrl: '/share/pages/buildShare/buildShare',
  1022. shareQuery: 'cid=' + id + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  1023. shareImage: this.data.detail.cover_share_img ? this.data.detail.cover_share_img : this.data.detail.cover[0],
  1024. shareTitle: this.data.detail.name + '-楼盘进度',
  1025. wshareshow: true
  1026. })
  1027. },
  1028. sharetap() {
  1029. this.setData({
  1030. shareId: this.data.cid,
  1031. shareType: 'building',
  1032. shareUrl: '/share/pages/buildprogress/buildprogress',
  1033. shareQuery: 'cid=' + this.data.cid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id,
  1034. shareImage: this.data.detail.cover_share_img ? this.data.detail.cover_share_img : this.data.detail.cover[0],
  1035. shareTitle: this.data.detail.name,
  1036. wshareshow: true
  1037. })
  1038. },
  1039. setpostertap: function () {
  1040. if (this.data.bType == 'b') {
  1041. wx.navigateTo({
  1042. url: '/index/pages/setposter/setposter?type=building&aid=' + this.data.cid + "&ty=b&listshare=",
  1043. })
  1044. } else {
  1045. wx.navigateTo({
  1046. url: '/index/pages/setposter/setposter?type='+this.data.shareType+'&aid=' + this.data.shareId + "&listshare=",
  1047. })
  1048. }
  1049. },
  1050. sendfriendtap() {
  1051. this.sharelogtap();
  1052. },
  1053. shareurltap: function () {
  1054. wx.showLoading({
  1055. title: '加载中...',
  1056. })
  1057. if (this.data.bType == 'b') {
  1058. util.schemefun('/share/pages/buildprogress/buildprogress', 'uid=' + app.globalData.agentEmployeEid + '&cid=' + this.data.cid + '&ctp=' + app.globalData.clientype + "&agid=" + app.globalData.brokeruserId, this.data.cid, 'building', '');
  1059. } else {
  1060. util.schemefun(this.data.shareUrl, this.data.shareQuery, this.data.shareId, this.data.shareType, '');
  1061. }
  1062. this.sharelogtap();
  1063. },
  1064. /**
  1065. * 生命周期函数--监听页面初次渲染完成
  1066. */
  1067. onReady() {
  1068. },
  1069. /**
  1070. * 生命周期函数--监听页面显示
  1071. */
  1072. onShow() {
  1073. this.setData({
  1074. imgUrl: app.globalData.imgUrl,
  1075. })
  1076. },
  1077. /**
  1078. * 生命周期函数--监听页面隐藏
  1079. */
  1080. onHide() {
  1081. },
  1082. /**
  1083. * 生命周期函数--监听页面卸载
  1084. */
  1085. onUnload() {
  1086. },
  1087. setypetap(e) {
  1088. this.setData({
  1089. type: e.currentTarget.dataset.type
  1090. })
  1091. },
  1092. /**
  1093. * 页面相关事件处理函数--监听用户下拉动作
  1094. */
  1095. onPullDownRefresh() { },
  1096. /**
  1097. * 页面上拉触底事件的处理函数
  1098. */
  1099. onReachBottom() {
  1100. wx.showLoading({
  1101. title: '加载中...',
  1102. })
  1103. var that = this;
  1104. page = page * 1 + 1;
  1105. utils.$post({
  1106. url: app.globalData.webUrl + 'api/building/progress',
  1107. header: {
  1108. 'Authorization': 'bearer ' + app.globalData.token
  1109. },
  1110. data: {
  1111. id: that.data.cid,
  1112. page: page
  1113. },
  1114. success: function (res) {
  1115. setTimeout(() => { wx.hideLoading(); }, 1000);
  1116. if (res.data.code == '0') {
  1117. let progress = res.data.data;
  1118. if (page > 1 && !progress.length) {
  1119. wx.showToast({
  1120. title: '没有更多数据了',
  1121. icon: "none"
  1122. })
  1123. return;
  1124. }
  1125. that.data.progresslist = that.data.progresslist.concat(progress);
  1126. that.setData({
  1127. progresslist: that.data.progresslist,
  1128. datashow: true
  1129. })
  1130. }
  1131. }
  1132. })
  1133. },
  1134. sharelogtap: function () {
  1135. var that = this;
  1136. this.setData({
  1137. nowflag: false,
  1138. })
  1139. utils.$post({
  1140. url: app.globalData.webUrl + 'api/share/addlog',
  1141. header: {
  1142. 'Authorization': 'bearer ' + app.globalData.token
  1143. },
  1144. data: {
  1145. id: that.data.shareId,
  1146. type: that.data.shareType
  1147. },
  1148. success: function (r) { }
  1149. })
  1150. },
  1151. /**
  1152. * 用户点击右上角分享
  1153. */
  1154. onShareAppMessage(e) {
  1155. const that = this;
  1156. if (this.data.bType == 'b') {
  1157. this.sharelogtap();
  1158. return {
  1159. title: that.data.detail.name,
  1160. imageUrl: that.data.detail.cover_share_img ? that.data.detail.cover_share_img : that.data.detail.cover[0],
  1161. path: '/share/pages/buildprogress/buildprogress?cid=' + that.data.cid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + "&agid=" + app.globalData.brokeruserId
  1162. }
  1163. } else {
  1164. this.sharelogtap();
  1165. return {
  1166. title: that.data.shareTitle,
  1167. imageUrl: that.data.shareImage,
  1168. path: `${that.data.shareUrl}?${that.data.shareQuery}`
  1169. }
  1170. }
  1171. }
  1172. })