applyMember.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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://transcend.ringzle.com/xiaozhi-app/profile/2025/10/09/af9133fd-e15e-454d-9152-e4629fd0ce28.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://transcend.ringzle.com/xiaozhi-app/profile/2025/10/09/7799f9f2-1dca-4af3-980b-7f6def10e22f.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://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/b6d1fcb3-55ba-4104-b8cd-756b963a4da8.png"></image>
  23. <image class="sex" v-else-if="item.gender==0" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/a1899fd0-c468-48d9-b554-2f17b75a4157.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://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/87b5b244-d14f-43cd-991b-4ac9f48d909e.png"></image>
  33. <image v-else src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/12/b8a5cabd-57f8-4ad7-9677-f6372423c50a.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. const { proxy } = getCurrentInstance()
  51. const queryParams = ref({
  52. page:1,
  53. limit:-1,
  54. userId:''
  55. })
  56. const list = ref([])
  57. const selectNum = ref(0)
  58. const getMemberList = () => {
  59. proxy.$api.get('/core/family/member/page',queryParams.value).then(({data:res})=>{
  60. if(res.code!==0) return proxy.$showToast(res.msg)
  61. list.value = [...list.value,...res.data.list]
  62. list.value.forEach(l=>{
  63. l.age = getAge(l.idCard)
  64. l.select = false;
  65. l.idCardCopy = l.idCard.replace(/^(\d{6})(\d{8})(\d{3}[\dX])$/i,'$1********$3')
  66. })
  67. })
  68. }
  69. const isValid = (idCard) => {
  70. // 正则表达式校验18位身份证号码(最后一位可以是数字或X/x)
  71. 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]$/;
  72. return typeof idCard === 'string' && regex.test(idCard);
  73. }
  74. const getAge = (idCard) => {
  75. if (!isValid(idCard)) return 0
  76. // 从身份证的第7位开始,截取8位作为出生日期字符串 (YYYYMMDD)
  77. const birthDateStr = idCard.substring(6, 14);
  78. const birthYear = parseInt(birthDateStr.substring(0, 4), 10);
  79. const birthMonth = parseInt(birthDateStr.substring(4, 6), 10);
  80. const birthDay = parseInt(birthDateStr.substring(6, 8), 10);
  81. const today = new Date();
  82. const currentYear = today.getFullYear();
  83. const currentMonth = today.getMonth() + 1; // getMonth() 返回 0-11
  84. const currentDay = today.getDate();
  85. // 计算周岁
  86. let age = currentYear - birthYear;
  87. // 如果当前月份小于出生月份,或者月份相同但日期小于出生日期,说明今年的生日还没过
  88. if (currentMonth < birthMonth || (currentMonth === birthMonth && currentDay < birthDay)) {
  89. age--;
  90. }
  91. return age < 0 ? 0 : age;
  92. }
  93. const handleAdd = () => {
  94. uni.navigateTo({
  95. url:'/pagesHome/applyMemberVindicate'
  96. })
  97. }
  98. const handleEdit = (item,index) => {
  99. uni.navigateTo({
  100. url:'/pagesHome/applyMemberVindicate?id='+item.id
  101. })
  102. }
  103. const handleSelect = (item,index) => {
  104. list.value[index].select = !list.value[index].select;
  105. selectNum.value = list.value.filter(l=>l.select).length;
  106. }
  107. const confirmSelect = () => {
  108. if(list.value.filter(l=>l.select).length===0) return proxy.$showToast('请至少选择一位人员')
  109. let selectList = list.value.filter(l=>l.select);
  110. proxy.getOpenerEventChannel().emit('selectMembers',selectList);
  111. uni.navigateBack();
  112. }
  113. onMounted(()=>{
  114. try{
  115. queryParams.value.userId = JSON.parse(uni.getStorageSync('userInfo')).id;
  116. getMemberList()
  117. }catch(e){
  118. }
  119. })
  120. </script>
  121. <style scoped lang="scss">
  122. .common_page{
  123. padding-bottom: 60rpx;
  124. .add{
  125. margin-top: 20rpx;
  126. background: #FFFFFF;
  127. border-radius: 20rpx 20rpx 0 0;
  128. padding: 30rpx 24rpx 20rpx;
  129. .btn{
  130. width: 100%;
  131. background: rgba(112,207,82,0.08);
  132. border-radius: 24rpx;
  133. border: 1rpx dotted #70CF52;
  134. padding: 21rpx 0;
  135. image{
  136. width: 36rpx;
  137. height: 36rpx;
  138. }
  139. text{
  140. font-family: PingFang-SC, PingFang-SC;
  141. font-weight: bold;
  142. font-size: 28rpx;
  143. color: #70CF52;
  144. line-height: 40rpx;
  145. margin-left: 18rpx;
  146. letter-spacing: 2rpx;
  147. }
  148. }
  149. }
  150. .list{
  151. flex: 1;
  152. overflow: auto;
  153. background: #FFFFFF;
  154. border-radius: 0 0 20rpx 20rpx;
  155. padding: 0 24rpx;
  156. .box{
  157. padding: 37rpx 0;
  158. box-shadow: inset 0rpx -1rpx 0rpx 0rpx #F2F2F2;
  159. &-left{
  160. width: calc(100% - 76rpx);
  161. &-edit{
  162. width: 36rpx;
  163. height: 36rpx;
  164. image{
  165. width: 100%;
  166. height: 100%;
  167. }
  168. }
  169. &-info{
  170. width: calc(100% - 36rpx);
  171. padding-left: 20rpx;
  172. box-sizing: border-box;
  173. &-top{
  174. .name{
  175. font-family: PingFang-SC, PingFang-SC;
  176. font-weight: bold;
  177. font-size: 32rpx;
  178. color: #151B29;
  179. line-height: 32rpx;
  180. }
  181. .sex{
  182. width: 44rpx;
  183. height: 32rpx;
  184. margin-left: 16rpx;
  185. }
  186. .age{
  187. border-radius: 13rpx;
  188. font-family: PingFangSC, PingFang SC;
  189. font-weight: 400;
  190. font-size: 20rpx;
  191. line-height: 24rpx;
  192. padding: 4rpx 10rpx;
  193. margin-left: 13rpx;
  194. &.women{
  195. background: rgba(244,101,122,0.14);
  196. color: #F4657A;
  197. }
  198. &.man{
  199. background: rgba(5,169,254,0.12);
  200. color: #05A9FE;
  201. }
  202. }
  203. }
  204. &-bottom{
  205. font-family: PingFangSC, PingFang SC;
  206. font-weight: 400;
  207. font-size: 24rpx;
  208. color: #989998;
  209. line-height: 24rpx;
  210. margin-top: 23rpx;
  211. }
  212. }
  213. }
  214. &-right{
  215. width: 36rpx;
  216. height: 36rpx;
  217. image{
  218. width: 100%;
  219. height: 100%;
  220. }
  221. }
  222. }
  223. }
  224. .confirm{
  225. padding: 0 40rpx;
  226. margin: 40rpx 0 64rpx;
  227. display: inline-block;
  228. height: 90rpx;
  229. background: #B7F358;
  230. border-radius: 45rpx;
  231. font-family: PingFang-SC, PingFang-SC;
  232. font-weight: bold;
  233. font-size: 32rpx;
  234. color: #151B29;
  235. line-height: 90rpx;
  236. text-align: center;
  237. letter-spacing: 2rpx;
  238. }
  239. .empty{
  240. margin-top: 300rpx;
  241. text-align: center;
  242. font-size: 32rpx;
  243. color: #666666;
  244. }
  245. }
  246. </style>