index.vue 12 KB

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