1
0

viewbuilding.js 9.3 KB

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