goodsDetails.vue 36 KB

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