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

590 lines
14 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. <view class="line1">
  106. </view>
  107. <view class="flex money_total">
  108. <view>
  109. 合计
  110. </view>
  111. <view class="money_text">
  112. ¥&nbsp;{{ orderDetail.order.price }}
  113. </view>
  114. </view>
  115. </view>
  116. <view class="other_information box-size">
  117. <view class="form-title">
  118. 其他信息
  119. </view>
  120. <view class="line1">
  121. </view>
  122. <view class="horizontal_distribution text3">
  123. <view>
  124. 订单编号
  125. </view>
  126. <view>
  127. {{ orderDetail.order.orderSn }}
  128. </view>
  129. </view>
  130. <view class="line1">
  131. </view>
  132. <view class="horizontal_distribution text3">
  133. <view>
  134. 下单时间
  135. </view>
  136. <view>
  137. {{ orderDetail.order?.createTime }}
  138. </view>
  139. </view>
  140. <view class="line1">
  141. </view>
  142. <view class="horizontal_distribution text3">
  143. <view>
  144. 支付时间
  145. </view>
  146. <view>
  147. {{ orderDetail.order.payTime }}
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. <view class="bottom" v-if="pathType != 'my'">
  153. <view @click="rushToBuyAnOrder" class="bottom_button level" :style="{ borderRadius: '41rpx' }">
  154. 立即抢单
  155. </view>
  156. </view>
  157. <up-popup :show="showConfirmOrder" mode="bottom" @close="close" @open="open" :round="10" :closeable="true"
  158. :safeAreaInsetBottom="false"
  159. :customStyle="{padding:'60rpx 20rpx 40rpx 20rpx;position:relative;height:auto;background:#F6F5F8;'}">
  160. <view>
  161. <view style="position:absolute;top: 20rpx;left:0;text-align: center;width: 100%;">
  162. 订单信息
  163. </view>
  164. <view style="text-align: center;">
  165. 请全部确认后接单
  166. </view>
  167. <view class="order-confirmation">
  168. <view class="confirmation-item">
  169. <view class="confirmation-base">
  170. <view class="title">
  171. 服务日期
  172. </view>
  173. <view class="desc">
  174. {{ getTextList().length }}:{{ getTextList().join(',') }}
  175. </view>
  176. </view>
  177. <view class="ok">
  178. <view class="btn" @click="handleConfirm(0)" :class="{ 'btn-confirmed': confirmStatus[0] }">
  179. {{ confirmStatus[0] ? '已确认' : '点击确定' }}
  180. </view>
  181. </view>
  182. </view>
  183. <view class="confirmation-item">
  184. <view class="confirmation-base">
  185. <view class="title">
  186. 服务地址
  187. </view>
  188. <view class="desc">
  189. {{ orderDetail.order.address }}
  190. </view>
  191. </view>
  192. <view class="ok">
  193. <view class="btn" @click="handleConfirm(1)" :class="{ 'btn-confirmed': confirmStatus[1] }">
  194. {{ confirmStatus[1] ? '已确认' : '点击确定' }}
  195. </view>
  196. </view>
  197. </view>
  198. <view class="confirmation-item">
  199. <view class="confirmation-base">
  200. <view class="title">
  201. 服务宠物
  202. </view>
  203. <view class="desc">
  204. <view v-for="pet in orderDetail.order.h5OrderVO.petVOList" :key="pet.id">
  205. {{ pet.breed }}
  206. </view>
  207. </view>
  208. </view>
  209. <view class="ok">
  210. <view class="btn" @click="handleConfirm(2)" :class="{ 'btn-confirmed': confirmStatus[2] }">
  211. {{ confirmStatus[2] ? '已确认' : '点击确定' }}
  212. </view>
  213. </view>
  214. </view>
  215. </view>
  216. <view class="handbook">
  217. 接单即接受
  218. <text class="text" @click="configPopupRef.open('pet_platform_introduction')">伴宠师手册</text>
  219. </view>
  220. <up-button @click="conform" color="#FFBF60" text="确定" shape="circle"></up-button>
  221. </view>
  222. </up-popup>
  223. <!-- 抢单成功 -->
  224. <up-popup :show="showOrderSuccess" mode="center" @close="orderSuccessClose" @open="orderSuccessOpen" :zIndex="999"
  225. :round="10" :safeAreaInsetBottom="false" :customStyle="{ width:'80%' , 'background-color': 'transparent' }">
  226. <view>
  227. <image style="width: 100%;" :src="configList?.order_success?.paramValueImage" mode="widthFix"></image>
  228. </view>
  229. <view style="margin-top: -100%;padding: 40rpx;20rpx">
  230. <view class="success-desc">
  231. {{ configList?.order_success?.paramValueText || '请立即添加服务顾问,并提供订单编码' }}
  232. </view>
  233. <view style="position: relative;z-index: 999;" class="qr-code">
  234. <image class="code-img" src="https://img.xjishu.com/img/zl/2018/6/30/1241359458913.gif"
  235. mode="aspectFill"></image>
  236. </view>
  237. <view class="input">
  238. <up-input placeholder="" border="none" v-model="value" disabled
  239. :customStyle="{height:'60rpx','text-indent': '20rem', 'background-color': '#F3F3F3', position : 'relative','z-index' : '999' }"></up-input>
  240. </view>
  241. <view class="button-group">
  242. <up-button @click="noneOrder" color="#FFBF60" text="复制订单编号" shape="circle"></up-button>
  243. <up-button v-if="showSecondButton" @click="toMyOrder" color="#FFBF60" text="到我的订单查看" shape="circle"></up-button>
  244. </view>
  245. </view>
  246. </up-popup>
  247. <configPopup ref="configPopupRef" />
  248. </template>
  249. <script setup>
  250. import {
  251. ref,
  252. computed
  253. } from 'vue'
  254. import {
  255. onLoad
  256. } from '@dcloudio/uni-app'
  257. import {
  258. getByOrderId
  259. } from "@/api/receivingHall/index.js"
  260. import {
  261. onShow
  262. } from '@dcloudio/uni-app'
  263. import order from '../../../api/order/order'
  264. import {
  265. startByOrderId
  266. } from "@/api/receivingHall/index.js"
  267. import {
  268. useStore
  269. } from "vuex"
  270. import dayjs from "dayjs";
  271. import configPopup from '@/components/configPopup.vue'
  272. const configPopupRef = ref(null)
  273. onLoad((options) => {
  274. orderId.value = options.id || null;
  275. pathType.value = options.type || ''
  276. });
  277. onShow(() => {
  278. getDetail();
  279. })
  280. const pathType = ref('')
  281. const store = useStore();
  282. const orderId = ref(null);
  283. const orderDetail = ref({});
  284. const showConfirmOrder = ref(false);
  285. const showOrderSuccess = ref(false);
  286. const value = ref("45619491656")
  287. const petList = ref([])
  288. const confirmStatus = ref([false, false, false]); // 添加确认状态数组,分别对应三个确认项
  289. const showSecondButton = ref(false); // 控制第二个按钮的显示
  290. const userInfo = computed(() => {
  291. return store.getters.userInfo
  292. })
  293. const configList = computed(() => {
  294. return store.getters.configList;
  295. })
  296. // 抢单
  297. const rushToBuyAnOrder = () => {
  298. open()
  299. }
  300. const typeInfo = [
  301. {
  302. title : '系统派单',
  303. content : '订单为系统派发,请确认订单信息后再抢单',
  304. },
  305. {
  306. title : '个人订单',
  307. content : '订单为系统派发,请确认订单信息后再抢单',
  308. },
  309. {
  310. title : '流失订单',
  311. content : '订单为系统派发,请确认订单信息后再抢单',
  312. },
  313. ]
  314. // 查看宠物信息
  315. const petInfo = () => {
  316. uni.navigateTo({
  317. url: "/otherPages/orderTakingManage/pet/index"
  318. })
  319. }
  320. const open = () => {
  321. showConfirmOrder.value = true;
  322. }
  323. const close = () => {
  324. showConfirmOrder.value = false;
  325. }
  326. const orderSuccessClose = () => {
  327. showOrderSuccess.value = false;
  328. };
  329. const orderSuccessOpen = () => {
  330. showOrderSuccess.value = true;
  331. // 重置按钮显示状态,初始只显示复制订单编号按钮
  332. showSecondButton.value = false;
  333. };
  334. // 处理确认按钮点击事件
  335. const handleConfirm = (index) => {
  336. confirmStatus.value[index] = true;
  337. }
  338. const conform = async () => {
  339. if(confirmStatus.value.includes(false)){
  340. uni.showToast({
  341. title: '请点击确认',
  342. icon: "none"
  343. });
  344. return
  345. }
  346. close();
  347. // 重置确认状态
  348. confirmStatus.value = [false, false, false];
  349. let response = await startByOrderId({
  350. id: orderId.value,
  351. userId: userInfo.value.userId
  352. })
  353. if (response.code == 200 && response.data) {
  354. uni.showToast({
  355. title: '接单成功~',
  356. icon: "none"
  357. });
  358. orderSuccessOpen();
  359. }
  360. }
  361. const getDetail = async () => {
  362. let response = await getByOrderId({
  363. id: orderId.value,
  364. userId: userInfo.value.userId,
  365. });
  366. if (response.code == 200 && response.data) {
  367. orderDetail.value = response.data;
  368. orderDetail.value.order.h5OrderVO.petVOList.forEach(pet => {
  369. pet.productNameText = getProductNameText(pet.id, orderDetail.value.order.h5OrderVO.orderItemList,
  370. orderDetail.value.order.h5OrderVO.orderServiceList)
  371. })
  372. }
  373. }
  374. function getOrderServiceText(petId, orderServiceList){
  375. let YYYY = undefined
  376. return orderServiceList
  377. .filter(service => service.petId == petId)//过滤
  378. .map(service => dayjs(service.serviceDate))//转成时间
  379. .sort((a, b) => a.valueOf() - b.valueOf())//排序
  380. .map((service, i) => {
  381. // if(YYYY && YYYY.format('YYYY-MM') == service.format('YYYY-MM')){
  382. // return service.format('DD')
  383. // }
  384. // if(YYYY && YYYY.format('YYYY') == service.format('YYYY')){
  385. // return service.format('MM-DD')
  386. // }
  387. // YYYY = service
  388. return service.format('MM-DD')
  389. })
  390. }
  391. function getProductNameText(petId, productList, orderServiceList){
  392. let orderService = orderServiceList.filter(service => service.petId == petId)
  393. // return productList
  394. // .filter(product => orderService.filter(service => service.id == product.orderServiceId).length > 0)
  395. // .map(product => {
  396. // return {
  397. // time : dayjs(orderService.filter(service => service.id == product.orderServiceId)
  398. // .serviceDate).format('MM-DD'),
  399. // name : product.productName,
  400. // }
  401. // })
  402. return orderService.map(item => {
  403. let name = ''
  404. productList.forEach(product => {
  405. if(item.id == product.orderServiceId){
  406. name = product.productName
  407. }
  408. })
  409. return {
  410. time : dayjs(item.serviceDate).format('MM-DD'),
  411. name,
  412. }
  413. })
  414. }
  415. function getTextList(){
  416. return orderDetail.value.order?.h5OrderVO
  417. .orderServiceList.map(item =>
  418. dayjs(item.serviceDate).format('MM-DD'))
  419. }
  420. const toDetail = (id) => {
  421. uni.navigateTo({
  422. url: `/otherPages/orderTakingManage/pet/detail?id=${id}`
  423. })
  424. }
  425. // 复制订单编号
  426. const noneOrder = () => {
  427. uni.setClipboardData({
  428. data: orderDetail.value.order.orderSn,
  429. success: function() {
  430. uni.showToast({
  431. title: '复制成功',
  432. icon: 'none'
  433. });
  434. // 点击复制按钮后显示第二个按钮
  435. showSecondButton.value = true;
  436. }
  437. });
  438. }
  439. // 跳转到我的订单页面
  440. const toMyOrder = () => {
  441. orderSuccessClose();
  442. uni.switchTab({
  443. url: '/pages/myOrdersManage/index'
  444. });
  445. }
  446. </script>
  447. <style scoped lang="scss">
  448. @import "index";
  449. .line1 {
  450. position: relative;
  451. margin: 10rpx 0 20rpx 0;
  452. &::before {
  453. position: absolute;
  454. top: 10rpx;
  455. left: -10rpx;
  456. content: "";
  457. width: 690rpx;
  458. height: 0.5rpx;
  459. background-color: #EFEFEF;
  460. // background-color: red;
  461. }
  462. }
  463. .time-content {
  464. max-height: 120rpx;
  465. overflow-y: auto;
  466. word-break: break-word;
  467. line-height: 1.5;
  468. padding: 4rpx 0;
  469. }
  470. .order-confirmation {
  471. .confirmation-item {
  472. display: flex;
  473. justify-content: space-between;
  474. align-items: center;
  475. background: white;
  476. padding: 20rpx;
  477. border-radius: 20rpx;
  478. overflow: hidden;
  479. margin: 20rpx 0rpx;
  480. .confirmation-base {
  481. width: 75%;
  482. .title {
  483. font-size: 34rpx;
  484. }
  485. .desc {
  486. color: #999999;
  487. }
  488. }
  489. .ok {
  490. display: flex;
  491. justify-content: center;
  492. width: 25%;
  493. .btn {
  494. display: flex;
  495. align-items: center;
  496. justify-content: center;
  497. background: #FFBF60;
  498. color: white;
  499. width: 100%;
  500. height: 60rpx;
  501. border-radius: 30rpx;
  502. }
  503. }
  504. }
  505. }
  506. .handbook {
  507. color: #999999;
  508. margin: 10rpx 0rpx;
  509. .text {
  510. color: #FFBF60;
  511. }
  512. }
  513. .success-desc {
  514. text-align: center;
  515. color: #787878;
  516. font-size: 32rpx;
  517. }
  518. .qr-code {
  519. display: flex;
  520. justify-content: center;
  521. margin: 40rpx 0rpx;
  522. .code-img {
  523. width: 160rpx;
  524. height: 160rpx;
  525. }
  526. }
  527. .input {
  528. margin-bottom: 40rpx;
  529. }
  530. .button-group {
  531. display: flex;
  532. align-items: center;
  533. gap: 20rpx;
  534. }
  535. .btn-confirmed {
  536. background: #CCCCCC !important; /* 灰色背景 */
  537. }
  538. </style>