index.vue 12 KB

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