123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- // nova-tourism/pages/my/my-order/index.js
- let Parse = getApp().Parse;
- const company = getApp().globalData.company
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- statusBarHeight: 0,
- screenHeight: 0,
- customHeight: 0,
- bottomNavHeight: 0,
- contentHeight: 0,
- active:0,
- option: [
- { text: '民宿订单', value: '民宿' },
- { text: '物品订单', value: '物品' },
- ],
- value:'民宿',
- roomList:[],
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- active:Number(options.active)
- })
- const systemInfo = wx.getSystemInfoSync();
- const statusBarHeight = systemInfo.statusBarHeight || 0;
- const screenHeight = systemInfo.screenHeight || 0;
- const custom = wx.getMenuButtonBoundingClientRect();
- const customHeight = custom.height + 10 + 2 || 0;
- const bottomNavHeight = systemInfo.screenHeight - systemInfo.safeArea.bottom || 0;
- const contentHeight = (screenHeight - bottomNavHeight - statusBarHeight - customHeight) * 750 / systemInfo.windowWidth;
- this.setData({
- statusBarHeight,
- screenHeight,
- customHeight,
- bottomNavHeight,
- contentHeight
- });
- this.getRoomOrder()
- },
- //改变民宿或物品
- change(e){
- console.log(this.data.value);
- this.setData({
- active:0
- })
- if(this.data.value=='民宿'){
- this.getRoomOrder()
- }else{
- }
- },
- //改变订单状态
- onChange(event){
- let active = event.detail.name;
- this.setData({
- active: active
- });
- if(this.data.value=='民宿'){
- this.getRoomOrder()
- }else{
- }
- console.log(this.data.active,this.data.value);
- },
- formatDate2(date1, date2) {
- date1 = new Date(date1);
- date2 = new Date(date2);
- // 获取年份、月份和日期
- const year1 = date1.getFullYear();
- const month1 = date1.getMonth() + 1; // 月份从0开始,所以要加1
- const day1 = date1.getDate();
- const year2 = date2.getFullYear();
- const month2 = date2.getMonth() + 1; // 月份从0开始,所以要加1
- const day2 = date2.getDate();
- // 返回格式化的字符串
- return `${year1}年${month1}月${day1}日入住 - ${year2}年${month2}月${day2}日离店`;
- },
- async getRoomOrder(){
- let Order = new Parse.Query('RoomOrder');
- Order.equalTo('company', company);
- Order.include('room');
- Order.equalTo('user', Parse.User.current().id);
- Order.include('shopStore');
- if (this.data.active == 0) {
- Order.equalTo('status', 100);
- }
- if (this.data.active == 1) {
- Order.equalTo('status', 200);
- }
- if (this.data.active == 2) {
- console.log(this.data.active);
- Order.equalTo('status', 800);
- }
- let room = await Order.find();
- let roomList = room.map(item => {
- let roomItme = item.toJSON();
- let startTime = roomItme.startTime
- let endTime = roomItme.endTime
- roomItme.tiem = this.formatDate2(startTime,endTime)
- return roomItme
- });
- this.setData({
- roomList
- })
- console.log(this.data.roomList);
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|