selectJz.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <uni-popup ref="popupRef" type="bottom" background-color="#fff" :is-mask-click="false" :mask-click="false">
  3. <view class="jz-select-list">
  4. <view class="phone-navBar-box">
  5. <view @click="goback2" class="nav-bar-icon"></view>
  6. <text class="nav-bar-title">选择家政阿姨</text>
  7. <uni-icons class="nav-bar-right-icon bar-ml10" type="search" size="20"
  8. @click="toggle('top')"></uni-icons>
  9. </view>
  10. <view>
  11. <search-dialog ref="searchDialogRef" shenfen="jz" @search-btn="dialogSearchBtn"
  12. @reset-search="dialogSearchReset"></search-dialog>
  13. </view>
  14. <!-- 无限滚动容器 -->
  15. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  16. :refresher-threshold="50" @scrolltolower="onScrolltolower" refresher-background="transparent"
  17. @refresherrefresh="onRefresh" class="jz-scroll-view">
  18. <uni-list class="jz-scroll-view">
  19. <radio-group @change="radioChange">
  20. <uni-list-item v-for="item in data.list" class="jz-list-item-box">
  21. <template v-slot:body>
  22. <view class="jz-select-card">
  23. <radio :value="item.id && item.id.toString()" activeBackgroundColor="#3fd2a1"
  24. :checked="item.id == data.activeData" />
  25. <view class="card-body-row">
  26. <view class="card-img-box">
  27. <img :src="item.icon" v-if="item.icon">
  28. <icon class="phone-default-userImg" v-else></icon>
  29. </view>
  30. <view class="body-content-row">
  31. <view class="head-name">{{item.realName}}</view>
  32. <view class="content-text-row">
  33. <view> {{item.age}}岁<text v-if="item.jingyan"> | {{item.jingyan}}经验</text>
  34. </view>
  35. <view class="text-status">{{item.zhuangtai}}</view>
  36. </view>
  37. <view class="content-text-row">
  38. {{item.jiguanShengName === item.jiguanShiName ? item.jiguanShengName : `${item.jiguanShengName} ${item.jiguanShiName}`}}人
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </template>
  44. </uni-list-item>
  45. </radio-group>
  46. <uni-load-more :status="data.state" @click="getMore(0)"
  47. :contentText="data.contentText"></uni-load-more>
  48. </uni-list>
  49. </scroll-view>
  50. <view class="select-jz-btn-box">
  51. <button @click="handleSelect" type="default" class="phone-green-btn">选择此家政阿姨</button>
  52. </view>
  53. </view>
  54. </uni-popup>
  55. </template>
  56. <script setup>
  57. import {
  58. ref,
  59. reactive,
  60. nextTick
  61. } from "vue";
  62. import {
  63. onLoad
  64. } from "@dcloudio/uni-app";
  65. import * as httpApi from "@/api/sanfang.js"
  66. import {
  67. getJiazhengList
  68. } from "@/api/jiazheng.js"
  69. import searchDialog from "./search.vue";
  70. const emits = defineEmits(['select'])
  71. function goback2() {
  72. popupRef.value.close();
  73. }
  74. const searchDialogRef = ref(null);
  75. const popupRef = ref(null)
  76. const data = reactive({
  77. status: 0,
  78. statusText: '待签字',
  79. state: 'more',
  80. list: [], // 考试列表
  81. loading: false,
  82. realName: '',
  83. page: 0,
  84. size: 10,
  85. activeData: null
  86. })
  87. function toggle() {
  88. searchDialogRef.value.handleShow();
  89. }
  90. function dialogSearchBtn(opt, searchInput) {
  91. data.realName = searchInput
  92. onRefresh()
  93. }
  94. function dialogSearchReset() {
  95. data.realName = '';
  96. }
  97. function onScrolltolower() {
  98. getMore()
  99. }
  100. function onRefresh() {
  101. if (data.loading) return;
  102. data.page = 0;
  103. data.list = [];
  104. data.loading = true;
  105. refreshData();
  106. }
  107. function refreshData() {
  108. const opt = {
  109. realName: data.realName,
  110. page: data.page,
  111. size: data.size,
  112. status: data.status
  113. }
  114. data.list = [];
  115. // 数学
  116. data.state = 'loading';
  117. data.page++;
  118. opt.page = data.page;
  119. getJiazhengList(opt).then(res => {
  120. data.list = data.list.concat(res.data.data);
  121. data.loading = false;
  122. if (res.data.total > data.list.length) {
  123. data.state = 'more';
  124. } else {
  125. data.state = 'no-more';
  126. }
  127. }).catch(err => {
  128. data.state = 'more';
  129. }).finally(() => {
  130. data.loading = false;
  131. })
  132. }
  133. function getMore() {
  134. const opt = {
  135. realName: data.realName,
  136. page: data.page,
  137. size: data.size,
  138. status: data.status
  139. }
  140. if (data.state == 'no-more') return;
  141. data.state = 'loading';
  142. data.page++;
  143. opt.page = data.page;
  144. getJiazhengList(opt).then(res => {
  145. data.list = data.list.concat(res.data.data);
  146. data.loading = false;
  147. if (res.data.total > data.list.length) {
  148. data.state = 'more';
  149. } else {
  150. data.state = 'no-more';
  151. }
  152. }).catch(err => {
  153. data.state = 'more';
  154. }).finally(() => {
  155. data.loading = false;
  156. })
  157. }
  158. function radioChange(opt) {
  159. data.activeData = data.list.find(item => item.id == opt.detail.value)
  160. }
  161. function handleSelect() {
  162. emits('select', data.activeData)
  163. popupRef.value.close();
  164. }
  165. function handleShow() {
  166. data.realName = '';
  167. popupRef.value.open();
  168. onRefresh();
  169. }
  170. defineExpose({
  171. handleShow
  172. })
  173. </script>
  174. <style>
  175. </style>