goodsDetails.vue 34 KB

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