国际研讨会照片 ppt的上传

This commit is contained in:
fengachen
2021-10-17 22:09:25 +08:00
parent 8b857e467b
commit c6f744eacf
5 changed files with 213 additions and 140 deletions
+5
View File
@@ -43,3 +43,8 @@ export default {
})
}
}
export{
baseUrl,
URL_CONFIG
}
+43 -33
View File
@@ -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) {
+111 -48
View File
@@ -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',
})
}
})
}
})
},
/**
* 生命周期函数--监听页面加载
*/
+4 -1
View File
@@ -1,3 +1,6 @@
{
"usingComponents": {}
"usingComponents": {
"image-upload":"../../components/imageUpload/imageUpload"
}
}
+50 -58
View File
@@ -5,14 +5,15 @@
<!-- 如果是小程序消息进入的报名页面 需要回显企业与参会人 参会企业不可更改 -->
<view class="form-item">
<text class="item-label flex-1">参会单位:</text>
<input placeholder-class="text-right" data-page='guoji' bindtap="selectCompany" name="selectedCompany.companyName"
bindinput="bindInputPhone" value="{{selectedCompany.companyName}}" placeholder="请选择参会单位" />
<input placeholder-class="text-right" data-page='guoji' bindtap="selectCompany"
name="selectedCompany.companyName" bindinput="bindInputPhone" value="{{selectedCompany.companyName}}"
placeholder="请选择参会单位" />
</view>
<view class="form-item">
<text class="item-label flex-1">参会人:</text>
<input placeholder-class="text-right" data-page='guoji' bindtap="selectPerson" data-selectType='1' bindinput="bindInputPhone"
value="{{selectedPerson.name}}" placeholder="请选择参会人" />
<input placeholder-class="text-right" data-page='guoji' bindtap="selectPerson" data-selectType='1'
bindinput="bindInputPhone" value="{{selectedPerson.name}}" placeholder="请选择参会人" />
</view>
<view class="form-item">
@@ -45,7 +46,7 @@
</view>
<!-- 选择身份是参会人和内部企业的时候显示 -->
<!-- 选择身份是参会人和内部企业的时候显示 -->
<view wx:if="{{!inviteCodeShowBool}}">
<view class="form-item-radio">
<view class="radio-label">
@@ -73,8 +74,8 @@
<view class="form-item">
<text class="item-label flex-1 validate">邮寄联系人:</text>
<input placeholder-class="text-right" data-page='guoji' data-selectType='2' name="phone" bindtap="selectPerson"
value="{{selectedPostPerson.name}}" placeholder="请选择邮寄联系人" />
<input placeholder-class="text-right" data-page='guoji' data-selectType='2' name="phone"
bindtap="selectPerson" value="{{selectedPostPerson.name}}" placeholder="请选择邮寄联系人" />
</view>
<view class="form-item">
@@ -130,29 +131,27 @@
</view>
</view>
<!-- vip显示 -->
<!-- vip显示 -->
<view wx:if="{{vipBool}}">
<view class="form-item">
<text class="item-label flex-1 validate">演讲题目:</text>
<input placeholder-class="text-right" name="speechTopic" placeholder="请输入演讲题目" />
<input placeholder-class="text-right" name="speechTopic" placeholder="请输入演讲题目" />
</view>
<view class="form-item">
<view class="form-item-radio">
<text class="item-label flex-1 validate">演讲PPT</text>
<input placeholder-class="text-right" name="postContactAddress" bindinput="bindInputPhone"
placeholder="请上传文件" />
<view style="margin-top:20rpx" bindtap="uploadPPT">{{tempFiles}} </view>
</view>
<view class="form-item">
<view class="form-item-radio">
<text class="item-label flex-1 validate">照片:</text>
<input placeholder-class="text-right" name="postContactAddress" bindinput="bindInputPhone"
placeholder="请上传" />
<image-upload style="margin-top:20rpx" bindgetIds='getImagesId' maxLength='1'></image-upload>
</view>
<view class="form-item-radio">
<text class="item-label flex-1 validate">个人简介:</text>
<textarea name="profile" placeholder="请输入个人简介" name="remark" />
@@ -184,7 +183,7 @@
</view>
</view>
<view class="form-item-radio">
<view class="radio-label">
<text class="item-label flex-1 validate">是否住酒店:</text>
@@ -200,7 +199,7 @@
<view class="form-item">
<text class="item-label flex-1">入住酒店时间:</text>
<picker name='inHotelTime' mode="date" bindchange="bindDateChangeInHotelTime">
<picker name='inHotelTime' mode="date" bindchange="bindDateChangeInHotelTime">
<view class="picker">
{{inHotelTime}}
</view>
@@ -209,17 +208,16 @@
<view class="form-item">
<text class="item-label flex-1">离店时间:</text>
<picker name='outHotelTime' placeholder="请选择离店时间" mode="date" bindchange="bindDateChangeOutHotelTime">
<picker name='outHotelTime' placeholder="请选择离店时间" mode="date" bindchange="bindDateChangeOutHotelTime">
<view class="picker">
{{outHotelTime}}
{{outHotelTime}}
</view>
</picker>
</view>
<view class="form-item">
<text class="item-label flex-1 validate">房型:</text>
<input placeholder-class="text-right" name="roomLayout" bindinput="bindInputPhone"
placeholder="请输入房型" />
<input placeholder-class="text-right" name="roomLayout" bindinput="bindInputPhone" placeholder="请输入房型" />
</view>
<view class="form-item-radio">
@@ -246,17 +244,15 @@
<view class="form-item">
<text class="item-label flex-1 validate">到达站:</text>
<input placeholder-class="text-right" name="destination" bindinput="bindInputPhone"
placeholder="请输入到达站" />
<input placeholder-class="text-right" name="destination" bindinput="bindInputPhone" placeholder="请输入到达站" />
</view>
<view class="form-item">
<text class="item-label flex-1 validate">到达班次:</text>
<input placeholder-class="text-right" name="arrivalShift" bindinput="bindInputPhone"
placeholder="请输入到达班次" />
<input placeholder-class="text-right" name="arrivalShift" bindinput="bindInputPhone" placeholder="请输入到达班次" />
</view>
<view class="form-item-radio">
<view class="radio-label">
<text class="item-label flex-1 validate">是否需要送站:</text>
@@ -293,8 +289,7 @@
<view class="form-item">
<text class="item-label flex-1">同行人:</text>
<input placeholder-class="text-right" name="peer" bindinput="bindInputPhone"
placeholder="请输入同行人" />
<input placeholder-class="text-right" name="peer" bindinput="bindInputPhone" placeholder="请输入同行人" />
</view>
<view class="form-item-radio">
@@ -309,27 +304,27 @@
</view>
<!-- 演讲嘉宾显示 -->
<view wx:if="{{speakerBool}}">
<view class="form-item">
<text class="item-label flex-1 validate">演讲题目:</text>
<input placeholder-class="text-right" name="speechTopic" placeholder="请输入演讲题目" />
</view>
<view class="form-item">
<view class="form-item-radio">
<text class="item-label flex-1 validate">演讲PPT</text>
<input placeholder-class="text-right" name="postContactAddress"
placeholder="请上传文件" />
<view style="margin-top:20rpx" bindtap="uploadPPT">{{tempFiles}} </view>
</view>
<view class="form-item">
<view class="form-item-radio">
<text class="item-label flex-1 validate">照片:</text>
<input placeholder-class="text-right" name="postContactAddress" bindinput="bindInputPhone"
placeholder="请上传" />
<!-- <input placeholder-class="text-right" name="postContactAddress" bindinput="bindInputPhone"
placeholder="请上传" /> -->
<image-upload style="margin-top:20rpx" bindgetIds='getImagesId' maxLength='1'></image-upload>
</view>
<view class="form-item-radio">
<text class="item-label flex-1 validate">个人简介:</text>
<textarea name="profile" placeholder="请输入个人简介" name="remark" />
@@ -385,16 +380,15 @@
<view class="form-item">
<text class="item-label flex-1 validate">到达站:</text>
<input placeholder-class="text-right" name="destination" placeholder="请输入到达站" />
<input placeholder-class="text-right" name="destination" placeholder="请输入到达站" />
</view>
<view class="form-item">
<text class="item-label flex-1 validate">到达班次:</text>
<input placeholder-class="text-right" name="arrivalShift" bindinput="bindInputPhone"
placeholder="请输入到达班次" />
<input placeholder-class="text-right" name="arrivalShift" bindinput="bindInputPhone" placeholder="请输入到达班次" />
</view>
<view class="form-item-radio">
<view class="radio-label">
<text class="item-label flex-1 validate">是否需要送站:</text>
@@ -419,12 +413,12 @@
<view class="form-item">
<text class="item-label flex-1 validate">离开站:</text>
<input placeholder-class="text-right" name="departureStation" placeholder="请输入离开站" />
<input placeholder-class="text-right" name="departureStation" placeholder="请输入离开站" />
</view>
<view class="form-item">
<text class="item-label flex-1 validate">离开班次:</text>
<input placeholder-class="text-right" name="departureShift" placeholder="请输入离开班次" />
<input placeholder-class="text-right" name="departureShift" placeholder="请输入离开班次" />
</view>
<view class="form-item">
@@ -495,17 +489,15 @@
<view class="form-item">
<text class="item-label flex-1 validate">到达站:</text>
<input placeholder-class="text-right" name="destination" bindinput="bindInputPhone"
placeholder="请输入到达站" />
<input placeholder-class="text-right" name="destination" bindinput="bindInputPhone" placeholder="请输入到达站" />
</view>
<view class="form-item">
<text class="item-label flex-1 validate">到达班次:</text>
<input placeholder-class="text-right" name="arrivalShift" bindinput="bindInputPhone"
placeholder="请输入到达班次" />
<input placeholder-class="text-right" name="arrivalShift" bindinput="bindInputPhone" placeholder="请输入到达班次" />
</view>
<view class="form-item-radio">
<view class="radio-label">
<text class="item-label flex-1 validate">是否需要送站:</text>
@@ -521,7 +513,7 @@
<view class="form-item">
<text class="item-label flex-1">离开时间:</text>
<picker name='departureTime' mode="date" bindchange="bindDateChangeLeaveTime">
<picker name='departureTime' mode="date" bindchange="bindDateChangeLeaveTime">
<view class="picker">
{{departureTime}}
</view>
@@ -542,7 +534,7 @@
<view class="form-item">
<text class="item-label flex-1 validate">同行人:</text>
<input placeholder-class="text-right" name="peer" placeholder="请输入同行人" />
<input placeholder-class="text-right" name="peer" placeholder="请输入同行人" />
</view>
<view class="btn-wrap">
@@ -552,7 +544,7 @@
</view>
<!-- 合作伙伴显示 -->
<view wx:if="{{cooperatieBool}}">
<view class="form-item">
<text class="item-label flex-1">抵达时间:</text>
<picker name='arrivalTime' mode="date" bindchange="bindDateChangeArriveTime">
@@ -562,10 +554,10 @@
</picker>
</view>
<view class="form-item">
<text class="item-label flex-1">离开时间:</text>
<picker name='departureTime' mode="date" bindchange="bindDateChangeLeaveTime">
<picker name='departureTime' mode="date" bindchange="bindDateChangeLeaveTime">
<view class="picker">
{{departureTime}}
</view>