building.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. const app = getApp();
  2. var utils = require("../../../utils/http");
  3. const util = require("../../../utils/util");
  4. let page = 1;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. filtrateflag: false,
  11. orderBuildType: 'new',
  12. buildinglist:[],
  13. imgUrl: app.globalData.imgUrl,
  14. datashow:false,
  15. wshareshow:false,
  16. nowtitle: '',
  17. nowimg: '',
  18. buildVal: "",
  19. islist: false,
  20. nowtype:'building',
  21. personMsg:app.globalData.personMsg
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad(options) {
  27. page = 1;
  28. wx.showLoading({
  29. title: '加载中...',
  30. })
  31. this.getBuildingProgress();
  32. },
  33. /**
  34. * 生命周期函数--监听页面初次渲染完成
  35. */
  36. onReady() {
  37. },
  38. /**
  39. * 生命周期函数--监听页面显示
  40. */
  41. onShow() {
  42. page = 1;
  43. this.setData({
  44. personMsg:app.globalData.personMsg
  45. })
  46. },
  47. allfiltratetap: function () {
  48. this.data.filtrateflag = !this.data.filtrateflag;
  49. this.setData({
  50. filtrateflag: this.data.filtrateflag,
  51. })
  52. },
  53. closefiltratetap: function () {
  54. this.setData({
  55. filtrateflag: false
  56. })
  57. },
  58. buildValInput(e) {
  59. this.setData({
  60. buildVal:e.detail.value
  61. })
  62. },
  63. jumpUploadBuilding() {
  64. wx.navigateTo({
  65. url: '/pages/other/other?type=9889',
  66. })
  67. },
  68. searchFunc() {
  69. wx.showLoading({
  70. title: '加载中...',
  71. })
  72. page = 1;
  73. this.getBuildingProgress();
  74. },
  75. setBuildFilter(e) {
  76. wx.showLoading({
  77. title: '加载中...',
  78. })
  79. page = 1;
  80. this.setData({
  81. orderBuildType: e.currentTarget.dataset.type
  82. })
  83. this.getBuildingProgress();
  84. },
  85. getBuildingProgress() {
  86. var that = this;
  87. utils.$post({
  88. url: app.globalData.webUrl + 'api/building/index',
  89. header: {
  90. 'Authorization': 'bearer ' + app.globalData.token
  91. },
  92. data: {
  93. order: that.data.orderBuildType,
  94. page: page,
  95. limit: "10",
  96. name: that.data.buildVal
  97. },
  98. success: function (res) {
  99. wx.hideLoading()
  100. if (res.data.code == 0) {
  101. res.data.data.forEach(v => {
  102. v.areastr = v.area_list.map(v => `${v}㎡`);
  103. v.update_time = v.update_time ? v.update_time.split(' ')[0] : '';
  104. v.duetime = v.duetime ? v.duetime.split(' ')[0] : '';
  105. })
  106. that.setData({
  107. buildinglist: res.data.data,
  108. datashow:true,
  109. })
  110. }
  111. }
  112. })
  113. },
  114. toPageDetail(e) {
  115. let id = e.currentTarget.dataset.id;
  116. wx.navigateTo({
  117. url: '/index/pages/progressdetail/progressdetail?cid=' + id,
  118. })
  119. },
  120. progressShare(e) {
  121. this.setData({
  122. nowtype: 'building',
  123. nowid: e.currentTarget.dataset.cid,
  124. nowtitle: e.currentTarget.dataset.title,
  125. nowimg: e.currentTarget.dataset.img,
  126. wshareshow: true,
  127. })
  128. },
  129. handleCollect(e) {
  130. let collect = e.currentTarget.dataset.collect;
  131. let id = e.currentTarget.dataset.id;
  132. let index = e.currentTarget.dataset.index;
  133. let urllink = !collect ? app.globalData.webUrl + 'api/building/collect' : app.globalData.webUrl + 'api/building/collectCancel';
  134. utils.$post({
  135. url: urllink,
  136. header: {
  137. 'Authorization': 'bearer ' + app.globalData.token
  138. },
  139. data: {
  140. id: id,
  141. },
  142. success: (res) => {
  143. if (res.data.code == 0) {
  144. this.data.buildinglist[index].collected = !collect;
  145. this.setData({
  146. buildinglist: this.data.buildinglist
  147. })
  148. wx.showToast({
  149. title: res.data.msg,
  150. icon: 'none',
  151. duration: 1000
  152. })
  153. }
  154. }
  155. })
  156. },
  157. shareurltap: function () {
  158. let that = this;
  159. wx.showLoading({
  160. title: '加载中...',
  161. })
  162. util.schemefun('/share/pages/buildprogress/buildprogress', 'uid=' + app.globalData.personMsg.id + '&cid=' + that.data.nowid + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id, that.data.nowid, 'building', '');
  163. this.sharelogtap();
  164. },
  165. setpostertap: function () {
  166. let that = this;
  167. let type = "building", usrl = "";
  168. wx.navigateTo({
  169. url: '/index/pages/setposter/setposter?type=' + type + '&aid=' + this.data.nowid + "&listshare=" + (that.data.listshare ? '123' : '') + usrl,
  170. })
  171. },
  172. sendfriendtap: function () {
  173. this.sharelogtap();
  174. },
  175. sharelogtap: function (e) {
  176. var that = this;
  177. utils.$post({
  178. url: app.globalData.webUrl + 'api/share/addlog',
  179. header: {
  180. 'Authorization': 'bearer ' + app.globalData.token
  181. },
  182. data: {
  183. id: that.data.nowid,
  184. type: that.data.nowtype,
  185. alertshow:'456'
  186. },
  187. success: function (r) {
  188. }
  189. })
  190. },
  191. /**
  192. * 生命周期函数--监听页面隐藏
  193. */
  194. onHide() {
  195. },
  196. /**
  197. * 生命周期函数--监听页面卸载
  198. */
  199. onUnload() {
  200. },
  201. /**
  202. * 页面相关事件处理函数--监听用户下拉动作
  203. */
  204. onPullDownRefresh() {
  205. wx.showLoading({
  206. title: '加载中...',
  207. })
  208. page = 1;
  209. this.getBuildingProgress();
  210. wx.stopPullDownRefresh();
  211. },
  212. /**
  213. * 页面上拉触底事件的处理函数
  214. */
  215. onReachBottom() {
  216. wx.showLoading({
  217. title: '加载中...',
  218. })
  219. var that = this;
  220. page = page * 1 + 1;
  221. utils.$post({
  222. url: app.globalData.webUrl + 'api/building/index',
  223. header: {
  224. 'Authorization': 'bearer ' + app.globalData.token
  225. },
  226. data: {
  227. order: that.data.orderBuildType,
  228. page: page,
  229. limit: "10",
  230. name: that.data.buildVal
  231. },
  232. success: function (res) {
  233. wx.hideLoading()
  234. if (res.data.code == 0) {
  235. let list = that.data.buildinglist;
  236. res.data.data.forEach(v => {
  237. v.areastr = v.area_list.map(v => `${v}㎡`);
  238. v.update_time = v.update_time ? v.update_time.split(' ')[0] : '';
  239. v.duetime = v.duetime ? v.duetime.split(' ')[0] : '';
  240. })
  241. list = list.concat(res.data.data);
  242. that.setData({
  243. buildinglist: list
  244. })
  245. }
  246. }
  247. })
  248. },
  249. /**
  250. * 用户点击右上角分享
  251. */
  252. onShareAppMessage(e) {
  253. if (e.from == "menu") {
  254. return {
  255. title: "营销楼盘-"+app.globalData.companyobj.company_name,
  256. imageUrl: app.globalData.imgUrl + 'xcx/aaa/buildcover.png',
  257. path: '/share/pages/buildinglist/buildinglist?uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&emid=' + app.globalData.personMsg.binded.id
  258. }
  259. } else {
  260. let that = this;
  261. this.setData({
  262. wshareshow: false
  263. })
  264. this.sharelogtap();
  265. return {
  266. title: that.data.nowtitle,
  267. imageUrl: that.data.nowimg,
  268. path: '/share/pages/buildprogress/buildprogress?cid=' + that.data.nowid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&empid=' + app.globalData.personMsg.binded.id
  269. }
  270. }
  271. }
  272. })