123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- const Parse = getApp().Parse;
- const app = getApp();
- const company = getApp().globalData.company;
- const dateF = require('../../../../utils/date');
- let navigationBarHeight = getApp().globalData.statusBarHeight + 44;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- active: 0,
- list: [],
- price: null,
- navigationBarHeight,
- activeColor:""
- },
- onChange(event) {
- let active = event.detail.name;
- this.setData({
- active: active
- });
- console.log(active);
- this.getRoomOrder();
- },
- storepackage(e) {
- let price = e.currentTarget.dataset.item.price;
- console.log(price);
- this.setData({
- show: true,
- price: price
- });
- },
- async acceptResult(e) {
- let { order } = this.data;
- let that = this;
- let { params, no } = e.detail;
- that.setData({
- show: false
- });
- try {
- if (params == 'ok') {
- order.set('isPay', true);
- await order.save();
- this.setData({
- isPay: true
- });
- wx.showToast({
- title: '支付成功',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false
- });
- } else {
- wx.showToast({
- title: '支付失败,取消订单',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false
- });
- }
- } catch (error) {
- console.log(error);
- wx.showToast({
- title: '支付失败',
- icon: 'error',
- duration: 1500
- });
- wx.hideLoading();
- }
- },
- //删除
- delOrder(e) {
- console.log(e);
- let { index } = e.currentTarget.dataset;
- let { list } = this.data;
- let _this = this;
- wx.showModal({
- title: '',
- content: '你确定删除该订单吗?',
- showCancel: true,
- cancelText: '取消',
- cancelColor: '#000000',
- confirmText: '确定',
- confirmColor: '#3CC51F',
- success: async result => {
- if (result.confirm) {
- await this.upDel(list[index].objectId);
- list.splice(index, 1);
- _this.setData({
- list
- });
- wx.showToast({
- title: '已取消',
- icon: 'none',
- image: '',
- duration: 1500
- });
- }
- },
- fail: () => {},
- complete: () => {}
- });
- },
- async upDel(id) {
- let ShopOrder = new Parse.Query('RoomOrder');
- let order = await ShopOrder.get(id);
- if (order && order.id) {
- console.log(order);
- await order.destroy();
- }
- },
- evaluation(e) {
- let id = e.currentTarget.dataset.item.objectId;
- console.log(id);
- wx.navigateTo({
- url: '/nova-tourism/pages/my/homestay-order/evaluation/index?id=' + id
- });
- },
- orderpay(e) {
- let id = e.currentTarget.dataset.item.objectId;
- console.log(id);
- wx.navigateTo({
- url:
- '/nova-tourism/pages/my/homestay-order/homestay-details/index?id=' + id
- });
- },
- replyRefund(e) {
- let id = e.currentTarget.dataset.item.objectId;
- console.log(id);
- wx.navigateTo({
- url:
- '/nova-tourism/pages/my/refund/reply-refund/index?schema=RoomOrder&id=' +
- id
- });
- },
- phone(e) {
- let phone = e.currentTarget.dataset.item.shopStore.mobile;
- console.log(phone);
- wx.makePhoneCall({
- phoneNumber: phone
- });
- },
- async getRoomOrder() {
- let Order = new Parse.Query('RoomOrder');
- Order.equalTo('company', company);
- Order.include('room');
- Order.equalTo('user', Parse.User.current().id);
- if (this.data.active == 0) {
- Order.exists('status');
- }
- if (this.data.active == 1) {
- Order.equalTo('status', 100);
- }
- if (this.data.active == 2) {
- Order.equalTo('status', 200);
- }
- if (this.data.active == 3) {
- console.log(this.data.active);
- Order.equalTo('status', 800);
- }
- Order.include('room');
- Order.find().then(res => {
- let list = [];
- res.forEach(item => {
- let activitys = item.toJSON();
- activitys.orderTime = dateF.formatTime(
- 'mm-dd',
- activitys.startTime.iso
- );
- activitys.Time = dateF.formatTime('mm-dd', activitys.endTime.iso);
- activitys.a = dateF.formatTime(
- 'YYYY-mm-dd HH:MM:SS',
- activitys.startTime.iso
- );
- activitys.e = dateF.formatTime(
- 'YYYY-mm-dd HH:MM:SS',
- activitys.endTime.iso
- );
- //计算天数
- activitys.day = parseInt(
- (new Date(activitys.e.replace(/-/g, '/')).getTime() -
- new Date(activitys.a.replace(/-/g, '/')).getTime()) /
- (1000 * 60 * 60 * 24)
- );
- list.push(activitys);
- });
- this.setData({
- list
- });
- console.log(this.data.list);
- });
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.setData({
- activeColor:getApp().globalData.activeColor || '#229293'
- })
- this.getRoomOrder();
- // this.getDayAll()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {},
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {},
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {},
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {},
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {},
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {},
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {}
- });
|