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