goodsDetails.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <view>
  3. <view>
  4. <up-card title="志愿者介绍" :head-style="{ height: '80rpx', padding: '20rpx',}">
  5. <template #body>
  6. <view class="card-container">
  7. <!-- 左侧图片 -->
  8. <image class="card-image" :src="listData.volunteerPicture" mode="aspectFill"></image>
  9. <!-- 中间信息(姓名/类别等) -->
  10. <view class="card-info">
  11. <view class="info-item">姓名:{{listData.name}}</view>
  12. <view class="info-item">服务项目:{{listData.projectName}}</view>
  13. <view v-if="serviceSubjectName != null" class="info-item">类别:{{ listData.projectTypeName }}
  14. </view>
  15. <view class="Telephone">科目:{{listData.serviceSubjectName}}</view>
  16. <view class="Telephone">电话:{{listData.phonenumber}}</view>
  17. </view>
  18. <!-- 右上角评分 - 使用绝对定位 -->
  19. <view class="card-rating">4.5 评分</view>
  20. </view>
  21. </template>
  22. </up-card>
  23. <up-card title="技能介绍" :thumb="thumb" :head-style="{ height: '80rpx', padding: '20rpx',}">
  24. <template #body>
  25. {{listData.skillDescribe}}
  26. </template>
  27. </up-card>
  28. <up-card title="证书" :thumb="thumb" :head-style="{ height: '80rpx', padding: '20rpx',}">
  29. <template #body>
  30. <view class="certificate">
  31. <image v-for="item in certificationPictures" :key="item" :src="item" mode="" style="width: 100%;" class="certificate-img"></image>
  32. </view>
  33. </template>
  34. </up-card>
  35. <!-- 固定底部按钮区 -->
  36. <view class="Wrap-btn">
  37. <uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup" @click="onClick"
  38. @buttonClick="buttonClick" />
  39. </view>
  40. </view>
  41. <!-- 底部弹框 -->
  42. <view>
  43. <up-popup :show="show" @close="close" @open="open">
  44. </up-popup>
  45. <up-popup v-model:show="show" @open="upPopupOpen">
  46. <view>
  47. <view class="Wrapper">
  48. <image src="/static/img/Location.png" class="Wrapper-img" />
  49. <span class="Wrapper-content">李四</span>
  50. <span class="Wrapper-content">重庆永川区</span>
  51. </view>
  52. <span style="margin-left: 15rpx; margin-top: 50rpx;">重庆永川区</span>
  53. </view>
  54. <up-divider></up-divider>
  55. <view class="Wrap-content1">
  56. <up-avatar :src="src"></up-avatar>
  57. <text style="margin-top: 15rpx;">¥{{onePrice}}</text>
  58. </view>
  59. <view class="Wrap-info">
  60. <text style="margin-left: 10rpx;">服务类别:</text>
  61. <up-text type="info" text="家庭教育"></up-text>
  62. </view>
  63. <view class="Wrap-content3">
  64. <text style="margin-left: 15rpx;">服务周期:</text>
  65. <view style="margin-top: 25rpx;">
  66. <uniDatetimePickerMy :modelValue="doorToDoorTime" :start="startDisabled" :end="endDisabled"
  67. type="daterange"></uniDatetimePickerMy>
  68. </view>
  69. <view>
  70. <its-calendar :timeArr="doorToDoorTimeArr" :timeHostArr="timeHostArr" @getByDate="getByDate"
  71. @getByTime="getByTime"></its-calendar>
  72. </view>
  73. </view>
  74. <view class="Wrap-content6">
  75. <text style="margin-left: 15rpx;">备注:</text>
  76. <up-input placeholder="请输入内容" border="surround" v-model="remark" @change="change"></up-input>
  77. </view>
  78. <view class="Wrap-detils-btn">
  79. <up-button type="primary" shape="circle" :customStyle="wrapqx" @click="handlCancel">取消</up-button>
  80. <up-button type="error" shape="circle" :customStyle="wrapqx" @click="handleBuy">
  81. 购买¥{{ computeMoney }}
  82. </up-button>
  83. </view>
  84. </up-popup>
  85. </view>
  86. <up-popup v-model:show="showSum">
  87. <view class="Wrap-Payment">
  88. <!-- 支付金额 -->
  89. <view class="payment-header">
  90. <text class="payment-title">现在支付</text>
  91. <text class="payment-amount">¥{{ computeMoney }}</text>
  92. </view>
  93. <up-line></up-line>
  94. <!-- 钱包支付选项 -->
  95. <view class="payment-option">
  96. <view class="option-left">
  97. <image src="../../static/my/钱包.png" class="payment-icon"></image>
  98. <text class="option-text">钱包</text>
  99. </view>
  100. <up-radio-group v-model="radiovalue1" placement="column" @change="groupChange">
  101. <up-radio :customStyle="{marginLeft: 'auto'}" v-for="(item, index) in radiolist1" :key="index"
  102. :label="item.name" :name="item.name"></up-radio>
  103. </up-radio-group>
  104. </view>
  105. <up-line></up-line>
  106. <!-- 微信支付选项 -->
  107. <view class="payment-option">
  108. <view class="option-left">
  109. <image src="../../static/微信支付.png" class="payment-icon"></image>
  110. <text class="option-text">微信支付</text>
  111. </view>
  112. <up-radio :customStyle="{marginLeft: 'auto'}" v-for="(item, index) in radiolist2" :key="index"
  113. :label="item.name" :name="item.name"></up-radio>
  114. </view>
  115. <up-line></up-line>
  116. <!-- 其他支付方式 -->
  117. <view class="other-payment">
  118. 其他方式支付 >
  119. </view>
  120. <!-- 条款说明 -->
  121. <view class="terms-of-service">
  122. 我同意购买守则,取消政策和退款政策,我也同意支付以下所示的总金额(含服务费)。
  123. </view>
  124. <!-- 确认按钮 -->
  125. <view class="confirm-button">
  126. <up-button type="primary" :text="`确认购买 · ¥${computeMoney}`"
  127. @click="handlConfiRmpurchase"></up-button>
  128. </view>
  129. </view>
  130. </up-popup>
  131. <up-notify message="支付成功" :show="showNotify"></up-notify>
  132. </view>
  133. </template>
  134. <script setup>
  135. // 点击当前时间,后面时间禁用
  136. // workDate获取点击的精确时间
  137. import {
  138. onLoad
  139. } from '@dcloudio/uni-app'
  140. import {
  141. onMounted,
  142. ref,
  143. nextTick,
  144. reactive,
  145. computed
  146. } from "vue";
  147. import {
  148. getDetailsvolunteerId,
  149. volunteerwork,
  150. volunteergetTimesByDate,
  151. ordersCreateOrder
  152. } from "@/api/volunteerDetailsApi/details.js"
  153. import itsCalendar from '@/components/its-calendar/its-calendar.vue';
  154. import uniDatetimePickerMy from "@/uni_modules/lic-uni-datetime-picker/components/lic-uni-datetime-picker/lic-uni-datetime-picker.vue"
  155. const src = ref('http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg')
  156. const onePrice = ref(400)
  157. const volunteerId = ref(''); // 存储志愿者ID
  158. const serviceCategory = ref('') //存储大类别
  159. const businessManagementId = ref('') //具体分类id
  160. const doorToDoorTimeArr = ref([]) // 完整时间范围
  161. const doorToDoorTime = ref([]) // 只具备开始、结束 时间
  162. const timeHostArr = ref([]) // 时间段数组
  163. const currentDate = ref([]) // 点击过的年月日数组数据
  164. const currentTime = ref('') // 最后一次点击时间的时间节点
  165. const selectedTimes = ref([]) // 存储所有选择的时间对象
  166. const totalTimes = ref(0) // 时间点 点击的次数
  167. const startDisabled = ref('')
  168. const endDisabled = ref('')
  169. const time = ref('')
  170. const listData = ref({})
  171. const show = ref(false); //立即购买
  172. const showSum = ref(false);
  173. const showNotify = ref(false) //支付成功提示
  174. const remark = ref('') //备注
  175. const computeMoney = computed(() => {
  176. return totalTimes.value * onePrice.value
  177. })
  178. const certificationPictures =computed(()=>{
  179. if(listData.value.certificationPicture){
  180. return listData.value.certificationPicture.split(',')
  181. }
  182. return []
  183. })
  184. // 定义方法
  185. function open() {
  186. // 打开逻辑,比如设置 show 为 true
  187. show.value = true;
  188. }
  189. function close() {
  190. // 关闭逻辑,设置 show 为 false
  191. show.value = false;
  192. }
  193. // 定义方法
  194. function openSum() {
  195. // 打开逻辑,比如设置 show 为 true
  196. showSum.value = true;
  197. }
  198. function closeSum() {
  199. // 关闭逻辑,设置 show 为 false
  200. showSum.value = false;
  201. }
  202. const handleBuy = () => {
  203. show.value = false; // 关闭第一个弹框
  204. showSum.value = true; // 打开第二个弹框
  205. };
  206. const handlCancel = () => {
  207. show.value = false; // 关闭第一个弹框
  208. }
  209. // 底部数据
  210. const options = ref([{
  211. icon: 'headphones',
  212. text: '客服'
  213. },
  214. {
  215. icon: 'shop',
  216. text: '收藏',
  217. },
  218. ]);
  219. const buttonGroup = ref([{
  220. text: '立即购买',
  221. backgroundColor: 'red',
  222. color: '#fff'
  223. }]);
  224. // 方法
  225. const onClick = (e) => {
  226. uni.showToast({
  227. title: `点击${e.content.text}`,
  228. icon: 'none'
  229. });
  230. };
  231. const buttonClick = (e) => {
  232. // console.log(e);
  233. // options.value[2].info++;
  234. show.value = true; // 打开弹框
  235. };
  236. // Radio 单选框数据
  237. const radiolist1 = reactive([{
  238. name: '',
  239. disabled: false,
  240. },
  241. ]);
  242. // up-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  243. const radiovalue1 = ref('苹果');
  244. const groupChange = (n) => {
  245. console.log('groupChange', n);
  246. };
  247. const radioChange = (n) => {
  248. console.log('radioChange', n);
  249. };
  250. // 修改详情页底部样式
  251. const customStyle = {
  252. height: '70rpx',
  253. paddingLeft: '30rpx',
  254. width: '540rpx'
  255. }
  256. const wrapqx = {
  257. // height: '70rpx',
  258. width: '240rpx',
  259. }
  260. // 获取传递的参数
  261. onLoad(async (options) => {
  262. // 解析传递过来的参数对象
  263. const params = JSON.parse(options.params);
  264. const {
  265. volunteerId: id,
  266. serviceCategory: categoy,
  267. businessManagementId: manage
  268. } = params;
  269. // 将volunteerId赋值给响应式变量
  270. volunteerId.value = id;
  271. serviceCategory.value = categoy
  272. // 使用传递的参数调用 API
  273. const res = await getDetailsvolunteerId({
  274. volunteerId: id,
  275. serviceCategory: categoy,
  276. businessManagementId: manage,
  277. });
  278. // 将获取到的结果赋值给响应式变量
  279. listData.value = res.data || {};
  280. });
  281. // 选择日期
  282. const getListTime = async () => {
  283. const params = {
  284. volunteerId: Number(volunteerId.value),
  285. }
  286. const res = await volunteerwork(params)
  287. if (res.data) {
  288. console.log(res.data, '>>>>>res.data333');
  289. doorToDoorTimeArr.value = res.data
  290. const newRes = [res.data[0], res.data[res.data.length - 1]]
  291. doorToDoorTime.value = newRes
  292. startDisabled.value = doorToDoorTime.value[0]
  293. endDisabled.value = doorToDoorTime.value[1]
  294. }
  295. }
  296. // 获取志愿者排班时间
  297. const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
  298. console.log(date, '获取日期2')
  299. if (!volunteerId.value) {
  300. console.error('volunteerId 为空');
  301. return;
  302. }
  303. const params = {
  304. volunteerId: volunteerId.value,
  305. date
  306. };
  307. try {
  308. const res = await volunteergetTimesByDate(params);
  309. const TArr = res.data.map(item => {
  310. return {
  311. ...item,
  312. hours: item.reservationTime,
  313. timeStamp: new Date(date + ' ' + item.reservationTime).getTime() / 1000
  314. }
  315. })
  316. let arr = []
  317. doorToDoorTimeArr.value.forEach(() => {
  318. arr.push(TArr)
  319. })
  320. timeHostArr.value = arr
  321. } catch (error) {
  322. console.error('获取排班时间失败:', error);
  323. }
  324. };
  325. // 点击具体时间触发
  326. // const getByTime = (timeObj) => {
  327. // // 检查 timeObj 是否已经被点击过
  328. // if (timeObj.clicked) {
  329. // console.log('>>>>>> 已经点击过此时间');
  330. // return; // 如果已经点击过,就直接返回,后续操作不执行
  331. // }
  332. // console.log('>>>>>>触发111');
  333. // currentDate.value.push(timeObj.yearToDate)
  334. // currentTime.value = timeObj.hours
  335. // totalTimes.value += 1 // 记录点击次数
  336. // // 标记该时间已点击
  337. // timeObj.clicked = true;
  338. // }
  339. const getByTime = (timeObj) => {
  340. if (timeObj.clicked) {
  341. console.log('>>>>>> 已经点击过此时间');
  342. return;
  343. }
  344. // 标记为已点击
  345. timeObj.clicked = true;
  346. // 添加到已选时间数组
  347. selectedTimes.value.push({
  348. date: timeObj.yearToDate,
  349. time: timeObj.hours,
  350. timestamp: timeObj.timeStamp
  351. });
  352. totalTimes.value = selectedTimes.value.length; // 更新点击次数
  353. }
  354. // 立即购买显示时执行
  355. const upPopupOpen = () => { //显示时初始化预存储信息数据
  356. totalTimes.value = 0
  357. currentTime.value = ''
  358. currentDate.value = []
  359. }
  360. // 确认购买
  361. const handlConfiRmpurchase = async () => {
  362. // 定义要发送的数据
  363. const orderData = {
  364. orders: {
  365. serviceOnePrice: onePrice.value, //需要传400死值返回给后端
  366. serviceTotalPrice: computeMoney.value, //需要传获取到的总价
  367. serviceCategory: serviceCategory.value, //大类别参数
  368. totalTimes: totalTimes.value, //点击的次数
  369. serviceStartDate: "2025-04-18",
  370. startTime: "8:00",
  371. serviceDuration: 4,
  372. paymentMethod: 1,
  373. addressId: 7,
  374. volunteerId: volunteerId.value,
  375. remark: remark.value
  376. },
  377. workDateList: [
  378. // {
  379. // workDate: currentDate.value,//需要传获取到的时间,就是某个月份
  380. // }
  381. ]
  382. };
  383. // currentDate.value.length && (new Set(currentDate.value)).forEach((item) => {
  384. // orderData.workDateList.push({
  385. // workDate: item,
  386. // workStartTime: currentTime.value,
  387. // })
  388. // })
  389. // 转换所有选择的时间
  390. selectedTimes.value.forEach(item => {
  391. orderData.workDateList.push({
  392. workDate: item.date,
  393. workStartTime: item.time
  394. });
  395. });
  396. try {
  397. const res = await ordersCreateOrder(orderData);
  398. if (res.code == 200) {
  399. showNotify.value = true
  400. uni.reLaunch({
  401. url: '/pages/index'
  402. });
  403. }
  404. } catch (error) {
  405. console.error('支付失败', error);
  406. }
  407. };
  408. onMounted(async () => {
  409. await getListTime()
  410. getByDate()
  411. })
  412. </script>
  413. <style scoped>
  414. .card-container {
  415. display: flex;
  416. position: relative;
  417. padding: 20rpx;
  418. align-items: flex-start;
  419. background-color: #fff;
  420. border-radius: 12rpx;
  421. }
  422. /* 左侧图片 */
  423. .card-image {
  424. width: 240rpx;
  425. height: 340rpx;
  426. border-radius: 12rpx;
  427. margin-right: 30rpx;
  428. flex-shrink: 0;
  429. }
  430. /* 中间信息区域 */
  431. .card-info {
  432. flex: 1;
  433. padding-right: 100rpx;
  434. }
  435. .Telephone {
  436. white-space: nowrap;
  437. margin-bottom: 24rpx;
  438. font-size: 28rpx;
  439. line-height: 1.6;
  440. color: #333;
  441. }
  442. .info-item {
  443. margin-bottom: 24rpx;
  444. font-size: 28rpx;
  445. line-height: 1.6;
  446. color: #333;
  447. }
  448. /* 右上角评分 */
  449. .card-rating {
  450. position: absolute;
  451. top: 20rpx;
  452. right: 20rpx;
  453. background-color: #f8f8f8;
  454. padding: 6rpx 16rpx;
  455. border-radius: 20rpx;
  456. font-size: 24rpx;
  457. color: #ff9900;
  458. font-weight: bold;
  459. }
  460. /* 固定在页面底部 */
  461. .Wrap-btn {
  462. /* display: flex; */
  463. /* justify-content: flex-end; */
  464. /* align-items: center; */
  465. position: fixed;
  466. bottom: 0;
  467. width: 100%;
  468. background-color: white;
  469. padding: 40rpx 20rpx;
  470. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1);
  471. }
  472. .Wrapper {
  473. display: flex;
  474. align-items: center;
  475. gap: 10rpx;
  476. margin-top: 10rpx;
  477. }
  478. .Wrapper-img {
  479. width: 50rpx;
  480. height: 50rpx;
  481. margin-left: 10rpx;
  482. }
  483. .Wrapper-content {
  484. color: rgba(16, 16, 16, 1);
  485. font-size: 25rpx;
  486. font-family: PingFangSC-regular;
  487. line-height: 20rpx;
  488. }
  489. .Wrap-content1 {
  490. display: flex;
  491. justify-content: flex-start;
  492. margin-left: 10rpx;
  493. margin-top: 10rpx;
  494. }
  495. .Wrap-info {
  496. display: flex;
  497. justify-content: flex-start;
  498. margin-left: 10rpx;
  499. margin-top: 25rpx;
  500. }
  501. .Wrap-content3 {
  502. margin-top: 25rpx;
  503. }
  504. .Wrap-content4 {
  505. margin-top: 25rpx;
  506. }
  507. .Wrap-content5 {
  508. display: flex;
  509. justify-content: flex-start;
  510. margin-left: 10rpx;
  511. margin-top: 25rpx;
  512. }
  513. .Wrap-content6 {
  514. margin-top: 25rpx;
  515. }
  516. .Wrap-detils-btn {
  517. display: flex;
  518. justify-content: flex-end;
  519. align-items: center;
  520. margin-top: 25rpx;
  521. /* position: fixed;
  522. bottom: 0;
  523. width: 100%;
  524. background-color: white;
  525. padding: 40rpx 20rpx;
  526. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1); */
  527. }
  528. .Wrap-Payment {
  529. padding: 30rpx;
  530. background-color: #fff;
  531. }
  532. .payment-header {
  533. display: flex;
  534. justify-content: space-between;
  535. align-items: center;
  536. padding: 20rpx 0;
  537. }
  538. .payment-title {
  539. font-size: 32rpx;
  540. font-weight: bold;
  541. }
  542. .payment-amount {
  543. font-size: 36rpx;
  544. color: #ff4d4f;
  545. font-weight: bold;
  546. }
  547. .payment-option {
  548. display: flex;
  549. justify-content: space-between;
  550. align-items: center;
  551. padding: 30rpx 0;
  552. }
  553. .option-left {
  554. display: flex;
  555. align-items: center;
  556. }
  557. .payment-icon {
  558. width: 80rpx;
  559. height: 80rpx;
  560. margin-right: 20rpx;
  561. }
  562. .option-text {
  563. font-size: 30rpx;
  564. font-weight: bold;
  565. }
  566. .other-payment {
  567. padding: 30rpx 0;
  568. color: #1890ff;
  569. font-size: 28rpx;
  570. }
  571. .terms-of-service {
  572. padding: 30rpx 0;
  573. font-size: 24rpx;
  574. color: #999;
  575. line-height: 1.5;
  576. }
  577. .confirm-button {
  578. margin-top: 40rpx;
  579. }
  580. .certificate {
  581. display: flex;
  582. flex-direction: column;
  583. }
  584. .certificate-img {
  585. margin-bottom: 24rpx;
  586. }
  587. </style>