index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  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>距离排序</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. id: '',
  118. list: [], // 考试列表
  119. loading: false,
  120. state: 'more',
  121. contentText: {
  122. contentdown: '查看更多',
  123. contentrefresh: '加载中',
  124. contentnomore: '没有更多'
  125. }
  126. })
  127. let isOpen = ref(false)
  128. let defauleImg = ref('@/static/images/my/user-default-img.png')
  129. const allJtClass = 'select-jt-default';
  130. let updataJtClass = ref('');
  131. let luruJtClass = ref('');
  132. let juliJtClass = ref('');
  133. let shaixuanStyleUpdate = ref('saixuan-item-box');
  134. let shaixuanStyleluru = ref('saixuan-item-box');
  135. let shaixuanStylejuli = ref('saixuan-item-box');
  136. const isOpenSelect = ref(false);
  137. const selectedOption = ref('');
  138. let isFirstClickUpdate = ref('true')
  139. let isFirstClickluru = ref('true')
  140. let isFirstClickjuli = ref('true')
  141. function updateTimeClick() {
  142. data.sortType = 1
  143. const isFirst = isFirstClickUpdate.value == 'true';
  144. const isSecond = isFirstClickUpdate.value == 'false';
  145. if (isFirst) {
  146. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  147. updataJtClass.value = 'saixuan-jt-default';
  148. isFirstClickUpdate.value = 'false';
  149. data.sortRule = 1
  150. } else if (isSecond) {
  151. shaixuanStyleUpdate.value = 'saixuan-item-box saixuan-active';
  152. updataJtClass.value = 'saixuan-jt-click';
  153. isFirstClickUpdate.value = 'empty';
  154. data.sortRule = 2
  155. } else {
  156. shaixuanStyleUpdate.value = 'saixuan-item-box';
  157. updataJtClass.value = '';
  158. isFirstClickUpdate.value = 'true';
  159. data.sortRule = 0
  160. }
  161. data.page = 0;
  162. refreshData()
  163. }
  164. function luruTimeClick() {
  165. data.sortType = 2
  166. const isFirst = isFirstClickluru.value == 'true';
  167. const isSecond = isFirstClickluru.value == 'false';
  168. if (isFirst) {
  169. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  170. luruJtClass.value = 'saixuan-jt-default';
  171. isFirstClickluru.value = 'false';
  172. data.sortRule = 1
  173. } else if (isSecond) {
  174. shaixuanStyleluru.value = 'saixuan-item-box saixuan-active';
  175. luruJtClass.value = 'saixuan-jt-click';
  176. isFirstClickluru.value = 'empty';
  177. data.sortRule = 2
  178. } else {
  179. shaixuanStyleluru.value = 'saixuan-item-box';
  180. luruJtClass.value = '';
  181. isFirstClickluru.value = 'true';
  182. data.sortRule = 0
  183. }
  184. data.page = 0;
  185. refreshData()
  186. }
  187. function juliClick() {
  188. data.sortType = 3
  189. const isFirst = isFirstClickjuli.value == 'true';
  190. const isSecond = isFirstClickjuli.value == 'false';
  191. if (isFirst) {
  192. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  193. juliJtClass.value = 'saixuan-jt-default';
  194. isFirstClickjuli.value = 'false';
  195. data.sortRule = 1
  196. } else if (isSecond) {
  197. shaixuanStylejuli.value = 'saixuan-item-box saixuan-active';
  198. juliJtClass.value = 'saixuan-jt-click';
  199. isFirstClickjuli.value = 'empty';
  200. data.sortRule = 2
  201. } else {
  202. shaixuanStylejuli.value = 'saixuan-item-box';
  203. juliJtClass.value = '';
  204. isFirstClickjuli.value = 'true';
  205. data.sortRule = 0
  206. }
  207. data.page = 0;
  208. refreshData()
  209. }
  210. function dialogSearchBtn(name, searchData) {
  211. switch (name) {
  212. case '姓名':
  213. dialogSearchReset();
  214. data.realName = searchData.value;
  215. break;
  216. case '手机号':
  217. data.userName = searchData.value;
  218. break;
  219. }
  220. data.page = 0;
  221. refreshData();
  222. }
  223. function dialogSearchReset() {
  224. data.userName = '';
  225. data.realName = '';
  226. }
  227. const clickAlltype = (data) => {
  228. isOpen.value = !isOpen.value;
  229. }
  230. const toggle = (data, index) => {
  231. searchDialogRef.value.handleShow();
  232. }
  233. const addJiazhengRenyuan = () => {
  234. let pageInfo = {
  235. status: 'add'
  236. }
  237. uni.redirectTo({
  238. url: "/pages/admin/Jiazheng/jiazhengUserManager?pageInfo=" + JSON.stringify(pageInfo)
  239. })
  240. }
  241. const lookUserInfo = (data) => {
  242. let pageInfo = {
  243. status: 'edit',
  244. id: data.id,
  245. userId: data.userId
  246. }
  247. uni.redirectTo({
  248. url: `/pages/admin/Jiazheng/jiazhengUserInfo?pageInfo=` + JSON.stringify(pageInfo)
  249. })
  250. }
  251. function goUpPage() {
  252. uni.redirectTo({
  253. url: `/pages/admin/ShouYe/shouye`
  254. })
  255. }
  256. function onRefresh() {
  257. data.page = 0;
  258. data.list = [];
  259. data.loading = true;
  260. refreshData();
  261. }
  262. function telephone(data) {
  263. console.log('data', data);
  264. if (data.userName) {
  265. uni.makePhoneCall({
  266. phoneNumber: data.userName
  267. });
  268. } else {
  269. uni.showToast({
  270. title: `无电话号`,
  271. icon: 'none',
  272. duration: 2000
  273. })
  274. return false
  275. }
  276. }
  277. function selectChangeSkill(item) {
  278. data.leixing = item[0].name
  279. console.log('selectChangeSkill', item);
  280. data.page = 0;
  281. refreshData()
  282. }
  283. function refreshData() {
  284. const opt = {
  285. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  286. "page": 1,
  287. "realName": data.realName,
  288. "size": 10,
  289. "sortRule": data.sortRule,
  290. "sortType": data.sortType,
  291. "userName": data.userName,
  292. "jingdu": data.jingdu,
  293. "weidu": data.weidu
  294. }
  295. data.list = [];
  296. // 数学
  297. data.state = 'loading';
  298. data.page++;
  299. opt.page = data.page;
  300. getJiazhengList(opt).then(res => {
  301. data.list = data.list.concat(res.data.data);
  302. data.list = data.list.map(item => {
  303. const newItem = {
  304. ...item
  305. };
  306. newItem.leixing = item.leixing.split(',');
  307. return newItem;
  308. })
  309. data.loading = false;
  310. if (res.data.total > data.list.length) {
  311. data.state = 'more';
  312. data.loading = false;
  313. } else {
  314. data.state = 'no-more';
  315. data.loading = false;
  316. }
  317. }).catch(err => {
  318. data.state = 'more';
  319. data.loading = false;
  320. })
  321. }
  322. function getMore() {
  323. const opt = {
  324. "leixing": data.leixing == '全部类型' ? '' : data.leixing,
  325. "page": 1,
  326. "realName": data.realName,
  327. "size": 10,
  328. "sortRule": data.sortRule,
  329. "sortType": data.sortType,
  330. "userName": data.userName,
  331. "jingdu": data.jingdu,
  332. "weidu": data.weidu
  333. }
  334. if (data.state == 'no-more') return;
  335. data.state = 'loading';
  336. data.page++;
  337. opt.page = data.page;
  338. getJiazhengList(opt).then(res => {
  339. data.list = data.list.concat(res.data.data);
  340. data.list = data.list.map(item => {
  341. const newItem = {
  342. ...item
  343. };
  344. newItem.leixing = item.leixing.split(',');
  345. return newItem;
  346. })
  347. console.log('data.list', data.list);
  348. data.loading = false;
  349. if (res.data.total > data.list.length) {
  350. data.state = 'more';
  351. data.loading = false;
  352. } else {
  353. data.state = 'no-more';
  354. data.loading = false;
  355. }
  356. }).catch(err => {
  357. data.state = 'more';
  358. data.loading = false;
  359. })
  360. }
  361. function getLeixing() {
  362. let req = {}
  363. getJiazhengLeixing(req).then(res => {
  364. res.data.unshift("全部类型");
  365. allType = dataConversionObject(res.data)
  366. console.log('allType', allType);
  367. })
  368. }
  369. function dataConversionObject(data) {
  370. let newList
  371. newList = data.map((name, index) => ({
  372. id: index,
  373. name: name
  374. }));
  375. return newList
  376. }
  377. function getCurrentWeizhi() {
  378. console.log('1231231');
  379. uni.getLocation({
  380. type: 'gcj02',
  381. success: function(res) {
  382. console.log('res', res)
  383. data.jingdu = res.longitude
  384. data.weidu = res.latitude
  385. console.log('当前位置的经度:' + res.longitude);
  386. console.log('当前位置的纬度:' + res.latitude);
  387. }
  388. });
  389. }
  390. onLoad(() => {
  391. getMore()
  392. getLeixing()
  393. getCurrentWeizhi()
  394. })
  395. </script>