You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

543 lines
16 KiB

6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <view class="home-content">
  3. <view class="card-container">
  4. <view class="float-button">
  5. <image @click="changeOrderType" style="width: 112rpx; height: 112rpx;" slot='cover'
  6. src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/SystemOrderCircle.png"/>
  7. </view>
  8. <view>
  9. <view class="top-select">
  10. <view style="width: 50%;">
  11. <view class="top-select-left" @click="getLocationInfo">
  12. <uni-icons type="location-filled" size="20" color="#FFB13F"></uni-icons>
  13. <text v-if="isCheckLocation"
  14. style="color: #FFB13F ;font-size: 28rpx;font-weight: 400; line-height: 28rpx; width: 280rpx; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;">{{locationName}}</text>
  15. <text v-else style="color: #AAAAAA;font-size: 28rpx;font-weight: 400;">选择地址</text>
  16. </view>
  17. </view>
  18. <view style="width: 50%;">
  19. <view class="top-select-right" @click="toggleCalendar('bottom')">
  20. <image style="width: 32rpx; height: 32rpx; margin-right: 10rpx;" slot='cover'
  21. src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/Calendar.png"/>
  22. <text v-if="isCheckTime" style="color: #FFB13F;font-size: 28rpx;font-weight: 400;">
  23. {{selectedDateShowText}}{{selectedDate.length}}</text>
  24. <text v-else style="color: #AAAAAA;font-size: 28rpx;font-weight: 400;">选择时间</text>
  25. </view>
  26. <view>
  27. <uni-popup ref="popup" background-color="#fff" @change="changePopup">
  28. <view class="popupBottom">
  29. <uni-calendar ref="calendar" class="uni-calendar--hook" :selected="selectedDate"
  30. :startDate="startDate" :endDate="endDate" :showMonth="false"
  31. @change="changeCalendar" @confirm="changeCalendar" @close="close" />
  32. <view style="display: flex; justify-content: center; align-items: center;">
  33. <!-- <button class="bottom-btn" @click="closePopup">确定</button> -->
  34. <image @click="closePopup" style="width: 670rpx; height: 80rpx;" slot='cover' src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/yesButton.png" />
  35. </view>
  36. </view>
  37. </uni-popup>
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view style="display: flex; margin: 10rpx 20rpx 0 20rpx;">
  43. <!-- <view>
  44. <image v-show="isCatCheck" @click="changeSelectedPet('cat')"
  45. style="width: 224rpx; height: 96rpx; margin-right: 20rpx;" slot='cover'
  46. src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/CatCheck.png" />
  47. <image v-show="!isCatCheck" @click="changeSelectedPet('cat')"
  48. style="width: 224rpx; height: 96rpx; margin-right: 20rpx;" slot='cover'
  49. src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/CatUncheck.png" />
  50. </view>
  51. <view>
  52. <image v-show="isDogCheck" @click="changeSelectedPet('dog')"
  53. style="width: 224rpx; height: 96rpx; margin-right: 20rpx;" slot='cover'
  54. src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/DogCheck.png" />
  55. <image v-show="!isDogCheck" @click="changeSelectedPet('dog')"
  56. style="width: 224rpx; height: 96rpx; margin-right: 20rpx;" slot='cover'
  57. src="https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/petServiceOrder/DogUncheck.png" />
  58. </view> -->
  59. <view style="padding: 10rpx 20rpx;border-radius: 50rpx;background-color: #fff;
  60. display: flex;align-items: center;justify-content: center;width: 450rpx;margin-right: 30rpx;
  61. color: #AAAAAA;" @click="openFilterPopup">
  62. <text>伴宠师条件筛选</text>
  63. <uni-icons type="forward" size="30rpx" color="#aaa"
  64. style="margin-top: 7rpx;margin-left: 10rpx;"></uni-icons>
  65. </view>
  66. <!-- 筛选弹窗组件 -->
  67. <filter-popup ref="filterPopup" @confirm="handleFilterConfirm"></filter-popup>
  68. <!-- <uni-easyinput style="border-radius: 84rpx; width: 224rpx; height: 96rpx;"
  69. borderColor="#FFB13F"
  70. prefixIcon="search" v-model="value"
  71. placeholder="输入名称"
  72. @confirm="getCompanionList"
  73. @iconClick="iconClick"></uni-easyinput> -->
  74. <u-search placeholder="输入名称"
  75. :showAction="false"
  76. @search="getCompanionList"
  77. @clear="getCompanionList"
  78. @custom="getCompanionList"
  79. height="96rpx"
  80. v-model="value"></u-search>
  81. <!-- <view style="width: 50%;" class="card">
  82. <uni-data-checkbox multiple selectedColor="#FFB13F" v-model="selectedPet" :localdata="catOrdog"
  83. @change="changeSelectedPet"></uni-data-checkbox>
  84. </view>
  85. <view style="width: 50%;">
  86. <uni-easyinput style="border-radius: 30rpx;" borderColor="#FFB13F" prefixIcon="search"
  87. v-model="value" placeholder="搜索" @iconClick="iconClick"></uni-easyinput>
  88. </view> -->
  89. <!-- <checkbox-group>
  90. <label>
  91. <checkbox value="cb" checked="true" color="#FFB13F" style="transform:scale(0.7)" />选中
  92. </label>
  93. <label>
  94. <checkbox class="color_FFB13F" value="cb" color="#FFB13F" style="transform:scale(0.7)" />未选中
  95. </label>
  96. </checkbox-group> -->
  97. </view>
  98. <view>
  99. <view v-if="companionList.length > 0" style="padding: 10rpx 0;">
  100. <companion-item
  101. v-for="(item,index) in companionList"
  102. :key="index"
  103. :item="item"
  104. @click="handleItemClick"
  105. @like="handleItemLike">
  106. </companion-item>
  107. </view>
  108. <view v-else
  109. style="
  110. color: #AAAAAA;
  111. display: flex; justify-content: center; align-items: center; height: 100px; font-size: 16px; font-weight: bold;">
  112. 暂无数据
  113. </view>
  114. </view>
  115. </view>
  116. </view>
  117. </template>
  118. <script>
  119. import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue';
  120. import uniFab from '@/uni_modules/uni-fab/components/uni-fab/uni-fab.vue'
  121. import FilterPopup from '@/components/FilterPopup/FilterPopup.vue'
  122. import CompanionItem from '@/components/CompanionItem/CompanionItem.vue'
  123. import positionMixin from '../../mixins/position';
  124. // import {
  125. // getCompanionList,
  126. // getCompanionInfo
  127. // } from "@/api/system/companion"
  128. import {
  129. getTeacherList,
  130. } from "@/api/order/order"
  131. export default {
  132. mixins: [positionMixin],
  133. data() {
  134. return {
  135. allInfo: {
  136. isCheckLocation: false,
  137. locationName: '',
  138. locationLatitude: '',
  139. locationLongitude: '',
  140. locationAddress: '',
  141. selectedDate: [],
  142. isCheckTime: false,
  143. },
  144. // 筛选条件
  145. filterOptions: {
  146. gender: '',
  147. petTypes: [],
  148. level: ''
  149. },
  150. selectedDate: [],
  151. startDate: '',
  152. endDate: '',
  153. isCheckLocation: false,
  154. locationName: '',
  155. locationLatitude: '',
  156. locationLongitude: '',
  157. locationAddress: '',
  158. isCheckTime: false,
  159. selectedDateShowText: '',
  160. isCatCheck: true,
  161. isDogCheck: true,
  162. petTypes: ['1', '2'],
  163. value: '',
  164. companionList: [],
  165. defaultStaffIamge: 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/banner/gold_people.png',
  166. }
  167. },
  168. components: {
  169. uniPopup,
  170. FilterPopup,
  171. CompanionItem
  172. },
  173. onLoad: function(option) {
  174. let info = JSON.parse(decodeURIComponent(option.info));
  175. this.allInfo = info
  176. console.log('this.allInfo', this.allInfo);
  177. this.setInfo()
  178. this.getCompanionList()
  179. },
  180. mounted() {
  181. this.getCalendarDate();
  182. },
  183. methods: {
  184. setInfo() {
  185. this.isCheckLocation = this.allInfo.isCheckLocation
  186. this.locationName = this.allInfo.locationName
  187. this.locationLatitude = this.allInfo.locationLatitude
  188. this.locationLongitude = this.allInfo.locationLongitude
  189. this.locationAddress = this.allInfo.locationAddress
  190. this.selectedDate = this.allInfo.selectedDate
  191. this.isCheckTime = this.allInfo.isCheckTime
  192. if (this.allInfo.selectedDate.length == 1) {
  193. this.selectedDateShowText = this.allInfo.selectedDate[0].date.replace(/-/g, "/") + ' '
  194. } else if (this.allInfo.selectedDate.length > 1) {
  195. this.selectedDateShowText = this.allInfo.selectedDate[0].date.replace(/-/g, "/") + '...' + ' '
  196. }
  197. },
  198. // 处理伴宠师列表项点击事件
  199. handleItemClick(item) {
  200. this.getInfo(item.userId)
  201. },
  202. // 处理伴宠师列表项点赞事件
  203. handleItemLike(item) {
  204. // 这里可以添加点赞的业务逻辑
  205. console.log('点赞伴宠师:', item)
  206. },
  207. changeOrderType() {
  208. uni.navigateTo({
  209. url: '/pages/newOrder/serviceNew2'
  210. });
  211. },
  212. getInfo(id) {
  213. if (id) {
  214. let info = encodeURIComponent(JSON
  215. .stringify(this.allInfo))
  216. uni.navigateTo({
  217. // url: '/pages_order/companionPetList/companionPetInfo',
  218. url: `/pages_order/companionPetList/companionPetInfo?id=${id}`
  219. });
  220. }
  221. },
  222. trigger(e) {
  223. uni.showModal({
  224. title: '提示',
  225. content: `激活状态:${e.item.active};选中项:${e.item.text}`,
  226. success(res) {
  227. if (res.confirm) {
  228. console.log('用户点击确定');
  229. } else if (res.cancel) {
  230. console.log('用户点击取消');
  231. }
  232. }
  233. });
  234. },
  235. fabClick() {
  236. uni.showToast({
  237. title: '点击了悬浮按钮',
  238. icon: 'none'
  239. });
  240. },
  241. getCompanionList() {
  242. // let data = {
  243. // longitude: this.locationLongitude,
  244. // latitude: this.locationLatitude,
  245. // petTypes: this.selectedPet,
  246. // staffName: '',
  247. // address: this.locationAddress
  248. // }
  249. let data = {
  250. // address: "上海市浦东新区浦东南路150弄",
  251. latitude: this.position.latitude,
  252. longitude: this.position.longitude,
  253. // latitude: 29.56471,
  254. // longitude: 106.55073,
  255. // petTypes: ["1", "2"],
  256. staffName: this.value,//搜素字段
  257. isZ : 1,
  258. }
  259. if(this.filterOptions.gender){
  260. data.sex = this.filterOptions.gender
  261. }
  262. if(this.filterOptions.petTypes.length){
  263. data.petTypes = this.filterOptions.petTypes.join(',')
  264. }
  265. if(this.filterOptions.level){
  266. data.teacherLevels = this.filterOptions.level
  267. }
  268. if(this.selectedDate.length > 0){
  269. data.selectedDate = this.selectedDate.map(n => n.date).join(',')
  270. }
  271. console.log('data', data);
  272. // getCompanionList(data).then(response => {
  273. // if (response.code == 200) {
  274. // this.companionList = response.rows
  275. // console.log(response);
  276. // }
  277. // console.log(response);
  278. // })
  279. getTeacherList(data).then(response => {
  280. if (response.code == 200) {
  281. this.companionList = response.rows
  282. this.calculateTeacherListDistance()
  283. }
  284. console.log(response);
  285. })
  286. },
  287. calculateTeacherListDistance(){
  288. this.companionList.forEach(item => {
  289. item.distanceText = this.calculateDistanceAddress(item.appletAddresseList)
  290. })
  291. this.companionList.sort((a,b) => a.distanceText - b.distanceText)
  292. },
  293. iconClick() {},
  294. changeSelectedPet(type) {
  295. console.log('changeSelectedPet type', type);
  296. if (type == 'cat') {
  297. this.isCatCheck = !this.isCatCheck
  298. if (this.petTypes.includes('1')) {
  299. if (!this.isCatCheck) {
  300. this.petTypes = this.petTypes.filter(item => item !== '1');
  301. }
  302. } else {
  303. this.isCatCheck ? this.petTypes.push('1') : ''
  304. }
  305. } else {
  306. this.isDogCheck = !this.isDogCheck
  307. if (this.petTypes.includes('2')) {
  308. if (!this.isDogCheck) {
  309. this.petTypes = this.petTypes.filter(item => item !== '2');
  310. }
  311. } else {
  312. this.isDogCheck ? this.petTypes.push('2') : ''
  313. }
  314. }
  315. console.log('this.petTypes', this.petTypes);
  316. },
  317. toggleCalendar(type) {
  318. this.type = type
  319. uni.hideTabBar()
  320. this.$refs.popup.open(type)
  321. },
  322. closePopup() {
  323. this.$refs.popup.close()
  324. setTimeout(() => {
  325. uni.showTabBar()
  326. }, 300)
  327. },
  328. changePopup(e) {
  329. console.log('当前模式:' + e.type + ',状态:' + e.show);
  330. if (e.show) {
  331. uni.hideTabBar()
  332. } else {
  333. setTimeout(() => {
  334. uni.showTabBar()
  335. }, 300)
  336. }
  337. },
  338. close() {
  339. console.log('弹窗关闭');
  340. },
  341. confirm(e) {
  342. console.log('confirm 返回:', e)
  343. },
  344. changeCalendar(e) {
  345. console.log('change 返回:', e)
  346. this.selectedDateShowText = ''
  347. // 选中日期
  348. const selectedValue = this.selectedDate.find(item => item.date === e.fulldate)
  349. if (selectedValue) {
  350. // 存在则移除
  351. this.selectedDate = this.selectedDate.filter(item => item.date !== e.fulldate);
  352. } else {
  353. this.selectedDate.push({
  354. date: e.fulldate,
  355. info: 'time'
  356. })
  357. }
  358. if (this.selectedDate.length > 0) {
  359. this.isCheckTime = true
  360. if (this.selectedDate.length == 1) {
  361. this.selectedDateShowText = this.selectedDate[0].date.replace(/-/g, "/") + ' '
  362. } else {
  363. this.selectedDateShowText = this.selectedDate[0].date.replace(/-/g, "/") + '...' + ' '
  364. }
  365. } else {
  366. this.isCheckTime = false
  367. }
  368. console.log(this.selectedDate);
  369. this.getCompanionList()
  370. },
  371. getCalendarDate() {
  372. let tomorrow = new Date()
  373. tomorrow.setDate(tomorrow.getDate() + 2);
  374. this.startDate = this.formatDate(tomorrow);
  375. // 获取三个月后的日期
  376. let threeMonthsLater = new Date();
  377. threeMonthsLater.setMonth(threeMonthsLater.getMonth() + 3);
  378. this.endDate = this.formatDate(threeMonthsLater);
  379. },
  380. formatDate(date) {
  381. let year = date.getFullYear();
  382. let month = (date.getMonth() + 1).toString().padStart(2, '0');
  383. let day = date.getDate().toString().padStart(2, '0');
  384. return year + '-' + month + '-' + day;
  385. },
  386. getLocationInfo() {
  387. wx.chooseLocation({
  388. type: 'gcj02', // 坐标系,默认为 wgs84 返回 gps 原始坐标,gcj02 返回可用于 wx.openLocation 的坐标
  389. success: (res) => {
  390. // 成功回调
  391. this.isCheckLocation = true
  392. this.locationName = res.address
  393. this.locationLongitude = res.longitude
  394. this.locationLatitude = res.latitude
  395. this.locationAddress = res.address
  396. console.log('选择的位置:', res);
  397. this.position.address = this.locationAddress
  398. this.position.longitude = this.locationLongitude
  399. this.position.latitude = this.locationLatitude
  400. this.getCompanionList()
  401. },
  402. fail: (err) => {
  403. // 失败回调
  404. console.error('选择位置失败:', err);
  405. }
  406. });
  407. },
  408. // 打开筛选弹窗
  409. openFilterPopup() {
  410. this.$refs.filterPopup.open()
  411. },
  412. // 处理筛选确认
  413. handleFilterConfirm(filterData) {
  414. console.log('筛选条件:', filterData)
  415. this.filterOptions = filterData
  416. // 根据筛选条件重新获取数据
  417. this.getCompanionList()
  418. },
  419. }
  420. }
  421. </script>
  422. <style lang="scss">
  423. .home-content {
  424. background: linear-gradient(360deg, #F5F5F7 0%, #FFBF60 99%);
  425. .card-container {
  426. margin: 0;
  427. padding: 0;
  428. .uni-card {
  429. border-radius: 16rpx;
  430. }
  431. .top-select {
  432. background-color: #fff;
  433. border: 1px solid #EBEEF5;
  434. // box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.08);
  435. display: flex;
  436. justify-content: space-between;
  437. margin: 0 10px 10px 10px;
  438. border-radius: 16rpx;
  439. padding: 13px;
  440. .top-select-left {
  441. display: flex;
  442. flex-wrap: nowrap;
  443. align-items: center;
  444. // justify-content: space-around;
  445. }
  446. .top-select-right {
  447. display: flex;
  448. flex-wrap: nowrap;
  449. align-items: center;
  450. }
  451. }
  452. .float-button {
  453. z-index: 10;
  454. position: fixed;
  455. bottom: 100rpx;
  456. /* 距离底部的距离 */
  457. right: 32rpx;
  458. /* 距离右侧的距离 */
  459. // width: 50px;
  460. // /* 按钮的宽度 */
  461. // height: 50px;
  462. }
  463. .is-input-border {
  464. border-radius: 84rpx;
  465. height: 96rpx;
  466. width: 224rpx;
  467. }
  468. .card {
  469. // border-radius: 50rpx;
  470. width: 50%;
  471. background-color: #fff;
  472. border: 1px solid #EBEEF5;
  473. box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.08);
  474. margin-right: 20rpx;
  475. // height: 80rpx;
  476. display: flex;
  477. align-items: center;
  478. justify-content: center;
  479. }
  480. .popupBottom {
  481. z-index: 99;
  482. height: 950rpx;
  483. overflow: hidden;
  484. position: fixed;
  485. bottom: 0;
  486. left: 0;
  487. right: 0;
  488. padding: 10rpx 20rpx;
  489. border-radius: 20rpx 20rpx 0 0;
  490. background-color: #fff;
  491. .bottom-btn {
  492. width: 100%;
  493. border-radius: 120rpx;
  494. background: #FFB13F;
  495. font-size: 32rpx;
  496. color: #FFFFFF;
  497. }
  498. }
  499. ::v-deep .wx-radio-input.wx-radio-input-checked {
  500. background-color: #00875a !important;
  501. border-color: #00875a !important;
  502. color: #ffffff !important;
  503. }
  504. .color_FFB13F {
  505. color: #FFB13F;
  506. }
  507. }
  508. }
  509. </style>