const app = getApp(); Page({ data: { //身份证手持页 // 上传的案例图片集合 scsfzImages: [], // 案例图片数目是否达到了最大数目 scsfzImagesNum: false, //加号图标 显示 scsfzimg: true, //上传图片 隐藏 scsfzinitial: true, //初始图片 隐藏 // 设置上传案例图片的最大数目 maxImages: 1, img1: '', //手持身份证 initial: [], //头部信息 SubmissionHidden: true, //提交隐藏显示 }, onLoad: function (options) { var that = this; // // 获取信息 let initial_url = 'my/authentication/educationchange'; let initial_data = { }; app.postRequest(initial_url, initial_data, function (res) { if (res.code == 201) { console.log(res.data.status); that.setData({ initial: res.data, // 初始数据 initialcode: res, //获取未上传状态 }) } if (res.data.status == 2) { //如果审核未通过 显示提交按钮 that.setData({ SubmissionHidden: false }) } else if (res.code != 201) { that.setData({ SubmissionHidden: false }) }else{ that.setData({ SubmissionHidden: true }) } }) }, // 上传学历 scsfzclick: function (e) { var _this = this; wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success(res) { let tempFilesSize = res.tempFiles[0].size; if (tempFilesSize > 1024 * 1024 * 3) { wx.showModal({ title: '提示', content: '图片不得超过3MB', showCancel: false, }) return; } _this.setData({ scsfzImages: res.tempFilePaths[0], scsfzImagesNum: true, scsfzimg: false, img1: res.tempFilePaths[0], }); } }) }, // //最后提交认证 Submission: function (e) { var _this =this; console.log(this.data.img1) if (this.data.img1 == '') { var _qrcode = '请上传学历证明' getApp().Tips(_qrcode); }else{ // console.log(this.data.img1) //上传图片 wx.uploadFile({ url: app.globalData.url + 'my/authentication/education', filePath: this.data.img1, name: 'img1', formData: { key: wx.getStorageSync('access_key'), token: wx.getStorageSync('access_token') }, success: function (res) { var data = JSON.parse(res.data); if (data.code == 201) { wx.showToast({ title: '提交成功', icon: 'success', duration: 2000 }) _this.onLoad(); return } var _qrcode = data.msg getApp().Tips(_qrcode); }, fail: function (d) { wx.showToast({ //这里提示失败 title: '上传失败', icon: 'none', // 不显示图标 duration: 2000 }) } }) } }, })