goodsDetails.vue 35 KB

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