goodsDetails.vue 36 KB

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