index.vue 11 KB

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