534 lines
13 KiB
JavaScript
534 lines
13 KiB
JavaScript
// pages/show/show.js
|
|
var app = getApp()
|
|
var miucms = require('../../utils/miucms.js');
|
|
var config = {};
|
|
var WxParse = require('../../wxParse/wxParse.js');
|
|
var screenWidth = 288;
|
|
var center_position = 144;
|
|
var avatar_height = 40;
|
|
var screenWidth2 = 288;
|
|
var center_position2 = 144;
|
|
var save = false;
|
|
var today = new Date();
|
|
var time_now = today.getFullYear() + '.' + (today.getMonth() > 8 ? (today.getMonth() + 1) : '0' + (today.getMonth() + 1)) + '.' + (today.getDate() > 9 ? today.getDate() : '0' + today.getDate());
|
|
var windowWidth = 0;
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
isloding: true,
|
|
tid: '',
|
|
uniqid: '',
|
|
token: '',
|
|
indicatorDots: true,
|
|
autoplay: true,
|
|
interval: 3000,
|
|
duration: 500,
|
|
circular: true,
|
|
current: 0,
|
|
coordinate: [],
|
|
brand: '',
|
|
consumption: '',
|
|
introduction: '',
|
|
life: '',
|
|
message: '',
|
|
traffic: '',
|
|
screen_data: {},
|
|
swiperHeight: 0,
|
|
markers: [],
|
|
attachment: [],
|
|
show_share_box: false,
|
|
share: false,
|
|
options: {},
|
|
isUserAuthorization: 0,
|
|
isAuthorization: 0,
|
|
showSchool: false,
|
|
showFooter: true, //底部栏
|
|
listTab: {},
|
|
q: '',
|
|
companyid: '',
|
|
withSameBrand: [],
|
|
irenCouponReceive: null,
|
|
irentCouponBig: true,
|
|
hideCoupon: false,
|
|
customerservice: null,
|
|
serviceWindowState: false,
|
|
serviceWindowList: [], // 客服弹出列表数据
|
|
tips: "", //客服弹窗提示语
|
|
},
|
|
timer: null,
|
|
onPageScroll(e) {
|
|
|
|
clearTimeout(this.timer)
|
|
if (!this.data.irentCouponBig && this.data.irenCouponReceive) {
|
|
// 显示在侧边栏
|
|
this.setData({
|
|
hideCoupon: true
|
|
})
|
|
}
|
|
this.timer = setTimeout(() => {
|
|
this.setData({
|
|
hideCoupon: false
|
|
})
|
|
}, 3000)
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
wx.getSystemInfo({
|
|
success: function (res) {
|
|
windowWidth = res.windowWidth
|
|
}
|
|
})
|
|
screenWidth = wx.getSystemInfoSync().screenWidth;
|
|
center_position = screenWidth / 2;
|
|
this.setData({
|
|
uniqid: options.uniqid || '',
|
|
source: options.source ? options.source : '',
|
|
options: options || {},
|
|
screenWidth: screenWidth,
|
|
screen_data: app.globalData.screen_data,
|
|
q: options.q ? options.q : '',
|
|
irentCouponBig: app.globalData.irentCouponBig
|
|
})
|
|
|
|
wx.showLoading()
|
|
this.get_config()
|
|
},
|
|
onShow() {
|
|
if (wx.getEnterOptionsSync().query && wx.getEnterOptionsSync().query.scancode_time && app.globalData.scancode_time != wx.getEnterOptionsSync().query.scancode_time) {
|
|
app.globalData.scancode_time = wx.getEnterOptionsSync().query.scancode_time;
|
|
this.setData({
|
|
options: wx.getEnterOptionsSync().query,
|
|
q: wx.getEnterOptionsSync().query.q
|
|
})
|
|
this.get_config()
|
|
console.log('irent onshow有更新')
|
|
}
|
|
console.log('irent onshow:', wx.getEnterOptionsSync().query)
|
|
},
|
|
|
|
get_config() {
|
|
var that = this;
|
|
if (app.globalData.config.lists) {
|
|
config = app.globalData.config;
|
|
|
|
that.setData({
|
|
user: app.globalData.user,
|
|
listTab: app.globalData.listTab
|
|
})
|
|
this.get_content();
|
|
} else {
|
|
setTimeout(function () {
|
|
that.get_config()
|
|
}, 200)
|
|
}
|
|
},
|
|
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function (res) {
|
|
|
|
if (res.from === 'button') {
|
|
// 来自页面内转发按钮
|
|
var types = res.from === 'button' ? 'share_btn' : 'show';
|
|
}
|
|
let that = this;
|
|
var title = that.data.data.title;
|
|
if (that.data.data.isquarantine) {
|
|
title = this.data.listTab.quarantineLists + '-' + that.data.data.title
|
|
}
|
|
return {
|
|
title: title,
|
|
imageUrl: that.data.data.thumbnail,
|
|
success: function (res) {
|
|
miucms.share(app, types)
|
|
},
|
|
fail: function (res) {
|
|
// 转发失败
|
|
}
|
|
}
|
|
|
|
},
|
|
get_content: function () {
|
|
let that = this;
|
|
var sendData = Object.assign({}, this.data.options, {
|
|
session: wx.getStorageSync('session'),
|
|
uniqid: that.data.uniqid,
|
|
q: that.data.q
|
|
})
|
|
miucms.request(app.globalData.config.studentapartment.details, sendData).then(data => {
|
|
wx.hideLoading()
|
|
if (data.extraparam) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: data.message,
|
|
})
|
|
} else {
|
|
|
|
that.data.coordinate = data.data.coordinate.split(',').map(item => {
|
|
return item * 1
|
|
});
|
|
let attachment = [];
|
|
if (data.data.video && data.data.video.length > 0) {
|
|
data.data.video.map(item => {
|
|
item['isvideo'] = 1;
|
|
attachment.push(item)
|
|
})
|
|
}
|
|
data.data.attachment.map(item => {
|
|
attachment.push({
|
|
image: item
|
|
})
|
|
})
|
|
|
|
that.setData({
|
|
irenCouponReceive: data.data.irenCouponReceive,
|
|
companyid: data.data.companyid,
|
|
uniqid: data.data.uniqid,
|
|
isAuthorization: data.code == 401 ? 1 : 0,
|
|
data: data.data,
|
|
attachment: attachment,
|
|
coordinate: that.data.coordinate,
|
|
brand: data.data.brand,
|
|
consumption: data.data.consumption,
|
|
introduction: data.data.introduction,
|
|
life: data.data.life,
|
|
message: data.data.message,
|
|
traffic: data.data.traffic,
|
|
markers: [{
|
|
id: 1,
|
|
latitude: that.data.coordinate[0],
|
|
longitude: that.data.coordinate[1],
|
|
width: 30,
|
|
height: 50
|
|
}],
|
|
customerservice: data.data.customerservice,
|
|
isloding: false
|
|
})
|
|
that.getList()
|
|
|
|
}
|
|
}).catch(res => {
|
|
wx.hideLoading()
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '抱歉,网络出错。请稍后重试~',
|
|
})
|
|
})
|
|
},
|
|
getList() {
|
|
let that = this;
|
|
var sendData = Object.assign({}, this.data.options, {
|
|
session: wx.getStorageSync('session'),
|
|
companyid: this.data.companyid
|
|
})
|
|
miucms.request(app.globalData.config.studentapartment.withSameBrand, sendData).then(data => {
|
|
wx.hideLoading()
|
|
if (data.extraparam) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: data.message,
|
|
})
|
|
} else {
|
|
that.setData({
|
|
withSameBrand: data.data
|
|
})
|
|
}
|
|
}).catch(res => {
|
|
wx.hideLoading()
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '抱歉,网络出错。请稍后重试~',
|
|
})
|
|
})
|
|
},
|
|
to_map: function (e) {
|
|
var that = this;
|
|
if (that.data.coordinate.length < 2) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '没有找到坐标',
|
|
})
|
|
return false
|
|
}
|
|
var latitude = that.data.coordinate[0];
|
|
var longitude = that.data.coordinate[1];
|
|
|
|
wx.openLocation({
|
|
latitude: latitude,
|
|
longitude: longitude,
|
|
scale: 24,
|
|
name: that.data.data.title,
|
|
address: that.data.data.address
|
|
})
|
|
},
|
|
|
|
navigategoBack() {
|
|
var pages = getCurrentPages();
|
|
if (pages.length == 1) {
|
|
wx.reLaunch({
|
|
url: `/pages/irentList/irentList`
|
|
});
|
|
} else {
|
|
wx.navigateBack({
|
|
changed: true
|
|
}); //返回上一页
|
|
}
|
|
},
|
|
toForm() {
|
|
wx.navigateTo({
|
|
url: `/pages/irentForm/irentForm?uniqid=${this.data.uniqid}`
|
|
})
|
|
},
|
|
send_form_id(e) {
|
|
// this.send_form_idd(e)
|
|
// return
|
|
// 有客服的弹出表单
|
|
// if (this.data.customerservice) {
|
|
// this.send_form_idd(e)
|
|
// return
|
|
// }
|
|
|
|
if (this.data.data.booking && this.data.data.booking.button == '优惠预定') {
|
|
this.tominiProgram();
|
|
} else {
|
|
this.send_form_idd(e)
|
|
|
|
return
|
|
// let url = this.data.customerservice ? '/' + this.data.data.booking.path + '&customerservice=' + this.data.customerservice : '/' + this.data.data.booking.path;
|
|
// wx.navigateTo({
|
|
// url: url,
|
|
// })
|
|
}
|
|
// return false;
|
|
wx.request({
|
|
url: app.globalData.config.FormidInsert,
|
|
data: {
|
|
session: wx.getStorageSync('session'),
|
|
formid: e.detail.formId,
|
|
statid: this.data.data.statid
|
|
},
|
|
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
header: app.globalData.header,
|
|
success: function (res) {}
|
|
})
|
|
},
|
|
// 弹出预登记
|
|
send_form_idd(e) {
|
|
if (this.data.serviceWindowList.length == 0) {
|
|
let url = `${app.globalData.baseURL}/tenement/apartment/customerservice`
|
|
miucms.request(url, {
|
|
uniqid: this.data.uniqid,
|
|
customerservice: this.data.customerservice
|
|
}).then(res => {
|
|
if (res.code == 200) {
|
|
let serviceWindowList = this.data.serviceWindowList.concat(res.data.customerservicelist)
|
|
console.log("serviceWindowList", serviceWindowList);
|
|
this.setData({
|
|
serviceWindowList,
|
|
tips: res.data.tips
|
|
})
|
|
if (serviceWindowList.length > 0) {
|
|
this.setData({
|
|
serviceWindowState: !this.data.serviceWindowState
|
|
})
|
|
} else {
|
|
let url = this.data.customerservice ? '/' + this.data.data.booking.path + '&customerservice=' + this.data.customerservice : '/' + this.data.data.booking.path;
|
|
wx.navigateTo({
|
|
url: url,
|
|
})
|
|
}
|
|
|
|
}
|
|
})
|
|
} else {
|
|
this.setData({
|
|
serviceWindowState: !this.data.serviceWindowState
|
|
})
|
|
}
|
|
|
|
// 应该是数据统计 开始
|
|
wx.request({
|
|
url: app.globalData.config.FormidInsert,
|
|
data: {
|
|
session: wx.getStorageSync('session'),
|
|
formid: e.detail.formId,
|
|
statid: this.data.data.statid
|
|
},
|
|
method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
header: app.globalData.header,
|
|
success: function (res) {}
|
|
})
|
|
// 应该是数据统计 结束
|
|
|
|
|
|
|
|
},
|
|
|
|
share_pic: function () {
|
|
let that = this;
|
|
if (!this.data.data.poster) {
|
|
wx.showToast({
|
|
title: '暂无分享图片~',
|
|
icon: 'none'
|
|
})
|
|
return false
|
|
}
|
|
// if(this.data.info.images && this.data.info.images.length>0){
|
|
// 有圖片,去到分享頁面
|
|
this.setData({
|
|
share: true,
|
|
show_naviagate: true
|
|
})
|
|
wx.setStorage({
|
|
key: 'share_info',
|
|
data: {
|
|
pic: [],
|
|
text: that.data.data.poster
|
|
},
|
|
})
|
|
|
|
},
|
|
close_share: function () {
|
|
this.setData({
|
|
share: false,
|
|
show_share_box: false
|
|
})
|
|
},
|
|
to_share() {
|
|
wx.navigateTo({
|
|
url: '/pages/share/share',
|
|
})
|
|
},
|
|
toindex: function () {
|
|
wx.reLaunch({
|
|
url: '/pages/index/index',
|
|
})
|
|
|
|
},
|
|
// 如果用户已经同意授权。则开始获取数据
|
|
islogin(obj) {
|
|
if (!obj.detail.ispageinlogin) {
|
|
wx.showLoading({
|
|
title: '加载中',
|
|
})
|
|
this.get_content();
|
|
}
|
|
},
|
|
// 点击去举报
|
|
toReport() {
|
|
if (this.data.isAuthorization == 1) {
|
|
this.setData({
|
|
isUserAuthorization: 1
|
|
})
|
|
return false
|
|
}
|
|
let that = this;
|
|
wx.navigateTo({
|
|
url: `/pages/report/report?id=${this.data.data.uniqid}&types=apartment`,
|
|
})
|
|
},
|
|
showSchoolAlert(e) {
|
|
this.setData({
|
|
showSchool: e.currentTarget.dataset.show == 1 ? true : false
|
|
})
|
|
},
|
|
// 开始播放视频,隐藏底部栏
|
|
playVideo() {
|
|
this.setData({
|
|
showFooter: false
|
|
})
|
|
},
|
|
// 关闭视频,显示底部栏
|
|
closeVideo() {
|
|
this.setData({
|
|
showFooter: true
|
|
})
|
|
},
|
|
// 前往对方小程序
|
|
tominiProgram(e) {
|
|
let types = e && e.currentTarget.dataset.types || '';
|
|
let {
|
|
path,
|
|
appId
|
|
} = types ? this.data.irenCouponReceive : this.data.data.booking;
|
|
let that = this;
|
|
wx.navigateToMiniProgram({
|
|
appId,
|
|
path,
|
|
|
|
success(res) {
|
|
// 打开成功
|
|
// console.log('打开成功')
|
|
},
|
|
complete(res) {
|
|
console.log('complete', res, appId)
|
|
let isOpen = res.errMsg == 'navigateToMiniProgram:ok' ? true : false;
|
|
that.stat(isOpen, types)
|
|
}
|
|
})
|
|
},
|
|
// 统计点击
|
|
stat(isOpen, types) {
|
|
if (types) {
|
|
if (this.data.irenCouponReceive.stat === null) {
|
|
return false
|
|
}
|
|
} else {
|
|
if (this.data.data.booking.stat === null) {
|
|
return false
|
|
}
|
|
}
|
|
let stat = types ? this.data.irenCouponReceive.stat : this.data.data.booking.stat;
|
|
miucms.request(app.globalData.config.studentapartment.stat, {
|
|
stat,
|
|
isOpen
|
|
}).then(res => {
|
|
|
|
}).catch(res => {})
|
|
},
|
|
// 放大,缩小现金券
|
|
showIrentCoupon() {
|
|
this.setData({
|
|
irentCouponBig: !this.data.irentCouponBig,
|
|
hideCoupon: false
|
|
})
|
|
if (!this.data.irentCouponBig) {
|
|
app.globalData.irentCouponBig = false;
|
|
}
|
|
},
|
|
|
|
// 切换客服弹窗状态
|
|
bindServiceWindow() {
|
|
this.setData({
|
|
serviceWindowState: !this.data.serviceWindowState
|
|
})
|
|
},
|
|
|
|
serviceWindow() {
|
|
return false
|
|
},
|
|
// QRCodeImage(e) {
|
|
// console.log(e);
|
|
// let url = e.currentTarget.dataset.url
|
|
// wx.previewImage({
|
|
// urls: [url],
|
|
// current: url
|
|
// })
|
|
// }
|
|
|
|
}) |