From c6f744eacf0b4ce3369c754720d50ca78bb20291 Mon Sep 17 00:00:00 2001 From: fengachen <373943794@qq.com> Date: Sun, 17 Oct 2021 22:09:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=BD=E9=99=85=E7=A0=94=E8=AE=A8=E4=BC=9A?= =?UTF-8?q?=E7=85=A7=E7=89=87=20ppt=E7=9A=84=E4=B8=8A=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/http/api.js | 5 + components/imageUpload/imageUpload.js | 76 +++++----- pages/signUpPageGuoji/signUpPageGuoji.js | 159 ++++++++++++++------- pages/signUpPageGuoji/signUpPageGuoji.json | 5 +- pages/signUpPageGuoji/signUpPageGuoji.wxml | 108 +++++++------- 5 files changed, 213 insertions(+), 140 deletions(-) diff --git a/assets/js/http/api.js b/assets/js/http/api.js index 3b2d071..5f87d10 100644 --- a/assets/js/http/api.js +++ b/assets/js/http/api.js @@ -43,3 +43,8 @@ export default { }) } } + +export{ + baseUrl, + URL_CONFIG +} diff --git a/components/imageUpload/imageUpload.js b/components/imageUpload/imageUpload.js index 6d5d5f1..e417f00 100644 --- a/components/imageUpload/imageUpload.js +++ b/components/imageUpload/imageUpload.js @@ -1,4 +1,9 @@ // components/imageUpload/imageUpload.js + +import { + baseUrl, + URL_CONFIG +} from "../../assets/js/http/api" Component({ /** * 组件的属性列表 @@ -34,7 +39,9 @@ Component({ let maxSize = this.data.maxSize * 1024 * 1024 let flag = true let maxLength = this.data.maxLength - console.log("maxLength",maxLength); + // 将图片的id抛出 + let imgids = [] + console.log("maxLength", maxLength); wx.chooseImage({ count: maxLength, // 默认9 sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 @@ -63,7 +70,7 @@ Component({ flag = false wx.showModal({ title: '错误提示', - content: `图片大于${that.data.maxSize}M`, + content: `图片大于${that.data.maxSize}MB`, showCancel: false, success(res) { if (res.confirm) { @@ -84,37 +91,40 @@ Component({ /** * 上传完成后把文件上传到服务器 */ - // if (flag) { - // let count = 0; - // for (let i = 0; i < tempFilePaths.length; i++) { - // //上传文件 - // wx.uploadFile({ - // url: 'imgUploadUrl', - // filePath: tempFilePaths[i], - // name: 'uploadfile_ant', - // header: { - // "Content-Type": "multipart/form-data" - // }, - // success: function (res) { - // console.log("上传图片", res); - // count++; - // //如果是最后一张,则隐藏等待中 - // if (count == tempFilePaths.length) { - // wx.hideToast(); - // } - // }, - // fail: function (res) { - // wx.hideToast(); - // wx.showModal({ - // title: '错误提示', - // content: '上传图片失败', - // showCancel: false, - // success: function (res) {} - // }) - // } - // }); - // } - // } + + if (flag) { + let count = 0; + for (let i = 0; i < tempFilePaths.length; i++) { + //上传文件 + wx.uploadFile({ + url: baseUrl + URL_CONFIG + 'sys/common/upload', + filePath: tempFilePaths[i], + name: "file", + formData: { + filetype: "image", + }, + success: function (res) { + imgids.push(JSON.parse(res.data).result.id) + count++; + //如果是最后一张,则隐藏等待中 + if (count == tempFilePaths.length) { + wx.hideToast(); + that.triggerEvent("getIds",imgids) + } + + }, + fail: function (res) { + wx.hideToast(); + wx.showModal({ + title: '错误提示', + content: '上传图片失败', + showCancel: false, + success: function (res) {} + }) + } + }); + } + } }, fail(err) { diff --git a/pages/signUpPageGuoji/signUpPageGuoji.js b/pages/signUpPageGuoji/signUpPageGuoji.js index 5e20b00..4b7c736 100644 --- a/pages/signUpPageGuoji/signUpPageGuoji.js +++ b/pages/signUpPageGuoji/signUpPageGuoji.js @@ -1,6 +1,7 @@ // pages/signUpPageGuoji/signUpPageGuoji.js import MeetingApi from "../../assets/js/http/meetingApi" import signUpApi from "../../assets/js/http/signUp" +import {baseUrl,URL_CONFIG} from '../../assets/js/http/api' Page({ /** @@ -48,15 +49,21 @@ Page({ // 抵达时间 arrivalTime: '请选择抵达时间', // 入住酒店时间 - inHotelTime:'请选择入住酒店时间', + inHotelTime: '请选择入住酒店时间', // 离店时间 - outHotelTime:'请选择离店时间', + outHotelTime: '请选择离店时间', // 离开时间 departureTime: '请选择离开时间', // 是否选择发票的选中的索引 index: -1, + // 上传图片的id + imageIds:'', + // 记录临时的文件名 用于回显 小程序上传后后端的名会乱码 + tempFiles:'点击上传', + // ppt Id + speechPpt:'', // 嘉宾身份 - guestType:-1, + guestType: -1, // 缴费方式 paymentMethodList: [{ value: '1', @@ -108,13 +115,13 @@ Page({ }) }, // 入住酒店时间 - bindDateChangeInHotelTime(e){ + bindDateChangeInHotelTime(e) { this.setData({ inHotelTime: e.detail.value }) }, // 离店时间选择 - bindDateChangeOutHotelTime(e){ + bindDateChangeOutHotelTime(e) { this.setData({ outHotelTime: e.detail.value }) @@ -210,7 +217,7 @@ Page({ }); console.log(validateArr[0].type); this.setData({ - guestType:validateArr[0].type + guestType: validateArr[0].type }) switch (validateArr[0].type) { case '1': @@ -241,7 +248,59 @@ Page({ } } }, - + // 获取图片的id + getImagesId(e) { + this.setData({ + imageIds:e.detail.join(',') + }) + }, + // ppt的上传 + uploadPPT(){ + const that = this + wx.chooseMessageFile({ + count: 1, //能选择文件的数量 + type: 'file', //能选择文件的类型,我这里只允许上传文件.还有视频,图片,或者都可以 + success(res) { + console.log(res); + var size = res.tempFiles[0].size; + var name = res.tempFiles[0].name; + var temporaryPdfArr = []; + temporaryPdfArr.push(res.tempFiles[0]); + var filePath = res.tempFiles[0].path; + if (size > 10485760 ) { //限制了文件的大小和具体文件类型 + wx.showToast({ + title: '文件大小不能超过10MB', + icon: "none", + duration: 2000, + mask: true + }) + } else { + wx.showLoading({ + title: '上传中...', + mask: true, + }); + // 如果多个文件 要循环上传 + wx.uploadFile({ + url: baseUrl + URL_CONFIG + 'sys/common/upload', //上传的路径 + filePath: filePath, //刚刚在data保存的文件路径 + name: 'file', //后台获取的凭据 + success(res) { + var fileBackDa = JSON.parse(res.data); + console.log(fileBackDa); + var backPdfArr = []; + backPdfArr.push(fileBackDa) + wx.hideLoading(); //隐藏提示框 + //上传成功, + that.setData({ + tempFiles:name, + speechPpt:fileBackDa.result.id + }); + } + }) + } + } + }) + }, // 返回一一个邀请码的数组用于校验输入的邀请码显示不同的字段 1VIP 2演讲嘉宾 3特邀嘉宾 4 合作伙伴 validateCodeArr(obj) { let { @@ -282,48 +341,52 @@ Page({ } }) }, - // 确定 - formSubmit(e){ + // 确定 + formSubmit(e) { + console.log(e); + const formData = Object.assign({}, e.detail.value) + // 会议id + formData.meetingId = '1449638073563172866' + // 参会人id + formData.companyContactId = this.data.selectedPerson.id + // 邮寄联系人id + formData.postContactId = this.data.selectedPostPerson.id + // 参会企业id + formData.companyId = this.data.selectedCompany.id + // 嘉宾身份类型 + formData.guestType = this.data.guestType + // 国际研讨会嘉宾上传的照片id + formData.photo = this.data.imageIds + // 国际研讨会嘉宾上传的ppt + formData.speechPpt = this.data.speechPpt + // 会议类型 + // formData.meetingType = this.data.selectedMeeting.meetingType + console.log(formData); - const formData = Object.assign({},e.detail.value) - // 会议id - formData.meetingId = '1449638073563172866' - // 参会人id - formData.companyContactId = this.data.selectedPerson.id - // 邮寄联系人id - formData.postContactId = this.data.selectedPostPerson.id - // 参会企业id - formData.companyId = this.data.selectedCompany.id - // 嘉宾身份类型 - formData.guestType = this.data.guestType - // 会议类型 - // formData.meetingType = this.data.selectedMeeting.meetingType - console.log(formData); - - signUpApi.signUpMeeting(formData).then(res => { - if(res.success){ - // 成功 清除缓存 跳转报名成功页面 - wx.removeStorage({ - key: 'selectedCompany', - }) - wx.removeStorage({ - key: 'selectedPerson', - }) - wx.removeStorage({ - key: 'selectedPostPerson', - }) - wx.removeStorage({ - key: 'currentMeetingInfo', - success(){ - // 跳转报名成功页面 - wx.navigateTo({ - url: '../signUpSuccess/signUpSuccess', - }) - } - }) - } - }) - }, + signUpApi.signUpMeeting(formData).then(res => { + if (res.success) { + // 成功 清除缓存 跳转报名成功页面 + wx.removeStorage({ + key: 'selectedCompany', + }) + wx.removeStorage({ + key: 'selectedPerson', + }) + wx.removeStorage({ + key: 'selectedPostPerson', + }) + wx.removeStorage({ + key: 'currentMeetingInfo', + success() { + // 跳转报名成功页面 + wx.navigateTo({ + url: '../signUpSuccess/signUpSuccess', + }) + } + }) + } + }) + }, /** * 生命周期函数--监听页面加载 */ diff --git a/pages/signUpPageGuoji/signUpPageGuoji.json b/pages/signUpPageGuoji/signUpPageGuoji.json index 8835af0..9dc72b8 100644 --- a/pages/signUpPageGuoji/signUpPageGuoji.json +++ b/pages/signUpPageGuoji/signUpPageGuoji.json @@ -1,3 +1,6 @@ { - "usingComponents": {} + "usingComponents": { + "image-upload":"../../components/imageUpload/imageUpload" + } + } \ No newline at end of file diff --git a/pages/signUpPageGuoji/signUpPageGuoji.wxml b/pages/signUpPageGuoji/signUpPageGuoji.wxml index c61bbdb..d3a99b5 100644 --- a/pages/signUpPageGuoji/signUpPageGuoji.wxml +++ b/pages/signUpPageGuoji/signUpPageGuoji.wxml @@ -5,14 +5,15 @@ 参会单位: - + 参会人: - + @@ -45,7 +46,7 @@ - + @@ -73,8 +74,8 @@ 邮寄联系人: - + @@ -130,29 +131,27 @@ - + - - + + 演讲题目: - + - + 演讲PPT: - + {{tempFiles}} - - + + 照片: - + - + 个人简介: