123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- let Parse = getApp().Parse
- const company = getApp().globalData.company
- let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
- const rechText = require('../../../../utils/rech-text')
- import date from '../../../../utils/date';
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- // list: {},
- // show: false,
- roomId: null,
- SwiperInfo: {
- duration: 500,
- autoplay: false,
- interval: 2000
- },
- stickyTop: navigationBarHeight,
- room: {},
- active: 'detail',
- time: '', // 入住时间
- condition: '', // 入住条件
- orders: [],
- commentCount: 0// 评论总数
- },
- showPopup() {
- console.log(12344)
- this.setData({ show: true })
- },
- //关闭 弹窗
- onClose: function () {
- this.setData({ show: false })
- console.log(this.data.show)
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- activeColor: getApp().globalData.activeColor || '#229293'
- })
- let roomId = options.id
- if (!roomId) {
- wx.navigateTo({
- url: `/nova-tourism/pages/index/index`
- })
- }
- this.selectComponent("#tabs").resize();
- let botHeight = wx.getStorageSync('botHeight', botHeight);
- console.log(botHeight);
- this.setData({ roomId, botHeight })
- this.getData()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () { },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () { },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () { },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () { },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () { },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () { },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- title: '房间详情',
- }
- },
- getData: async function () {
- await this.getRoom()
- console.log(navigationBarHeight);
- this.getRoomCount()
- this.getRoomComments()
- },
- async getRoom() {
- let Room = new Parse.Query('ShopRoom')
- Room.include("shop")
- let room = await Room.get(this.data.roomId)
- room = room.toJSON()
- if (room.details) {
- room.details = rechText.formatRichText(room.details)
- }
- room.rate = room.shop?.score
- room.workingTime = room.shop.workingTime
- console.log(room)
- this.setData({
- room
- })
- },
- async getRoomCount() {
- let Room = new Parse.Query('ShopRoom')
- Room.equalTo("shop", this.data.room.shop.objectId)
- let count = await Room.count()
- console.log(count)
- let temp = `room.shop.count`;
- this.setData({
- [temp]: count
- })
- console.log(this.data.room.shop.count);
- },
- async getRoomComments() {
- let Order = new Parse.Query('RoomOrder')
- Order.equalTo("room", this.data.roomId);
- Order.include("user");
- Order.greaterThanOrEqualTo("status", 800);
- Order.limit(2)
- let orders = await Order.find()
- orders = orders.map((order) => {
- order = order.toJSON()
- order['time'] = date.formatTime('YY-mm-dd HH:MM', order.updatedAt)
- return order;
- })
- console.log(orders)
- this.setData({
- orders
- })
- let commentCount = await Order.count()
- console.log(commentCount);
- this.setData({
- commentCount
- })
- console.log(this.data.orders);
- },
- tabChange(event) {
- let name = event.detail.name;
- console.log(event.detail.name);
- wx.pageScrollTo({
- offsetTop: navigationBarHeight,
- selector: `#${name}`,
- duration: 300,
- success(res) {
- console.log('res', res);
- },
- fail(err) {
- console.log('err', err);
- }
- })
- },
- navigate() {
- let currentUser = Parse.User.current()
- currentUser = currentUser.toJSON()
- console.log(currentUser, currentUser.idcard);
- if (currentUser.idcard) {
- console.log(currentUser);
- wx.navigateTo({
- url: `/nova-tourism/pages/homestay/room-order/index?id=${this.data.room.objectId}`
- })
- } else {
- wx.showToast({
- title: '请先进行实名认证',
- icon: 'none'
- })
- wx.navigateTo({
- url: `/common-page/pages/info/cauth/cauth?themeColor=#FFE300`
- })
- }
- },
- navigateComments() {
- wx.navigateTo({
- url: `/nova-tourism/pages/homestay/comments/index?id=${this.data.roomId}`
- })
- },
- /* 选择入住条件 */
- selectCheck() { },
- /* 选择入住时间 */
- selectTime() { }
- })
|