// pages/mExtra/pSupervisionchangeDetail/pSupervisionchangeDetail.js import bUpload from "../../../base/behaviors/bUpload" import bLoadingStatus from '../../../base/behaviors/bLoadingStatus' import bLoadingToast from '../../../base/behaviors/bLoadingToast' import taskservice from "../../../service/taskservice" Page({ behaviors: [bUpload, bLoadingStatus, bLoadingToast], /** * 页面的初始数据 */ data: { problemList: [], pIndex: 0, previewImageUrls: [], previewCurrent: 0, showPreview: false, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var that = this this.getOpenerEventChannel().on('acceptDataFromOpenerPage', function (data) { that.setData({ problemList: data.data, index: data.index, }) }) }, submitDialog(e) { const index = e.currentTarget.dataset.index if (this.data.imgFiles.length == 0) { wx.showToast({ title: '请至少选择一张图片', icon: 'none', }) } else { this.setData({ showDialog: true, pIndex: index }) } }, changeProblem() { this.setData({ showDialog: false, }) this.setData({loading: true}) const pId = this.data.problemList[this.data.pIndex].guid let path = [] this.data.imgFiles.forEach(f => { path.push(f.url) }); taskservice.uploadChangePic(pId, path, { success: (res)=> { this.setData({loading: false}) this.getOpenerEventChannel().emit('uploadOver', { index: this.data.index }) wx.navigateBack({ delta: 1, }) }, complete (res) { } }) }, //图片放大预览 previewImage(e) { const { index, type } = e.currentTarget.dataset; const previewImageUrls = [] const pro = this.data.problemList[index[0]] if (type == 'pro') { pro.proPics.forEach(p => { previewImageUrls.push(p) }); } else { pro.changePics.forEach(p => { previewImageUrls.push(p) }); } this.setData({ previewImageUrls, previewCurrent: index[1], showPreview: true, title: pro.problemname }); }, })