index.vue 10 KB

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