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.

542 lines
16 KiB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 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. }
  258. if(this.filterOptions.gender){
  259. data.sex = this.filterOptions.gender
  260. }
  261. if(this.filterOptions.petTypes.length){
  262. data.petTypes = this.filterOptions.petTypes.join(',')
  263. }
  264. if(this.filterOptions.level){
  265. data.teacherLevels = this.filterOptions.level
  266. }
  267. if(this.selectedDate.length > 0){
  268. data.selectedDate = this.selectedDate.map(n => n.date).join(',')
  269. }
  270. console.log('data', data);
  271. // getCompanionList(data).then(response => {
  272. // if (response.code == 200) {
  273. // this.companionList = response.rows
  274. // console.log(response);
  275. // }
  276. // console.log(response);
  277. // })
  278. getTeacherList(data).then(response => {
  279. if (response.code == 200) {
  280. this.companionList = response.rows
  281. this.calculateTeacherListDistance()
  282. }
  283. console.log(response);
  284. })
  285. },
  286. calculateTeacherListDistance(){
  287. this.companionList.forEach(item => {
  288. item.distanceText = this.calculateDistanceAddress(item.appletAddresseList)
  289. })
  290. this.companionList.sort((a,b) => a.distanceText - b.distanceText)
  291. },
  292. iconClick() {},
  293. changeSelectedPet(type) {
  294. console.log('changeSelectedPet type', type);
  295. if (type == 'cat') {
  296. this.isCatCheck = !this.isCatCheck
  297. if (this.petTypes.includes('1')) {
  298. if (!this.isCatCheck) {
  299. this.petTypes = this.petTypes.filter(item => item !== '1');
  300. }
  301. } else {
  302. this.isCatCheck ? this.petTypes.push('1') : ''
  303. }
  304. } else {
  305. this.isDogCheck = !this.isDogCheck
  306. if (this.petTypes.includes('2')) {
  307. if (!this.isDogCheck) {
  308. this.petTypes = this.petTypes.filter(item => item !== '2');
  309. }
  310. } else {
  311. this.isDogCheck ? this.petTypes.push('2') : ''
  312. }
  313. }
  314. console.log('this.petTypes', this.petTypes);
  315. },
  316. toggleCalendar(type) {
  317. this.type = type
  318. uni.hideTabBar()
  319. this.$refs.popup.open(type)
  320. },
  321. closePopup() {
  322. this.$refs.popup.close()
  323. setTimeout(() => {
  324. uni.showTabBar()
  325. }, 300)
  326. },
  327. changePopup(e) {
  328. console.log('当前模式:' + e.type + ',状态:' + e.show);
  329. if (e.show) {
  330. uni.hideTabBar()
  331. } else {
  332. setTimeout(() => {
  333. uni.showTabBar()
  334. }, 300)
  335. }
  336. },
  337. close() {
  338. console.log('弹窗关闭');
  339. },
  340. confirm(e) {
  341. console.log('confirm 返回:', e)
  342. },
  343. changeCalendar(e) {
  344. console.log('change 返回:', e)
  345. this.selectedDateShowText = ''
  346. // 选中日期
  347. const selectedValue = this.selectedDate.find(item => item.date === e.fulldate)
  348. if (selectedValue) {
  349. // 存在则移除
  350. this.selectedDate = this.selectedDate.filter(item => item.date !== e.fulldate);
  351. } else {
  352. this.selectedDate.push({
  353. date: e.fulldate,
  354. info: 'time'
  355. })
  356. }
  357. if (this.selectedDate.length > 0) {
  358. this.isCheckTime = true
  359. if (this.selectedDate.length == 1) {
  360. this.selectedDateShowText = this.selectedDate[0].date.replace(/-/g, "/") + ' '
  361. } else {
  362. this.selectedDateShowText = this.selectedDate[0].date.replace(/-/g, "/") + '...' + ' '
  363. }
  364. } else {
  365. this.isCheckTime = false
  366. }
  367. console.log(this.selectedDate);
  368. this.getCompanionList()
  369. },
  370. getCalendarDate() {
  371. let tomorrow = new Date()
  372. tomorrow.setDate(tomorrow.getDate() + 2);
  373. this.startDate = this.formatDate(tomorrow);
  374. // 获取三个月后的日期
  375. let threeMonthsLater = new Date();
  376. threeMonthsLater.setMonth(threeMonthsLater.getMonth() + 3);
  377. this.endDate = this.formatDate(threeMonthsLater);
  378. },
  379. formatDate(date) {
  380. let year = date.getFullYear();
  381. let month = (date.getMonth() + 1).toString().padStart(2, '0');
  382. let day = date.getDate().toString().padStart(2, '0');
  383. return year + '-' + month + '-' + day;
  384. },
  385. getLocationInfo() {
  386. wx.chooseLocation({
  387. type: 'gcj02', // 坐标系,默认为 wgs84 返回 gps 原始坐标,gcj02 返回可用于 wx.openLocation 的坐标
  388. success: (res) => {
  389. // 成功回调
  390. this.isCheckLocation = true
  391. this.locationName = res.address
  392. this.locationLongitude = res.longitude
  393. this.locationLatitude = res.latitude
  394. this.locationAddress = res.address
  395. console.log('选择的位置:', res);
  396. this.position.address = this.locationAddress
  397. this.position.longitude = this.locationLongitude
  398. this.position.latitude = this.locationLatitude
  399. this.getCompanionList()
  400. },
  401. fail: (err) => {
  402. // 失败回调
  403. console.error('选择位置失败:', err);
  404. }
  405. });
  406. },
  407. // 打开筛选弹窗
  408. openFilterPopup() {
  409. this.$refs.filterPopup.open()
  410. },
  411. // 处理筛选确认
  412. handleFilterConfirm(filterData) {
  413. console.log('筛选条件:', filterData)
  414. this.filterOptions = filterData
  415. // 根据筛选条件重新获取数据
  416. this.getCompanionList()
  417. },
  418. }
  419. }
  420. </script>
  421. <style lang="scss">
  422. .home-content {
  423. background: linear-gradient(360deg, #F5F5F7 0%, #FFBF60 99%);
  424. .card-container {
  425. margin: 0;
  426. padding: 0;
  427. .uni-card {
  428. border-radius: 16rpx;
  429. }
  430. .top-select {
  431. background-color: #fff;
  432. border: 1px solid #EBEEF5;
  433. // box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.08);
  434. display: flex;
  435. justify-content: space-between;
  436. margin: 0 10px 10px 10px;
  437. border-radius: 16rpx;
  438. padding: 13px;
  439. .top-select-left {
  440. display: flex;
  441. flex-wrap: nowrap;
  442. align-items: center;
  443. // justify-content: space-around;
  444. }
  445. .top-select-right {
  446. display: flex;
  447. flex-wrap: nowrap;
  448. align-items: center;
  449. }
  450. }
  451. .float-button {
  452. z-index: 10;
  453. position: fixed;
  454. bottom: 100rpx;
  455. /* 距离底部的距离 */
  456. right: 32rpx;
  457. /* 距离右侧的距离 */
  458. // width: 50px;
  459. // /* 按钮的宽度 */
  460. // height: 50px;
  461. }
  462. .is-input-border {
  463. border-radius: 84rpx;
  464. height: 96rpx;
  465. width: 224rpx;
  466. }
  467. .card {
  468. // border-radius: 50rpx;
  469. width: 50%;
  470. background-color: #fff;
  471. border: 1px solid #EBEEF5;
  472. box-shadow: 0px 0px 3px 1px rgba(0, 0, 0, 0.08);
  473. margin-right: 20rpx;
  474. // height: 80rpx;
  475. display: flex;
  476. align-items: center;
  477. justify-content: center;
  478. }
  479. .popupBottom {
  480. z-index: 99;
  481. height: 950rpx;
  482. overflow: hidden;
  483. position: fixed;
  484. bottom: 0;
  485. left: 0;
  486. right: 0;
  487. padding: 10rpx 20rpx;
  488. border-radius: 20rpx 20rpx 0 0;
  489. background-color: #fff;
  490. .bottom-btn {
  491. width: 100%;
  492. border-radius: 120rpx;
  493. background: #FFB13F;
  494. font-size: 32rpx;
  495. color: #FFFFFF;
  496. }
  497. }
  498. ::v-deep .wx-radio-input.wx-radio-input-checked {
  499. background-color: #00875a !important;
  500. border-color: #00875a !important;
  501. color: #ffffff !important;
  502. }
  503. .color_FFB13F {
  504. color: #FFB13F;
  505. }
  506. }
  507. }
  508. </style>