// pages/pageIndex/pageIndex.js var WxParse = require('../../wxParse/wxParse.js'); var app = getApp() var config = {}; var miucms = require('../../utils/miucms.js'); Page({ /** * 页面的初始数据 */ data: { loding: true, HKapartment: [], otherHousing: [], HKhousing: [], banner: [], service: '', servicename: '', video: '', screen_data: {}, advListHKhousing: {}, advListotherHousing: {}, initState: false, unreadMessages: 0, // 底部我的图标 未读系统通知数量 areaList: ['school', 'district', 'type'], areaTab: "school", // school district type areaObj: { 'school': 0, 'district': 1, 'type': 2, }, envVersionState: false, // 是否在开发环境 images: "https://oss.gter.net/Zvt57TuJSUvkyhw-xG7Y2l-W-58oc3nqqsgFptxhXa6SWi2uePJ5Bg8cFLPIvsEG-4BUA27F7lfn5E55tXAL34gR30K6A7FxO7Sa1zx17l80NDI5", // 新公寓列表的图片链接 随时删除 tabList: [{ title: "推荐", value: "recommend", left: 26, }, { title: "整租", value: "entire", left: 122.5, }, { title: "合租", value: "joint", left: 221.5, }, { title: "已认证", value: "authenticated", left: 316.5, }, { title: "招室友", value: "attract", left: 436, }, ], tabValue: 0, }, /** * 生命周期函数--监听页面加载 */ timer: null, onLoad: function (options) { wx.showLoading() this.get_config() let accountInfo = wx.getAccountInfoSync() let envVersion = accountInfo.miniProgram.envVersion if (envVersion != 'develop') return this.setData({ envVersionState: true }) }, // 获取系统通知数量 getNoticeNumber() { if (app.globalData.unreadMessagesState) return miucms.count().then(res => { this.setData({ unreadMessages: res.data.count }) }) }, get_config() { var that = this; this.setData({ screen_data: app.globalData.screen_data, bottomLift: app.globalData.screen_data.bottomLift, }) // if (app.globalData.code) { if (app.globalData.config && app.globalData.config.lists) { this.get_list(); this.getNewInit() this.setData({ initState: true }) } else { setTimeout(function () { that.get_config() }, 10) } }, // 新初始化数据 getNewInit() { miucms.wxget(`${app.globalData.baseURL}/tenement/v2/api/home`).then(res => { let data = res.data console.log(data); let { search, apartment, tabs } = data this.setData({ ...data }) console.log("tabs", this.data.tabs); }) }, get_list() { var that = this; miucms.request('https://app.gter.net/tenement/home', {}).then(data => { let advListHKhousing = {}, advListotherHousing = {}; if (data.data.advList && data.data.advList.HKhousing && data.data.advList.HKhousing.length > 0) { data.data.advList.HKhousing.forEach(item => { advListHKhousing[item.position + ''] = Object.assign({}, item) }) } if (data.data.advList && data.data.advList.otherHousing && data.data.advList.otherHousing.length > 0) { data.data.advList.otherHousing.forEach(item => { advListotherHousing[item.position + ''] = Object.assign({}, item) }) } let findHouseSource = data.data.findHouseSource findHouseSource.forEach(element => { if (Array.isArray(element['rent'])) element['rent'] = `${element['rent'][0]} ~ ${ element['rent'][1] }` }) that.setData({ HKapartment: data.data.HKapartment, otherHousing: data.data.otherHousing, findHouseSource, HKhousing: data.data.HKhousing, banner: data.data.banner, service: data.data.service, servicename: data.data.servicename, advListHKhousing, advListotherHousing, loding: false }, function () { wx.hideLoading() that.getNoticeNumber() }) }).catch(res => {}) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: "寄托香港租房" } }, copy() { // const content = 'GTservice'; // const content = 'Gternet2'; const content = this.data.servicename; miucms.copy(content).then((res) => {}).catch(err => {}) }, play(e) { this.setData({ video: e.detail.src }) }, closePage(e) { this.setData({ video: '' }) }, // 关闭广告 closeAd(e) { let { position, world, id } = e.detail; if (world) { delete this.data.advListotherHousing[position]; this.setData({ advListotherHousing: this.data.advListotherHousing }) } else { delete this.data.advListHKhousing[position]; this.setData({ advListHKhousing: this.data.advListHKhousing }) } miucms.closeAD(id) }, // 点击广告 clickAD(e) { miucms.clickAD(e.detail.id) }, setValue(e) { let key = e.currentTarget.dataset.key let value = e.currentTarget.dataset.value this.setData({ [key]: value }) }, // 公共跳转 publicJumps(e) { let url = e.currentTarget.dataset.url wx.navigateTo({ url, }) } })