goodsDetails.vue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444
  1. <template>
  2. <view>
  3. <view>
  4. <Detiles></Detiles>
  5. <up-card
  6. title="服务描述"
  7. :thumb="thumb"
  8. :head-style="{ height: '80rpx', padding: '20rpx', fontWeight: 'bold' }"
  9. >
  10. <template #body>
  11. <view class="service-description-container">
  12. <view class="service-text">{{ listData.businessDescribe }}</view>
  13. <view class="service-price-tag">¥{{ listData.businessPrice }}</view>
  14. </view>
  15. </template>
  16. </up-card>
  17. </view>
  18. <view>
  19. <up-card
  20. title="志愿者介绍"
  21. :head-style="{ height: '80rpx', padding: '20rpx', fontWeight: 'bold' }"
  22. >
  23. <template #body>
  24. <view class="volunteer-card">
  25. <!-- 左侧图片 -->
  26. <image
  27. class="volunteer-image"
  28. :src="listData.volunteerPicture"
  29. mode="aspectFill"
  30. ></image>
  31. <!-- 中间信息(姓名/类别等) -->
  32. <view class="volunteer-info">
  33. <view class="info-row">
  34. <text class="info-label">姓名:</text>
  35. <text class="info-value">{{ listData.name }}</text>
  36. </view>
  37. <view class="info-row">
  38. <text class="info-label">服务项目:</text>
  39. <text class="info-value">{{ listData.businessTierName }}</text>
  40. </view>
  41. <view v-if="serviceSubjectName != null" class="info-row">
  42. <text class="info-label">类别:</text>
  43. <text class="info-value">{{ listData.projectTypeName }}</text>
  44. </view>
  45. <view class="info-row">
  46. <text class="info-label">服务时长:</text>
  47. <text class="info-value">{{ listData.businessDuration }}</text>
  48. </view>
  49. <view class="info-row">
  50. <text class="info-label">电话:</text>
  51. <text class="info-value">{{ listData.phonenumber }}</text>
  52. </view>
  53. </view>
  54. <!-- 右上角评分 -->
  55. <view class="volunteer-rating">
  56. <text class="rating-text">4.5</text>
  57. <text class="rating-label">评分</text>
  58. </view>
  59. </view>
  60. </template>
  61. </up-card>
  62. <up-card
  63. title="技能介绍"
  64. :thumb="thumb"
  65. :head-style="{ height: '80rpx', padding: '20rpx', fontWeight: 'bold' }"
  66. >
  67. <template #body>
  68. <view class="skill-description">
  69. {{ listData.skillDescribe }}
  70. </view>
  71. </template>
  72. </up-card>
  73. <up-card
  74. title="证书"
  75. :thumb="thumb"
  76. :head-style="{ height: '80rpx', padding: '20rpx' }"
  77. >
  78. <template #body>
  79. <view class="certificate">
  80. <image
  81. v-for="item in certificationPictures"
  82. :key="item"
  83. :src="item"
  84. mode=""
  85. style="width: 100%"
  86. class="certificate-img"
  87. ></image>
  88. </view>
  89. </template>
  90. </up-card>
  91. <!-- 固定底部按钮区 -->
  92. <view class="Wrap-btn">
  93. <uni-goods-nav
  94. :fill="true"
  95. :options="options"
  96. :buttonGroup="buttonGroup"
  97. @click="onClick"
  98. @buttonClick="buttonClick"
  99. />
  100. </view>
  101. </view>
  102. <!-- 底部第一层弹框 -->
  103. <view>
  104. <up-popup :show="show" @close="close" @open="open"> </up-popup>
  105. <up-popup :show="show" @open="upPopupOpen" :custom-style="popupStyle">
  106. <scroll-view scroll-y class="popup-scroll-content">
  107. <view>
  108. <view class="Wrapper">
  109. <image src="/static/img/Location.png" class="Wrapper-img" />
  110. <span class="Wrapper-content">李四</span>
  111. <span class="Wrapper-content">重庆永川区</span>
  112. </view>
  113. <span style="margin-left: 15rpx; margin-top: 50rpx">重庆永川区</span>
  114. </view>
  115. <up-divider></up-divider>
  116. <view class="Wrap-content1">
  117. <up-avatar :src="src"></up-avatar>
  118. <text class="service-price">¥{{ businessPrice }}</text>
  119. </view>
  120. <view class="service-info-item">
  121. <text class="service-label">服务类别:</text>
  122. <up-text type="info" class="service-value" text="家庭教育"></up-text>
  123. </view>
  124. <view class="service-info-item">
  125. <text class="service-label">上门服务次数:</text>
  126. <up-number-box
  127. :modelValue="singleQuantity"
  128. :min="listData.minQuantity"
  129. :max="minQuantityMax"
  130. class="service-number-box"
  131. @change="valChange"
  132. ></up-number-box>
  133. <view class="service-values">{{ listData.minQuantity + listData.businessUnit }}</view>
  134. </view>
  135. <view class="service-period">
  136. <text class="service-label">服务周期:</text>
  137. <view class="date-picker-container">
  138. <uniDatetimePickerMy
  139. :modelValue="doorToDoorTime"
  140. :start="startDisabled"
  141. :end="endDisabled"
  142. type="daterange"
  143. ></uniDatetimePickerMy>
  144. </view>
  145. <view>
  146. <!-- :businessDuration="listData.businessDuration" -->
  147. <its-calendar
  148. v-if="show"
  149. ref="itsCalendarRef"
  150. :businessDuration="businessDurationComputed"
  151. :minQuantity="singleQuantity"
  152. :timeArr="doorToDoorTimeArr"
  153. :timeHostArr="timeHostArr"
  154. :businessTierName="listData.businessTierName"
  155. class="calendar-component"
  156. @getByDate="getByDate"
  157. @getByTime="getByTime"
  158. ></its-calendar>
  159. </view>
  160. </view>
  161. <view class="remark-container">
  162. <text class="service-label">备注:</text>
  163. <up-input
  164. placeholder="请输入内容"
  165. border="surround"
  166. v-model="remark"
  167. class="remark-input"
  168. @change="change"
  169. ></up-input>
  170. </view>
  171. <!-- 保持内容底部有足够的空白以避免按钮遮挡内容 -->
  172. <view style="height: 120rpx;"></view>
  173. </scroll-view>
  174. <!-- 将按钮移到scroll-view外部,但保持在popup内 -->
  175. <view class="popup-fixed-bottom">
  176. <up-button
  177. type="primary"
  178. shape="circle"
  179. :customStyle="wrapqx"
  180. @click="handlCancel"
  181. >取消</up-button
  182. >
  183. <up-button
  184. type="error"
  185. shape="circle"
  186. :customStyle="wrapqx"
  187. @click="handleBuy"
  188. >
  189. 预约¥{{ computeMoney }}
  190. </up-button>
  191. </view>
  192. </up-popup>
  193. </view>
  194. <!-- 第二个弹框-->
  195. <up-popup :show="showSecond">
  196. <view>
  197. <up-cell-group>
  198. <view
  199. @click="jumpToAddressSelect"
  200. style="display: flex; align-items: center; padding: 10px"
  201. >
  202. <up-icon name="more-dot-fill" size="16" />
  203. <view v-if="selectedAddress" style="margin-left: 8px; flex: 1">
  204. <view class="address-display">
  205. <text class="address-line">
  206. {{ selectedAddress.provinceName }}{{ selectedAddress.cityName
  207. }}{{ selectedAddress.districtName }}
  208. </text>
  209. <view class="contact-info">
  210. <text class="contact-name">{{ selectedAddress.name }}</text>
  211. <text class="contact-phone">{{
  212. selectedAddress.telephone
  213. }}</text>
  214. </view>
  215. </view>
  216. </view>
  217. <text v-else style="margin-left: 8px; font-size: 18px"
  218. >请选择服务地址</text
  219. >
  220. </view>
  221. <scroll-view scroll-y style="height: 460rpx">
  222. <view
  223. class="card-container"
  224. v-for="(item, index) in selectedTimes"
  225. :key="index"
  226. >
  227. <image
  228. class="card-image"
  229. :src="listData.volunteerPicture"
  230. mode="aspectFill"
  231. ></image>
  232. <view class="card-content">
  233. <view class="info-item"
  234. >服务项目:{{ listData.projectName }}</view
  235. >
  236. <view class="Telephone"
  237. >服务时长:{{ listData.businessDuration }}</view
  238. >
  239. <view class="date">日期:{{ item.date }}</view>
  240. <view class="time"> 时间:{{ item.time }} </view>
  241. </view>
  242. </view>
  243. </scroll-view>
  244. </up-cell-group>
  245. </view>
  246. <view class="Wrap-Payment">
  247. <!-- 支付金额 -->
  248. <view class="payment-header">
  249. <text class="payment-title">现在支付</text>
  250. <text class="payment-amount">¥{{ computeMoney }}</text>
  251. </view>
  252. <up-line></up-line>
  253. <!-- 钱包支付选项 -->
  254. <view class="payment-option">
  255. <view class="option-left">
  256. <image src="/static/钱包.png" class="payment-icon"></image>
  257. <text class="option-text">钱包</text>
  258. </view>
  259. <up-radio-group
  260. v-model="radiovalue1"
  261. placement="column"
  262. @change="handlePaymentMethodChange"
  263. >
  264. <up-radio
  265. :customStyle="{ marginLeft: 'auto' }"
  266. v-for="(item, index) in radiolist1"
  267. :key="index"
  268. :label="item.name"
  269. :name="item.name"
  270. ></up-radio>
  271. </up-radio-group>
  272. </view>
  273. <up-line></up-line>
  274. <!-- 微信支付选项 -->
  275. <view class="payment-option">
  276. <view class="option-left">
  277. <image src="/static/微信支付.png" class="payment-icon"></image>
  278. <text class="option-text">微信支付</text>
  279. </view>
  280. <up-radio-group
  281. v-model="radiovalue1"
  282. placement="column"
  283. @change="handlePaymentMethodChange"
  284. >
  285. <up-radio
  286. :customStyle="{ marginLeft: 'auto' }"
  287. v-for="(item, index) in radiolist2"
  288. :key="index"
  289. :label="item.name"
  290. :name="item.name"
  291. ></up-radio>
  292. </up-radio-group>
  293. </view>
  294. <up-line></up-line>
  295. <!-- 其他支付方式 -->
  296. <view class="other-payment">
  297. <text class="other-payment-text">其他方式支付</text>
  298. <up-icon name="arrow-right" size="14" color="#1890ff"></up-icon>
  299. </view>
  300. <!-- 条款说明 -->
  301. <view class="terms-of-service">
  302. 我同意购买守则,取消政策和退款政策,我也同意支付以下所示的总金额(含服务费)。
  303. </view>
  304. </view>
  305. <view class="Wrap-detils-btn">
  306. <up-button
  307. type="primary"
  308. shape="circle"
  309. :customStyle="wrapqx"
  310. @click="closeSecond"
  311. >取消</up-button
  312. >
  313. <up-button
  314. type="error"
  315. shape="circle"
  316. :customStyle="wrapqx"
  317. @click="handlConfiRmpurchase"
  318. >
  319. 购买¥{{ computeMoney }}
  320. </up-button>
  321. </view>
  322. </up-popup>
  323. <view v-if="addressFlag" class="box">
  324. <addressComponent
  325. :modelValue="addressFlag"
  326. @update:modelValue="(val) => (addressFlag = val)"
  327. :addressInfo="addressInfo"
  328. @update:addressInfo="handleAddressUpdate"
  329. ></addressComponent>
  330. </view>
  331. </view>
  332. </template>
  333. <script setup>
  334. import { onLoad } from '@dcloudio/uni-app'
  335. import { onMounted, ref, reactive, computed, nextTick } from 'vue'
  336. import {
  337. getDetailsvolunteerId,
  338. volunteerwork,
  339. volunteergetTimesByDate,
  340. ordersCreateOrder,
  341. coreUsersOrdersPayCancel,
  342. } from '@/api/volunteerDetailsApi/details.js'
  343. import itsCalendar from '@/components/its-calendar/its-calendar.vue'
  344. import uniDatetimePickerMy from '@/uni_modules/lic-uni-datetime-picker/components/lic-uni-datetime-picker/lic-uni-datetime-picker.vue'
  345. import addressComponent from '@/pages_home/components/volunteerData/adresss.vue'
  346. import Detiles from './detiles.vue'
  347. // const src = ref(
  348. // 'http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg'
  349. // )
  350. const itsCalendarRef = ref(null)
  351. const businessPrice = ref() //价格
  352. const singleQuantity = ref(1) // 购买次数,默认为1,不可为0
  353. const volunteerId = ref('') // 存储志愿者ID
  354. const serviceCategory = ref('') //存储大类别
  355. const businessManagementId = ref('') //具体分类id
  356. const doorToDoorTimeArr = ref([]) // 完整时间范围
  357. const doorToDoorTime = ref([]) // 只具备开始、结束 时间
  358. const timeHostArr = ref([]) // 时间段数组
  359. const currentDate = ref([]) // 点击过的年月日数组数据
  360. const currentTime = ref('') // 最后一次点击时间的时间节点
  361. const selectedTimes = ref([]) // 存储所有选择的时间对象
  362. const totalTimes = ref(0) // 时间点 点击的次数
  363. const startDisabled = ref('')
  364. const endDisabled = ref('')
  365. const listData = ref({})
  366. const show = ref(false) //第一层弹框
  367. const showSecond = ref(false) //第二层弹框
  368. const remark = ref('') //备注
  369. const radiovalue1 = ref(null)
  370. const selectedAddress = ref(null)
  371. const addressFlag = ref(false)
  372. const paymentMethod = ref(null) // Add payment method ref with default value 1 (wallet)
  373. const addressInfo = ref(null)
  374. const value = ref(1) // 将在onLoad中更新为listData.minQuantity
  375. const minQuantityMax = ref(99999) // 步进器最大值控制变量
  376. // Radio 单选框数据
  377. const radiolist1 = reactive([
  378. {
  379. name: '钱包支付',
  380. disabled: false,
  381. },
  382. ])
  383. const radiolist2 = reactive([
  384. {
  385. name: '微信支付',
  386. disabled: false,
  387. },
  388. ])
  389. const businessDurationComputed = computed(() => {
  390. // listData.value.businessDuration
  391. let result = 0
  392. if (listData.value.businessDuration < 30) {
  393. result = 30
  394. } else {
  395. const num = Math.floor(listData.value.businessDuration / 30)
  396. result = (num + 1) * 30
  397. }
  398. console.log(result, '>>>>>>>result')
  399. return result
  400. })
  401. // 设置第一个弹框的样式
  402. const popupStyle = {
  403. height: '80vh', // 设置为视窗高度的80%
  404. overflow: 'hidden', // 防止内容溢出
  405. position: 'relative', // 需要这个来支持内部的绝对定位元素
  406. }
  407. // 详情底部立即购买弹框
  408. const buttonClick = (e) => {
  409. show.value = true // 打开弹框
  410. }
  411. // 详情页第一层弹框
  412. function open() {
  413. show.value = true
  414. }
  415. // 第一层弹框取消
  416. function close() {
  417. // 关闭逻辑,设置 show 为 false
  418. show.value = false
  419. }
  420. // 第一个弹框逻辑
  421. const handleBuy = () => {
  422. console.log(selectedTimes.value, '>>>>>>selectedTimes.value')
  423. if (selectedTimes.value.length === 0) {
  424. uni.showToast({
  425. title: '请选择服务时间',
  426. icon: 'none',
  427. })
  428. return
  429. }
  430. show.value = false // 关闭第一个弹框
  431. showSecond.value = true // 打开第二个弹框
  432. }
  433. // 第二层弹框取消
  434. function closeSecond() {
  435. // 关闭逻辑,设置 show 为 false
  436. showSecond.value = false
  437. show.value = true // 打开第一个弹框
  438. }
  439. const handlCancel = () => {
  440. show.value = false // 关闭第一个弹框
  441. selectedTimes.value = [] // 清空已选时间
  442. totalTimes.value = 0 // 重置点击次数
  443. }
  444. const jumpToAddressSelect = () => {
  445. addressFlag.value = true
  446. }
  447. // 新增:处理子组件传回的地址数据
  448. const handleAddressUpdate = (newAddress) => {
  449. selectedAddress.value = newAddress
  450. addressFlag.value = false // 关闭选择器
  451. }
  452. // 详情底部底部数据
  453. const options = ref([
  454. {
  455. icon: 'headphones',
  456. text: '客服',
  457. },
  458. {
  459. icon: 'shop',
  460. text: '收藏',
  461. },
  462. ])
  463. // 详情底部立即购买样式
  464. const buttonGroup = ref([
  465. {
  466. text: '立即购买',
  467. backgroundColor: 'red',
  468. color: '#fff',
  469. },
  470. ])
  471. // 底部帮助客服方法
  472. const onClick = (e) => {
  473. uni.showToast({
  474. title: `点击${e.content.text}`,
  475. icon: 'none',
  476. })
  477. }
  478. // 修改详情页底部样式
  479. const customStyle = {
  480. height: '70rpx',
  481. paddingLeft: '30rpx',
  482. width: '540rpx',
  483. }
  484. const wrapqx = {
  485. // height: '70rpx',
  486. width: '240rpx',
  487. }
  488. // 获取传递的参数
  489. onLoad(async (options) => {
  490. const option = JSON.parse(decodeURIComponent(options.params))
  491. const {
  492. volunteerId: id,
  493. serviceCategory: categoy,
  494. businessManagementId: manage,
  495. } = option
  496. volunteerId.value = id
  497. serviceCategory.value = categoy
  498. businessManagementId.value = manage
  499. const res = await getDetailsvolunteerId({
  500. volunteerId: id,
  501. serviceCategory: categoy,
  502. businessManagementId: manage,
  503. })
  504. listData.value = res.data || {}
  505. // 更新步进器的初始值为listData中的minQuantity
  506. value.value = listData.value.minQuantity || 1
  507. businessPrice.value = listData.value.businessPrice || 0
  508. singleQuantity.value = listData.value.minQuantity || 1
  509. })
  510. // 添加步进器值变化处理函数
  511. const valChange = (obj) => {
  512. // const durationMs = listData.value.businessDuration * obj.value * 60
  513. const durationMs = businessDurationComputed.value * obj.value * 60
  514. const a = itsCalendarRef.value.upItem
  515. const b = itsCalendarRef.value.timeHostArr
  516. const c = itsCalendarRef.value.day_index
  517. // const seconds = listData.value.businessDuration * obj.value * 60
  518. const seconds = businessDurationComputed.value * obj.value * 60
  519. const endTimestamp = a.timeStamp + durationMs
  520. // 根据当前时间分割出后续应选数据数组
  521. const filteredSlots = b[c].filter((i) => {
  522. return i.timeStamp > a.timeStamp && i.timeStamp <= endTimestamp
  523. })
  524. const timestampDifferenceValue = filteredSlots.length
  525. ? filteredSlots[filteredSlots.length - 1].timeStamp - a.timeStamp
  526. : 0
  527. // console.log(filteredSlots, '>>>>>filteredSlots')
  528. if (timestampDifferenceValue < durationMs) {
  529. minQuantityMax.value = obj.value - 1
  530. // 所选时间差值 小于 服务时间值 结束执行
  531. uni.showToast({ title: '所选时间的服务时间不充足!', icon: 'none' })
  532. return false
  533. }
  534. singleQuantity.value = obj.value || 1
  535. nextTick(() => {
  536. itsCalendarRef.value.handleTimeClick2()
  537. })
  538. }
  539. // 选择日期
  540. const getListTime = async () => {
  541. const params = {
  542. volunteerId: Number(volunteerId.value),
  543. }
  544. const res = await volunteerwork(params)
  545. if (res.data && res.data.length > 0) {
  546. doorToDoorTimeArr.value = res.data
  547. const newRes = [res.data[0], res.data[res.data.length - 1]]
  548. doorToDoorTime.value = newRes
  549. startDisabled.value = doorToDoorTime.value[0]
  550. endDisabled.value = doorToDoorTime.value[1]
  551. // 默认加载第一个日期的排班时间
  552. getByDate(res.data[0])
  553. } else {
  554. console.error('接口返回的日期范围为空')
  555. doorToDoorTimeArr.value = []
  556. timeHostArr.value = [] // 清空时间段
  557. }
  558. }
  559. // 获取志愿者排班时间
  560. const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
  561. // 检查日期是否为空
  562. if (!date) {
  563. coannsole.error('日期为空,跳过获取排班时间')
  564. return
  565. }
  566. if (!volunteerId.value) {
  567. console.error('volunteerId 为空')
  568. return
  569. }
  570. const params = {
  571. volunteerId: volunteerId.value,
  572. date,
  573. }
  574. try {
  575. const res = await volunteergetTimesByDate(params)
  576. const TArr = res.data.map((item) => {
  577. // 初始化disabled变量
  578. let disabled = false
  579. if (item.hasReservation === 1) disabled = true
  580. let itemTime =
  581. item.timeStamp > 9999999999 ? item.timeStamp : item.timeStamp * 1000
  582. if (new Date().getTime() > itemTime) disabled = true
  583. return {
  584. ...item,
  585. hours: item.reservationTime,
  586. timeStamp: new Date(`${date} ${item.reservationTime}`).getTime() / 1000,
  587. date: date,
  588. // checked: false, // 每次点击请求时间后,延续之前选中状态,不初始化选中
  589. disabled,
  590. }
  591. })
  592. // 如果 doorToDoorTimeArr.value 为空,直接返回
  593. if (!doorToDoorTimeArr.value.length) {
  594. console.error('可选的日期范围为空')
  595. return
  596. }
  597. // 填充时间段数组
  598. timeHostArr.value = Array(doorToDoorTimeArr.value.length).fill(TArr)
  599. } catch (error) {
  600. console.error('获取排班时间失败:', error)
  601. }
  602. }
  603. const getByTime = (timeObj) => {
  604. if (timeObj.clicked) {
  605. return
  606. }
  607. if (timeObj.checked) {
  608. // 选中 添加到已选时间数组
  609. selectedTimes.value.push({
  610. date: timeObj.date,
  611. time: timeObj.hours,
  612. timestamp: timeObj.timeStamp,
  613. })
  614. } else {
  615. // 取消选中
  616. const index = selectedTimes.value.findIndex(
  617. (item) => item.timestamp === timeObj.timeStamp
  618. )
  619. selectedTimes.value.splice(index, 1)
  620. }
  621. totalTimes.value = selectedTimes.value.length // 更新点击次数
  622. }
  623. // 立即购买显示时执行
  624. const upPopupOpen = () => {
  625. //显示时初始化预存储信息数据
  626. selectedTimes.value = []
  627. totalTimes.value = 0
  628. currentTime.value = ''
  629. currentDate.value = []
  630. // 初始化disabled/checked 数据状态
  631. getByDate()
  632. }
  633. const computeMoney = computed(() => {
  634. // console.log(
  635. // totalTimes.value,
  636. // businessPrice.value,
  637. // singleQuantity.value,
  638. // '>>>>>> console.log(totalTimes.value * businessPrice.value * minQuantity.value);'
  639. // )
  640. return totalTimes.value * businessPrice.value * singleQuantity.value
  641. })
  642. const certificationPictures = computed(() => {
  643. if (listData.value.certificationPicture) {
  644. return listData.value.certificationPicture.split(',')
  645. }
  646. return []
  647. })
  648. // 确认购买
  649. const handlConfiRmpurchase = () => {
  650. if (!selectedAddress.value) {
  651. uni.showToast({
  652. title: '请选择服务地址',
  653. icon: 'none',
  654. duration: 2000,
  655. })
  656. return // 阻止购买
  657. } else if (!paymentMethod.value) {
  658. uni.showToast({
  659. title: '请选择支付方式',
  660. icon: 'none',
  661. duration: 2000,
  662. })
  663. return // 阻止购买
  664. }
  665. // 如果有地址,执行购买逻辑
  666. proceedToPayment()
  667. }
  668. const proceedToPayment = async () => {
  669. try {
  670. // 定义要发送的数据
  671. const orderData = {
  672. orders: {
  673. // serviceOnePrice: businessPrice.value,
  674. // serviceTotalPrice: computeMoney.value,
  675. serviceCategory: serviceCategory.value,
  676. totalTimes: totalTimes.value,
  677. paymentMethod: paymentMethod.value,
  678. volunteerId: volunteerId.value,
  679. remark: remark.value,
  680. businessManagementId: businessManagementId.value,
  681. volunteerInfoId: listData.value.volunteerInfoId,
  682. addressId: selectedAddress.value.addressId,
  683. singleQuantity: singleQuantity.value,
  684. },
  685. workDateList: [],
  686. }
  687. // 转换所有选择的时间
  688. selectedTimes.value.forEach((item) => {
  689. orderData.workDateList.push({
  690. workDate: item.date,
  691. workStartTime: item.time,
  692. })
  693. })
  694. // 创建订单
  695. const res = await ordersCreateOrder(orderData)
  696. if (res.code !== 200) {
  697. throw new Error('创建订单失败')
  698. }
  699. // 保存订单号
  700. const mainOrderId = res.data.mainOrderId
  701. // console.log('创建订单成功,订单号:', mainOrderId)
  702. // 如果是微信支付
  703. if (paymentMethod.value === 2) {
  704. return new Promise((resolve, reject) => {
  705. uni.requestPayment({
  706. ...res.data,
  707. package: res.data.packageValue,
  708. success: (payRes) => {
  709. // console.log('支付成功:', payRes)
  710. if (payRes.errMsg === 'requestPayment:ok') {
  711. uni.showToast({
  712. title: '支付成功',
  713. icon: 'success',
  714. duration: 1500,
  715. mask: true,
  716. })
  717. setTimeout(() => {
  718. uni.reLaunch({
  719. url: '/pages/classify',
  720. })
  721. }, 1500)
  722. resolve(payRes)
  723. }
  724. },
  725. fail: async (payRes) => {
  726. // console.log('支付失败或取消:', payRes)
  727. try {
  728. // 调用取消支付接口
  729. const cancelRes = await coreUsersOrdersPayCancel({ mainOrderId })
  730. // console.log('取消支付接口调用成功:', cancelRes)
  731. if (payRes.errMsg === 'requestPayment:fail cancel') {
  732. uni.showToast({
  733. title: '已取消支付',
  734. icon: 'none',
  735. duration: 1500,
  736. mask: true,
  737. })
  738. } else {
  739. uni.showToast({
  740. title:error.response?.data?.msg,
  741. icon: 'error',
  742. duration: 1500,
  743. mask: true,
  744. })
  745. }
  746. reject(payRes)
  747. } catch (error) {
  748. console.error('取消支付接口调用失败:', error)
  749. uni.showToast({
  750. title: '取消支付失败',
  751. icon: 'error',
  752. duration: 1500,
  753. mask: true,
  754. })
  755. reject(error)
  756. }
  757. },
  758. })
  759. })
  760. }
  761. // 如果是钱包支付
  762. if (paymentMethod.value === 1) {
  763. uni.showToast({
  764. title: '支付成功',
  765. icon: 'success',
  766. duration: 1500,
  767. mask: true,
  768. })
  769. setTimeout(() => {
  770. uni.reLaunch({
  771. url: '/pages/classify',
  772. })
  773. }, 1500)
  774. }
  775. } catch (error) {
  776. console.error('支付失败:', error)
  777. uni.showToast({
  778. title: error.response?.data?.msg,
  779. icon: 'error',
  780. duration: 1500,
  781. mask: true,
  782. })
  783. }
  784. }
  785. // 修改支付方式
  786. const handlePaymentMethodChange = (value) => {
  787. if (value === '钱包支付') {
  788. paymentMethod.value = 1
  789. } else if (value === '微信支付') {
  790. paymentMethod.value = 2
  791. }
  792. }
  793. onMounted(async () => {
  794. await getListTime()
  795. })
  796. </script>
  797. <style scoped>
  798. /* 添加卡片样式 */
  799. .card-container {
  800. display: flex;
  801. padding: 20rpx;
  802. margin: 10rpx;
  803. background-color: #fff;
  804. border-radius: 10rpx;
  805. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  806. }
  807. .card-image {
  808. width: 120rpx;
  809. height: 120rpx;
  810. border-radius: 10rpx;
  811. margin-right: 20rpx;
  812. }
  813. .card-content {
  814. flex: 1;
  815. display: flex;
  816. flex-direction: column;
  817. justify-content: space-between;
  818. }
  819. .info-item,
  820. .Telephone,
  821. .date,
  822. .time {
  823. font-size: 26rpx;
  824. margin-bottom: 8rpx;
  825. }
  826. .box {
  827. height: 100vh;
  828. width: 100vw;
  829. position: fixed;
  830. top: 0;
  831. left: 0;
  832. z-index: 999999;
  833. background: red;
  834. }
  835. .card-container {
  836. display: flex;
  837. position: relative;
  838. padding: 20rpx;
  839. align-items: flex-start;
  840. background-color: #fff;
  841. border-radius: 12rpx;
  842. }
  843. /* 左侧图片 */
  844. .card-image {
  845. width: 240rpx;
  846. height: 380rpx;
  847. border-radius: 12rpx;
  848. margin-right: 30rpx;
  849. flex-shrink: 0;
  850. }
  851. /* 中间信息区域 */
  852. .card-info {
  853. flex: 1;
  854. padding-right: 100rpx;
  855. }
  856. .Telephone {
  857. white-space: nowrap;
  858. margin-bottom: 24rpx;
  859. font-size: 28rpx;
  860. line-height: 1.6;
  861. color: #333;
  862. }
  863. .info-item {
  864. margin-bottom: 24rpx;
  865. font-size: 28rpx;
  866. line-height: 1.6;
  867. color: #333;
  868. }
  869. /* 右上角评分 */
  870. .card-rating {
  871. position: absolute;
  872. top: 20rpx;
  873. right: 20rpx;
  874. background-color: #f8f8f8;
  875. padding: 6rpx 16rpx;
  876. border-radius: 20rpx;
  877. font-size: 24rpx;
  878. color: #ff9900;
  879. font-weight: bold;
  880. }
  881. /* 固定在页面底部 */
  882. .Wrap-btn {
  883. /* display: flex; */
  884. /* justify-content: flex-end; */
  885. /* align-items: center; */
  886. position: fixed;
  887. bottom: 0;
  888. width: 100%;
  889. background-color: white;
  890. padding: 40rpx 20rpx;
  891. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1);
  892. }
  893. .Wrapper {
  894. display: flex;
  895. align-items: center;
  896. gap: 10rpx;
  897. margin-top: 10rpx;
  898. }
  899. .Wrapper-img {
  900. width: 50rpx;
  901. height: 50rpx;
  902. margin-left: 10rpx;
  903. }
  904. .Wrapper-content {
  905. color: rgba(16, 16, 16, 1);
  906. font-size: 25rpx;
  907. font-family: PingFangSC-regular;
  908. line-height: 20rpx;
  909. }
  910. .Wrap-content1 {
  911. display: flex;
  912. justify-content: flex-start;
  913. margin-left: 10rpx;
  914. margin-top: 10rpx;
  915. }
  916. .Wrap-info {
  917. display: flex;
  918. justify-content: flex-start;
  919. margin-left: 10rpx;
  920. margin-top: 25rpx;
  921. }
  922. .Wrap-content3 {
  923. margin-top: 25rpx;
  924. }
  925. .Wrap-content4 {
  926. margin-top: 25rpx;
  927. }
  928. .Wrap-content5 {
  929. display: flex;
  930. justify-content: flex-start;
  931. margin-left: 10rpx;
  932. margin-top: 25rpx;
  933. }
  934. .Wrap-content6 {
  935. margin-top: 25rpx;
  936. }
  937. .Wrap-detils-btn {
  938. display: flex;
  939. justify-content: flex-end;
  940. align-items: center;
  941. margin-top: 25rpx;
  942. /* position: fixed;
  943. bottom: 0;
  944. width: 100%;
  945. background-color: white;
  946. padding: 40rpx 20rpx;
  947. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1); */
  948. }
  949. .Wrap-Payment {
  950. padding: 40rpx 30rpx;
  951. background-color: #fff;
  952. border-radius: 16rpx;
  953. margin-bottom: 20rpx;
  954. }
  955. .payment-header {
  956. display: flex;
  957. justify-content: space-between;
  958. align-items: center;
  959. padding: 20rpx 0 30rpx;
  960. }
  961. .payment-title {
  962. font-size: 32rpx;
  963. font-weight: bold;
  964. color: #333;
  965. }
  966. .payment-amount {
  967. font-size: 40rpx;
  968. color: #ff4d4f;
  969. font-weight: bold;
  970. }
  971. .payment-option {
  972. display: flex;
  973. justify-content: space-between;
  974. align-items: center;
  975. padding: 30rpx 0;
  976. }
  977. .option-left {
  978. display: flex;
  979. align-items: center;
  980. }
  981. .payment-icon {
  982. width: 64rpx;
  983. height: 64rpx;
  984. margin-right: 24rpx;
  985. border-radius: 8rpx;
  986. }
  987. .option-text {
  988. font-size: 30rpx;
  989. font-weight: 500;
  990. color: #333;
  991. }
  992. .other-payment {
  993. padding: 30rpx 0;
  994. display: flex;
  995. align-items: center;
  996. justify-content: space-between;
  997. }
  998. .other-payment-text {
  999. color: #1890ff;
  1000. font-size: 28rpx;
  1001. }
  1002. .terms-of-service {
  1003. padding: 30rpx 0;
  1004. font-size: 24rpx;
  1005. color: #999;
  1006. line-height: 1.6;
  1007. background-color: #f9f9f9;
  1008. padding: 20rpx;
  1009. border-radius: 8rpx;
  1010. }
  1011. .Wrap-detils-btn {
  1012. display: flex;
  1013. justify-content: space-between;
  1014. align-items: center;
  1015. padding: 30rpx;
  1016. background-color: #fff;
  1017. border-top: 1px solid #f0f0f0;
  1018. }
  1019. .certificate {
  1020. display: flex;
  1021. flex-direction: column;
  1022. }
  1023. .certificate-img {
  1024. margin-bottom: 24rpx;
  1025. }
  1026. /* 第二层弹框 */
  1027. .card-container {
  1028. display: flex;
  1029. flex-direction: row;
  1030. align-items: flex-start;
  1031. padding: 10px;
  1032. }
  1033. .card-image {
  1034. width: 100px;
  1035. /* Adjust as needed */
  1036. height: 100px;
  1037. /* Adjust as needed */
  1038. border-radius: 8px;
  1039. margin-right: 15px;
  1040. object-fit: cover;
  1041. }
  1042. .card-content {
  1043. flex: 1;
  1044. display: flex;
  1045. flex-direction: column;
  1046. }
  1047. .info-item,
  1048. .Telephone,
  1049. .date,
  1050. .time {
  1051. margin-bottom: 5px;
  1052. font-size: 14px;
  1053. color: #333;
  1054. }
  1055. .time span {
  1056. margin-right: 8px;
  1057. }
  1058. .address-line {
  1059. font-size: 14px;
  1060. line-height: 20rpx;
  1061. /* 行高20rpx */
  1062. color: #333;
  1063. /* 深色文字 */
  1064. display: block;
  1065. /* 确保独占一行 */
  1066. margin-bottom: 30rpx;
  1067. /* 下边距30rpx */
  1068. }
  1069. /* 联系人信息容器 */
  1070. .contact-info {
  1071. display: flex;
  1072. gap: 20rpx;
  1073. /* 姓名和电话之间的间距 */
  1074. }
  1075. /* 姓名样式 */
  1076. .contact-name {
  1077. font-size: 12px;
  1078. color: #999;
  1079. /* 灰色文字 */
  1080. line-height: 20rpx;
  1081. }
  1082. /* 电话样式 */
  1083. .contact-phone {
  1084. font-size: 12px;
  1085. color: #999;
  1086. /* 灰色文字 */
  1087. line-height: 20rpx;
  1088. }
  1089. /* 服务描述卡片样式 */
  1090. .service-description-container {
  1091. display: flex;
  1092. justify-content: space-between;
  1093. align-items: flex-start;
  1094. }
  1095. .service-text {
  1096. flex: 1;
  1097. margin-right: 20rpx;
  1098. }
  1099. .service-price-tag {
  1100. font-size: 36rpx;
  1101. font-weight: bold;
  1102. color: #ff4d4f;
  1103. white-space: nowrap;
  1104. padding: 8rpx 16rpx;
  1105. background-color: #fff2f0;
  1106. border-radius: 8rpx;
  1107. }
  1108. /* 弹框滚动内容样式 */
  1109. .popup-scroll-content {
  1110. height: calc(80vh - 120rpx); /* 减去底部按钮区域的高度 */
  1111. padding: 24rpx;
  1112. padding-bottom: 30px; /* 增加底部内边距,避免内容被按钮遮挡 */
  1113. box-sizing: border-box;
  1114. }
  1115. /* 固定底部按钮样式 */
  1116. .popup-fixed-bottom {
  1117. position: absolute; /* 相对于popup容器定位 */
  1118. bottom: 0;
  1119. left: 0;
  1120. right: 0;
  1121. width: 100%;
  1122. background-color: white;
  1123. padding: 20rpx;
  1124. box-sizing: border-box;
  1125. display: flex;
  1126. justify-content: flex-end; /* 右对齐按钮 */
  1127. align-items: center;
  1128. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1); /* 顶部阴影,创造分隔感 */
  1129. z-index: 1; /* 确保按钮在内容之上 */
  1130. }
  1131. /* 服务信息项样式 */
  1132. .service-info-item {
  1133. display: flex;
  1134. align-items: center;
  1135. padding: 24rpx 0;
  1136. border-bottom: 1px solid #f5f5f5;
  1137. }
  1138. .service-values{
  1139. margin-left: 20rpx;
  1140. }
  1141. .service-label {
  1142. width: 200rpx;
  1143. font-size: 28rpx;
  1144. color: #666;
  1145. flex-shrink: 0;
  1146. }
  1147. .service-value {
  1148. font-size: 28rpx;
  1149. color: #333;
  1150. font-weight: 500;
  1151. }
  1152. .service-number-box {
  1153. background-color: #f8f8f8;
  1154. border-radius: 8rpx;
  1155. }
  1156. /* 服务周期样式 */
  1157. .service-period {
  1158. padding: 24rpx 0;
  1159. border-bottom: 1px solid #f5f5f5;
  1160. }
  1161. .date-picker-container {
  1162. margin: 20rpx 0;
  1163. padding: 12rpx;
  1164. background-color: #f8f8f8;
  1165. border-radius: 8rpx;
  1166. }
  1167. .calendar-component {
  1168. margin-top: 20rpx;
  1169. border: 1px solid #f0f0f0;
  1170. border-radius: 8rpx;
  1171. }
  1172. /* 备注容器样式 */
  1173. .remark-container {
  1174. padding: 24rpx 0;
  1175. display: flex;
  1176. flex-direction: column;
  1177. }
  1178. .remark-input {
  1179. margin-top: 16rpx;
  1180. background-color: #f8f8f8;
  1181. border-radius: 8rpx;
  1182. }
  1183. /* 修改卡片基础样式 */
  1184. .card-container {
  1185. display: flex;
  1186. padding: 24rpx;
  1187. margin: 16rpx 0;
  1188. background-color: #fff;
  1189. border-radius: 12rpx;
  1190. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  1191. }
  1192. /* 志愿者卡片样式 */
  1193. .volunteer-card {
  1194. display: flex;
  1195. position: relative;
  1196. padding: 24rpx 0;
  1197. align-items: flex-start;
  1198. }
  1199. .volunteer-image {
  1200. width: 180rpx;
  1201. height: 180rpx;
  1202. border-radius: 12rpx;
  1203. margin-right: 24rpx;
  1204. flex-shrink: 0;
  1205. object-fit: cover;
  1206. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  1207. }
  1208. .volunteer-info {
  1209. flex: 1;
  1210. display: flex;
  1211. flex-direction: column;
  1212. gap: 16rpx;
  1213. }
  1214. .info-row {
  1215. display: flex;
  1216. align-items: center;
  1217. }
  1218. .info-label {
  1219. color: #666;
  1220. font-size: 26rpx;
  1221. margin-right: 8rpx;
  1222. width: 140rpx;
  1223. flex-shrink: 0;
  1224. }
  1225. .info-value {
  1226. color: #333;
  1227. font-size: 26rpx;
  1228. font-weight: 500;
  1229. }
  1230. .volunteer-rating {
  1231. position: absolute;
  1232. top: 24rpx;
  1233. right: 0;
  1234. background-color: #fff8e6;
  1235. padding: 8rpx 16rpx;
  1236. border-radius: 20rpx;
  1237. display: flex;
  1238. align-items: center;
  1239. border: 1px solid #ffebb7;
  1240. }
  1241. .rating-text {
  1242. font-size: 28rpx;
  1243. color: #ff9900;
  1244. font-weight: bold;
  1245. margin-right: 6rpx;
  1246. }
  1247. .rating-label {
  1248. font-size: 24rpx;
  1249. color: #ff9900;
  1250. }
  1251. /* 技能描述样式 */
  1252. .skill-description {
  1253. padding: 16rpx 0;
  1254. font-size: 28rpx;
  1255. line-height: 1.6;
  1256. color: #333;
  1257. }
  1258. /* 证书样式 */
  1259. .certificate {
  1260. display: flex;
  1261. flex-direction: column;
  1262. gap: 20rpx;
  1263. }
  1264. .certificate-img {
  1265. border-radius: 8rpx;
  1266. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  1267. margin-bottom: 16rpx;
  1268. }
  1269. /* Address selection styles */
  1270. .address-display {
  1271. padding: 16rpx;
  1272. background-color: #f8f8f8;
  1273. border-radius: 8rpx;
  1274. margin-bottom: 16rpx;
  1275. }
  1276. .address-line {
  1277. font-size: 28rpx;
  1278. line-height: 40rpx;
  1279. color: #333;
  1280. display: block;
  1281. margin-bottom: 12rpx;
  1282. font-weight: 500;
  1283. }
  1284. .contact-info {
  1285. display: flex;
  1286. gap: 20rpx;
  1287. }
  1288. .contact-name, .contact-phone {
  1289. font-size: 26rpx;
  1290. color: #666;
  1291. line-height: 36rpx;
  1292. }
  1293. </style>