goodsDetails.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483
  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-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: `敬请期待`,
  481. icon: 'none',
  482. })
  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. let selectLength = [] // 所有日期選擇數組匯總
  518. const disFlag = false // 是否多选参数 / 备用禁用步进器
  519. Object.keys(itsCalendarRef.value.selectedTimeSlots).forEach(i => {
  520. selectLength.push(...itsCalendarRef.value.selectedTimeSlots[i])
  521. })
  522. if (selectLength.length > 1) {
  523. setTimeout(() => {
  524. singleQuantity.value = obj.value - 1
  525. }, 100)
  526. uni.showToast({ title: '请选择单个时间进行调整服务次数', icon: 'none' })
  527. return false
  528. }
  529. // const seconds = listData.value.businessDuration * obj.value * 60
  530. const seconds = businessDurationComputed.value * obj.value * 60
  531. const endTimestamp = a.timeStamp + durationMs
  532. // 根据当前时间分割出后续应选数据数组
  533. const filteredSlots = b[c].filter((i) => {
  534. return i.timeStamp > a.timeStamp && i.timeStamp <= endTimestamp
  535. })
  536. const timestampDifferenceValue = filteredSlots.length
  537. ? filteredSlots[filteredSlots.length - 1].timeStamp - a.timeStamp
  538. : 0
  539. // console.log(filteredSlots, '>>>>>filteredSlots')
  540. if (timestampDifferenceValue < durationMs) {
  541. minQuantityMax.value = obj.value - 1
  542. // 所选时间差值 小于 服务时间值 结束执行
  543. uni.showToast({ title: '所选时间的服务时间不充足!', icon: 'none' })
  544. return false
  545. }
  546. singleQuantity.value = obj.value || 1
  547. nextTick(() => {
  548. itsCalendarRef.value.handleTimeClick2()
  549. })
  550. }
  551. // 选择日期
  552. const getListTime = async () => {
  553. const params = {
  554. volunteerId: Number(volunteerId.value),
  555. }
  556. const res = await volunteerwork(params)
  557. if (res.data && res.data.length > 0) {
  558. doorToDoorTimeArr.value = res.data
  559. const newRes = [res.data[0], res.data[res.data.length - 1]]
  560. doorToDoorTime.value = newRes
  561. startDisabled.value = doorToDoorTime.value[0]
  562. endDisabled.value = doorToDoorTime.value[1]
  563. // 默认加载第一个日期的排班时间
  564. getByDate(res.data[0])
  565. } else {
  566. console.error('接口返回的日期范围为空')
  567. doorToDoorTimeArr.value = []
  568. timeHostArr.value = [] // 清空时间段
  569. }
  570. }
  571. // 获取志愿者排班时间
  572. const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
  573. // 检查日期是否为空
  574. if (!date) {
  575. coannsole.error('日期为空,跳过获取排班时间')
  576. return
  577. }
  578. if (!volunteerId.value) {
  579. console.error('volunteerId 为空')
  580. return
  581. }
  582. const params = {
  583. volunteerId: volunteerId.value,
  584. date,
  585. }
  586. try {
  587. const res = await volunteergetTimesByDate(params)
  588. const TArr = res.data.map((item) => {
  589. // 初始化disabled变量
  590. let disabled = false
  591. if (item.hasReservation === 1) disabled = true
  592. let itemTime =
  593. item.timeStamp > 9999999999 ? item.timeStamp : item.timeStamp * 1000
  594. if (new Date().getTime() > itemTime) disabled = true
  595. return {
  596. ...item,
  597. hours: item.reservationTime,
  598. timeStamp: new Date(`${date} ${item.reservationTime}`).getTime() / 1000,
  599. date: date,
  600. // checked: false, // 每次点击请求时间后,延续之前选中状态,不初始化选中
  601. disabled,
  602. }
  603. })
  604. // 如果 doorToDoorTimeArr.value 为空,直接返回
  605. if (!doorToDoorTimeArr.value.length) {
  606. console.error('可选的日期范围为空')
  607. return
  608. }
  609. // 填充时间段数组
  610. timeHostArr.value = Array(doorToDoorTimeArr.value.length).fill(TArr)
  611. } catch (error) {
  612. console.error('获取排班时间失败:', error)
  613. }
  614. }
  615. const getByTime = (timeObj) => {
  616. if (timeObj.clicked) {
  617. return
  618. }
  619. if (timeObj.checked) {
  620. // 选中 添加到已选时间数组
  621. selectedTimes.value.push({
  622. date: timeObj.date,
  623. time: timeObj.hours,
  624. timestamp: timeObj.timeStamp,
  625. })
  626. } else {
  627. // 取消选中
  628. const index = selectedTimes.value.findIndex(
  629. (item) => item.timestamp === timeObj.timeStamp
  630. )
  631. selectedTimes.value.splice(index, 1)
  632. }
  633. console.log(selectedTimes, '.>>>selectedTimes');
  634. console.log(selectedTimes.value.length, '>>>>>>selectedTimes.value.length');
  635. totalTimes.value = selectedTimes.value.length // 更新点击次数
  636. }
  637. // 立即购买显示时执行
  638. const upPopupOpen = () => {
  639. //显示时初始化预存储信息数据
  640. selectedTimes.value = []
  641. totalTimes.value = 0
  642. currentTime.value = ''
  643. currentDate.value = []
  644. // 初始化disabled/checked 数据状态
  645. getByDate()
  646. }
  647. const computeMoney = computed(() => {
  648. // console.log(
  649. // totalTimes.value,
  650. // businessPrice.value,
  651. // singleQuantity.value,
  652. // '>>>>>> console.log(totalTimes.value * businessPrice.value * minQuantity.value);'
  653. // )
  654. console.log(totalTimes.value, businessPrice.value, singleQuantity.value, '>>>>>>>>7777777');
  655. return totalTimes.value * businessPrice.value * singleQuantity.value
  656. })
  657. const certificationPictures = computed(() => {
  658. if (listData.value.certificationPicture) {
  659. return listData.value.certificationPicture.split(',')
  660. }
  661. return []
  662. })
  663. // 确认购买
  664. const handlConfiRmpurchase = () => {
  665. if (!selectedAddress.value) {
  666. uni.showToast({
  667. title: '请选择服务地址',
  668. icon: 'none',
  669. duration: 2000,
  670. })
  671. return // 阻止购买
  672. } else if (!paymentMethod.value) {
  673. uni.showToast({
  674. title: '请选择支付方式',
  675. icon: 'none',
  676. duration: 2000,
  677. })
  678. return // 阻止购买
  679. }
  680. // 如果有地址,执行购买逻辑
  681. proceedToPayment()
  682. }
  683. const proceedToPayment = async () => {
  684. try {
  685. // 定义要发送的数据
  686. const orderData = {
  687. orders: {
  688. // serviceOnePrice: businessPrice.value,
  689. // serviceTotalPrice: computeMoney.value,
  690. serviceCategory: serviceCategory.value,
  691. totalTimes: totalTimes.value,
  692. paymentMethod: paymentMethod.value,
  693. volunteerId: volunteerId.value,
  694. remark: remark.value,
  695. businessManagementId: businessManagementId.value,
  696. volunteerInfoId: listData.value.volunteerInfoId,
  697. addressId: selectedAddress.value.addressId,
  698. singleQuantity: singleQuantity.value,
  699. },
  700. workDateList: [],
  701. }
  702. // 转换所有选择的时间
  703. selectedTimes.value.forEach((item) => {
  704. orderData.workDateList.push({
  705. workDate: item.date,
  706. workStartTime: item.time,
  707. })
  708. })
  709. // 创建订单
  710. const res = await ordersCreateOrder(orderData)
  711. if (res.code !== 200) {
  712. throw new Error('创建订单失败')
  713. }
  714. // 保存订单号
  715. const mainOrderId = res.data.mainOrderId
  716. // console.log('创建订单成功,订单号:', mainOrderId)
  717. // 如果是微信支付
  718. if (paymentMethod.value === 2) {
  719. return new Promise((resolve, reject) => {
  720. uni.requestPayment({
  721. ...res.data,
  722. package: res.data.packageValue,
  723. success: (payRes) => {
  724. // console.log('支付成功:', payRes)
  725. if (payRes.errMsg === 'requestPayment:ok') {
  726. uni.showToast({
  727. title: '支付成功',
  728. icon: 'success',
  729. duration: 1500,
  730. mask: true,
  731. })
  732. setTimeout(() => {
  733. uni.reLaunch({
  734. url: '/pages/classify',
  735. })
  736. }, 1500)
  737. resolve(payRes)
  738. }
  739. },
  740. fail: async (payRes) => {
  741. // console.log('支付失败或取消:', payRes)
  742. try {
  743. // 调用取消支付接口
  744. const cancelRes = await coreUsersOrdersPayCancel({ mainOrderId })
  745. // console.log('取消支付接口调用成功:', cancelRes)
  746. if (payRes.errMsg === 'requestPayment:fail cancel') {
  747. uni.showToast({
  748. title: '已取消支付',
  749. icon: 'none',
  750. duration: 1500,
  751. mask: true,
  752. })
  753. } else {
  754. uni.showToast({
  755. title:error.response?.data?.msg,
  756. icon: 'error',
  757. duration: 1500,
  758. mask: true,
  759. })
  760. }
  761. reject(payRes)
  762. } catch (error) {
  763. console.error('取消支付接口调用失败:', error)
  764. uni.showToast({
  765. title: '取消支付失败',
  766. icon: 'error',
  767. duration: 1500,
  768. mask: true,
  769. })
  770. reject(error)
  771. }
  772. },
  773. })
  774. })
  775. }
  776. // 如果是钱包支付
  777. if (paymentMethod.value === 1) {
  778. uni.showToast({
  779. title: '支付成功',
  780. icon: 'success',
  781. duration: 1500,
  782. mask: true,
  783. })
  784. setTimeout(() => {
  785. uni.reLaunch({
  786. url: '/pages/classify',
  787. })
  788. }, 1500)
  789. }
  790. } catch (error) {
  791. console.error('支付失败:', error)
  792. uni.showToast({
  793. title: error.response?.data?.msg,
  794. icon: 'error',
  795. duration: 1500,
  796. mask: true,
  797. })
  798. }
  799. }
  800. // 修改支付方式
  801. const handlePaymentMethodChange = (value) => {
  802. if (value === '钱包支付') {
  803. paymentMethod.value = 1
  804. } else if (value === '微信支付') {
  805. paymentMethod.value = 2
  806. }
  807. }
  808. const changeMinQuantityMax = (val = 99999) => {
  809. minQuantityMax.value = val
  810. }
  811. onMounted(async () => {
  812. await getListTime()
  813. })
  814. </script>
  815. <style scoped>
  816. /* 添加卡片样式 */
  817. .card-container {
  818. display: flex;
  819. padding: 20rpx;
  820. margin: 10rpx;
  821. background-color: #fff;
  822. border-radius: 10rpx;
  823. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
  824. }
  825. .card-image {
  826. width: 120rpx;
  827. height: 120rpx;
  828. border-radius: 10rpx;
  829. margin-right: 20rpx;
  830. }
  831. .card-content {
  832. flex: 1;
  833. display: flex;
  834. flex-direction: column;
  835. justify-content: space-between;
  836. }
  837. .info-item,
  838. .Telephone,
  839. .date,
  840. .time {
  841. font-size: 26rpx;
  842. margin-bottom: 8rpx;
  843. }
  844. .box {
  845. height: 100vh;
  846. width: 100vw;
  847. position: fixed;
  848. top: 0;
  849. left: 0;
  850. z-index: 999999;
  851. background: red;
  852. }
  853. .card-container {
  854. display: flex;
  855. position: relative;
  856. padding: 20rpx;
  857. align-items: flex-start;
  858. background-color: #fff;
  859. border-radius: 12rpx;
  860. }
  861. /* 左侧图片 */
  862. .card-image {
  863. width: 240rpx;
  864. height: 380rpx;
  865. border-radius: 12rpx;
  866. margin-right: 30rpx;
  867. flex-shrink: 0;
  868. }
  869. /* 中间信息区域 */
  870. .card-info {
  871. flex: 1;
  872. padding-right: 100rpx;
  873. }
  874. .Telephone {
  875. white-space: nowrap;
  876. margin-bottom: 24rpx;
  877. font-size: 28rpx;
  878. line-height: 1.6;
  879. color: #333;
  880. }
  881. .info-item {
  882. margin-bottom: 24rpx;
  883. font-size: 28rpx;
  884. line-height: 1.6;
  885. color: #333;
  886. }
  887. /* 右上角评分 */
  888. .card-rating {
  889. position: absolute;
  890. top: 20rpx;
  891. right: 20rpx;
  892. background-color: #f8f8f8;
  893. padding: 6rpx 16rpx;
  894. border-radius: 20rpx;
  895. font-size: 24rpx;
  896. color: #ff9900;
  897. font-weight: bold;
  898. }
  899. /* 固定在页面底部 */
  900. .Wrap-btn {
  901. /* display: flex; */
  902. /* justify-content: flex-end; */
  903. /* align-items: center; */
  904. position: fixed;
  905. bottom: 0;
  906. width: 100%;
  907. background-color: white;
  908. padding: 40rpx 20rpx;
  909. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1);
  910. }
  911. .Wrapper {
  912. display: flex;
  913. align-items: center;
  914. gap: 10rpx;
  915. margin-top: 10rpx;
  916. }
  917. .Wrapper-img {
  918. width: 50rpx;
  919. height: 50rpx;
  920. margin-left: 10rpx;
  921. }
  922. .Wrapper-content {
  923. color: rgba(16, 16, 16, 1);
  924. font-size: 25rpx;
  925. font-family: PingFangSC-regular;
  926. line-height: 20rpx;
  927. }
  928. .Wrap-content1 {
  929. display: flex;
  930. justify-content: flex-start;
  931. margin-left: 10rpx;
  932. margin-top: 10rpx;
  933. }
  934. .Wrap-info {
  935. display: flex;
  936. justify-content: flex-start;
  937. margin-left: 10rpx;
  938. margin-top: 25rpx;
  939. }
  940. .Wrap-content3 {
  941. margin-top: 25rpx;
  942. }
  943. .Wrap-content4 {
  944. margin-top: 25rpx;
  945. }
  946. .Wrap-content5 {
  947. display: flex;
  948. justify-content: flex-start;
  949. margin-left: 10rpx;
  950. margin-top: 25rpx;
  951. }
  952. .Wrap-content6 {
  953. margin-top: 25rpx;
  954. }
  955. .Wrap-detils-btn {
  956. display: flex;
  957. justify-content: flex-end;
  958. align-items: center;
  959. margin-top: 25rpx;
  960. /* position: fixed;
  961. bottom: 0;
  962. width: 100%;
  963. background-color: white;
  964. padding: 40rpx 20rpx;
  965. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1); */
  966. }
  967. .Wrap-Payment {
  968. padding: 40rpx 30rpx;
  969. background-color: #fff;
  970. border-radius: 16rpx;
  971. margin-bottom: 20rpx;
  972. }
  973. .payment-header {
  974. display: flex;
  975. justify-content: space-between;
  976. align-items: center;
  977. padding: 20rpx 0 30rpx;
  978. }
  979. .payment-title {
  980. font-size: 32rpx;
  981. font-weight: bold;
  982. color: #333;
  983. }
  984. .payment-amount {
  985. font-size: 40rpx;
  986. color: #ff4d4f;
  987. font-weight: bold;
  988. }
  989. .payment-option {
  990. display: flex;
  991. justify-content: space-between;
  992. align-items: center;
  993. padding: 30rpx 0;
  994. }
  995. .option-left {
  996. display: flex;
  997. align-items: center;
  998. }
  999. .payment-icon {
  1000. width: 64rpx;
  1001. height: 64rpx;
  1002. margin-right: 24rpx;
  1003. border-radius: 8rpx;
  1004. }
  1005. .option-text {
  1006. font-size: 30rpx;
  1007. font-weight: 500;
  1008. color: #333;
  1009. }
  1010. .other-payment {
  1011. padding: 30rpx 0;
  1012. display: flex;
  1013. align-items: center;
  1014. justify-content: space-between;
  1015. }
  1016. .other-payment-text {
  1017. color: #1890ff;
  1018. font-size: 28rpx;
  1019. }
  1020. .terms-of-service {
  1021. padding: 30rpx 0;
  1022. font-size: 24rpx;
  1023. color: #999;
  1024. line-height: 1.6;
  1025. background-color: #f9f9f9;
  1026. padding: 20rpx;
  1027. border-radius: 8rpx;
  1028. }
  1029. .Wrap-detils-btn {
  1030. display: flex;
  1031. justify-content: space-between;
  1032. align-items: center;
  1033. padding: 30rpx;
  1034. background-color: #fff;
  1035. border-top: 1px solid #f0f0f0;
  1036. }
  1037. .certificate {
  1038. display: flex;
  1039. flex-direction: column;
  1040. }
  1041. .certificate-img {
  1042. margin-bottom: 24rpx;
  1043. }
  1044. /* 第二层弹框 */
  1045. .card-container {
  1046. display: flex;
  1047. flex-direction: row;
  1048. align-items: flex-start;
  1049. padding: 10px;
  1050. }
  1051. .card-image {
  1052. width: 100px;
  1053. /* Adjust as needed */
  1054. height: 100px;
  1055. /* Adjust as needed */
  1056. border-radius: 8px;
  1057. margin-right: 15px;
  1058. object-fit: cover;
  1059. }
  1060. .card-content {
  1061. flex: 1;
  1062. display: flex;
  1063. flex-direction: column;
  1064. }
  1065. .info-item,
  1066. .Telephone,
  1067. .date,
  1068. .time {
  1069. margin-bottom: 5px;
  1070. font-size: 14px;
  1071. color: #333;
  1072. }
  1073. .time span {
  1074. margin-right: 8px;
  1075. }
  1076. .address-line {
  1077. font-size: 14px;
  1078. line-height: 20rpx;
  1079. /* 行高20rpx */
  1080. color: #333;
  1081. /* 深色文字 */
  1082. display: block;
  1083. /* 确保独占一行 */
  1084. margin-bottom: 30rpx;
  1085. /* 下边距30rpx */
  1086. }
  1087. /* 联系人信息容器 */
  1088. .contact-info {
  1089. display: flex;
  1090. gap: 20rpx;
  1091. /* 姓名和电话之间的间距 */
  1092. }
  1093. /* 姓名样式 */
  1094. .contact-name {
  1095. font-size: 12px;
  1096. color: #999;
  1097. /* 灰色文字 */
  1098. line-height: 20rpx;
  1099. }
  1100. /* 电话样式 */
  1101. .contact-phone {
  1102. font-size: 12px;
  1103. color: #999;
  1104. /* 灰色文字 */
  1105. line-height: 20rpx;
  1106. }
  1107. /* 服务描述卡片样式 */
  1108. .service-description-container {
  1109. display: flex;
  1110. justify-content: space-between;
  1111. align-items: flex-start;
  1112. }
  1113. .service-text {
  1114. flex: 1;
  1115. margin-right: 20rpx;
  1116. }
  1117. .service-price-tag {
  1118. font-size: 36rpx;
  1119. font-weight: bold;
  1120. color: #ff4d4f;
  1121. white-space: nowrap;
  1122. padding: 8rpx 16rpx;
  1123. background-color: #fff2f0;
  1124. border-radius: 8rpx;
  1125. }
  1126. /* 弹框滚动内容样式 */
  1127. .popup-scroll-content {
  1128. height: calc(80vh - 120rpx); /* 减去底部按钮区域的高度 */
  1129. padding: 24rpx;
  1130. padding-bottom: 30px; /* 增加底部内边距,避免内容被按钮遮挡 */
  1131. box-sizing: border-box;
  1132. }
  1133. /* 固定底部按钮样式 */
  1134. .popup-fixed-bottom {
  1135. position: absolute; /* 相对于popup容器定位 */
  1136. bottom: 0;
  1137. left: 0;
  1138. right: 0;
  1139. width: 100%;
  1140. background-color: white;
  1141. padding: 20rpx;
  1142. box-sizing: border-box;
  1143. display: flex;
  1144. justify-content: flex-end; /* 右对齐按钮 */
  1145. align-items: center;
  1146. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1); /* 顶部阴影,创造分隔感 */
  1147. z-index: 1; /* 确保按钮在内容之上 */
  1148. }
  1149. /* 服务信息项样式 */
  1150. .service-info-item {
  1151. display: flex;
  1152. align-items: center;
  1153. padding: 24rpx 0;
  1154. border-bottom: 1px solid #f5f5f5;
  1155. }
  1156. .service-values{
  1157. margin-left: 20rpx;
  1158. }
  1159. .service-label {
  1160. width: 200rpx;
  1161. font-size: 28rpx;
  1162. color: #666;
  1163. flex-shrink: 0;
  1164. }
  1165. .service-label1{
  1166. width: 400rpx;
  1167. font-size: 28rpx;
  1168. color: #666;
  1169. flex-shrink: 0;
  1170. }
  1171. .service-value {
  1172. font-size: 28rpx;
  1173. color: #333;
  1174. font-weight: 500;
  1175. }
  1176. .service-number-box {
  1177. background-color: #f8f8f8;
  1178. border-radius: 8rpx;
  1179. }
  1180. /* 服务周期样式 */
  1181. .service-period {
  1182. padding: 24rpx 0;
  1183. border-bottom: 1px solid #f5f5f5;
  1184. }
  1185. .date-picker-container {
  1186. margin: 20rpx 0;
  1187. padding: 12rpx;
  1188. background-color: #f8f8f8;
  1189. border-radius: 8rpx;
  1190. }
  1191. .calendar-component {
  1192. margin-top: 20rpx;
  1193. border: 1px solid #f0f0f0;
  1194. border-radius: 8rpx;
  1195. }
  1196. /* 备注容器样式 */
  1197. .remark-container {
  1198. padding: 24rpx 0;
  1199. display: flex;
  1200. flex-direction: column;
  1201. }
  1202. .remark-input {
  1203. margin-top: 16rpx;
  1204. background-color: #f8f8f8;
  1205. border-radius: 8rpx;
  1206. }
  1207. /* 修改卡片基础样式 */
  1208. .card-container {
  1209. display: flex;
  1210. padding: 24rpx;
  1211. margin: 16rpx 0;
  1212. background-color: #fff;
  1213. border-radius: 12rpx;
  1214. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  1215. }
  1216. /* 志愿者卡片样式 */
  1217. .volunteer-card {
  1218. display: flex;
  1219. position: relative;
  1220. padding: 24rpx 0;
  1221. align-items: flex-start;
  1222. }
  1223. .volunteer-image {
  1224. width: 180rpx;
  1225. height: 180rpx;
  1226. border-radius: 12rpx;
  1227. margin-right: 24rpx;
  1228. flex-shrink: 0;
  1229. object-fit: cover;
  1230. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  1231. }
  1232. .volunteer-info {
  1233. flex: 1;
  1234. display: flex;
  1235. flex-direction: column;
  1236. gap: 16rpx;
  1237. }
  1238. .info-row {
  1239. display: flex;
  1240. align-items: center;
  1241. }
  1242. .info-label {
  1243. color: #666;
  1244. font-size: 26rpx;
  1245. margin-right: 8rpx;
  1246. width: 140rpx;
  1247. flex-shrink: 0;
  1248. }
  1249. .info-value {
  1250. color: #333;
  1251. font-size: 26rpx;
  1252. font-weight: 500;
  1253. }
  1254. .volunteer-rating {
  1255. position: absolute;
  1256. top: 24rpx;
  1257. right: 0;
  1258. background-color: #fff8e6;
  1259. padding: 8rpx 16rpx;
  1260. border-radius: 20rpx;
  1261. display: flex;
  1262. align-items: center;
  1263. border: 1px solid #ffebb7;
  1264. }
  1265. .rating-text {
  1266. font-size: 28rpx;
  1267. color: #ff9900;
  1268. font-weight: bold;
  1269. margin-right: 6rpx;
  1270. }
  1271. .rating-label {
  1272. font-size: 24rpx;
  1273. color: #ff9900;
  1274. }
  1275. /* 技能描述样式 */
  1276. .skill-description {
  1277. padding: 16rpx 0;
  1278. font-size: 28rpx;
  1279. line-height: 1.6;
  1280. color: #333;
  1281. }
  1282. /* 证书样式 */
  1283. .certificate {
  1284. display: flex;
  1285. flex-direction: column;
  1286. gap: 20rpx;
  1287. }
  1288. .certificate-img {
  1289. border-radius: 8rpx;
  1290. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  1291. margin-bottom: 16rpx;
  1292. }
  1293. /* Address selection styles */
  1294. .address-display {
  1295. padding: 16rpx;
  1296. background-color: #f8f8f8;
  1297. border-radius: 8rpx;
  1298. margin-bottom: 16rpx;
  1299. }
  1300. .address-line {
  1301. font-size: 28rpx;
  1302. line-height: 40rpx;
  1303. color: #333;
  1304. display: block;
  1305. margin-bottom: 12rpx;
  1306. font-weight: 500;
  1307. }
  1308. .contact-info {
  1309. display: flex;
  1310. gap: 20rpx;
  1311. }
  1312. .contact-name, .contact-phone {
  1313. font-size: 26rpx;
  1314. color: #666;
  1315. line-height: 36rpx;
  1316. }
  1317. </style>