index.vue 10 KB

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