index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. const util = require('../../utils/util.js');
  2. const api = require('../../config/api.js');
  3. const user = require('../../services/user.js');
  4. import header from './data'
  5. import {
  6. Router
  7. } from '../../utils/router.js'
  8. const app = getApp()
  9. //获取应用实例
  10. Router({
  11. data: {
  12. // 头部导航栏的高度
  13. statusBarHeight: app.globalData.statusBarHeight,
  14. classifyList: [{
  15. type: 0,
  16. title: '新房',
  17. icon: "../../static/images/icon/house@2x.png",
  18. },
  19. {
  20. type: 1,
  21. title: '二手房',
  22. icon: "../../static/images/icon/second_hand@2x.png",
  23. },
  24. {
  25. type: 2,
  26. title: '公寓',
  27. icon: "../../static/images/icon/apartments@2x.png",
  28. },
  29. {
  30. type: 3,
  31. title: '民宿',
  32. icon: "../../static/images/icon/b&b@2x.png",
  33. },
  34. {
  35. type: 4,
  36. title: '社区',
  37. icon: "../../static/images/icon/community@2x.png",
  38. },
  39. ],
  40. type:'',
  41. middleType: 11,
  42. // type :-1:所有;0:新房;1:二手房;2:公寓;3:民宿;4:社区
  43. // 11:新上房源;12:热门房源;13:热门企业;
  44. // 21:商家列表;
  45. // 31:VR场景;32:VR直播间
  46. middleTabList: [{
  47. type: 11,
  48. title: '新上房源'
  49. },
  50. {
  51. type: 12,
  52. title: '热门房源'
  53. },
  54. {
  55. type: 13,
  56. title: '热门企业'
  57. },
  58. ],
  59. middleList: [{
  60. url: 'https://m4.publicimg.browser.qq.com/publicimg/pcqb/ewtab_yunying/477_266_datu_20210802.jpg',
  61. title: '华发水岸1'
  62. }, {
  63. url: 'https://m4.publicimg.browser.qq.com/publicimg/pcqb/ewtab_yunying/477_266_datu_20210802.jpg',
  64. title: '华发水岸1'
  65. }, {
  66. url: 'https://m4.publicimg.browser.qq.com/publicimg/pcqb/ewtab_yunying/477_266_datu_20210802.jpg',
  67. title: '华发水岸1'
  68. }, ],
  69. roomTabList: [{
  70. type: 0,
  71. title: '新房'
  72. },
  73. {
  74. type: 1,
  75. title: '二手房'
  76. },
  77. {
  78. type: 2,
  79. title: '公寓'
  80. },
  81. ],
  82. roomType: 0,
  83. city: app.globalData.city,
  84. fetcherData: {
  85. type:'',
  86. city: '',
  87. page_num: 1,
  88. page_size: 20,
  89. name:''
  90. }
  91. },
  92. onShareAppMessage: function () {
  93. return {
  94. path: '/pages/index/index'
  95. }
  96. },
  97. onPullDownRefresh() {
  98. // this.setData({
  99. // brandList: this.data.brandList.slice(0, 10),
  100. // currentPage: 1
  101. // });
  102. // this.getBrandList(1, false, true);
  103. app.onPullDownRefresh()
  104. },
  105. onReachBottom: function () {
  106. console.log('onReachBottom')
  107. },
  108. inputFocus: function () {},
  109. changeMiddleTab(e) {
  110. let type = e.currentTarget.dataset.type
  111. this.setData({
  112. middleType: type
  113. })
  114. },
  115. chengeRoomType(e) {
  116. let type = e.currentTarget.dataset.type
  117. this.setData({
  118. roomType: type
  119. })
  120. },
  121. getRoomList(){
  122. this.setData({
  123. 'fetcherData.type':this.data.roomType,
  124. })
  125. if(app.globalData.city=='全国'){
  126. this.setData({
  127. 'fetcherData.city':'',
  128. })
  129. }else{
  130. this.setData({
  131. 'fetcherData.city':app.globalData.city,
  132. })
  133. }
  134. util.request(api.OrderList, this.data.fetcherData).then( (res)=> {
  135. console.log(res)
  136. if (res.errno === 0) {
  137. }
  138. });
  139. },
  140. getMiddleList(){
  141. this.setData({
  142. 'fetcherData.type':this.data.middleType,
  143. })
  144. if(app.globalData.city=='全国'){
  145. this.setData({
  146. 'fetcherData.city':'',
  147. })
  148. }else{
  149. this.setData({
  150. 'fetcherData.city':app.globalData.city,
  151. })
  152. }
  153. util.request(api.OrderList, this.data.fetcherData).then( (res)=> {
  154. console.log(res)
  155. if (res.errno === 0) {
  156. }
  157. });
  158. },
  159. toCity() {
  160. wx.navigateTo({
  161. url: `/pages/city/city`
  162. })
  163. },
  164. toSearch(e) {
  165. var id = e.currentTarget.dataset.id
  166. wx.navigateTo({
  167. url: `/pages/searchRoom/searchRoom?id=` + id
  168. })
  169. },
  170. onLoad: async function (options) {
  171. },
  172. onReady: function () {
  173. // 页面渲染完成
  174. this.getRoomList()
  175. this.getMiddleList()
  176. },
  177. onShow: function (options) {
  178. console.log(app.globalData.city)
  179. // 页面显示
  180. let city = app.globalData.city
  181. if (city != this.data.city) {
  182. this.setData({
  183. 'city': app.globalData.city,
  184. })
  185. this.getRoomList()
  186. this.getMiddleList()
  187. }
  188. },
  189. onHide: function () {
  190. // 页面隐藏
  191. },
  192. onUnload: function () {
  193. // 页面关闭
  194. }
  195. })