index.vue 11 KB

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