浏览代码

自定义报名信息

xhj 2 年之前
父节点
当前提交
be2138fb56

+ 3 - 0
match/list/index.vue

@@ -87,6 +87,9 @@ export default {
 			if (!this.isLoad) return false;
 			this.isLoad = false;
 			let form = this.form;
+			if(req.getStorage("shareId")){
+				form.shareSaleNo = req.getStorage("shareId")
+			}
 			uni.showLoading();
 			req.getRequest(
 				'/api/match/list',

+ 2 - 2
match/sign/sign.vue

@@ -22,7 +22,7 @@
 			<view class="tit ddflex">报名信息<text>{{personList.length}}人</text></view>
 			<view class="add" @click="addSign()">+ 添加报名人</view>
 			<view class="list">
-				<view class="li ddflex" v-for="(item,index) in personList" :key="index" @click="jumpUrl('/match/signPerson/signPerson?index='+(index+1))">
+				<view class="li ddflex" v-for="(item,index) in personList" :key="index" @click="jumpUrl('/match/signPerson/signPerson?index='+(index+1)+'&id='+detail.id)">
 					<image src="../../static/pages/images/userimg.png" mode="aspectFill" class="user"></image>
 					<view class="fflex">{{item.name}}<text>{{item.phone}}</text></view>
 					<image src="../static/images/jian.png" class="jian" @click="delPerson(index)"></image>
@@ -142,7 +142,7 @@ export default {
 		addSign(){
 			// this.isAdd = true;
 			uni.navigateTo({
-				url: '/match/signPerson/signPerson'
+				url: '/match/signPerson/signPerson?id='+this.detail.id
 			})
 		},
 		cancel(){

+ 15 - 6
match/signConfirm/signConfirm.vue

@@ -22,16 +22,21 @@
 			<view class="li" v-for="(item,index) in personList" :key="index">
 				<view class="ddflex">
 					<view class="fflex">{{item.name}}</view>
-					<view class="ddflex" style="color: #A1A1A1;font-size: 24rpx;" v-if="item.extend&&item.extend.length>0">
+					<view class="ddflex" style="color: #A1A1A1;font-size: 24rpx;" v-if="item.extend&&item.extend.length>0" @click="openExtend(item)">
 						展开
-						<image style="width: 9rpx;height: 19rpx;margin-left: 10rpx;" src="/static/pages/images/more.png"></image>
+						<image :style="'width: 9rpx;height: 19rpx;margin-left: 10rpx;'+(item.isOpen?'transform: rotate(90deg);':'')" src="/static/pages/images/more.png"></image>
 					</view>
 				</view>
 				<view style="line-height: 42rpx;color: #A1A1A1;">{{item.phone}}</view>
-				<view v-if="item.extend&&item.extend.length>0">
-					<view v-for="it in item.extend" class="ddflex" style="font-size: 24rpx;margin-top: 20rpx;">
-						<view style="color: #A1A1A1;margin-right: 24rpx;">{{it.label}}</view>
-						<view style="color: #333333;">{{it.value}}</view>
+				<view v-if="item.extend&&item.extend.length>0&&item.isOpen">
+					<view v-for="it in item.extend">
+						<view v-if="it.value" class="ddflex" style="font-size: 24rpx;margin-top: 20rpx;">
+							<view style="color: #A1A1A1;margin-right: 24rpx;">{{it.chineseName}}</view>
+							<view v-if="it.type==4||it.type==5" class="ddflex">
+								<image :src="iit" v-for="iit in it.value.split(',')" style="width: 50rpx;height: 50rpx;margin-right: 10rpx;" mode="aspectFill"></image>
+							</view>
+							<view v-else style="color: #333333;">{{it.value}}</view>
+						</view>
 					</view>
 				</view>
 			</view>
@@ -168,6 +173,10 @@ export default {
 				this.jumpUrl('/match/success/success?id=' + this.detail.id)
 			})
 		},
+		openExtend(item){
+			item.isOpen = item.isOpen?false:true
+			this.personList = JSON.parse(JSON.stringify(this.personList))
+		},
 		formatTime(date){
 			date = new Date(date.replace(/-/g, '/'))
 			return util.formatTime(date).t3

+ 38 - 0
match/signPerson/signPerson.css

@@ -83,4 +83,42 @@ page{
 	font-weight: 400;
 	color: #FFFFFF;
 	text-align: center;
+}
+
+.upload-photo{
+	width: 120rpx;
+	height: 120rpx;
+	background: #F8F8F8;
+	border-radius: 10rpx 10rpx 10rpx 10rpx;
+	opacity: 1;
+	margin-bottom: 20rpx;
+}
+.upload-photo image{
+	width: 46rpx;
+	height: 35rpx;
+	margin: auto;
+}
+.upload-photo-image{
+	width: 120rpx;
+	height: 120rpx;
+	border-radius: 10rpx 10rpx 10rpx 10rpx;
+	opacity: 1;
+	margin-right: 20rpx;
+	position: relative;
+	margin-bottom: 20rpx;
+}
+.upload-photo-image:nth-child(5n){
+	margin-right: 0rpx;
+}
+.upload-photo-image image{
+	width: 120rpx;
+	height: 120rpx;
+	border-radius: 10rpx 10rpx 10rpx 10rpx;
+}
+.upload-photo-close{
+	width: 28rpx !important;
+	height: 28rpx !important;
+	position: absolute;
+	top:-14rpx;
+	right: -14rpx;
 }

+ 122 - 19
match/signPerson/signPerson.vue

@@ -10,35 +10,61 @@
 				<input v-model="phone" placeholder="请输入手机号" placeholder-class="p-placeholder"/>
 			</view>
 			<view v-for='item,index in parmas' class="p-form-item">
-				<view class="p-label">{{item.label}}</view>
+				<view class="p-label">{{item.chineseName}}</view>
 				<!-- 输入框 -->
 				<view v-if="item.type==1" class="p-input">
-					<input v-model="item.value" :placeholder="'请输入'+item.label" placeholder-class="p-placeholder"/>
+					<input v-model="item.value" :placeholder="'请输入'+item.chineseName" placeholder-class="p-placeholder"/>
 				</view>
 				<!-- 单选 -->
 				<view v-if="item.type==2" class="p-select">
 					<view class="ddflex">
-						<view class="ddflex p-select-item"  v-for="it in item.data" @click="pSelect(item,it)">
-							<image v-if="item.value===it.value" src="/static/images/select_h.png"></image>
+						<view class="ddflex p-select-item"  v-for="it in item.selectValues" @click="pSelect(item,it)">
+							<image v-if="item.value===it.name" src="/static/images/select_h.png"></image>
 							<image v-else src="/static/images/select.png"></image>
-							<view>{{it.label}}</view>
+							<view>{{it.name}}</view>
 						</view>
 					</view>
 				</view>
 				<!-- 多选 -->
 				<view v-if="item.type==3" class="p-select-group">
 					<view class="ddflex">
-						<view :class="'ddflex p-select-group-item '+(item.value.indexOf(it.value)!=-1?'p-select-group-item-active':'')"  v-for="it in item.data" @click="pSelectGroup(item,it)">
-							<view>{{it.label}}</view>
+						<view :class="'ddflex p-select-group-item '+(item.value&&item.value.split(',').indexOf(it.name)!=-1?'p-select-group-item-active':'')"  v-for="it in item.selectValues" @click="pSelectGroup(item,it)">
+							<view>{{it.name}}</view>
+						</view>
+					</view>
+				</view>
+				<!-- 图片 -->
+				<view v-if="item.type==4">
+					<view class="ddflex" style="margin-top: 30rpx;">
+						<view class="upload-photo-image" v-if="item.value" @click="uploadImage(item)">
+							<image :src="item.value" mode="aspectFill"></image>
+							<image class="upload-photo-close" src="/static/pages/images/close3.png"
+								@click.stop="deleteImage(item)"></image>
+						</view>
+						<view class="upload-photo ddflex" @click="uploadImage(item)" v-else>
+							<image src="../static/images/photo.png"></image>
+						</view>
+					</view>
+				</view>
+				<!-- 多图片 -->
+				<view v-if="item.type==5">
+					<view class="ddflex" style="margin-top: 30rpx;">
+						<view class="upload-photo-image" v-for="it,idx in item.value?item.value.split(','):[]" @click="uploadImage(item)">
+							<image :src="it" mode="aspectFill"></image>
+							<image class="upload-photo-close" src="/static/pages/images/close3.png"
+								@click.stop="deleteImage(item,idx)"></image>
+						</view>
+						<view class="upload-photo ddflex" @click="uploadImage(item)">
+							<image src="../static/images/photo.png"></image>
 						</view>
 					</view>
 				</view>
 				<!-- 文本域 -->
-				<view v-if="item.type==4" class="p-input">
+				<!-- <view v-if="item.type==4" class="p-input">
 					<view class="ddflex">
-						<textarea v-model="item.value" :placeholder="'请输入'+item.label" placeholder-class="p-placeholder"></textarea>
+						<textarea v-model="item.value" :placeholder="'请输入'+item.chineseName" placeholder-class="p-placeholder"></textarea>
 					</view>
-				</view>
+				</view> -->
 			</view>
 		</view>
 		
@@ -64,6 +90,7 @@ import util from "../../utils/util.js";
 				name:'',
 				phone:'',
 				parmas:[],
+				// type 1 输入框 2单择框 3多选框 4单图片 5多图片
 				// parmas:[{
 				// 	label:'姓名',
 				// 	name:'name',
@@ -97,10 +124,13 @@ import util from "../../utils/util.js";
 				// 	value:'',
 				// 	type:4,//文本域
 				// }],
-				index:null
+				index:null,
+				id:null
 			}
 		},
-		onLoad(options) {
+		async onLoad(options) {
+			this.id = options.id
+			await this.getExtForm()
 			if(options.index){
 				this.index = options.index
 				if(req.getStorage('personList')){
@@ -110,7 +140,7 @@ import util from "../../utils/util.js";
 					 this.parmas.map(item=>{
 						 parmas.extend.map(it=>{
 							if(item.type == it.type&&item.name == it.name){
-														 item.value = it.value
+								item.value = it.value
 							}
 						 })
 					 })
@@ -121,26 +151,52 @@ import util from "../../utils/util.js";
 			
 		},
 		methods: {
+			getExtForm(){
+				return new Promise((r,j)=>{
+					req.getRequest('/api/match/detail',{id:this.id},res=>{
+						this.parmas = res.extForm?JSON.parse(res.extForm):[]
+						if(this.parmas.length>0){
+							this.parmas.map(item=>{
+								item.value = ''
+							})
+						}
+						r()
+					})
+				})
+			},
 			pSelect(item,it){
-				if(item.value === it.value){
+				console.log('cc')
+				if(item.value === it.name){
 					item.value=''
-				}else if(item.value != it.value){
-					item.value=it.value
+				}else if(item.value != it.name){
+					item.value=it.name
 				}
+				this.parmas = JSON.parse(JSON.stringify(this.parmas))
 			},
 			pSelectGroup(item,it){
 				if(item.value=='') item.value=[]
-				let index = item.value.indexOf(it.value)
+				else item.value = item.value.split(',')
+				let index = item.value.indexOf(it.name)
 				if(index!=-1){
 					item.value.splice(index,1)
 				}else {
-					item.value.push(it.value)
+					item.value.push(it.name)
 				}
+				item.value = item.value.join(',')
+				this.parmas = JSON.parse(JSON.stringify(this.parmas))
 			},
 			submit(){
 				if(!this.name)  return req.msg('请填写报名人员姓名');
 				if(!this.phone)  return req.msg('请填写报名人员手机号码');
 				if(!util.isMobile(this.phone)) return req.msg('请填写正确的手机号码')
+				
+				// 数据校验
+				for(let i=0;i<this.parmas.length;i++){
+					let item = this.parmas[i]
+					if(item.required==1){
+						if(!item.value) return req.msg("请完善"+item.chineseName)
+					}
+				}
 				if(this.index){
 					console.log('parmas',JSON.stringify(this.parmas))
 					let personList = []
@@ -172,7 +228,54 @@ import util from "../../utils/util.js";
 					req.setStorage('personList',personList)
 					uni.navigateBack()
 				}
-			}
+			},
+			uploadImage(item) {
+				let that = this;
+				let count = 1
+				if(item.type==5) {
+					count = 9
+					item.value = item.value?item.value.split(','):[]
+				}
+				uni.chooseImage({
+					count: count,
+					sizeType: ['original', 'compressed'],
+					sourceType: ['album', 'camera'],
+					success: function({
+						tempFilePaths
+					}) {
+						var promise = Promise.all(
+							tempFilePaths.map(tempFilePath => {
+								return new Promise(function(resolve, reject) {
+									req.uploadFile('/api/nocheck/upload', tempFilePath,
+									res => {
+										if(item.type==5) {
+											console.log('item.type')
+											item.value = item.value.concat(res.src)
+										}
+										else item.value = res.src
+										resolve()
+									});
+								});
+							})
+						);
+						promise
+							.then(function(results) {
+								item.value = item.value.join(',')
+								that.parmas = JSON.parse(JSON.stringify(that.parmas))
+								console.log(results);
+							})
+							.catch(function(err) {
+								console.log(err);
+							});
+					}
+				});
+			},
+			deleteImage(item,index) {
+				if(item.type==5) {
+					item.value.splice(index, 1)
+				}
+				else item.value = ''
+			},
 		},
 		mounted() {
 			const systemInfo = uni.getSystemInfoSync();

+ 2 - 1
pages/index/index.vue

@@ -578,7 +578,8 @@
 			getMatchList() {
 				req.getRequest('/api/match/list', {
 					page: 1,
-					limit: 10
+					limit: 10,
+					shareSaleNo:req.getStorage("shareId")?req.getStorage("shareId"):null
 				}, res => {
 					this.matchList = res
 				})

+ 3 - 0
pages/matchList/index.vue

@@ -108,6 +108,9 @@ export default {
 			if (!this.isLoad) return false;
 			this.isLoad = false;
 			let form = this.form;
+			if(req.getStorage("shareId")){
+				form.shareSaleNo = req.getStorage("shareId")
+			}
 			uni.showLoading();
 			req.getRequest(
 				'/api/match/list',