detail.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. import HTTP from "../../../../../requestFn/Api"
  2. var QQMapWX = require('../../../utils/qqmap-wx-jssdk.min.js');
  3. var qqmapsdk = new QQMapWX({
  4. key: 'ZZFBZ-RK6L6-FPZS5-E3MBZ-63LS2-7WBJE' // 必填
  5. });
  6. const app = getApp();
  7. import openIM from "../../../../../utils/openim"
  8. Page({
  9. data: {
  10. detail: {},
  11. current: 0,
  12. autoplay: true,
  13. duration: 500,
  14. interval: 5000,
  15. garden_id: null,
  16. pay_time_type: {
  17. 1: '月付',
  18. 2: '季付',
  19. 3: '半年付',
  20. 4: '年付'
  21. },
  22. direction: {
  23. 1: '东',
  24. 2: '南',
  25. 3: '西',
  26. 4: '北'
  27. },
  28. rent_type: {
  29. 1: '整租',
  30. 2: '合租',
  31. 3: '转租'
  32. },
  33. special_conf: {
  34. 1: '智能门锁',
  35. 2: 'WIFI',
  36. 3: '近地铁',
  37. 4: '停车位',
  38. 5: '独卫',
  39. 6: '私人阳台',
  40. 7: '首次出租'
  41. },
  42. base_conf: {
  43. 1: {
  44. name: "床",
  45. icon: "/static/base_conf/ic_bedroom.png"
  46. },
  47. 2: {
  48. name: "天然气",
  49. icon: "/static/base_conf/meiqitianranqi.png"
  50. },
  51. 3: {
  52. name: "暖气",
  53. icon: "/static/base_conf/nuanqi.png"
  54. },
  55. 4: {
  56. name: "宽带",
  57. icon: "/static/base_conf/kuandai.png"
  58. },
  59. 5: {
  60. name: "冰箱",
  61. icon: "/static/base_conf/bingxiang.png"
  62. },
  63. 6: {
  64. name: "衣柜",
  65. icon: "/static/base_conf/yigui.png"
  66. },
  67. 7: {
  68. name: "沙发",
  69. icon: "/static/base_conf/shafa.png"
  70. },
  71. 8: {
  72. name: "空调",
  73. icon: "/static/base_conf/kongtiao.png"
  74. },
  75. 9: {
  76. name: "电视机",
  77. icon: "/static/base_conf/dianshiji-.png"
  78. },
  79. 10: {
  80. name: "热水器",
  81. icon: "/static/base_conf/reshuiqi.png"
  82. },
  83. 11: {
  84. name: "洗衣机",
  85. icon: "/static/base_conf/xiyiji.png"
  86. },
  87. },
  88. manager_list: [],
  89. garden_info: {},
  90. total: 0,
  91. tabList: [{
  92. text: '交通',
  93. key: "交通"
  94. }, {
  95. text: '商超',
  96. key: "商超"
  97. }, {
  98. text: '教育',
  99. key: "教育"
  100. }, {
  101. text: '餐饮',
  102. key: "餐饮"
  103. }, {
  104. text: '金融',
  105. key: "金融"
  106. }, {
  107. text: '医疗',
  108. key: "医疗"
  109. }, {
  110. text: '外卖',
  111. key: "外卖"
  112. }, ],
  113. renthouse_list: [],
  114. bottom: 0,
  115. keyword: "交通",
  116. longitude: 0,
  117. latitude: 0
  118. },
  119. onLoad() {
  120. const {
  121. screenHeight,
  122. safeArea
  123. } = app.globalData.systemInfo;
  124. const {
  125. bottom
  126. } = safeArea;
  127. let safeHeight = screenHeight - bottom;
  128. this.setData({
  129. bottom: safeHeight
  130. });
  131. },
  132. onShow(options) {
  133. const that = this;
  134. const eventChannel = that.getOpenerEventChannel()
  135. eventChannel.on('acceptDataFromOpenerPage', function (data) {
  136. const strData = JSON.stringify(data);
  137. const {
  138. garden_id,
  139. id,
  140. lat: latitude,
  141. lnt: longitude
  142. } = data.data[0]
  143. that.setData({
  144. detail: {
  145. ...data.data[0],
  146. rent_id: data.data[0].id
  147. },
  148. latitude,
  149. longitude,
  150. strData
  151. })
  152. that.getHouse_manager(garden_id, id);
  153. that.getGardenInfo(garden_id);
  154. that.getRentHouse(garden_id);
  155. that.nearby_search()
  156. })
  157. },
  158. previewImage(e) {
  159. wx.previewImage({
  160. current: this.data.detail.house_pic[e.currentTarget.dataset.index],
  161. urls: this.data.detail.house_pic,
  162. });
  163. },
  164. getHouse_manager(garden_id, rent_id) {
  165. HTTP.HouseManager({
  166. garden_id,
  167. rent_id
  168. }).then(res => {
  169. this.setData({
  170. manager_list: res.list
  171. })
  172. })
  173. },
  174. callManager(e) {
  175. const {
  176. id
  177. } = e.currentTarget;
  178. const {
  179. name,
  180. phone
  181. } = this.data.manager_list.filter(item => item.id == id)[0]
  182. wx.navigateTo({
  183. url: `../manager/manager?name=${name}&phone=${phone}`,
  184. })
  185. },
  186. getGardenInfo(garden_id) {
  187. HTTP.GardenInfo({
  188. garden_id
  189. }).then(res => {
  190. this.setData({
  191. garden_info: res
  192. })
  193. })
  194. },
  195. async getRentHouse(garden_id) {
  196. let data = await HTTP.RentHouse({
  197. garden_id,
  198. approve_status: 2,
  199. page: 1,
  200. page_size: 9999
  201. })
  202. const {
  203. list,
  204. total
  205. } = data;
  206. let newarr = list.slice(0, 5)
  207. this.setData({
  208. total: total,
  209. renthouse_list: newarr
  210. })
  211. },
  212. goRentHouse() {
  213. // const {
  214. // garden_id,
  215. // garden_name
  216. // } = this.data.detail;
  217. // let pages = getCurrentPages();
  218. // let prevPage = pages[pages.length - 2];
  219. // prevPage.setData({
  220. // searchData: {
  221. // garden_id
  222. // }
  223. // })
  224. wx.navigateTo({
  225. url: '../renthouse/renthouse',
  226. })
  227. },
  228. tabChangeHandle(e) {
  229. const {
  230. value: keyword
  231. } = e.detail;
  232. this.setData({
  233. keyword,
  234. })
  235. this.nearby_search();
  236. },
  237. phoneManager() {
  238. wx.makePhoneCall({
  239. phoneNumber: this.data.detail.contact_phone,
  240. })
  241. },
  242. CallManager(e) {
  243. const {
  244. phone: phoneNumber
  245. } = e.currentTarget.dataset;
  246. wx.makePhoneCall({
  247. phoneNumber,
  248. })
  249. },
  250. garden_detail() {
  251. const {
  252. garden_info,
  253. detail
  254. } = this.data;
  255. wx.navigateTo({
  256. url: '../garden-detail/garden-detail',
  257. success: function (res) {
  258. res.eventChannel.emit('acceptDataFromOpenerPage', {
  259. garden_info: {
  260. ...detail,
  261. ...garden_info,
  262. }
  263. })
  264. }
  265. })
  266. },
  267. appointmentHouse() {
  268. const that = this;
  269. wx.navigateTo({
  270. url: '../appointment/appointment',
  271. success: function (res) {
  272. res.eventChannel.emit('acceptDataFromOpenerPage', {
  273. detail: {
  274. ...that.data.detail,
  275. rent_id: that.data.detail.id
  276. }
  277. })
  278. }
  279. })
  280. },
  281. goHouseDetail(e) {
  282. const {
  283. house
  284. } = e.currentTarget.dataset;
  285. let data = [house]
  286. wx.navigateTo({
  287. url: '../detail/detail',
  288. success: function (res) {
  289. res.eventChannel.emit('acceptDataFromOpenerPage', {
  290. data
  291. })
  292. }
  293. })
  294. },
  295. goMapPlan() {
  296. const {
  297. addr,
  298. lat,
  299. lnt
  300. } = this.data.detail;
  301. // let plugin = requirePlugin('routePlan');
  302. // let key = 'ZZFBZ-RK6L6-FPZS5-E3MBZ-63LS2-7WBJE'; //使用在腾讯位置服务申请的key
  303. // let referer = '易小居'; //调用插件的app的名称
  304. // let endPoint = JSON.stringify({ //终点
  305. // 'name': addr,
  306. // 'latitude': lat,
  307. // 'longitude': lnt
  308. // });
  309. // wx.navigateTo({
  310. // url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint
  311. // })
  312. // wx.navigateTo({
  313. // url: `../map/map?lat=${lat}&lnt=${lnt}`,
  314. // })
  315. wx.openLocation({
  316. latitude: lat,
  317. longitude: lnt,
  318. address: addr,
  319. scale: 18,
  320. fail(err) {
  321. wx.showToast({
  322. title: '请再次尝试',
  323. icon: "none"
  324. })
  325. }
  326. })
  327. },
  328. nearby_search() {
  329. var _this = this;
  330. const {
  331. keyword,
  332. latitude,
  333. longitude
  334. } = _this.data;
  335. // 调用接口
  336. qqmapsdk.search({
  337. keyword, //搜索关键词
  338. location: {
  339. latitude,
  340. longitude
  341. },
  342. success: function (res) { //搜索成功后的回调
  343. var mks = []
  344. for (var i = 0; i < res.data.length; i++) {
  345. mks.push({ // 获取返回结果,放到mks数组中
  346. title: res.data[i].title,
  347. id: i,
  348. latitude: res.data[i].location.lat,
  349. longitude: res.data[i].location.lng,
  350. width: 20,
  351. height: 20,
  352. callout: {
  353. content: res.data[i].title,
  354. color: '#333',
  355. fontSize: 14,
  356. padding: 8,
  357. display: 'BYCLICK',
  358. textAlign: 'center'
  359. }
  360. })
  361. }
  362. _this.setData({ //设置markers属性,将搜索结果显示在地图中
  363. markers: mks
  364. })
  365. },
  366. fail: function (res) {
  367. wx.showToast({
  368. title: '查询失败',
  369. icon: "none"
  370. })
  371. },
  372. });
  373. },
  374. goChat() {
  375. const that =this;
  376. const {
  377. manager_list,
  378. strData: cardDesc,
  379. } = that.data;
  380. const itemList = manager_list.map(item => item.name);
  381. wx.showActionSheet({
  382. itemList,
  383. itemColor: "#03BB7A",
  384. success(res) {
  385. app.sendCard(cardDesc,that,res);
  386. }
  387. })
  388. }
  389. })