猫妈狗爸伴宠师小程序前端代码
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.

678 lines
17 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
5 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
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
5 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
2 months ago
6 months ago
5 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
  1. <template>
  2. <!-- <div>订单详情</div> -->
  3. <view class="box box-size">
  4. <view class="top box-size" :style="{ borderRadius: '16rpx' }">
  5. <view class="top_left box-size">
  6. <view>
  7. 本单客户支付金额
  8. <view class="vertically_center text1">
  9. ¥ {{ orderDetail.order?.h5OrderVO?.payAmount }}
  10. </view>
  11. </view>
  12. X
  13. <view>
  14. 您的分成比例
  15. <view class="vertically_center text1">
  16. <!-- 20% -->
  17. {{ orderDetail.pet_payment_bcs[userInfo.userBcsRole - 1].paramValueText }}
  18. </view>
  19. </view>
  20. =
  21. <view>
  22. 本单酬劳
  23. <view class="vertically_center text1">
  24. ¥ {{ orderDetail.order.orderGive}}
  25. <!-- ¥ {{ orderDetail.pet_payment_bcs[userInfo.userBcsRole - 1].paramValueNo * orderDetail.order?.h5OrderVO?.payAmount }} -->
  26. </view>
  27. </view>
  28. </view>
  29. <view class="top_bottom">
  30. <!-- 订单为系统派发请确认订单信息后再抢单 -->
  31. {{ typeInfo[orderDetail.order.type].content }}
  32. </view>
  33. <view class="top-button" :style="{ borderRadius: '27rpx' }">
  34. {{ typeInfo[orderDetail.order.type].title }}
  35. </view>
  36. </view>
  37. <view class="information box-size" style="border-radius: 15rpx;
  38. padding-bottom: 30rpx;">
  39. <view class="form-title">
  40. 基本信息
  41. </view>
  42. <view class="line1">
  43. </view>
  44. <view class="time">
  45. <view>
  46. 服务日期
  47. </view>
  48. <view v-if="orderDetail.order" class="time-content">
  49. {{ getTextList().join(',') }}
  50. </view>
  51. </view>
  52. <view class="line1">
  53. </view>
  54. <view class="time">
  55. <view>
  56. 服务地址
  57. </view>
  58. <view class="time-content">
  59. {{ orderDetail.order?.address }}
  60. </view>
  61. </view>
  62. </view>
  63. <view class="service box-size" :style="{ borderRadius: '8rpx' }">
  64. <!-- <view class="horizontal_distribution service_top">
  65. <view class="form-title">
  66. 服务内容和酬劳
  67. </view>
  68. <view @click="petInfo" class="text2 flex">
  69. 查看宠物信息
  70. <u-icon name="arrow-right-double" color="#F5F5F5" size="10"></u-icon>
  71. </view>
  72. </view>
  73. <view class="line1">
  74. </view>
  75. <view v-for="pet in orderDetail.order.h5OrderVO.petVOList"
  76. @click="toDetail(pet.id)"
  77. :key="pet.id" class="pet_information box-size">
  78. <view class="flex pet_item box-size">
  79. <view class="img" :style="{borderRadius:'100rpx'}">
  80. <image :src="pet.photo" mode=""></image>
  81. </view>
  82. <view>
  83. <view class="flex name">
  84. <view class="name_text">
  85. {{ pet.breed }}
  86. </view>
  87. <image :src="pet.gender == '男生' ? 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/sex_m.png':
  88. 'https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/sex_f.png'" mode=""></image>
  89. </view>
  90. {{ pet.type }}{{ pet.bodyType }}
  91. </view>
  92. </view>
  93. <view class="pet-level" v-for="(it, i) in pet.productNameText"
  94. :key="i" style="margin: 4rpx 0;">
  95. <text style="color: #999;padding-right: 20rpx">{{ it.time }}</text>
  96. <text>{{ it.name }}</text>
  97. <text style="color: #999;padding-left: 20rpx">上门1次</text>
  98. </view>
  99. <view class="pet-level">
  100. 12-15
  101. <text>专业喂养</text>
  102. 上门1次
  103. </view>
  104. </view> -->
  105. <ServiceItems :items="serviceList"/>
  106. <view class="line1">
  107. </view>
  108. <view class="flex money_total">
  109. <view>
  110. 合计
  111. </view>
  112. <view class="money_text">
  113. ¥&nbsp;{{ orderDetail.order.price }}
  114. </view>
  115. </view>
  116. </view>
  117. <view class="other_information box-size">
  118. <view class="form-title">
  119. 其他信息
  120. </view>
  121. <view class="line1">
  122. </view>
  123. <view class="horizontal_distribution text3">
  124. <view>
  125. 订单编号
  126. </view>
  127. <view>
  128. {{ orderDetail.order.orderSn }}
  129. </view>
  130. </view>
  131. <view class="line1">
  132. </view>
  133. <view class="horizontal_distribution text3">
  134. <view>
  135. 下单时间
  136. </view>
  137. <view>
  138. {{ orderDetail.order?.createTime }}
  139. </view>
  140. </view>
  141. <view class="line1">
  142. </view>
  143. <view class="horizontal_distribution text3">
  144. <view>
  145. 支付时间
  146. </view>
  147. <view>
  148. {{ orderDetail.order.payTime }}
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. <view class="bottom" v-if="pathType != 'my'">
  154. <view @click="rushToBuyAnOrder" class="bottom_button level" :style="{ borderRadius: '41rpx' }">
  155. 立即抢单
  156. </view>
  157. </view>
  158. <up-popup :show="showConfirmOrder" mode="bottom" @close="close" @open="open" :round="10" :closeable="true"
  159. :safeAreaInsetBottom="false"
  160. :customStyle="{padding:'60rpx 20rpx 40rpx 20rpx;position:relative;height:auto;background:#F6F5F8;'}">
  161. <view>
  162. <view style="position:absolute;top: 20rpx;left:0;text-align: center;width: 100%;">
  163. 订单信息
  164. </view>
  165. <view style="text-align: center;">
  166. 请全部确认后接单
  167. </view>
  168. <view class="order-confirmation">
  169. <view class="confirmation-item">
  170. <view class="confirmation-base">
  171. <view class="title">
  172. 服务日期
  173. </view>
  174. <view class="desc">
  175. {{ getTextList().length }}:{{ getTextList().join(',') }}
  176. </view>
  177. </view>
  178. <view class="ok">
  179. <view class="btn" @click="handleConfirm(0)" :class="{ 'btn-confirmed': confirmStatus[0] }">
  180. {{ confirmStatus[0] ? '已确认' : '点击确定' }}
  181. </view>
  182. </view>
  183. </view>
  184. <view class="confirmation-item">
  185. <view class="confirmation-base">
  186. <view class="title">
  187. 服务地址
  188. </view>
  189. <view class="desc">
  190. {{ orderDetail.order.address }}
  191. </view>
  192. </view>
  193. <view class="ok">
  194. <view class="btn" @click="handleConfirm(1)" :class="{ 'btn-confirmed': confirmStatus[1] }">
  195. {{ confirmStatus[1] ? '已确认' : '点击确定' }}
  196. </view>
  197. </view>
  198. </view>
  199. <view class="confirmation-item">
  200. <view class="confirmation-base">
  201. <view class="title">
  202. 服务宠物
  203. </view>
  204. <view class="desc">
  205. <view v-for="pet in orderDetail.order.h5OrderVO.petVOList" :key="pet.id">
  206. {{ pet.breed }}{{ pet.bodyType }}
  207. </view>
  208. </view>
  209. </view>
  210. <view class="ok">
  211. <view class="btn" @click="handleConfirm(2)" :class="{ 'btn-confirmed': confirmStatus[2] }">
  212. {{ confirmStatus[2] ? '已确认' : '点击确定' }}
  213. </view>
  214. </view>
  215. </view>
  216. </view>
  217. <view class="handbook">
  218. 接单即接受
  219. <text class="text" @click="configPopupRef.open('pet_platform_introduction')">伴宠师手册</text>
  220. </view>
  221. <up-button @click="conform" color="#FFBF60" text="确定" shape="circle"></up-button>
  222. </view>
  223. </up-popup>
  224. <!-- 抢单成功 -->
  225. <up-popup :show="showOrderSuccess" mode="center" @close="orderSuccessClose" @open="orderSuccessOpen" :zIndex="999"
  226. :round="10" :safeAreaInsetBottom="false" :customStyle="{ width:'80%' , 'background-color': 'transparent' }">
  227. <view>
  228. <image style="width: 100%;" :src="configList?.order_success?.paramValueImage" mode="widthFix"></image>
  229. </view>
  230. <view style="margin-top: -100%;padding: 40rpx;20rpx">
  231. <view class="success-desc">
  232. {{ configList?.order_success?.paramValueText || '请立即添加服务顾问,并提供订单编码' }}
  233. </view>
  234. <view style="position: relative;z-index: 999;" class="qr-code">
  235. <image class="code-img" :src="
  236. configList?.pet_qrcode?.paramValueImage ||
  237. 'https://img.xjishu.com/img/zl/2018/6/30/1241359458913.gif'"
  238. mode="aspectFill"></image>
  239. </view>
  240. <view class="input">
  241. <up-input placeholder="" border="none" v-model="value" disabled
  242. :customStyle="{height:'60rpx','text-indent': '20rem', 'background-color': '#F3F3F3', position : 'relative','z-index' : '999' }"></up-input>
  243. </view>
  244. <view class="button-group">
  245. <up-button @click="noneOrder" color="#FFBF60" text="复制订单编号" shape="circle"></up-button>
  246. <up-button v-if="showSecondButton" @click="toMyOrder" color="#FFBF60" text="到我的订单查看" shape="circle"></up-button>
  247. </view>
  248. </view>
  249. </up-popup>
  250. <configPopup ref="configPopupRef" />
  251. <!-- 客服组件 -->
  252. <CustomerService />
  253. </template>
  254. <script setup>
  255. import {
  256. ref,
  257. computed
  258. } from 'vue'
  259. import {
  260. onLoad
  261. } from '@dcloudio/uni-app'
  262. import {
  263. getByOrderId
  264. } from "@/api/receivingHall/index.js"
  265. import {
  266. onShow
  267. } from '@dcloudio/uni-app'
  268. import order from '../../../api/order/order'
  269. import {
  270. startByOrderId
  271. } from "@/api/receivingHall/index.js"
  272. import {
  273. useStore
  274. } from "vuex"
  275. import ServiceItems from '@/components/order/ServiceItems.vue'
  276. import dayjs from "dayjs";
  277. import configPopup from '@/components/configPopup.vue'
  278. const configPopupRef = ref(null)
  279. onLoad((options) => {
  280. orderId.value = options.id || null;
  281. pathType.value = options.type || ''
  282. });
  283. onShow(() => {
  284. getDetail();
  285. })
  286. const pathType = ref('')
  287. const store = useStore();
  288. const orderId = ref(null);
  289. const orderDetail = ref({});
  290. const serviceList = ref([]);
  291. const showConfirmOrder = ref(false);
  292. const showOrderSuccess = ref(false);
  293. const value = ref("45619491656")
  294. const petList = ref([])
  295. const confirmStatus = ref([false, false, false]); // 添加确认状态数组,分别对应三个确认项
  296. const showSecondButton = ref(false); // 控制第二个按钮的显示
  297. const userInfo = computed(() => {
  298. return store.getters.userInfo
  299. })
  300. const configList = computed(() => {
  301. return store.getters.configList;
  302. })
  303. // 抢单
  304. const rushToBuyAnOrder = () => {
  305. open()
  306. }
  307. const typeInfo = [
  308. {
  309. title : '系统派单',
  310. content : '订单为系统派发,请确认订单信息后再抢单',
  311. },
  312. {
  313. title : '个人订单',
  314. content : '订单为个人订单,请确认订单信息后再接单',
  315. },
  316. {
  317. title : '流失订单',
  318. content : '订单为系统派发,请确认订单信息后再抢单',
  319. },
  320. ]
  321. // 查看宠物信息
  322. const petInfo = () => {
  323. uni.navigateTo({
  324. url: "/otherPages/orderTakingManage/pet/index?id=" + orderDetail.value.order.orderId
  325. })
  326. }
  327. const open = () => {
  328. showConfirmOrder.value = true;
  329. }
  330. const close = () => {
  331. showConfirmOrder.value = false;
  332. }
  333. const orderSuccessClose = () => {
  334. showOrderSuccess.value = false;
  335. };
  336. const orderSuccessOpen = () => {
  337. showOrderSuccess.value = true;
  338. // 重置按钮显示状态,初始只显示复制订单编号按钮
  339. showSecondButton.value = false;
  340. };
  341. // 处理确认按钮点击事件
  342. const handleConfirm = (index) => {
  343. confirmStatus.value[index] = true;
  344. }
  345. const conform = async () => {
  346. if(confirmStatus.value.includes(false)){
  347. uni.showToast({
  348. title: '请点击确认',
  349. icon: "none"
  350. });
  351. return
  352. }
  353. close();
  354. // 重置确认状态
  355. confirmStatus.value = [false, false, false];
  356. let response = await startByOrderId({
  357. id: orderId.value,
  358. userId: userInfo.value.userId
  359. })
  360. if (response.code == 200 && response.data) {
  361. uni.showToast({
  362. title: '接单成功~',
  363. icon: "none"
  364. });
  365. orderSuccessOpen();
  366. }
  367. }
  368. const getDetail = async () => {
  369. let response = await getByOrderId({
  370. id: orderId.value,
  371. userId: userInfo.value.userId,
  372. });
  373. if (response.code == 200 && response.data) {
  374. orderDetail.value = response.data;
  375. let data = response.data.order.h5OrderVO;
  376. //=====================服务项目以及费用的计算开始=====================
  377. let items = []
  378. //1、找出有哪些日期
  379. let days = [...new Set(data.orderServiceList.map(item => item.serviceDate))]
  380. days.forEach(day => {
  381. let price = 0;
  382. let itemsText = []
  383. //2、找出每个日期对应的服务对象
  384. let dayItems = data.orderServiceList.filter(item => item.serviceDate === day)
  385. //3、找出每个服务对象对应的宠物
  386. let pets = data.petVOList.filter(item => dayItems.some(dayItem => dayItem.petId === item.id))
  387. //深度拷贝pets
  388. pets = JSON.parse(JSON.stringify(pets))
  389. //4、将每个服务对象添加进对应的宠物
  390. pets.forEach(pet => {
  391. pet.serviceList = dayItems.filter(item => item.petId === pet.id)
  392. let itemList = []
  393. //5、将每个服务对象中添加对应的项目
  394. pet.serviceList.forEach(item => {
  395. itemList.push(...(data.orderItemList.filter(n => n.orderServiceId == item.id)))
  396. })
  397. itemList.forEach(p => {
  398. price += p.salePrice * p.quantity
  399. itemsText = [...new Set([...itemsText, p.productName])]
  400. })
  401. pet.itemList = itemList
  402. })
  403. //6、将每个宠物添加进items
  404. items.push({
  405. price,
  406. pets,
  407. day,
  408. itemsText,
  409. })
  410. })
  411. //根据日期排序
  412. items = items.sort((a, b) => dayjs(a.day).valueOf() - dayjs(b.day).valueOf())
  413. items.forEach(n => {
  414. n.day = dayjs(n.day).format('MM-DD')
  415. })
  416. console.log(items);
  417. serviceList.value = items
  418. //=====================服务项目以及费用的计算结束=====================
  419. orderDetail.value.order.h5OrderVO.petVOList.forEach(pet => {
  420. pet.productNameText = getProductNameText(pet.id, orderDetail.value.order.h5OrderVO.orderItemList,
  421. orderDetail.value.order.h5OrderVO.orderServiceList)
  422. })
  423. }
  424. }
  425. function getOrderServiceText(petId, orderServiceList){
  426. let YYYY = undefined
  427. return orderServiceList
  428. .filter(service => service.petId == petId)//过滤
  429. .map(service => dayjs(service.serviceDate))//转成时间
  430. .sort((a, b) => a.valueOf() - b.valueOf())//排序
  431. .map((service, i) => {
  432. // if(YYYY && YYYY.format('YYYY-MM') == service.format('YYYY-MM')){
  433. // return service.format('DD')
  434. // }
  435. // if(YYYY && YYYY.format('YYYY') == service.format('YYYY')){
  436. // return service.format('MM-DD')
  437. // }
  438. // YYYY = service
  439. return service.format('MM-DD')
  440. })
  441. }
  442. function getProductNameText(petId, productList, orderServiceList){
  443. let orderService = orderServiceList.filter(service => service.petId == petId)
  444. // return productList
  445. // .filter(product => orderService.filter(service => service.id == product.orderServiceId).length > 0)
  446. // .map(product => {
  447. // return {
  448. // time : dayjs(orderService.filter(service => service.id == product.orderServiceId)
  449. // .serviceDate).format('MM-DD'),
  450. // name : product.productName,
  451. // }
  452. // })
  453. return orderService.map(item => {
  454. let name = ''
  455. productList.forEach(product => {
  456. if(item.id == product.orderServiceId){
  457. name = product.productName
  458. }
  459. })
  460. return {
  461. time : dayjs(item.serviceDate).format('MM-DD'),
  462. name,
  463. }
  464. })
  465. }
  466. function getTextList(){
  467. // return orderDetail.value.order?.h5OrderVO
  468. // .orderServiceList.map(item =>
  469. // dayjs(item.serviceDate).format('MM-DD'))
  470. return serviceList.value.map(n => n.day)
  471. }
  472. const toDetail = (id) => {
  473. uni.navigateTo({
  474. url: `/otherPages/orderTakingManage/pet/detail?id=${id}`
  475. })
  476. }
  477. // 复制订单编号
  478. const noneOrder = () => {
  479. uni.setClipboardData({
  480. data: orderDetail.value.order.orderSn,
  481. success: function() {
  482. uni.showToast({
  483. title: '复制成功',
  484. icon: 'none'
  485. });
  486. // 点击复制按钮后显示第二个按钮
  487. showSecondButton.value = true;
  488. }
  489. });
  490. }
  491. // 跳转到我的订单页面
  492. const toMyOrder = () => {
  493. orderSuccessClose();
  494. uni.switchTab({
  495. url: '/pages/myOrdersManage/index'
  496. });
  497. }
  498. </script>
  499. <style scoped lang="scss">
  500. @import "index";
  501. .line1 {
  502. position: relative;
  503. margin: 10rpx 0 20rpx 0;
  504. &::before {
  505. position: absolute;
  506. top: 10rpx;
  507. left: -10rpx;
  508. content: "";
  509. width: 690rpx;
  510. height: 0.5rpx;
  511. background-color: #EFEFEF;
  512. // background-color: red;
  513. }
  514. }
  515. .time-content {
  516. max-height: 120rpx;
  517. overflow-y: auto;
  518. word-break: break-word;
  519. line-height: 1.5;
  520. padding: 4rpx 0;
  521. }
  522. .order-confirmation {
  523. .confirmation-item {
  524. display: flex;
  525. justify-content: space-between;
  526. align-items: center;
  527. background: white;
  528. padding: 20rpx;
  529. border-radius: 20rpx;
  530. overflow: hidden;
  531. margin: 20rpx 0rpx;
  532. .confirmation-base {
  533. width: 75%;
  534. .title {
  535. font-size: 34rpx;
  536. }
  537. .desc {
  538. color: #999999;
  539. font-size: 28rpx;
  540. margin-top: 20rpx;
  541. }
  542. }
  543. .ok {
  544. display: flex;
  545. justify-content: center;
  546. width: 25%;
  547. .btn {
  548. display: flex;
  549. align-items: center;
  550. justify-content: center;
  551. background: #FFBF60;
  552. color: white;
  553. width: 100%;
  554. font-size: 26rpx;
  555. padding: 15rpx 20rpx;
  556. border-radius: 30rpx;
  557. }
  558. }
  559. }
  560. }
  561. .handbook {
  562. color: #999999;
  563. margin: 10rpx 0rpx;
  564. .text {
  565. color: #FFBF60;
  566. }
  567. }
  568. .success-desc {
  569. text-align: center;
  570. color: #787878;
  571. font-size: 32rpx;
  572. }
  573. .qr-code {
  574. display: flex;
  575. justify-content: center;
  576. margin: 40rpx 0rpx;
  577. .code-img {
  578. width: 160rpx;
  579. height: 160rpx;
  580. }
  581. }
  582. .input {
  583. margin-bottom: 40rpx;
  584. }
  585. .button-group {
  586. display: flex;
  587. align-items: center;
  588. gap: 20rpx;
  589. }
  590. .btn-confirmed {
  591. background: #CCCCCC !important; /* 灰色背景 */
  592. }
  593. </style>