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

673 lines
17 KiB

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