goodsDetails.vue 17 KB

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