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

676 lines
17 KiB

5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
3 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
3 months ago
5 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
4 months ago
4 months ago
5 months ago
4 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
2 weeks ago
5 months ago
3 months ago
5 months ago
5 months ago
4 months ago
4 months ago
5 months ago
5 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="https://img.xjishu.com/img/zl/2018/6/30/1241359458913.gif"
  236. mode="aspectFill"></image>
  237. </view>
  238. <view class="input">
  239. <up-input placeholder="" border="none" v-model="value" disabled
  240. :customStyle="{height:'60rpx','text-indent': '20rem', 'background-color': '#F3F3F3', position : 'relative','z-index' : '999' }"></up-input>
  241. </view>
  242. <view class="button-group">
  243. <up-button @click="noneOrder" color="#FFBF60" text="复制订单编号" shape="circle"></up-button>
  244. <up-button v-if="showSecondButton" @click="toMyOrder" color="#FFBF60" text="到我的订单查看" shape="circle"></up-button>
  245. </view>
  246. </view>
  247. </up-popup>
  248. <configPopup ref="configPopupRef" />
  249. <!-- 客服组件 -->
  250. <CustomerService />
  251. </template>
  252. <script setup>
  253. import {
  254. ref,
  255. computed
  256. } from 'vue'
  257. import {
  258. onLoad
  259. } from '@dcloudio/uni-app'
  260. import {
  261. getByOrderId
  262. } from "@/api/receivingHall/index.js"
  263. import {
  264. onShow
  265. } from '@dcloudio/uni-app'
  266. import order from '../../../api/order/order'
  267. import {
  268. startByOrderId
  269. } from "@/api/receivingHall/index.js"
  270. import {
  271. useStore
  272. } from "vuex"
  273. import ServiceItems from '@/components/order/ServiceItems.vue'
  274. import dayjs from "dayjs";
  275. import configPopup from '@/components/configPopup.vue'
  276. const configPopupRef = ref(null)
  277. onLoad((options) => {
  278. orderId.value = options.id || null;
  279. pathType.value = options.type || ''
  280. });
  281. onShow(() => {
  282. getDetail();
  283. })
  284. const pathType = ref('')
  285. const store = useStore();
  286. const orderId = ref(null);
  287. const orderDetail = ref({});
  288. const serviceList = ref([]);
  289. const showConfirmOrder = ref(false);
  290. const showOrderSuccess = ref(false);
  291. const value = ref("45619491656")
  292. const petList = ref([])
  293. const confirmStatus = ref([false, false, false]); // 添加确认状态数组,分别对应三个确认项
  294. const showSecondButton = ref(false); // 控制第二个按钮的显示
  295. const userInfo = computed(() => {
  296. return store.getters.userInfo
  297. })
  298. const configList = computed(() => {
  299. return store.getters.configList;
  300. })
  301. // 抢单
  302. const rushToBuyAnOrder = () => {
  303. open()
  304. }
  305. const typeInfo = [
  306. {
  307. title : '系统派单',
  308. content : '订单为系统派发,请确认订单信息后再抢单',
  309. },
  310. {
  311. title : '个人订单',
  312. content : '订单为个人订单,请确认订单信息后再接单',
  313. },
  314. {
  315. title : '流失订单',
  316. content : '订单为系统派发,请确认订单信息后再抢单',
  317. },
  318. ]
  319. // 查看宠物信息
  320. const petInfo = () => {
  321. uni.navigateTo({
  322. url: "/otherPages/orderTakingManage/pet/index?id=" + orderDetail.value.order.orderId
  323. })
  324. }
  325. const open = () => {
  326. showConfirmOrder.value = true;
  327. }
  328. const close = () => {
  329. showConfirmOrder.value = false;
  330. }
  331. const orderSuccessClose = () => {
  332. showOrderSuccess.value = false;
  333. };
  334. const orderSuccessOpen = () => {
  335. showOrderSuccess.value = true;
  336. // 重置按钮显示状态,初始只显示复制订单编号按钮
  337. showSecondButton.value = false;
  338. };
  339. // 处理确认按钮点击事件
  340. const handleConfirm = (index) => {
  341. confirmStatus.value[index] = true;
  342. }
  343. const conform = async () => {
  344. if(confirmStatus.value.includes(false)){
  345. uni.showToast({
  346. title: '请点击确认',
  347. icon: "none"
  348. });
  349. return
  350. }
  351. close();
  352. // 重置确认状态
  353. confirmStatus.value = [false, false, false];
  354. let response = await startByOrderId({
  355. id: orderId.value,
  356. userId: userInfo.value.userId
  357. })
  358. if (response.code == 200 && response.data) {
  359. uni.showToast({
  360. title: '接单成功~',
  361. icon: "none"
  362. });
  363. orderSuccessOpen();
  364. }
  365. }
  366. const getDetail = async () => {
  367. let response = await getByOrderId({
  368. id: orderId.value,
  369. userId: userInfo.value.userId,
  370. });
  371. if (response.code == 200 && response.data) {
  372. orderDetail.value = response.data;
  373. let data = response.data.order.h5OrderVO;
  374. //=====================服务项目以及费用的计算开始=====================
  375. let items = []
  376. //1、找出有哪些日期
  377. let days = [...new Set(data.orderServiceList.map(item => item.serviceDate))]
  378. days.forEach(day => {
  379. let price = 0;
  380. let itemsText = []
  381. //2、找出每个日期对应的服务对象
  382. let dayItems = data.orderServiceList.filter(item => item.serviceDate === day)
  383. //3、找出每个服务对象对应的宠物
  384. let pets = data.petVOList.filter(item => dayItems.some(dayItem => dayItem.petId === item.id))
  385. //深度拷贝pets
  386. pets = JSON.parse(JSON.stringify(pets))
  387. //4、将每个服务对象添加进对应的宠物
  388. pets.forEach(pet => {
  389. pet.serviceList = dayItems.filter(item => item.petId === pet.id)
  390. let itemList = []
  391. //5、将每个服务对象中添加对应的项目
  392. pet.serviceList.forEach(item => {
  393. itemList.push(...(data.orderItemList.filter(n => n.orderServiceId == item.id)))
  394. })
  395. itemList.forEach(p => {
  396. price += p.salePrice * p.quantity
  397. itemsText = [...new Set([...itemsText, p.productName])]
  398. })
  399. pet.itemList = itemList
  400. })
  401. //6、将每个宠物添加进items
  402. items.push({
  403. price,
  404. pets,
  405. day,
  406. itemsText,
  407. })
  408. })
  409. //根据日期排序
  410. items = items.sort((a, b) => dayjs(a.day).valueOf() - dayjs(b.day).valueOf())
  411. items.forEach(n => {
  412. n.day = dayjs(n.day).format('MM-DD')
  413. })
  414. console.log(items);
  415. serviceList.value = items
  416. //=====================服务项目以及费用的计算结束=====================
  417. orderDetail.value.order.h5OrderVO.petVOList.forEach(pet => {
  418. pet.productNameText = getProductNameText(pet.id, orderDetail.value.order.h5OrderVO.orderItemList,
  419. orderDetail.value.order.h5OrderVO.orderServiceList)
  420. })
  421. }
  422. }
  423. function getOrderServiceText(petId, orderServiceList){
  424. let YYYY = undefined
  425. return orderServiceList
  426. .filter(service => service.petId == petId)//过滤
  427. .map(service => dayjs(service.serviceDate))//转成时间
  428. .sort((a, b) => a.valueOf() - b.valueOf())//排序
  429. .map((service, i) => {
  430. // if(YYYY && YYYY.format('YYYY-MM') == service.format('YYYY-MM')){
  431. // return service.format('DD')
  432. // }
  433. // if(YYYY && YYYY.format('YYYY') == service.format('YYYY')){
  434. // return service.format('MM-DD')
  435. // }
  436. // YYYY = service
  437. return service.format('MM-DD')
  438. })
  439. }
  440. function getProductNameText(petId, productList, orderServiceList){
  441. let orderService = orderServiceList.filter(service => service.petId == petId)
  442. // return productList
  443. // .filter(product => orderService.filter(service => service.id == product.orderServiceId).length > 0)
  444. // .map(product => {
  445. // return {
  446. // time : dayjs(orderService.filter(service => service.id == product.orderServiceId)
  447. // .serviceDate).format('MM-DD'),
  448. // name : product.productName,
  449. // }
  450. // })
  451. return orderService.map(item => {
  452. let name = ''
  453. productList.forEach(product => {
  454. if(item.id == product.orderServiceId){
  455. name = product.productName
  456. }
  457. })
  458. return {
  459. time : dayjs(item.serviceDate).format('MM-DD'),
  460. name,
  461. }
  462. })
  463. }
  464. function getTextList(){
  465. // return orderDetail.value.order?.h5OrderVO
  466. // .orderServiceList.map(item =>
  467. // dayjs(item.serviceDate).format('MM-DD'))
  468. return serviceList.value.map(n => n.day)
  469. }
  470. const toDetail = (id) => {
  471. uni.navigateTo({
  472. url: `/otherPages/orderTakingManage/pet/detail?id=${id}`
  473. })
  474. }
  475. // 复制订单编号
  476. const noneOrder = () => {
  477. uni.setClipboardData({
  478. data: orderDetail.value.order.orderSn,
  479. success: function() {
  480. uni.showToast({
  481. title: '复制成功',
  482. icon: 'none'
  483. });
  484. // 点击复制按钮后显示第二个按钮
  485. showSecondButton.value = true;
  486. }
  487. });
  488. }
  489. // 跳转到我的订单页面
  490. const toMyOrder = () => {
  491. orderSuccessClose();
  492. uni.switchTab({
  493. url: '/pages/myOrdersManage/index'
  494. });
  495. }
  496. </script>
  497. <style scoped lang="scss">
  498. @import "index";
  499. .line1 {
  500. position: relative;
  501. margin: 10rpx 0 20rpx 0;
  502. &::before {
  503. position: absolute;
  504. top: 10rpx;
  505. left: -10rpx;
  506. content: "";
  507. width: 690rpx;
  508. height: 0.5rpx;
  509. background-color: #EFEFEF;
  510. // background-color: red;
  511. }
  512. }
  513. .time-content {
  514. max-height: 120rpx;
  515. overflow-y: auto;
  516. word-break: break-word;
  517. line-height: 1.5;
  518. padding: 4rpx 0;
  519. }
  520. .order-confirmation {
  521. .confirmation-item {
  522. display: flex;
  523. justify-content: space-between;
  524. align-items: center;
  525. background: white;
  526. padding: 20rpx;
  527. border-radius: 20rpx;
  528. overflow: hidden;
  529. margin: 20rpx 0rpx;
  530. .confirmation-base {
  531. width: 75%;
  532. .title {
  533. font-size: 34rpx;
  534. }
  535. .desc {
  536. color: #999999;
  537. font-size: 28rpx;
  538. margin-top: 20rpx;
  539. }
  540. }
  541. .ok {
  542. display: flex;
  543. justify-content: center;
  544. width: 25%;
  545. .btn {
  546. display: flex;
  547. align-items: center;
  548. justify-content: center;
  549. background: #FFBF60;
  550. color: white;
  551. width: 100%;
  552. font-size: 26rpx;
  553. padding: 15rpx 20rpx;
  554. border-radius: 30rpx;
  555. }
  556. }
  557. }
  558. }
  559. .handbook {
  560. color: #999999;
  561. margin: 10rpx 0rpx;
  562. .text {
  563. color: #FFBF60;
  564. }
  565. }
  566. .success-desc {
  567. text-align: center;
  568. color: #787878;
  569. font-size: 32rpx;
  570. }
  571. .qr-code {
  572. display: flex;
  573. justify-content: center;
  574. margin: 40rpx 0rpx;
  575. .code-img {
  576. width: 160rpx;
  577. height: 160rpx;
  578. }
  579. }
  580. .input {
  581. margin-bottom: 40rpx;
  582. }
  583. .button-group {
  584. display: flex;
  585. align-items: center;
  586. gap: 20rpx;
  587. }
  588. .btn-confirmed {
  589. background: #CCCCCC !important; /* 灰色背景 */
  590. }
  591. </style>