index.vue 10 KB

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