// pages/vehicleMaintenance/maintainSend/maintainSend.ts import { postAction } from '../../../../api/base'; const dayjs = require('dayjs'); Page({ /** * 页面的初始数据 */ data: { cancelIdea: '', // 作废原因 upkeepObject: '' as any, // 维修单数据 userInfo: '' as any, // 用户信息 checkPeople: '' //审批人 }, // 输入报修内容 textareaInput(e: any) { this.setData({ cancelIdea: e.detail.value }); }, // 提交申请 submit() { // 未完成的情况下没有填写原因 if (!this.data.cancelIdea) { wx.showToast({ title: '请填写作废原因', icon: 'none' }); return; } let params = { id: this.data.upkeepObject.id, cancelIdea: this.data.cancelIdea, realname: this.data.userInfo.realname }; wx.showLoading({ title: '加载中', mask: true }); postAction('api/vehicles/upkeepBill/cancel', params) .then((res: any) => { if (res.code == 200) { wx.hideLoading(); wx.showToast({ title: '作废成功', icon: 'none' }); wx.setStorageSync('message', { checkPeople: this.data.userInfo.realname, date: dayjs().format('YYYY-MM-DD HH:mm:ss'), cancelIdea: this.data.cancelIdea, id: this.data.upkeepObject.id, flowStatus: 9 }); wx.redirectTo({ url: '../message/message', fail: e => { console.log(e); } }); } else { wx.hideLoading(); wx.showToast({ title: res.message, icon: 'none' }); } }) .catch((err: any) => { wx.hideLoading(); wx.showToast({ title: err.message, icon: 'none' }); }); }, getInf() { // 获取信息 let info = wx.getStorageSync('upkeepObject'); console.log('看书', info); wx.removeStorage({ key: 'upkeepObject' }); let userInfo = wx.getStorageSync('userInfo'); this.setData({ upkeepObject: info, userInfo: userInfo, checkPeople: userInfo.realname }); }, /** * 生命周期函数--监听页面加载 */ onLoad() {}, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { this.getInf(); }, /** * 生命周期函数--监听页面显示 */ onShow() { // 不放onReady 是因为有可能切出去然后状态改了得跳转到别的页面 }, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage() {} });