2023-04-17 16:14:18 +08:00

190 lines
4.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/UK/UK.js
var WxParse = require('../../wxParse/wxParse.js');
var app = getApp()
var config = {};
var miucms = require('../../utils/miucms.js');
Page({
/**
* 页面的初始数据
*/
data: {
appid:'wxb09c358c3ec5e34f',
activeCity:0,
activeCityIndex:0,
wechat:'',
strategy:[],
hotHouseList:[],
swiperHeight:220,
activeSwiperIndex:0,
current:0,
aboutBelloliving:[
{
text:'6年时间八楼校舍帮助上万中国留学生寻找住所。住宿是留学的开始我们秉持公正透明的态度为留学生提供方便可靠的住宿。',
icon:'year',
name:'6年',
},
{
text: '在八楼所有房源均为实地考察的真实房源。我们对虚假房源实施“0容忍策略”。',
icon: 'percent',
name: '真实房源',
},
{
text: "不仅如此八楼所有学生公寓预定业务均为100%免费,并且与公寓供应商官方价格一致,绝不加价。",
icon: 'free',
name: '0服务费',
},
{
text: "我们将会为您提供最简单、最方便、最贴心的服务。",
icon: 'service',
name: '优质服务',
}
],
banner:""
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.get_list();
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
get_list(){
var that = this;
wx.showLoading({
title: '',
})
miucms.request('https://app.gter.net/tenement/belloliving', {}).then(res => {
wx.hideLoading()
var data = res.data;
var hotCity = [], beforeLength = 0;
data.hotHouseList.forEach(item=>{
hotCity.push({
cityName: item.cityName,
cityid:item.cityid,
length: item.houseList.length,
beforeLength: beforeLength
})
beforeLength += item.houseList.length;
})
that.setData({
hotHouseList: data.hotHouseList,
strategy: data.strategy,
wechat: data.wechat,
hotCity: hotCity,
activeCity: data.hotHouseList[0].cityid,
banner: data.banner
})
}).catch(res => { wx.hideLoading() })
},
swiperList:{},
changeHotCity(e){
this.setData({
activeCity:e.currentTarget.dataset.id,
current: e.currentTarget.dataset.beforelength,
activeCityIndex:e.currentTarget.dataset.index,
activeSwiperIndex:0
})
this.stat('cityswitch', e.currentTarget.dataset.id, e.currentTarget.dataset.name)
},
loadHeight(e){
if (this.data.swiperHeight>220){return false}
this.setData({
swiperHeight: e.detail.height
})
},
changeSwiper(e){
// .detail.current
if(e.detail.source== "touch"){
// 用户主动触发
for (var i = this.data.hotCity.length-1;i>=0;i--){
if (e.detail.current >= this.data.hotCity[i].beforeLength) {
if (this.data.hotCity[i].cityid != this.data.activeCity){
this.setData({
activeCity: this.data.hotCity[i].cityid,
activeCityIndex:i,
})
}
this.setData({
activeSwiperIndex: e.detail.current - this.data.hotCity[i].beforeLength
})
break;
}
}
}
},
copy(e){
wx.setClipboardData({
data: e.currentTarget.dataset.wechat,
})
this.stat('service', e.currentTarget.dataset.wechat, e.currentTarget.dataset.wechat)
},
// 点击房源
statHouse(e){
this.stat('house', e.currentTarget.dataset.id, e.currentTarget.dataset.name)
},
// 点击按钮
statBtn(e) {
this.stat(e.currentTarget.dataset.type, e.currentTarget.dataset.id, e.currentTarget.dataset.name)
},
// 统计点击
stat(type, id, name, isOpen){
miucms.request('https://app.gter.net/tenement/belloliving/stat', { type, relatedid: { id, name, isOpen}}).then(res => {
var data = res.data;
}).catch(res => { })
},
tominiProgram(e){
let {path,name,id,type} = e.currentTarget.dataset;
let that = this;
wx.navigateToMiniProgram({
appId: that.data.appid,
path,
success(res) {
// 打开成功
console.log('打开成功')
},
complete(res){
console.log('complete',res)
let isOpen = res.errMsg =='navigateToMiniProgram:ok' ? true:false;
that.stat(type, id, name, isOpen)
}
})
}
})