applyMember.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. <template>
  2. <view class="common_page adffc" :style="{'height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title="报名信息" bgColor="#FFFFFF"></cus-header>
  4. <view class="add">
  5. <view class="btn adfacjc" @click="handleAdd">
  6. <image src="https://oss.familydaf.cn/sxsnfile/20251218/53f6db8797e14d86ae7f81af03a3d971.png"></image>
  7. <text>添加</text>
  8. </view>
  9. </view>
  10. <template v-if="list.length">
  11. <view class="list">
  12. <up-list @scrolltolower="scrolltolower" style="height: 100%;">
  13. <up-list-item v-for="(item, index) in list" :key="index">
  14. <view class="box adfacjb">
  15. <view class="box-left adfac" @click="handleEdit(item,index)">
  16. <view class="box-left-edit">
  17. <image src="https://oss.familydaf.cn/sxsnfile/20251218/d5230de5913447c0864780312d5812fe.png"></image>
  18. </view>
  19. <view class="box-left-info">
  20. <view class="box-left-info-top adfac">
  21. <view class="name">{{item.name||''}}</view>
  22. <image class="sex" v-if="item.gender==1" src="https://oss.familydaf.cn/sxsnfile/20251218/473d5677fbdb4106acdb9a163377d27f.png"></image>
  23. <image class="sex" v-else-if="item.gender==0" src="https://oss.familydaf.cn/sxsnfile/20251218/02bc40a1c47b40f1a36b55cd0553211c.png"></image>
  24. <view class="age" :class="{'women':item.gender==1,'man':item.gender==0}">{{item.age}}岁</view>
  25. </view>
  26. <view class="box-left-info-bottom">
  27. 身份证 {{item.idCardCopy}}
  28. </view>
  29. </view>
  30. </view>
  31. <view class="box-right" @click="handleSelect(item,index)">
  32. <image v-if="item.select" src="https://oss.familydaf.cn/sxsnfile/20251218/c11b9a1b56f34e1189621f4270f0349a.png"></image>
  33. <image v-else src="https://oss.familydaf.cn/sxsnfile/20251218/2a2f7bdefb474a3e93faa00aef6d0e1f.png"></image>
  34. </view>
  35. </view>
  36. </up-list-item>
  37. </up-list>
  38. </view>
  39. <view class="confirm" @click="confirmSelect">确定,已选择{{selectNum}}人</view>
  40. </template>
  41. <view class="dataEmpty" v-else>
  42. <page-empty text="暂无可选成员,请添加"></page-empty>
  43. </view>
  44. </view>
  45. </template>
  46. <script setup name="">
  47. import CusHeader from '@/components/CusHeader/index.vue'
  48. import PageEmpty from '@/components/pageEmpty/index.vue'
  49. import { ref, onMounted, getCurrentInstance } from 'vue'
  50. import { onShow } from '@dcloudio/uni-app'
  51. const { proxy } = getCurrentInstance()
  52. const queryParams = ref({
  53. page:1,
  54. limit:-1,
  55. userId:''
  56. })
  57. const list = ref([])
  58. const selectNum = ref(0)
  59. const eventChannel = ref(null)
  60. onShow(()=>{
  61. const ec = proxy.getOpenerEventChannel();
  62. if (Object.keys(ec).length) {
  63. eventChannel.value = ec;
  64. }
  65. try{
  66. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo')).id;
  67. queryParams.value.page = 1;
  68. list.value = [];
  69. getMemberList()
  70. }catch(e){
  71. }
  72. })
  73. const getMemberList = () => {
  74. proxy.$api.get('/core/family/member/page',queryParams.value).then(({data:res})=>{
  75. if(res.code!==0) return proxy.$showToast(res.msg)
  76. list.value = [...list.value,...res.data.list]
  77. list.value.forEach(l=>{
  78. l.age = getAge(l.idCard)
  79. l.select = false;
  80. l.idCardCopy = l.idCard.replace(/^(\d{6})(\d{8})(\d{3}[\dX])$/i,'$1********$3')
  81. })
  82. })
  83. }
  84. const isValid = (idCard) => {
  85. // 正则表达式校验18位身份证号码(最后一位可以是数字或X/x)
  86. const regex = /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
  87. return typeof idCard === 'string' && regex.test(idCard);
  88. }
  89. const getAge = (idCard) => {
  90. if (!isValid(idCard)) return 0
  91. // 从身份证的第7位开始,截取8位作为出生日期字符串 (YYYYMMDD)
  92. const birthDateStr = idCard.substring(6, 14);
  93. const birthYear = parseInt(birthDateStr.substring(0, 4), 10);
  94. const birthMonth = parseInt(birthDateStr.substring(4, 6), 10);
  95. const birthDay = parseInt(birthDateStr.substring(6, 8), 10);
  96. const today = new Date();
  97. const currentYear = today.getFullYear();
  98. const currentMonth = today.getMonth() + 1; // getMonth() 返回 0-11
  99. const currentDay = today.getDate();
  100. // 计算周岁
  101. let age = currentYear - birthYear;
  102. // 如果当前月份小于出生月份,或者月份相同但日期小于出生日期,说明今年的生日还没过
  103. if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay)) {
  104. age--;
  105. }
  106. return age < 0 ? 0 : age;
  107. }
  108. const handleAdd = () => {
  109. uni.navigateTo({
  110. url:'/pagesHome/applyMemberVindicate'
  111. })
  112. }
  113. const handleEdit = (item,index) => {
  114. uni.navigateTo({
  115. url:'/pagesHome/applyMemberVindicate?id='+item.id
  116. })
  117. }
  118. const handleSelect = (item,index) => {
  119. list.value[index].select = !list.value[index].select;
  120. selectNum.value = list.value.filter(l=>l.select).length;
  121. }
  122. const confirmSelect = () => {
  123. if(list.value.filter(l=>l.select).length===0) return proxy.$showToast('请至少选择一位人员')
  124. let selectList = list.value.filter(l=>l.select);
  125. if (eventChannel.value) {
  126. eventChannel.value.emit('selectMembers', selectList);
  127. uni.navigateBack();
  128. }else {
  129. uni.navigateBack();
  130. }
  131. }
  132. </script>
  133. <style scoped lang="scss">
  134. .common_page{
  135. padding-bottom: 60rpx;
  136. .add{
  137. margin-top: 20rpx;
  138. background: #FFFFFF;
  139. border-radius: 20rpx 20rpx 0 0;
  140. padding: 30rpx 24rpx 20rpx;
  141. .btn{
  142. width: 100%;
  143. background: rgba(112,207,82,0.08);
  144. border-radius: 24rpx;
  145. border: 1rpx dotted #70CF52;
  146. padding: 21rpx 0;
  147. image{
  148. width: 36rpx;
  149. height: 36rpx;
  150. }
  151. text{
  152. font-family: PingFang-SC, PingFang-SC;
  153. font-weight: bold;
  154. font-size: 28rpx;
  155. color: #70CF52;
  156. line-height: 40rpx;
  157. margin-left: 18rpx;
  158. letter-spacing: 2rpx;
  159. }
  160. }
  161. }
  162. .list{
  163. flex: 1;
  164. overflow: auto;
  165. background: #FFFFFF;
  166. border-radius: 0 0 20rpx 20rpx;
  167. padding: 0 24rpx;
  168. .box{
  169. padding: 37rpx 0;
  170. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #F2F2F2;
  171. &-left{
  172. width: calc(100% - 76rpx);
  173. &-edit{
  174. width: 36rpx;
  175. height: 36rpx;
  176. image{
  177. width: 100%;
  178. height: 100%;
  179. }
  180. }
  181. &-info{
  182. width: calc(100% - 36rpx);
  183. padding-left: 20rpx;
  184. box-sizing: border-box;
  185. &-top{
  186. .name{
  187. font-family: PingFang-SC, PingFang-SC;
  188. font-weight: bold;
  189. font-size: 32rpx;
  190. color: #151B29;
  191. line-height: 32rpx;
  192. }
  193. .sex{
  194. width: 44rpx;
  195. height: 32rpx;
  196. margin-left: 16rpx;
  197. }
  198. .age{
  199. border-radius: 13rpx;
  200. font-family: PingFangSC, PingFang SC;
  201. font-weight: 400;
  202. font-size: 20rpx;
  203. line-height: 24rpx;
  204. padding: 4rpx 10rpx;
  205. margin-left: 13rpx;
  206. &.women{
  207. background: rgba(244,101,122,0.14);
  208. color: #F4657A;
  209. }
  210. &.man{
  211. background: rgba(5,169,254,0.12);
  212. color: #05A9FE;
  213. }
  214. }
  215. }
  216. &-bottom{
  217. font-family: PingFangSC, PingFang SC;
  218. font-weight: 400;
  219. font-size: 24rpx;
  220. color: #989998;
  221. line-height: 24rpx;
  222. margin-top: 23rpx;
  223. }
  224. }
  225. }
  226. &-right{
  227. width: 36rpx;
  228. height: 36rpx;
  229. image{
  230. width: 100%;
  231. height: 100%;
  232. }
  233. }
  234. }
  235. }
  236. .confirm{
  237. padding: 0 40rpx;
  238. margin: 40rpx 0 64rpx;
  239. display: inline-block;
  240. height: 90rpx;
  241. background: #B7F358;
  242. border-radius: 45rpx;
  243. font-family: PingFang-SC, PingFang-SC;
  244. font-weight: bold;
  245. font-size: 32rpx;
  246. color: #151B29;
  247. line-height: 90rpx;
  248. text-align: center;
  249. letter-spacing: 2rpx;
  250. }
  251. .empty{
  252. margin-top: 300rpx;
  253. text-align: center;
  254. font-size: 32rpx;
  255. color: #666666;
  256. }
  257. }
  258. </style>