goodsDetails.vue 15 KB

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