// pagesPublic/pages/work-order/work-order.js var dateTimePicker = require('../../../utils/dateTimePicker'); Page({ /** * 页面的初始数据 */ data: { isUser: true, currentIndex: 0, date: '2023-10-01', time: '12:00', dateTimeArray: null, dateTime: null, startYear: 2000, endYear: 2250, typeList: ['报修类型一', '报修类型二', '报修类型三'], list: [{ type: '维修类型一', address: '食堂二楼楼梯地砖', time: '2022-03-15 13:45' }, { type: '维修类型一', address: '食堂二楼楼梯地砖', time: '2022-03-15 13:45' }] }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { // 获取完整的年月日 时分秒,以及默认显示的数组 var obj = dateTimePicker.dateTimePicker(this.data.startYear, this.data.endYear); // 精确到分的处理,将数组的秒去掉 // var lastArray = obj.dateTimeArray.pop(); // var lastTime = obj.dateTime.pop(); this.setData({ dateTime: obj.dateTime, dateTimeArray: obj.dateTimeArray }); // 查询所有报修类型 }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 点击切换标题 * @param {*} e */ titleClick(e) { this.setData({ currentIndex: e.currentTarget.dataset.idx }); }, /** * 切换swiper-item触发bindchange事件 * @param {*} e */ pagechange: function (e) { console.info(e) // 通过touch判断,改变tab的下标值 if ("touch" === e.detail.source) { // let currentPageIndex = this.data.currentIndex; // currentPageIndex = (currentPageIndex + 1) % 2; // 拿到当前索引并动态改变 this.setData({ currentIndex: e.detail.current }); } }, /** * 报修类型选择 * @param {*} e */ typePickerChange(e) { console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ index: e.detail.value }); }, /** * 提交工单 * @param {*} e */ submitWorkOrder(e) { console.info(e); if (!e.detail.value.type) { wx.showToast({ title: '请选择报修类型', icon: 'error' }); return; } if (!e.detail.value.address) { wx.showToast({ title: '请输入地址', icon: 'error' }); return; } if (!e.detail.value.phone) { wx.showToast({ title: '请输入联系电话', icon: 'error' }); return; } if (!e.detail.value.arriveTime) { wx.showToast({ title: '请选择上门时间', icon: 'error' }); return; } }, /** * 上传报修图片 */ uploadImage() { wx.chooseMedia({ success(res) { console.info(res); } }); }, /** * 查看工单详情 * @param {*} e */ toDetail(e) { wx.navigateTo({ url: '../work-order-detail/work-order-detail', }); }, toRepairDetail() { wx.navigateTo({ url: '../work-order-detail/work-order-detail', }); } })