goodsDetails.vue 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495
  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. margin-left: 10rpx;
  941. margin-top: 10rpx;
  942. }
  943. .Wrap-info {
  944. display: flex;
  945. justify-content: flex-start;
  946. margin-left: 10rpx;
  947. margin-top: 25rpx;
  948. }
  949. .Wrap-content3 {
  950. margin-top: 25rpx;
  951. }
  952. .Wrap-content4 {
  953. margin-top: 25rpx;
  954. }
  955. .Wrap-content5 {
  956. display: flex;
  957. justify-content: flex-start;
  958. margin-left: 10rpx;
  959. margin-top: 25rpx;
  960. }
  961. .Wrap-content6 {
  962. margin-top: 25rpx;
  963. }
  964. .Wrap-detils-btn {
  965. display: flex;
  966. justify-content: flex-end;
  967. align-items: center;
  968. margin-top: 25rpx;
  969. /* position: fixed;
  970. bottom: 0;
  971. width: 100%;
  972. background-color: white;
  973. padding: 40rpx 20rpx;
  974. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1); */
  975. }
  976. .Wrap-Payment {
  977. padding: 40rpx 30rpx;
  978. background-color: #fff;
  979. border-radius: 16rpx;
  980. margin-bottom: 20rpx;
  981. }
  982. .payment-header {
  983. display: flex;
  984. justify-content: space-between;
  985. align-items: center;
  986. padding: 20rpx 0 30rpx;
  987. }
  988. .payment-title {
  989. font-size: 32rpx;
  990. font-weight: bold;
  991. color: #333;
  992. }
  993. .payment-amount {
  994. font-size: 40rpx;
  995. color: #ff4d4f;
  996. font-weight: bold;
  997. }
  998. .payment-option {
  999. display: flex;
  1000. justify-content: space-between;
  1001. align-items: center;
  1002. padding: 30rpx 0;
  1003. }
  1004. .option-left {
  1005. display: flex;
  1006. align-items: center;
  1007. }
  1008. .payment-icon {
  1009. width: 64rpx;
  1010. height: 64rpx;
  1011. margin-right: 24rpx;
  1012. border-radius: 8rpx;
  1013. }
  1014. .option-text {
  1015. font-size: 30rpx;
  1016. font-weight: 500;
  1017. color: #333;
  1018. }
  1019. .other-payment {
  1020. padding: 30rpx 0;
  1021. display: flex;
  1022. align-items: center;
  1023. justify-content: space-between;
  1024. }
  1025. .other-payment-text {
  1026. color: #1890ff;
  1027. font-size: 28rpx;
  1028. }
  1029. .terms-of-service {
  1030. padding: 30rpx 0;
  1031. font-size: 24rpx;
  1032. color: #999;
  1033. line-height: 1.6;
  1034. background-color: #f9f9f9;
  1035. padding: 20rpx;
  1036. border-radius: 8rpx;
  1037. }
  1038. .Wrap-detils-btn {
  1039. display: flex;
  1040. justify-content: space-between;
  1041. align-items: center;
  1042. padding: 30rpx;
  1043. background-color: #fff;
  1044. border-top: 1px solid #f0f0f0;
  1045. }
  1046. .certificate {
  1047. display: flex;
  1048. flex-direction: column;
  1049. }
  1050. .certificate-img {
  1051. margin-bottom: 24rpx;
  1052. }
  1053. /* 第二层弹框 */
  1054. .card-container {
  1055. display: flex;
  1056. flex-direction: row;
  1057. align-items: flex-start;
  1058. padding: 10px;
  1059. }
  1060. .card-image {
  1061. width: 100px;
  1062. /* Adjust as needed */
  1063. height: 100px;
  1064. /* Adjust as needed */
  1065. border-radius: 8px;
  1066. margin-right: 15px;
  1067. object-fit: cover;
  1068. }
  1069. .card-content {
  1070. flex: 1;
  1071. display: flex;
  1072. flex-direction: column;
  1073. }
  1074. .info-item,
  1075. .Telephone,
  1076. .date,
  1077. .time {
  1078. margin-bottom: 5px;
  1079. font-size: 14px;
  1080. color: #333;
  1081. }
  1082. .time span {
  1083. margin-right: 8px;
  1084. }
  1085. .address-line {
  1086. font-size: 14px;
  1087. line-height: 20rpx;
  1088. /* 行高20rpx */
  1089. color: #333;
  1090. /* 深色文字 */
  1091. display: block;
  1092. /* 确保独占一行 */
  1093. margin-bottom: 30rpx;
  1094. /* 下边距30rpx */
  1095. }
  1096. /* 联系人信息容器 */
  1097. .contact-info {
  1098. display: flex;
  1099. gap: 20rpx;
  1100. /* 姓名和电话之间的间距 */
  1101. }
  1102. /* 姓名样式 */
  1103. .contact-name {
  1104. font-size: 12px;
  1105. color: #999;
  1106. /* 灰色文字 */
  1107. line-height: 20rpx;
  1108. }
  1109. /* 电话样式 */
  1110. .contact-phone {
  1111. font-size: 12px;
  1112. color: #999;
  1113. /* 灰色文字 */
  1114. line-height: 20rpx;
  1115. }
  1116. /* 服务描述卡片样式 */
  1117. .service-description-container {
  1118. display: flex;
  1119. justify-content: space-between;
  1120. align-items: flex-start;
  1121. }
  1122. .service-text {
  1123. flex: 1;
  1124. margin-right: 20rpx;
  1125. }
  1126. .service-price-tag {
  1127. font-size: 36rpx;
  1128. font-weight: bold;
  1129. color: #ff4d4f;
  1130. white-space: nowrap;
  1131. padding: 8rpx 16rpx;
  1132. background-color: #fff2f0;
  1133. border-radius: 8rpx;
  1134. }
  1135. /* 弹框滚动内容样式 */
  1136. .popup-scroll-content {
  1137. height: calc(80vh - 120rpx); /* 减去底部按钮区域的高度 */
  1138. padding: 24rpx;
  1139. padding-bottom: 30px; /* 增加底部内边距,避免内容被按钮遮挡 */
  1140. box-sizing: border-box;
  1141. }
  1142. /* 固定底部按钮样式 */
  1143. .popup-fixed-bottom {
  1144. position: absolute; /* 相对于popup容器定位 */
  1145. bottom: 0;
  1146. left: 0;
  1147. right: 0;
  1148. width: 100%;
  1149. background-color: white;
  1150. padding: 20rpx;
  1151. box-sizing: border-box;
  1152. display: flex;
  1153. justify-content: flex-end; /* 右对齐按钮 */
  1154. align-items: center;
  1155. box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.1); /* 顶部阴影,创造分隔感 */
  1156. z-index: 1; /* 确保按钮在内容之上 */
  1157. }
  1158. /* 服务信息项样式 */
  1159. .service-info-item {
  1160. display: flex;
  1161. align-items: center;
  1162. padding: 24rpx 0;
  1163. border-bottom: 1px solid #f5f5f5;
  1164. }
  1165. .service-values{
  1166. margin-left: 20rpx;
  1167. }
  1168. .service-label {
  1169. width: 200rpx;
  1170. font-size: 28rpx;
  1171. color: #666;
  1172. flex-shrink: 0;
  1173. }
  1174. .service-label1{
  1175. width: 400rpx;
  1176. font-size: 28rpx;
  1177. color: #666;
  1178. flex-shrink: 0;
  1179. }
  1180. .service-value {
  1181. font-size: 28rpx;
  1182. color: #333;
  1183. font-weight: 500;
  1184. }
  1185. .service-number-box {
  1186. background-color: #f8f8f8;
  1187. border-radius: 8rpx;
  1188. }
  1189. /* 服务周期样式 */
  1190. .service-period {
  1191. padding: 24rpx 0;
  1192. border-bottom: 1px solid #f5f5f5;
  1193. }
  1194. .date-picker-container {
  1195. margin: 20rpx 0;
  1196. padding: 12rpx;
  1197. background-color: #f8f8f8;
  1198. border-radius: 8rpx;
  1199. }
  1200. .calendar-component {
  1201. margin-top: 20rpx;
  1202. border: 1px solid #f0f0f0;
  1203. border-radius: 8rpx;
  1204. }
  1205. /* 备注容器样式 */
  1206. .remark-container {
  1207. padding: 24rpx 0;
  1208. display: flex;
  1209. flex-direction: column;
  1210. }
  1211. .remark-input {
  1212. margin-top: 16rpx;
  1213. background-color: #f8f8f8;
  1214. border-radius: 8rpx;
  1215. }
  1216. /* 修改卡片基础样式 */
  1217. .card-container {
  1218. display: flex;
  1219. padding: 24rpx;
  1220. margin: 16rpx 0;
  1221. background-color: #fff;
  1222. border-radius: 12rpx;
  1223. box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  1224. }
  1225. /* 志愿者卡片样式 */
  1226. .volunteer-card {
  1227. display: flex;
  1228. position: relative;
  1229. padding: 24rpx 0;
  1230. align-items: flex-start;
  1231. }
  1232. .volunteer-image {
  1233. width: 180rpx;
  1234. height: 180rpx;
  1235. border-radius: 12rpx;
  1236. margin-right: 24rpx;
  1237. flex-shrink: 0;
  1238. object-fit: cover;
  1239. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.1);
  1240. }
  1241. .volunteer-info {
  1242. flex: 1;
  1243. display: flex;
  1244. flex-direction: column;
  1245. gap: 16rpx;
  1246. }
  1247. .info-row {
  1248. display: flex;
  1249. align-items: center;
  1250. }
  1251. .info-label {
  1252. color: #666;
  1253. font-size: 26rpx;
  1254. margin-right: 8rpx;
  1255. width: 140rpx;
  1256. flex-shrink: 0;
  1257. }
  1258. .info-value {
  1259. color: #333;
  1260. font-size: 26rpx;
  1261. font-weight: 500;
  1262. }
  1263. .volunteer-rating {
  1264. position: absolute;
  1265. top: 24rpx;
  1266. right: 0;
  1267. background-color: #fff8e6;
  1268. padding: 8rpx 16rpx;
  1269. border-radius: 20rpx;
  1270. display: flex;
  1271. align-items: center;
  1272. border: 1px solid #ffebb7;
  1273. }
  1274. .rating-text {
  1275. font-size: 28rpx;
  1276. color: #ff9900;
  1277. font-weight: bold;
  1278. margin-right: 6rpx;
  1279. }
  1280. .rating-label {
  1281. font-size: 24rpx;
  1282. color: #ff9900;
  1283. }
  1284. /* 技能描述样式 */
  1285. .skill-description {
  1286. padding: 16rpx 0;
  1287. font-size: 28rpx;
  1288. line-height: 1.6;
  1289. color: #333;
  1290. }
  1291. /* 证书样式 */
  1292. .certificate {
  1293. display: flex;
  1294. flex-direction: column;
  1295. gap: 20rpx;
  1296. }
  1297. .certificate-img {
  1298. border-radius: 8rpx;
  1299. box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
  1300. margin-bottom: 16rpx;
  1301. }
  1302. /* Address selection styles */
  1303. .address-display {
  1304. padding: 16rpx;
  1305. background-color: #f8f8f8;
  1306. border-radius: 8rpx;
  1307. margin-bottom: 16rpx;
  1308. }
  1309. .address-line {
  1310. font-size: 28rpx;
  1311. line-height: 40rpx;
  1312. color: #333;
  1313. display: block;
  1314. margin-bottom: 12rpx;
  1315. font-weight: 500;
  1316. }
  1317. .contact-info {
  1318. display: flex;
  1319. gap: 20rpx;
  1320. }
  1321. .contact-name, .contact-phone {
  1322. font-size: 26rpx;
  1323. color: #666;
  1324. line-height: 36rpx;
  1325. }
  1326. .service-description-box {
  1327. padding-bottom: 180rpx;
  1328. }
  1329. </style>