const Parse = getApp().Parse; const company = getApp().globalData.company const dateF = require('../../../../../utils/date') Page({ /** * 页面的初始数据 */ data: { id: "", order: {}, value: 3.5, fileList: {}, content: null, }, onChange(event) { this.setData({ value: event.detail, }); }, blur(e) { let name = e.currentTarget.dataset.name this.setData({ [name]: e.detail.value }) }, changeFile(e) { console.log(e); let fileList = e.detail this.setData({ fileList }) }, async getShopOrder() { let id = this.data.id console.log(id); let ShopOrder = new Parse.Query('RoomOrder') ShopOrder.include('room') let shopOrder = await ShopOrder.get(id) let orderTime = dateF.formatTime("mm-dd", shopOrder.toJSON().startTime.iso) let Time = dateF.formatTime("mm-dd", shopOrder.toJSON().endTime.iso) let a = dateF.formatTime("YYYY-mm-dd HH:MM:SS", shopOrder.toJSON().startTime.iso) let e = dateF.formatTime("YYYY-mm-dd HH:MM:SS", shopOrder.toJSON().endTime.iso) //计算天数 let day = parseInt((new Date(e.replace(/-/g, '/')).getTime() - new Date(a.replace(/-/g, '/')).getTime()) / (1000 * 60 * 60 * 24)) console.log(day, Time, orderTime); this.setData({ order: shopOrder.toJSON(), day: day, orderTime: orderTime, Time: Time }) console.log(this.data.order); }, async submit() { const _this = this let images = [] for (let index = 0; index < this.data.fileList.length; index++) { let item = this.data.fileList[index]; images.push(item.url) } console.log(this.data.content, images, this.data.value); if (!this.data.content) { wx.showToast({ title: '请填写完整信息', icon: 'none' }) return } let shopOrder let query = new Parse.Query("RoomOrder") shopOrder = await query.get(this.data.id) shopOrder.set("content", this.data.content) shopOrder.set("images", images) shopOrder.set("status", 800) shopOrder.set("score", this.data.value) shopOrder.save().then(res => { console.log(res) wx.showToast({ title: '修改成功', icon: 'none' }) _this.setData({ }) wx.navigateBack({ delta: 1, }); }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { let id = options.id this.setData({ id: id }) this.getShopOrder() }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })