// pages/inspect/detail.js Page({ /** * 页面的初始数据 */ data: { desc:'', img:'' }, binddescInput: function (e) { this.data.desc = e.detail.value }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.data.id=options.id; wx.request({ url: getApp().globalData.serverUrl + 'api/troublefollowtask?a=detail&id=' + options.id, header: { 'content-type': 'application/json', // 'Cookie': getApp().globalData.sessionId, }, method: 'GET', success: res => { if (res.statusCode === 200) { // if (res.data.img) { // res.data.img = getApp().globalData.serverUrl + res.data.img // } this.setData(res.data) } } }) }, previewImage: function (e) { var current = e.target.dataset.src wx.previewImage({ current: current, urls: [current] }) }, deleteImage: function (e) { var that = this; //var index = e.currentTarget.dataset.index; //获取当前长按图片下标 wx.showModal({ title: '系统提醒', content: '确定要删除此图片吗?', success: function (res) { if (res.confirm) { that.data.img2 = null } else if (res.cancel) { return false } that.setData({ img2: that.data.img2 }); } }) }, chooseImage: function (e) { var that = this wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function (res) { wx.showLoading({ title: '上传图片..', mask: true }) wx.uploadFile({ header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, url: getApp().globalData.serverUrl + 'upfile', filePath: res.tempFilePaths[0], name: 'upfile', success(res) { wx.hideLoading() var obj = JSON.parse(res.data); that.data.img2 = getApp().globalData.serverUrl + obj['filepath'] that.setData({ img2: that.data.img2 }) }, complete: function (res) { wx.hideLoading() } }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, submit: function () { var that = this if(that.data.desc){ let data = { id:that.data.id, desc: that.data.desc, } // if (that.data.img2 && that.data.img2.indexOf(getApp().globalData.serverUrl) != -1) { // data.img2 = data.img2.replace(getApp().globalData.serverUrl, '') // } wx.showLoading({ title: '提交中', }) wx.request({ url: getApp().globalData.serverUrl + 'api/troublefollowtask/?a=handle', header: { 'content-type': 'application/json', // 默认值 'Cookie': getApp().globalData.sessionId, }, method: 'POST', data: data, success: res => { wx.navigateBack({ }) wx.hideLoading(); } }); }else{ wx.showToast({ title: '未填写跟踪描述', icon:'none' }) } }, })