Commit 396643b7 authored by 潘永坪's avatar 潘永坪

填写订单页面开发

parent 34f47abe
...@@ -96,7 +96,7 @@ export default{ ...@@ -96,7 +96,7 @@ export default{
return d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg)) return d*(1 + fl*(h1*sf*(1-sg) - h2*(1-sf)*sg))
}, },
phoneReg:function(){//手机正则 phoneReg:function(){//手机正则
return /^(13[0-9]|14[0-9]|15[0-9]|18[0-9]|17[0-9]|19[0-9]|16[0-9])\d{8}$/ return /^(13[0-9]|14[0-9]|15[0-9]|18[0-9]|17[0-9]|19[0-9]|16[0-9]|12[0-9])\d{8}$/
}, },
idReg:function(){//身份证正则 idReg:function(){//身份证正则
return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/ return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X|x)$/
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<view class="son-wrap"> <view class="son-wrap">
<view class="top"> <view class="top">
<view class="top-num"> <view class="top-num">
需填写{{buyNum}}位联系人 需填写{{contactNum}}位联系人
</view> </view>
<view @click="showEdit()" class="top-add"> <view @click="showEdit()" class="top-add">
<text> <text>
...@@ -14,20 +14,25 @@ ...@@ -14,20 +14,25 @@
<view class="bottom"> <view class="bottom">
<checkbox-group @change="chooseContactChange"> <checkbox-group @change="chooseContactChange">
<view class="bottom-list" v-for="(item,index) of contactData" :key="item.id"> <view class="bottom-list" v-for="(item,index) of listTotal" :key="item.id">
<label> <label>
<checkbox :value="JSON.stringify(item)" :checked="item.ifChoose" color="#3688ff" /> <checkbox :value="JSON.stringify(item)" :checked="item.ifChoose" color="#3688ff" />
<view class="bottom-content"> <view class="bottom-content">
<view> <view>
{{item.name}} {{item.name}}
</view> </view>
<view> <view>
<text> <text>
身份证 身份证
</text> </text>
{{item.credentialNumber?item.credentialNumber.substr(0,3)+"****"+item.credentialNumber.substr(14,4):"无"}} {{item.credentialNumber?item.credentialNumber.substr(0,3)+"****"+item.credentialNumber.substr(14,4):"无"}}
</view> </view>
<view>
<text>
手机号
</text>
{{item.phone?item.phone.substr(0,3)+"****"+item.phone.substr(7,4):"无"}}
</view>
</view> </view>
</label> </label>
...@@ -38,12 +43,12 @@ ...@@ -38,12 +43,12 @@
<u-icon name="trash-fill" color="#3688ff" size="56"></u-icon> <u-icon name="trash-fill" color="#3688ff" size="56"></u-icon>
</view> </view>
</view> </view>
<view style="margin: 40rpx 0;text-align: center;" v-if='contactData&&contactData.length>0'> <view style="margin: 40rpx 0;text-align: center;" v-if='listTotal&&listTotal.length>0'>
已展示所有联系人 已展示所有联系人
</view> </view>
</checkbox-group> </checkbox-group>
<view class="bottom-sure"> <view class="bottom-sure" @click="config()">
确定 确定
</view> </view>
</view> </view>
...@@ -54,22 +59,22 @@ ...@@ -54,22 +59,22 @@
<script> <script>
export default { export default {
props: ['contactData', 'orderTouristList', 'buyNum'], props: ['contactTotal', 'contactNum'],
watch: { watch: {
orderTouristList: { contactTotal: {
handler(newValue, oldValue) { handler(newValue, oldValue) {
if (newValue) { if (newValue) {
this.chooseContact = this.orderTouristList this.listTotal = this.contactTotal
} }
}, },
deep: true, deep: true,
immediate: true immediate: true
} }
}, },
data() { data() {
return { return {
showPop: false, //控制联系人弹窗显示隐藏 showPop: false, //控制联系人弹窗显示隐藏
chooseContact: [], //选中的联系人 listTotal:[],//所有联系人
showModal: false, //确认弹窗显示隐藏 showModal: false, //确认弹窗显示隐藏
contactId:'',//删除联系人的Id contactId:'',//删除联系人的Id
...@@ -91,20 +96,41 @@ export default { ...@@ -91,20 +96,41 @@ export default {
//---确定选中的联系人 //---确定选中的联系人
config() { config() {
this.showPop = false this.showPop = false
this.$emit('contactListConfig', this.chooseContact) //选中的排在前面
this.listTotal.sort(function (a, b) {
return b.ifChoose-a.ifChoose
})
this.$parent.contactTotal=this.listTotal
let chooseArr=[]
this.listTotal.forEach(item=>{
if(item.ifChoose){
chooseArr.push(item)
}
})
this.$parent.chooseContact=chooseArr
}, },
//---联系人姓名变化 //---联系人姓名变化
chooseContactChange(e){ chooseContactChange(e){
let value=e.detail.value let value=e.detail.value
if (value.length > this.contactNum) {
let number=value.length-this.contactNum
value=value.slice(number)
}
let arr=[] let arr=[]
value.forEach(item=>{ value.forEach(item=>{
arr.push(JSON.parse(item)) arr.push(JSON.parse(item))
}) })
this.chooseContact=arr //先全部取消选中,后面根据选中的值来判断谁选中
if (arr.length > this.buyNum) { this.listTotal.forEach(item=>{
arr.shift() item.ifChoose=false
} })
arr.forEach(item=>{
this.listTotal.forEach(item2=>{
if(item.id==item2.id){
item2.ifChoose=true
}
})
})
}, },
//---点击删除 //---点击删除
clickDele(id) { clickDele(id) {
...@@ -123,7 +149,6 @@ export default { ...@@ -123,7 +149,6 @@ export default {
icon:'none' icon:'none'
}) })
this.showModal = false this.showModal = false
this.showPop=false
this.$parent.getContactList() this.$parent.getContactList()
} else { } else {
uni.showToast({ uni.showToast({
......
<template> <template>
<view class="editBox" v-show="showEdit"> <view class="editBox" v-show="showEdit">
<view @click="close()" class="return"> <view @click="close()" class="return">
<u-icon name="close"></u-icon> <u-icon name="close" bold></u-icon>
</view> </view>
<view class="editTop"> <view class="editTop">
</view> </view>
<view class="editBottom"> <view class="editBottom">
<view class="bottomContent"> <view class="bottomContent">
<view> <view>
<text> <text>
姓名: 姓名:
</text> </text>
<input v-model.trim="name" placeholder="请输入中文姓名" /> <input v-model.trim="name" placeholder="请输入中文姓名,必填" />
</view> </view>
<view> <view>
<text> <text>
身份证: 身份证:
</text> </text>
<input v-model.trim="credentialNumber" maxlength="18" placeholder="请输入身份证号码" /> <input v-model.trim="credentialNumber" maxlength="18" placeholder="请输入身份证号码,必填" />
</view>
<view>
<text>
联系电话:
</text>
<input v-model.trim="phone" maxlength="11" placeholder="用于接收行程信息" />
</view> </view>
<view> <view>
<!--编辑--> <a class="complete" @click="keepSave()">完成</a>
<a class="middle-btn" @click="keepEdit()" v-if="editBtn">完成</a>
<!--新增-->
<a class="middle-btn" @click="keepPlus()" v-else="">完成</a>
</view> </view>
</view> </view>
...@@ -37,130 +38,98 @@ ...@@ -37,130 +38,98 @@
</template> </template>
<script> <script>
export default { export default {
props: ["editContact"], props: ['editContact'],
data() { data() {
return { return {
showEdit: false, //控制组件显示隐藏 showEdit: false, //控制组件显示隐藏
name: "", //姓名 name: '', //姓名
credentialNumber: "", //身份证号 credentialNumber: '', //身份证号
reviseContactId: "", //被修改人id phone:'',//手机号码
editBtn: "", //控制编辑完成按钮显示隐藏 reviseContactId: '', //被修改人id
} }
}, },
watch: { watch: {
editContact: { // editContact: {
handler(newValue, oldValue) { handler(newValue, oldValue) {
if (newValue) { console.log(111)
this.editBtn = true this.name = newValue.name||''
} else { this.credentialNumber = newValue.credentialNumber||''
this.editBtn = false this.reviseContactId = newValue.id||''
} this.phone=newValue.phone||''
this.name = newValue.name||'' },
this.credentialNumber = newValue.credentialNumber||'' deep: true,
this.reviseContactId = newValue.id||'' immediate: true
}, }
deep: false, },
immediate: false methods: {
} //---关闭弹窗
}, close() {
methods: { this.showEdit = false
//---关闭弹窗 },
close() { //---保存
this.showEdit = false keepSave() {
}, if (!this.$commonjs.nameReg().test(this.name)) {
//---新增保存 uni.showToast({
keepPlus() { title:'请输入正确的中文名字',
if (!this.$commonjs.nameReg().test(this.name)) { icon:'none'
uni.showToast({ })
title:'请输入正确的中文名字', return
icon:'none' }
}) if (!this.$commonjs.idReg().test(this.credentialNumber)) {
return uni.showToast({
} title:'请输入正确身份证号',
if (!this.$commonjs.idReg().test(this.credentialNumber)) { icon:'none'
uni.showToast({ })
title:'请输入正确身份证号', return
icon:'none' }
}) if (this.phone&&!this.$commonjs.phoneReg().test(this.phone)) {
return uni.showToast({
} title:'请输入正确电话号码',
let data = { icon:'none'
name: this.name, //保存姓名 })
phone: "", //电话号码 return
credentialNumber: this.credentialNumber, //身份证号 }
category: "", //成人或者儿童 let data = {
openid: uni.getStorageSync("openid"), //用户Id name: this.name, //保存姓名
credentialsType: "", //证件类型 phone:this.phone, //电话号码
merchantType: 1, //商户类型,1.景区,2.酒店,3.餐饮 credentialNumber: this.credentialNumber, //身份证号
} openid: uni.getStorageSync('openid'), //用户Id
this.$request("wechatUser/contact/saveContact", data).then((res) => { merchantType: 1, //商户类型,1.景区,2.酒店,3.餐饮
if (res.code == "00") { id: this.reviseContactId, //被修改人id
uni.showToast({ category: '', //成人或者儿童
title:'保存成功', credentialsType: '', //证件类型
icon:'none' }
}) let queryUrl=''
this.$parent.addChoose() if(this.reviseContactId){
this.showEdit = false queryUrl='wechatUser/contact/updateContact'
this.name = "" //成功之后清空数据,防止下次新增的时候出现之前的数据 }else{
this.credentialNumber = "" queryUrl='wechatUser/contact/saveContact'
} else { }
uni.showToast({ this.$request(queryUrl, data).then((res) => {
title:res.message, if (res.code == '00') {
icon:'none' uni.showToast({
}) title:'保存成功',
} icon:'none'
}) })
}, if(!this.reviseContactId){
//---编辑保存 this.$parent.addChoose()
keepEdit() { }
if (!this.$commonjs.nameReg().test(this.name)) { this.showEdit = false
uni.showToast({ } else {
title:'请输入正确的中文名字', uni.showToast({
icon:'none' title:res.message,
}) icon:'none'
return })
} }
if (!this.$commonjs.idReg().test(this.credentialNumber)) { })
uni.showToast({ }
title:'请输入正确身份证号', }
icon:'none' }
})
return
}
let data = {
name: this.name, //保存姓名
phone: "", //电话号码
credentialNumber: this.credentialNumber, //身份证号
category: "", //成人或者儿童
openid: uni.getStorageSync("openid"), //用户Id
credentialsType: "", //证件类型
merchantType: 1, //商户类型,1.景区,2.酒店,3.餐饮
id: this.reviseContactId, //被修改人id
}
this.$request("wechatUser/contact/updateContact", data).then((res) => {
if (res.code == "00") {
uni.showToast({
title:'修改成功',
icon:'none'
})
this.$parent.getContactList()
this.showEdit = false
} else {
uni.showToast({
title:res.message,
icon:'none'
})
}
})
}
}
}
</script> </script>
<style scoped="scoped"> <style scoped="scoped" lang="scss">
.editBox { .editBox {
height: 100%;
background: #F5F5F5; background: #F5F5F5;
position: fixed; position: fixed;
top: 0; top: 0;
...@@ -168,8 +137,6 @@ ...@@ -168,8 +137,6 @@
right: 0; right: 0;
bottom: 0; bottom: 0;
z-index: 10000; z-index: 10000;
overflow-y: auto;
font-size:28rpx;
} }
.return { .return {
height:100rpx; height:100rpx;
...@@ -201,7 +168,7 @@ ...@@ -201,7 +168,7 @@
} }
.bottomContent view text { .bottomContent view text {
display: inline-block; display: inline-block;
width: 120rpx; width: 140rpx;
text-align-last: justify; text-align-last: justify;
margin-right: 20rpx; margin-right: 20rpx;
} }
...@@ -209,10 +176,17 @@ ...@@ -209,10 +176,17 @@
flex: 1; flex: 1;
} }
.bottomContent view:last-child { .bottomContent view:last-child {
display: flex;
justify-content: center;
align-items: center;
margin-top: 60rpx; margin-top: 60rpx;
border: none; border: none;
} }
.complete{
width:100%;
height:70rpx;
border-radius:16rpx;
color: #FFFFFF;
text-align: center;
line-height:70rpx;
background:$theme;
display: inline-block;
}
</style> </style>
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment