// subpages/points/pages/demand/finish.js // @ts-nocheck import { wxRequestPost } from "@utils/promise-wx-api" import { nextTick, } from "@utils/tools" Page({ /** * 页面的初始数据 */ data: { info: {}, serviceStartTime: '', serviceEndTime: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: async function (options) { await this.getInfo(options) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, async getInfo(op) { const params = { demandRecId: op.id } // let url = 'heart/residemand/detail-hall' // if (op.source == 'my') url = 'heart/residemand/my-detail' let { data: { data: { code, data }, }, msg, } = await wxRequestPost('heart/residemand/detail-hall', params, { isMock: false }); console.log('getInfo', data) if (msg == 'success' && code == 0) { this.setData({ info: data }) } }, async handleSubmit() { const { serviceStartTime, serviceEndTime, info } = this.data if (!serviceStartTime) { wx.showToast({ title: '服务开始时间不能为空', icon: 'none', duration: 1500 }) return } if (!serviceEndTime) { wx.showToast({ title: '服务结束时间不能为空', icon: 'none', duration: 1500 }) return } wx.showLoading({ title: '提交中...' }) const params = { demandRecId: info.demandRecId, serviceId: info.serviceId, serviceStartTime, serviceEndTime } let { data: { data: { code, data }, }, msg, } = await wxRequestPost('heart/residemand/finish', params, { isMock: false }); console.log('handleSubmit', data) await nextTick(1000) wx.hideLoading() if (msg == 'success' && code == 0) { await wx.showToast({ title: '提交成功', icon: 'none', duration: 1500 }) await nextTick(1000) wx.navigateBack({ delta: 1 }) } }, handleTimeChange(e: any) { let { serviceStartTime } = this.data const { dateTimeArray, dateTime } = e.detail serviceStartTime = `${dateTimeArray[0][dateTime[0]]}-${dateTimeArray[1][dateTime[1]]}-${dateTimeArray[2][dateTime[2]]} ${dateTimeArray[3][dateTime[3]]}:${dateTimeArray[4][dateTime[4]]}:${dateTimeArray[5][dateTime[5]]}` console.log('change', e.detail) this.setData({ serviceStartTime }) }, handleTimeEChange(e: any) { let { serviceEndTime } = this.data const { dateTimeArray, dateTime } = e.detail serviceEndTime = `${dateTimeArray[0][dateTime[0]]}-${dateTimeArray[1][dateTime[1]]}-${dateTimeArray[2][dateTime[2]]} ${dateTimeArray[3][dateTime[3]]}:${dateTimeArray[4][dateTime[4]]}:${dateTimeArray[5][dateTime[5]]}` console.log('change', e.detail) this.setData({ serviceEndTime }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })