SelectContact.vue
5.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<template>
<div id="selectContact">
<div class="box">
<template v-for="(item,index) in contactList">
<div class="contact_item" v-if="!hideParent&&item.userType!=1||item.userType==1" :key="index">
<van-icon class="edit" name="edit" @click="editContact(index)" />
<div class="info">
<p class="name">{{item.travelerName}}<span v-if="!item.travelerIdCard||!item.gender">需完善</span></p>
<p class="des">{{item.userType==1?'学生':'家长'}}·{{item.travelerMobile}}</p>
</div>
<van-checkbox v-if="item.userType==1" class="checkbox" v-model="item.checked" shape="square"></van-checkbox>
<van-checkbox v-else class="checkbox" v-model="item.checked" @change="checkboxChange" shape="square"></van-checkbox>
</div>
</template>
<div class="add_btn" @click="showAddChildPopupGroup=true">
<van-icon name="add-o" />
新增出行学生
</div>
</div>
<van-button class="btn" type="primary" @click="selectContact">确定</van-button>
<van-popup style="background: transparent;" get-container="body" v-model="showAddChildPopupGroup">
<AddChildPopupGroup @complete="complete"></AddChildPopupGroup>
</van-popup>
</div>
</template>
<script>
import AddChildPopupGroup from '@/views/PublicHome/component/AddChildPopupGroup'
import { Dialog } from 'vant';
export default {
data () {
return {
limit: '',
hideParent: false,
contactList: [],
showAddChildPopupGroup: false
}
},
mounted () {
this.limit = this.$route.query.limit;
this.hideParent = this.$route.query.hideParent ? true : false;
console.log(this.hideParent)
this.getContactList()
},
methods: {
// 获取联系人列表
getContactList () {
this.$toast.loading({
message: '加载中...',
duration: 0,
forbidClick: true
})
const userInfo = JSON.parse(sessionStorage.getItem('userInfo'))
this.yxAxios.get(`${this.proxyUrl}/prod/user/info/getPortalUserByNum?userNum=${userInfo.centerNo}`).then((res) => {
this.$toast.clear()
if (res.data.code == 200) {
let userInfo = res.data.data.userInfo;
let contactList = userInfo.subUsers
contactList.unshift({
travelerMobile: userInfo?.phone,
travelerNum: userInfo?.centerNo,
travelerIdCard: userInfo?.idCard,
userType: 2,
travelerName: userInfo?.nickName,
gender: userInfo?.gender,
})
this.contactList = contactList
}
})
},
// 修改联系人
editContact (index) {
let contactItem = this.contactList[index]
let editContact = {
travelerMobile: contactItem.travelerMobile,
userType: contactItem.userType,
travelerIdCard: contactItem.travelerIdCard,
travelerNum: contactItem.travelerNum,
travelerName: contactItem.travelerName
}
sessionStorage.setItem('editContact', JSON.stringify(editContact))
this.$router.push({ name: 'EditContact' })
},
complete () {
this.showAddChildPopupGroup = false;
this.getContactList()
},
// 选择联系人完成
selectContact () {
let contactList = this.contactList;
let selectedArr = [];
for (let i in contactList) {
if (contactList[i]?.checked) {
if ((!contactList[i].travelerIdCard||!contactList[i].gender) && !this.hideParent) {
this.$toast('请先完善您选择的联系人信息')
return;
} else {
selectedArr.push({
travelerName: contactList[i].travelerName,
travelerMobile: contactList[i].travelerMobile,
travelerNum: contactList[i].travelerNum
})
}
}
}
console.log(this.limit, selectedArr.length)
if (this.limit && this.limit != selectedArr.length) {
this.$toast(`请选择${this.limit}位联系人`)
return;
}
// console.log(selectedArr)
sessionStorage.setItem('selectedContactArr', JSON.stringify(selectedArr))
this.$router.back()
},
checkboxChange (e) {
if (e == true) {
Dialog.alert({
title: '温馨提示',
message: '活动参与主体为学生本人,请选择出行学生!未绑定学生,请新增出行学生进行添加。',
confirmButtonColor:'#3385FF'
})
}
}
},
components: {
AddChildPopupGroup
}
}
</script>
<style lang="scss" scoped>
#selectContact {
min-height: 100vh;
box-sizing: border-box;
padding: 16px 0;
background: #f6f7fa;
.box {
width: 702px;
margin: 0 auto;
padding: 0 24px;
padding-bottom: 200px;
box-sizing: border-box;
background: #fff;
border-radius: 16px;
.add_btn {
line-height: 104px;
font-size: 28px;
color: #4092ff;
text-align: center;
}
.contact_item {
display: flex;
align-items: center;
justify-content: space-between;
.edit {
padding: 20px 20px 20px 0;
font-size: 40px;
color: #4092ff;
}
.info {
width: 500px;
padding: 28px 0;
.name {
display: flex;
align-items: center;
font-size: 30px;
span {
display: inline-block;
padding: 2px 8px;
margin-left: 16px;
font-size: 20px;
color: #fe3b3b;
background: #ffeeee;
border-radius: 4px;
}
}
.des {
font-size: 26px;
color: #999;
}
}
.checkbox {
padding: 20px 0 20px 20px;
}
}
}
.btn {
position: fixed;
bottom: 100px;
left: 24px;
width: 702px;
height: 90px;
background: #4092ff;
border: 1px solid #4092ff;
box-shadow: 0px 10px 40px 0px #a0c9ff;
border-radius: 45px;
}
}
</style>