2023-04-21 15:39:57 +08:00

149 lines
3.2 KiB
JavaScript

// 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, // 底部我的图标 未读系统通知数量
},
/**
* 生命周期函数--监听页面加载
*/
timer: null,
onLoad: function (options) {
wx.showLoading()
this.get_config()
},
// 获取系统通知数量
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.setData({
initState: true
})
} else {
setTimeout(function () {
that.get_config()
}, 10)
}
},
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)
})
}
that.setData({
HKapartment: data.data.HKapartment,
otherHousing: data.data.otherHousing,
findHouseSource: data.data.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;
if (!content) return
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)
}
})