// pages/backlog/accident/accident.ts import { getAction } from '../../../api/base'; Page({ /** * 页面的初始数据 */ data: { tabActive: 0, id: '', item: {} as any }, // 变更tab changeTab(e: any) { console.log(e.currentTarget.dataset.tab); this.setData({ tabActive: e.currentTarget.dataset.tab }); }, getDetailInf() { let parms = { id: this.data.id }; getAction('api/vehicles/backlog/getAccidentInfoById', parms).then( (res: any) => { if (res.code == 200) { console.log(res.result); res.result.accidentScenePhotoList = res.result.accidentScenePhoto ? res.result.accidentScenePhoto.split(',') : []; res.result.accidentSceneVideoList = res.result.accidentSceneVideo ? res.result.accidentSceneVideo.split(',') : []; res.result.insuranceInvestigationReportList = res.result .insuranceInvestigationReport ? res.result.insuranceInvestigationReport.split(',') : []; res.result.accidentInsuranceInfo.documentImageList = res.result .accidentInsuranceInfo.documentImage ? res.result.accidentInsuranceInfo.documentImage.split(',') : []; this.setData({ item: res.result }); } else { wx.showToast({ title: res.message, icon: 'none' }); } } ); }, previewImg(e: any) { let that = this; let { index, key, key2 } = e.currentTarget.dataset; if (key2) { wx.previewImage({ current: that.data.item[key][key2][index | 0], // 当前显示图片的http链接 默认urls[0] urls: that.data.item[key][key2] // 需要预览的图片http链接列表 }); } else { wx.previewImage({ current: that.data.item[key][index | 0], // 当前显示图片的http链接 默认urls[0] urls: that.data.item[key] // 需要预览的图片http链接列表 }); } }, previewVidoe(e: any) { let that = this; let { index, key } = e.currentTarget.dataset; let sources: any = that.data.item[key].map((item: any) => { return { type: 'video', url: item }; }); wx.previewMedia({ current: index, sources: sources }); }, toFeedback() { let that = this; // 违章信息 wx.setStorageSync('violation', ''); // 跳转到违章处理反馈 wx.navigateTo({ url: '../accidentFeedback/accidentFeedback', success: function (res) { // 通过eventChannel向被打开页面传送数据 res.eventChannel.emit('eventName', { ...that.data.item }); }, fail: e => { console.log(e); } }); }, /** * 生命周期函数--监听页面加载 */ onLoad() { const eventChannel = this.getOpenerEventChannel(); getApp().EventChannel = eventChannel; }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { let id = wx.getStorageSync('backlogInf').id; this.setData({ id: id }); this.getDetailInf(); }, /** * 生命周期函数--监听页面显示 */ onShow() {}, /** * 生命周期函数--监听页面隐藏 */ onHide() {}, /** * 生命周期函数--监听页面卸载 */ onUnload() {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom() {}, /** * 用户点击右上角分享 */ onShareAppMessage() {} });