const Parse = getApp().Parse; const company = getApp().globalData.company; const dateF = require('../../../../../utils/date') Page({ /** * 页面的初始数据 */ data: { id:null, schema:null, order:{}, explain: '', show:false, causes:[ { label: '多拍/拍错/不想要', value: '多拍/拍错/不想要', checked: false }, { label: '时间变更', value: '时间变更', checked: false }, { label: '其他', value: '其他', checked: false } ], causeVal:'', activeColor:'' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ activeColor:getApp().globalData.activeColor || '#229293' }) let {id,schema}=options; this.setData({ id, schema }) if(schema == 'RoomOrder'){ this.getRoomOrder() return } this.getOrder() }, async getRoomOrder() { console.log(this.data.schema,this.data.id); let Order = new Parse.Query("RoomOrder") Order.include('shopStore') Order.include('room') let parseOrder = await Order.get(this.data.id) console.log(parseOrder); if(parseOrder && parseOrder.id){ let order = parseOrder.toJSON() order.startTime = dateF.formatTime("YYYY/mm/dd", order.startTime.iso) order.endTime = dateF.formatTime("YYYY/mm/dd", order.endTime.iso) this.setData({ parseOrder, order }) } console.log(this.data.order); }, async getOrder() { console.log(this.data.schema,this.data.id); let Order = new Parse.Query(this.data.schema || 'ShopOrder') Order.include('shopStore') let parseOrder = await Order.get(this.data.id) console.log(parseOrder); if(parseOrder && parseOrder.id){ let order = parseOrder.toJSON() this.setData({ parseOrder, order }) } console.log(this.data.order); }, async submit(){ if(this.data.causeVal.trim() == '' ){ wx.showToast({ title: '请选择退款原因', icon: 'none' }) return } let parseOrder = this.data.parseOrder; parseOrder.fetch().then((res) =>{ console.log(res); parseOrder.set("status", 500); parseOrder.set("refundCause", this.data.causeVal); parseOrder.set("refundExplain", this.data.explain); parseOrder.save(); wx.showToast({ title: '提交成功', icon: 'none' }) setTimeout(() => { wx.navigateBack({ delta: 1, }) }, 1000); },err =>{ console.log(err); }) }, showPopup() { this.setData({ show: true }); }, onClose() { this.setData({ show: false }); }, causeChange(event){ console.log(event); this.setData({ causeVal: event.detail.value }); }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })