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