index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <template>
  2. <view class="admin-jiazheng-list">
  3. <view class="phone-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">家政人员</text>
  6. <view class="nav-bar-icon-box">
  7. <uni-icons class="nav-bar-right-icon" type="plusempty" size="22" color="#666"
  8. @click="addJiazhengRenyuan"></uni-icons>
  9. <uni-icons class="nav-bar-right-icon" type="search" size="22" color="#666"
  10. @click="toggle('top')"></uni-icons>
  11. </view>
  12. </view>
  13. <view class="jiazheng-search-box">
  14. <view @click.stop="clickAlltype" class="select-item-box">
  15. <text>{{data.leixing}}</text>
  16. <icon :class="allJtClass" />
  17. </view>
  18. <view class="jiazheng-search-right">
  19. <!-- 当前点击 增加 saixuan-active-->
  20. <view @click="updateTimeClick" :class="shaixuanStyleUpdate">
  21. <text>更新时间</text>
  22. <icon :class="updataJtClass" />
  23. </view>
  24. <view @click="luruTimeClick" :class="shaixuanStyleluru">
  25. <!-- class切换 saixuan-jt-default saixuan-jt-click-->
  26. <text>录入时间</text>
  27. <icon :class="luruJtClass" />
  28. </view>
  29. <view @click="juliClick" :class="shaixuanStylejuli">
  30. <!-- class切换 saixuan-jt-default saixuan-jt-click-->
  31. <text :class="data.weizhiFlag?'':'saixuan-disabled'">距离排序</text>
  32. <icon :class="juliJtClass" />
  33. </view>
  34. </view>
  35. </view>
  36. <view class="all-type-box" v-show="isOpen" @click="clickAlltype">
  37. <dataChecked :list="allType" mode="single" :defaultCount="99" :showAdd="false"
  38. @change="selectChangeSkill" />
  39. </view>
  40. <view>
  41. <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="data.loading"
  42. :refresher-threshold="50" refresher-background="transparent" @refresherrefresh="onRefresh"
  43. class="jz-scroll-view">
  44. <uni-list class="admin-list-box">
  45. <uni-list-item v-for="item in data.list" class="jz-list-item-box">
  46. <template v-slot:body>
  47. <view class="card-head-row">
  48. <view class="head-name">{{item.realName}}</view>
  49. <button type="default" class="phone-green-btn bz-tel-btn"
  50. @click.stop="telephone(item)">打电话</button>
  51. <share :id="item.id" ref="shareRef">分享</share>
  52. </view>
  53. <view @click="lookUserInfo(item)" class="card-body-row">
  54. <view class="card-img-box">
  55. <img :src="item.icon" v-if="item.icon">
  56. <icon class="phone-default-userImg" v-else></icon>
  57. </view>
  58. <view class="body-content-row">
  59. <view class="content-text-row">
  60. <view> {{item.age}}岁<text v-if="item.jingyan"> | {{item.jingyan}}经验</text>
  61. </view>
  62. <view class="text-status">{{item.zhuangtai}}</view>
  63. </view>
  64. <view class="content-text-row">
  65. {{item.jiguanShengName === item.jiguanShiName ? item.jiguanShengName : `${item.jiguanShengName} ${item.jiguanShiName}`}}人
  66. </view>
  67. <view class="content-lx-box">
  68. <view class="content-lx-item" v-for="item2 in item.leixing" :key="item2">
  69. {{item2}}</view>
  70. </view>
  71. <!-- <view class="content-text-row">{{item.jiguan}}</view> -->
  72. </view>
  73. </view>
  74. </template>
  75. </uni-list-item>
  76. <uni-load-more :status="data.state" @click="getMore(0)"
  77. :contentText="data.contentText"></uni-load-more>
  78. </uni-list>
  79. </scroll-view>
  80. </view>
  81. <view>
  82. <search-dialog ref="searchDialogRef" @search-btn="dialogSearchBtn"
  83. @reset-search="dialogSearchReset"></search-dialog>
  84. </view>
  85. <customTabbarAdminVue :current-tab="1"></customTabbarAdminVue>
  86. </view>
  87. </template>
  88. <script setup>
  89. import {
  90. ref,
  91. reactive
  92. } from "vue";
  93. import {
  94. onLoad
  95. } from "@dcloudio/uni-app";
  96. import {
  97. getJiazhengList,
  98. getJiazhengLeixing
  99. } from "@/api/jiazheng.js"
  100. import dataChecked from './common/dataChecked.vue';
  101. import searchDialog from "./common/search.vue";
  102. import share from "./common/share.vue";
  103. import customTabbarAdminVue from "@/components/custom-tabbar/custom-tabbar-admin.vue";
  104. const searchDialogRef = ref(null);
  105. const shareRef = ref(null);
  106. let allType = ref([])
  107. let data = reactive({
  108. leixing: '全部类型',
  109. page: 0,
  110. size: 10,
  111. realName: '',
  112. sortRule: '', //排序规则(1降序,2升序
  113. sortRule: '', //排序类型(1更新时间,2录入时间)
  114. userName: '',
  115. weidu: '',
  116. jingdu: '',
  117. weizhiFlag: false,
  118. id: '',
  119. list: [], // 考试列表
  120. loading: false,
  121. state: 'more',
  122. contentText: {
  123. contentdown: '查看更多',
  124. contentrefresh: '加载中',
  125. contentnomore: '没有更多'
  126. }
  127. })
  128. let isOpen = ref(false)
  129. let defauleImg = ref('@/static/images/my/user-default-img.png')
  130. const allJtClass = 'select-jt-default';
  131. let updataJtClass = ref('');
  132. let luruJtClass = ref('');
  133. let juliJtClass = ref('');
  134. let shaixuanStyleUpdate = ref('saixuan-item-box');
  135. let shaixuanStyleluru = ref('saixuan-item-box');
  136. let shaixuanStylejuli = ref('saixuan-item-box');
  137. const isOpenSelect = ref(false);
  138. const selectedOption = ref('');
  139. let isFirstClickUpdate = ref('true')
  140. let isFirstClickluru = ref('true')
  141. let isFirstClickjuli = ref('true')
  142. function updateTimeClick() {
  143. data.sortType = 1
  144. const isFirst = isFirstClickUpdate.value == 'true';
  145. const isSecond = isFirstClickUpdate.value == 'false';
  146. if (isFirst) {
  147. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  148. updataJtClass.value = 'saixuan-jt-default';
  149. isFirstClickUpdate.value = 'false';
  150. data.sortRule = 1
  151. } else if (isSecond) {
  152. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  153. updataJtClass.value = 'saixuan-jt-click';
  154. isFirstClickUpdate.value = 'empty';
  155. data.sortRule = 2
  156. } else {
  157. shaixuanStyleUpdate.value = 'saixuan-item-box';
  158. updataJtClass.value = '';
  159. isFirstClickUpdate.value = 'true';
  160. data.sortRule = 0
  161. }
  162. data.page = 0;
  163. refreshData()
  164. }
  165. function luruTimeClick() {
  166. data.sortType = 2
  167. const isFirst = isFirstClickluru.value == 'true';
  168. const isSecond = isFirstClickluru.value == 'false';
  169. if (isFirst) {
  170. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  171. luruJtClass.value = 'saixuan-jt-default';
  172. isFirstClickluru.value = 'false';
  173. data.sortRule = 1
  174. } else if (isSecond) {
  175. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  176. luruJtClass.value = 'saixuan-jt-click';
  177. isFirstClickluru.value = 'empty';
  178. data.sortRule = 2
  179. } else {
  180. shaixuanStyleluru.value = 'saixuan-item-box';
  181. luruJtClass.value = '';
  182. isFirstClickluru.value = 'true';
  183. data.sortRule = 0
  184. }
  185. data.page = 0;
  186. refreshData()
  187. }
  188. function juliClick() {
  189. if(!data.weizhiFlag){
  190. uni.showToast({
  191. title: `当前位置经纬度获取失败,请重新进入该页面!`,
  192. icon: 'none',
  193. duration: 2000
  194. })
  195. return false
  196. }
  197. data.sortType = 3
  198. const isFirst = isFirstClickjuli.value == 'true';
  199. const isSecond = isFirstClickjuli.value == 'false';
  200. if (isFirst) {
  201. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  202. juliJtClass.value = 'saixuan-jt-default';
  203. isFirstClickjuli.value = 'false';
  204. data.sortRule = 1
  205. } else if (isSecond) {
  206. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  207. juliJtClass.value = 'saixuan-jt-click';
  208. isFirstClickjuli.value = 'empty';
  209. data.sortRule = 2
  210. } else {
  211. shaixuanStylejuli.value = 'saixuan-item-box';
  212. juliJtClass.value = '';
  213. isFirstClickjuli.value = 'true';
  214. data.sortRule = 0
  215. }
  216. data.page = 0;
  217. refreshData()
  218. }
  219. function dialogSearchBtn(name, searchData) {
  220. switch (name) {
  221. case '姓名':
  222. dialogSearchReset();
  223. data.realName = searchData.value;
  224. break;
  225. case '手机号':
  226. data.userName = searchData.value;
  227. break;
  228. }
  229. data.page = 0;
  230. refreshData();
  231. }
  232. function dialogSearchReset() {
  233. data.userName = '';
  234. data.realName = '';
  235. }
  236. const clickAlltype = (data) => {
  237. isOpen.value = !isOpen.value;
  238. }
  239. const toggle = (data, index) => {
  240. searchDialogRef.value.handleShow();
  241. }
  242. const addJiazhengRenyuan = () => {
  243. let pageInfo = {
  244. status: 'add'
  245. }
  246. uni.redirectTo({
  247. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  248. })
  249. }
  250. const lookUserInfo = (data) => {
  251. let pageInfo = {
  252. status: 'edit',
  253. id: data.id,
  254. userId: data.userId
  255. }
  256. uni.redirectTo({
  257. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  258. })
  259. }
  260. function goUpPage() {
  261. uni.redirectTo({
  262. url: `/pages/admin/ShouYe/shouye`
  263. })
  264. }
  265. function onRefresh() {
  266. data.page = 0;
  267. data.list = [];
  268. data.loading = true;
  269. refreshData();
  270. }
  271. function telephone(data) {
  272. console.log('data', data);
  273. if (data.userName) {
  274. uni.makePhoneCall({
  275. phoneNumber: data.userName
  276. });
  277. } else {
  278. uni.showToast({
  279. title: `无电话号`,
  280. icon: 'none',
  281. duration: 2000
  282. })
  283. return false
  284. }
  285. }
  286. function selectChangeSkill(item) {
  287. if(item.length>0){
  288. data.leixing = item[0].name
  289. console.log('selectChangeSkill', item);
  290. data.page = 0;
  291. refreshData()
  292. }
  293. }
  294. function refreshData() {
  295. const opt = {
  296. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  297. "page": 1,
  298. "realName": data.realName,
  299. "size": 10,
  300. "sortRule": data.sortRule,
  301. "sortType": data.sortType,
  302. "userName": data.userName,
  303. "jingdu": data.jingdu,
  304. "weidu": data.weidu
  305. }
  306. data.list = [];
  307. // 数学
  308. data.state = 'loading';
  309. data.page++;
  310. opt.page = data.page;
  311. getJiazhengList(opt).then(res => {
  312. data.list = data.list.concat(res.data.data);
  313. data.list = data.list.map(item => {
  314. const newItem = {
  315. ...item
  316. };
  317. newItem.leixing = item.leixing.split(',');
  318. return newItem;
  319. })
  320. data.loading = false;
  321. if (res.data.total > data.list.length) {
  322. data.state = 'more';
  323. data.loading = false;
  324. } else {
  325. data.state = 'no-more';
  326. data.loading = false;
  327. }
  328. }).catch(err => {
  329. data.state = 'more';
  330. data.loading = false;
  331. })
  332. }
  333. function getMore() {
  334. const opt = {
  335. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  336. "page": 1,
  337. "realName": data.realName,
  338. "size": 10,
  339. "sortRule": data.sortRule,
  340. "sortType": data.sortType,
  341. "userName": data.userName,
  342. "jingdu": data.jingdu,
  343. "weidu": data.weidu
  344. }
  345. if (data.state == 'no-more') return;
  346. data.state = 'loading';
  347. data.page++;
  348. opt.page = data.page;
  349. getJiazhengList(opt).then(res => {
  350. data.list = data.list.concat(res.data.data);
  351. data.list = data.list.map(item => {
  352. const newItem = {
  353. ...item
  354. };
  355. newItem.leixing = item.leixing.split(',');
  356. return newItem;
  357. })
  358. console.log('data.list', data.list);
  359. data.loading = false;
  360. if (res.data.total > data.list.length) {
  361. data.state = 'more';
  362. data.loading = false;
  363. } else {
  364. data.state = 'no-more';
  365. data.loading = false;
  366. }
  367. }).catch(err => {
  368. data.state = 'more';
  369. data.loading = false;
  370. })
  371. }
  372. function getLeixing() {
  373. let req = {}
  374. getJiazhengLeixing(req).then(res => {
  375. res.data.unshift("全部类型");
  376. allType = dataConversionObject(res.data)
  377. console.log('allType', allType);
  378. })
  379. }
  380. function dataConversionObject(data) {
  381. let newList
  382. newList = data.map((name, index) => ({
  383. id: index,
  384. name: name
  385. }));
  386. return newList
  387. }
  388. function getCurrentWeizhi() {
  389. console.log('1231231');
  390. uni.getLocation({
  391. type: 'wgs84',
  392. success: function(res) {
  393. console.log('res', res)
  394. data.jingdu = res.longitude
  395. data.weidu = res.latitude
  396. data.weizhiFlag = true
  397. console.log('当前位置的经度:' + res.longitude);
  398. console.log('当前位置的纬度:' + res.latitude);
  399. }
  400. });
  401. }
  402. onLoad(() => {
  403. getMore()
  404. getLeixing()
  405. getCurrentWeizhi()
  406. })
  407. </script>