goodsDetails.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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="value" @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 value = ref(''); //备注响应式
  162. const volunteerId = ref(''); // 存储志愿者ID
  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 computeMoney = computed(() => {
  177. return totalTimes.value * onePrice.value
  178. })
  179. // 定义方法
  180. function open() {
  181. // 打开逻辑,比如设置 show 为 true
  182. show.value = true;
  183. }
  184. function close() {
  185. // 关闭逻辑,设置 show 为 false
  186. show.value = false;
  187. }
  188. // 定义方法
  189. function openSum() {
  190. // 打开逻辑,比如设置 show 为 true
  191. showSum.value = true;
  192. }
  193. function closeSum() {
  194. // 关闭逻辑,设置 show 为 false
  195. showSum.value = false;
  196. }
  197. const handleBuy = () => {
  198. show.value = false; // 关闭第一个弹框
  199. showSum.value = true; // 打开第二个弹框
  200. };
  201. const handlCancel = () => {
  202. show.value = false; // 关闭第一个弹框
  203. }
  204. // 底部数据
  205. const options = ref([{
  206. icon: 'headphones',
  207. text: '客服'
  208. },
  209. {
  210. icon: 'shop',
  211. text: '收藏',
  212. },
  213. ]);
  214. const buttonGroup = ref([{
  215. text: '立即购买',
  216. backgroundColor: 'red',
  217. color: '#fff'
  218. }]);
  219. // 方法
  220. const onClick = (e) => {
  221. uni.showToast({
  222. title: `点击${e.content.text}`,
  223. icon: 'none'
  224. });
  225. };
  226. const buttonClick = (e) => {
  227. // console.log(e);
  228. // options.value[2].info++;
  229. show.value = true; // 打开弹框
  230. };
  231. // Radio 单选框数据
  232. const radiolist1 = reactive([{
  233. name: '',
  234. disabled: false,
  235. },
  236. ]);
  237. // up-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  238. const radiovalue1 = ref('苹果');
  239. const groupChange = (n) => {
  240. console.log('groupChange', n);
  241. };
  242. const radioChange = (n) => {
  243. console.log('radioChange', n);
  244. };
  245. // 修改详情页底部样式
  246. const customStyle = {
  247. height: '70rpx',
  248. paddingLeft: '30rpx',
  249. width: '540rpx'
  250. }
  251. const wrapqx = {
  252. // height: '70rpx',
  253. width: '240rpx',
  254. }
  255. // 获取传递的参数
  256. onLoad(async (options) => {
  257. // 解析传递过来的参数对象
  258. const params = JSON.parse(options.params);
  259. const {
  260. volunteerId: id, // 重命名以避免命名冲突
  261. serviceCategory
  262. } = params;
  263. // 将volunteerId赋值给响应式变量
  264. volunteerId.value = id;
  265. // 使用传递的参数调用 API
  266. const res = await getDetailsvolunteerId({
  267. volunteerId: id,
  268. serviceCategory
  269. });
  270. // 将获取到的结果赋值给响应式变量
  271. listData.value = res.data || {};
  272. });
  273. // 选择日期
  274. const getListTime = async () => {
  275. const params = {
  276. volunteerId: Number(volunteerId.value),
  277. }
  278. const res = await volunteerwork(params)
  279. if (res.data) {
  280. console.log(res.data, '>>>>>res.data333');
  281. doorToDoorTimeArr.value = res.data
  282. const newRes = [res.data[0], res.data[res.data.length - 1]]
  283. doorToDoorTime.value = newRes
  284. startDisabled.value = doorToDoorTime.value[0]
  285. endDisabled.value = doorToDoorTime.value[1]
  286. }
  287. }
  288. // 获取志愿者排班时间
  289. const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
  290. currentDate.value.push(date)
  291. console.log(date, '获取日期2')
  292. if (!volunteerId.value) {
  293. console.error('volunteerId 为空');
  294. return;
  295. }
  296. const params = {
  297. volunteerId: volunteerId.value,
  298. date
  299. };
  300. try {
  301. const res = await volunteergetTimesByDate(params);
  302. const TArr = res.data.map(item => {
  303. return {
  304. ...item,
  305. hours: item.reservationTime,
  306. timeStamp: new Date(date + ' ' + item.reservationTime).getTime() / 1000
  307. }
  308. })
  309. let arr = []
  310. doorToDoorTimeArr.value.forEach(() => {
  311. arr.push(TArr)
  312. })
  313. timeHostArr.value = arr
  314. } catch (error) {
  315. console.error('获取排班时间失败:', error);
  316. }
  317. };
  318. // 点击具体时间触发
  319. const getByTime = (timeObj) => {
  320. currentTime.value = timeObj.hours
  321. totalTimes.value += 1 // 记录点击次数
  322. console.log(totalTimes.value, '>>>>>>>>>totalTimes.value');
  323. }
  324. // 立即购买显示时执行
  325. const upPopupOpen = () => { //显示时初始化预存储信息数据
  326. totalTimes.value = 0
  327. currentTime.value = ''
  328. if (doorToDoorTimeArr.value.length) currentDate.value = [doorToDoorTimeArr.value[0]]
  329. }
  330. // 确认购买
  331. const handlConfiRmpurchase = async () => {
  332. // 定义要发送的数据
  333. const orderData = {
  334. orders: {
  335. serviceOnePrice: onePrice.value, //需要传400死值返回给后端
  336. serviceTotalPrice: computeMoney.value, //需要传获取到的总价
  337. serviceCategory: 2,
  338. totalTimes: totalTimes.value, //点击的次数
  339. serviceStartDate: "2025-04-18",
  340. startTime: "8:00",
  341. serviceDuration: 4,
  342. paymentMethod: 1,
  343. addressId: 7,
  344. remark: "我是图图小淘气,面对世界很好奇!",
  345. volunteerId: volunteerId.value
  346. },
  347. workDateList: [
  348. // {
  349. // workDate: currentDate.value,//需要传获取到的时间,就是某个月份
  350. // }
  351. ]
  352. };
  353. (new Set(currentDate.value)).forEach((item) => {
  354. orderData.workDateList.push({
  355. workDate: item,
  356. workStartTime: currentTime.value,
  357. })
  358. })
  359. try {
  360. const res = await ordersCreateOrder(orderData);
  361. if (res.code == 200) {
  362. showNotify.value = true
  363. uni.reLaunch({
  364. url: '/pages/index'
  365. });
  366. }
  367. } catch (error) {
  368. console.error('支付失败', error);
  369. }
  370. };
  371. onMounted(async () => {
  372. await getListTime()
  373. getByDate()
  374. })
  375. </script>
  376. <style scoped>
  377. .card-container {
  378. display: flex;
  379. position: relative;
  380. padding: 20rpx;
  381. align-items: flex-start;
  382. background-color: #fff;
  383. border-radius: 12rpx;
  384. }
  385. /* 左侧图片 */
  386. .card-image {
  387. width: 240rpx;
  388. height: 340rpx;
  389. border-radius: 12rpx;
  390. margin-right: 30rpx;
  391. flex-shrink: 0;
  392. }
  393. /* 中间信息区域 */
  394. .card-info {
  395. flex: 1;
  396. padding-right: 100rpx;
  397. }
  398. .Telephone {
  399. white-space: nowrap;
  400. margin-bottom: 24rpx;
  401. font-size: 28rpx;
  402. line-height: 1.6;
  403. color: #333;
  404. }
  405. .info-item {
  406. margin-bottom: 24rpx;
  407. font-size: 28rpx;
  408. line-height: 1.6;
  409. color: #333;
  410. }
  411. /* 右上角评分 */
  412. .card-rating {
  413. position: absolute;
  414. top: 20rpx;
  415. right: 20rpx;
  416. background-color: #f8f8f8;
  417. padding: 6rpx 16rpx;
  418. border-radius: 20rpx;
  419. font-size: 24rpx;
  420. color: #ff9900;
  421. font-weight: bold;
  422. }
  423. /* 固定在页面底部 */
  424. .Wrap-btn {
  425. /* display: flex; */
  426. /* justify-content: flex-end; */
  427. /* align-items: center; */
  428. position: fixed;
  429. bottom: 0;
  430. width: 100%;
  431. background-color: white;
  432. padding: 40rpx 20rpx;
  433. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1);
  434. }
  435. .Wrapper {
  436. display: flex;
  437. align-items: center;
  438. gap: 10rpx;
  439. margin-top: 10rpx;
  440. }
  441. .Wrapper-img {
  442. width: 50rpx;
  443. height: 50rpx;
  444. margin-left: 10rpx;
  445. }
  446. .Wrapper-content {
  447. color: rgba(16, 16, 16, 1);
  448. font-size: 25rpx;
  449. font-family: PingFangSC-regular;
  450. line-height: 20rpx;
  451. }
  452. .Wrap-content1 {
  453. display: flex;
  454. justify-content: flex-start;
  455. margin-left: 10rpx;
  456. margin-top: 10rpx;
  457. }
  458. .Wrap-info {
  459. display: flex;
  460. justify-content: flex-start;
  461. margin-left: 10rpx;
  462. margin-top: 25rpx;
  463. }
  464. .Wrap-content3 {
  465. margin-top: 25rpx;
  466. }
  467. .Wrap-content4 {
  468. margin-top: 25rpx;
  469. }
  470. .Wrap-content5 {
  471. display: flex;
  472. justify-content: flex-start;
  473. margin-left: 10rpx;
  474. margin-top: 25rpx;
  475. }
  476. .Wrap-content6 {
  477. margin-top: 25rpx;
  478. }
  479. .Wrap-detils-btn {
  480. display: flex;
  481. justify-content: flex-end;
  482. align-items: center;
  483. margin-top: 25rpx;
  484. /* position: fixed;
  485. bottom: 0;
  486. width: 100%;
  487. background-color: white;
  488. padding: 40rpx 20rpx;
  489. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1); */
  490. }
  491. .Wrap-Payment {
  492. padding: 30rpx;
  493. background-color: #fff;
  494. }
  495. .payment-header {
  496. display: flex;
  497. justify-content: space-between;
  498. align-items: center;
  499. padding: 20rpx 0;
  500. }
  501. .payment-title {
  502. font-size: 32rpx;
  503. font-weight: bold;
  504. }
  505. .payment-amount {
  506. font-size: 36rpx;
  507. color: #ff4d4f;
  508. font-weight: bold;
  509. }
  510. .payment-option {
  511. display: flex;
  512. justify-content: space-between;
  513. align-items: center;
  514. padding: 30rpx 0;
  515. }
  516. .option-left {
  517. display: flex;
  518. align-items: center;
  519. }
  520. .payment-icon {
  521. width: 80rpx;
  522. height: 80rpx;
  523. margin-right: 20rpx;
  524. }
  525. .option-text {
  526. font-size: 30rpx;
  527. font-weight: bold;
  528. }
  529. .other-payment {
  530. padding: 30rpx 0;
  531. color: #1890ff;
  532. font-size: 28rpx;
  533. }
  534. .terms-of-service {
  535. padding: 30rpx 0;
  536. font-size: 24rpx;
  537. color: #999;
  538. line-height: 1.5;
  539. }
  540. .confirm-button {
  541. margin-top: 40rpx;
  542. }
  543. </style>