// pages/rzcx/rzcx.js const app = getApp(); Page({ /** * 页面的初始数据 */ data: { user: app.globalData.imgUrl + '/image/user.svg', add: app.globalData.imgUrl + '/image/add.svg', del: app.globalData.imgUrl + '/image/del.svg', videoIcon: app.globalData.imgUrl + '/image/video.png', disabled: false, id: '', picType: '', evalList: {}, dataSet: {}, picturesInfo: {}, entityId: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; console.log(options) let id = options.id that.setData({ id }) let disabled = options.disabled let flag = options.flag || '' var userinfo = wx.getStorageSync("user"); wx.request({ url: app.globalData.url + '/api/entry/find?id=' + id + '&flag=' + flag, success: function (res) { console.log(res.data) // if (res.data.code == 0) { console.log(res.data) var evalList1019 = res.data.list || []; console.log('37', evalList1019) var evalList = { evalList1019, }; for (var i in evalList) { evalList[i] = evalList[i].map(({ url, uid }) => ({ pic: url, id: uid })) } console.log('48', evalList) that.setData({ picturesInfo: { ...res.data, createrId: userinfo.id, }, entityId: res.data.id, disabled, evalList }) // } else { // wx.showModal({ // title: '提示', // content: "请求失败!" // }) // } } }) }, inputChange: function (e) { var name = e.currentTarget.dataset.name; this.setData({ picturesInfo: { ...this.data.picturesInfo, [name]: e.detail.value } }) }, submit: function (e) { var picturesInfo = this.data.picturesInfo; if (!picturesInfo.reason) { return app.showModal("请填写申请理由!"); } var that = this; console.log(picturesInfo) wx.request({ url: app.globalData.url + '/api/entry/miniSave', data: picturesInfo, method: 'POST', header: { "Content-Type": "application/json" }, success: function (res) { // if (res.data.code == 0) { wx.showToast({ title: '提交成功', icon: 'success', duration: 2000 }) setTimeout(function () { wx.reLaunch({ url: '../zhwj/zhwj', }) }, 2000) // } else { // wx.showModal({ // title: '提示', // content: "提交失败!" // }) // } } }) }, // 删除图片 clearImg: function (e) { var that = this; app.clearImg(e, that) }, //预览图片 previewImage: function (e) { app.previewImage(e) }, uploadFiles: function (e) { var that = this; wx.showActionSheet({ itemList: ['拍照上传', '选择图片'], success: function (res) { app.joinPicture(e, that, 1019, that.data.entityId) }, fail: function (res) {} }) }, })