index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  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="18" color="#666"
  8. @click="addJiazhengRenyuan"></uni-icons>
  9. <uni-icons class="nav-bar-right-icon" type="search" size="18" 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. data.leixing = item[0].name
  288. console.log('selectChangeSkill', item);
  289. data.page = 0;
  290. refreshData()
  291. }
  292. function refreshData() {
  293. const opt = {
  294. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  295. "page": 1,
  296. "realName": data.realName,
  297. "size": 10,
  298. "sortRule": data.sortRule,
  299. "sortType": data.sortType,
  300. "userName": data.userName,
  301. "jingdu": data.jingdu,
  302. "weidu": data.weidu
  303. }
  304. data.list = [];
  305. // 数学
  306. data.state = 'loading';
  307. data.page++;
  308. opt.page = data.page;
  309. getJiazhengList(opt).then(res => {
  310. data.list = data.list.concat(res.data.data);
  311. data.list = data.list.map(item => {
  312. const newItem = {
  313. ...item
  314. };
  315. newItem.leixing = item.leixing.split(',');
  316. return newItem;
  317. })
  318. data.loading = false;
  319. if (res.data.total > data.list.length) {
  320. data.state = 'more';
  321. data.loading = false;
  322. } else {
  323. data.state = 'no-more';
  324. data.loading = false;
  325. }
  326. }).catch(err => {
  327. data.state = 'more';
  328. data.loading = false;
  329. })
  330. }
  331. function getMore() {
  332. const opt = {
  333. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  334. "page": 1,
  335. "realName": data.realName,
  336. "size": 10,
  337. "sortRule": data.sortRule,
  338. "sortType": data.sortType,
  339. "userName": data.userName,
  340. "jingdu": data.jingdu,
  341. "weidu": data.weidu
  342. }
  343. if (data.state == 'no-more') return;
  344. data.state = 'loading';
  345. data.page++;
  346. opt.page = data.page;
  347. getJiazhengList(opt).then(res => {
  348. data.list = data.list.concat(res.data.data);
  349. data.list = data.list.map(item => {
  350. const newItem = {
  351. ...item
  352. };
  353. newItem.leixing = item.leixing.split(',');
  354. return newItem;
  355. })
  356. console.log('data.list', data.list);
  357. data.loading = false;
  358. if (res.data.total > data.list.length) {
  359. data.state = 'more';
  360. data.loading = false;
  361. } else {
  362. data.state = 'no-more';
  363. data.loading = false;
  364. }
  365. }).catch(err => {
  366. data.state = 'more';
  367. data.loading = false;
  368. })
  369. }
  370. function getLeixing() {
  371. let req = {}
  372. getJiazhengLeixing(req).then(res => {
  373. res.data.unshift("全部类型");
  374. allType = dataConversionObject(res.data)
  375. console.log('allType', allType);
  376. })
  377. }
  378. function dataConversionObject(data) {
  379. let newList
  380. newList = data.map((name, index) => ({
  381. id: index,
  382. name: name
  383. }));
  384. return newList
  385. }
  386. function getCurrentWeizhi() {
  387. console.log('1231231');
  388. uni.getLocation({
  389. type: 'gcj02',
  390. success: function(res) {
  391. console.log('res', res)
  392. data.jingdu = res.longitude
  393. data.weidu = res.latitude
  394. data.weizhiFlag = true
  395. console.log('当前位置的经度:' + res.longitude);
  396. console.log('当前位置的纬度:' + res.latitude);
  397. }
  398. });
  399. }
  400. onLoad(() => {
  401. getMore()
  402. getLeixing()
  403. getCurrentWeizhi()
  404. })
  405. </script>