goodsDetails.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  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.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. <image src="/static/zhiyuanzhe.jpg" mode="" style="width: 100%;"></image>
  31. </template>
  32. </up-card>
  33. <!-- 固定底部按钮区 -->
  34. <view class="Wrap-btn">
  35. <uni-goods-nav :fill="true" :options="options" :buttonGroup="buttonGroup" @click="onClick"
  36. @buttonClick="buttonClick" />
  37. </view>
  38. </view>
  39. <!-- 底部弹框 -->
  40. <view>
  41. <up-popup :show="show" @close="close" @open="open">
  42. </up-popup>
  43. <up-popup v-model:show="show" @open="upPopupOpen">
  44. <view>
  45. <view class="Wrapper">
  46. <image src="/static/img/Location.png" class="Wrapper-img" />
  47. <span class="Wrapper-content">李四</span>
  48. <span class="Wrapper-content">重庆永川区</span>
  49. </view>
  50. <span style="margin-left: 15rpx; margin-top: 50rpx;">重庆永川区</span>
  51. </view>
  52. <up-divider></up-divider>
  53. <view class="Wrap-content1">
  54. <up-avatar :src="src"></up-avatar>
  55. <text style="margin-top: 15rpx;">¥{{onePrice}}</text>
  56. </view>
  57. <view class="Wrap-info">
  58. <text style="margin-left: 10rpx;">服务类别:</text>
  59. <up-text type="info" text="家庭教育"></up-text>
  60. </view>
  61. <view class="Wrap-content3">
  62. <text style="margin-left: 15rpx;">服务周期:</text>
  63. <view style="margin-top: 25rpx;">
  64. <uniDatetimePickerMy :modelValue="doorToDoorTime" :start="startDisabled" :end="endDisabled"
  65. type="daterange"></uniDatetimePickerMy>
  66. </view>
  67. <view>
  68. <its-calendar :timeArr="doorToDoorTimeArr" :timeHostArr="timeHostArr" @getByDate="getByDate"
  69. @getByTime="getByTime"></its-calendar>
  70. </view>
  71. </view>
  72. <view class="Wrap-content6">
  73. <text style="margin-left: 15rpx;">备注:</text>
  74. <up-input placeholder="请输入内容" border="surround" v-model="skillDescribe" @change="change"></up-input>
  75. </view>
  76. <view class="Wrap-detils-btn">
  77. <up-button type="primary" shape="circle" :customStyle="wrapqx" @click="handlCancel">取消</up-button>
  78. <up-button type="error" shape="circle" :customStyle="wrapqx" @click="handleBuy">
  79. 购买¥{{ computeMoney }}
  80. </up-button>
  81. </view>
  82. </up-popup>
  83. </view>
  84. <up-popup v-model:show="showSum">
  85. <view class="Wrap-Payment">
  86. <!-- 支付金额 -->
  87. <view class="payment-header">
  88. <text class="payment-title">现在支付</text>
  89. <text class="payment-amount">¥{{ computeMoney }}</text>
  90. </view>
  91. <up-line></up-line>
  92. <!-- 钱包支付选项 -->
  93. <view class="payment-option">
  94. <view class="option-left">
  95. <image src="../../static/my/钱包.png" class="payment-icon"></image>
  96. <text class="option-text">钱包</text>
  97. </view>
  98. <up-radio-group v-model="radiovalue1" placement="column" @change="groupChange">
  99. <up-radio :customStyle="{marginLeft: 'auto'}" v-for="(item, index) in radiolist1" :key="index"
  100. :label="item.name" :name="item.name"></up-radio>
  101. </up-radio-group>
  102. </view>
  103. <up-line></up-line>
  104. <!-- 微信支付选项 -->
  105. <view class="payment-option">
  106. <view class="option-left">
  107. <image src="../../static/微信支付.png" class="payment-icon"></image>
  108. <text class="option-text">微信支付</text>
  109. </view>
  110. <up-radio :customStyle="{marginLeft: 'auto'}" v-for="(item, index) in radiolist2" :key="index"
  111. :label="item.name" :name="item.name"></up-radio>
  112. </view>
  113. <up-line></up-line>
  114. <!-- 其他支付方式 -->
  115. <view class="other-payment">
  116. 其他方式支付 >
  117. </view>
  118. <!-- 条款说明 -->
  119. <view class="terms-of-service">
  120. 我同意购买守则,取消政策和退款政策,我也同意支付以下所示的总金额(含服务费)。
  121. </view>
  122. <!-- 确认按钮 -->
  123. <view class="confirm-button">
  124. <up-button type="primary" :text="`确认购买 · ¥${computeMoney}`"
  125. @click="handlConfiRmpurchase"></up-button>
  126. </view>
  127. </view>
  128. </up-popup>
  129. <up-notify message="支付成功" :show="showNotify"></up-notify>
  130. </view>
  131. </template>
  132. <script setup>
  133. // 点击当前时间,后面时间禁用
  134. // workDate获取点击的精确时间
  135. import {
  136. onLoad
  137. } from '@dcloudio/uni-app'
  138. import {
  139. onMounted,
  140. ref,
  141. nextTick,
  142. reactive,
  143. computed
  144. } from "vue";
  145. import {
  146. getDetailsvolunteerId,
  147. volunteerwork,
  148. volunteergetTimesByDate,
  149. ordersCreateOrder
  150. } from "@/api/volunteerDetailsApi/details.js"
  151. import itsCalendar from '@/components/its-calendar/its-calendar.vue';
  152. import uniDatetimePickerMy from "@/uni_modules/lic-uni-datetime-picker/components/lic-uni-datetime-picker/lic-uni-datetime-picker.vue"
  153. const src = ref('http://pic2.sc.chinaz.com/Files/pic/pic9/202002/hpic2119_s.jpg')
  154. const onePrice = ref(400)
  155. const volunteerId = ref(''); // 存储志愿者ID
  156. const serviceCategory = ref('') //存储大类别
  157. const businessManagementId = ref('') //具体分类id
  158. const doorToDoorTimeArr = ref([]) // 完整时间范围
  159. const doorToDoorTime = ref([]) // 只具备开始、结束 时间
  160. const timeHostArr = ref([]) // 时间段数组
  161. const currentDate = ref([]) // 点击过的年月日数组数据
  162. const currentTime = ref('') // 最后一次点击时间的时间节点
  163. const totalTimes = ref(0) // 时间点 点击的次数
  164. const startDisabled = ref('')
  165. const endDisabled = ref('')
  166. const time = ref('')
  167. const listData = ref({})
  168. const show = ref(false); //立即购买
  169. const showSum = ref(false);
  170. const showNotify = ref(false) //支付成功提示
  171. const skillDescribe = ref('') //备注
  172. const computeMoney = computed(() => {
  173. return totalTimes.value * onePrice.value
  174. })
  175. // 定义方法
  176. function open() {
  177. // 打开逻辑,比如设置 show 为 true
  178. show.value = true;
  179. }
  180. function close() {
  181. // 关闭逻辑,设置 show 为 false
  182. show.value = false;
  183. }
  184. // 定义方法
  185. function openSum() {
  186. // 打开逻辑,比如设置 show 为 true
  187. showSum.value = true;
  188. }
  189. function closeSum() {
  190. // 关闭逻辑,设置 show 为 false
  191. showSum.value = false;
  192. }
  193. const handleBuy = () => {
  194. show.value = false; // 关闭第一个弹框
  195. showSum.value = true; // 打开第二个弹框
  196. };
  197. const handlCancel = () => {
  198. show.value = false; // 关闭第一个弹框
  199. }
  200. // 底部数据
  201. const options = ref([{
  202. icon: 'headphones',
  203. text: '客服'
  204. },
  205. {
  206. icon: 'shop',
  207. text: '收藏',
  208. },
  209. ]);
  210. const buttonGroup = ref([{
  211. text: '立即购买',
  212. backgroundColor: 'red',
  213. color: '#fff'
  214. }]);
  215. // 方法
  216. const onClick = (e) => {
  217. uni.showToast({
  218. title: `点击${e.content.text}`,
  219. icon: 'none'
  220. });
  221. };
  222. const buttonClick = (e) => {
  223. // console.log(e);
  224. // options.value[2].info++;
  225. show.value = true; // 打开弹框
  226. };
  227. // Radio 单选框数据
  228. const radiolist1 = reactive([{
  229. name: '',
  230. disabled: false,
  231. },
  232. ]);
  233. // up-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  234. const radiovalue1 = ref('苹果');
  235. const groupChange = (n) => {
  236. console.log('groupChange', n);
  237. };
  238. const radioChange = (n) => {
  239. console.log('radioChange', n);
  240. };
  241. // 修改详情页底部样式
  242. const customStyle = {
  243. height: '70rpx',
  244. paddingLeft: '30rpx',
  245. width: '540rpx'
  246. }
  247. const wrapqx = {
  248. // height: '70rpx',
  249. width: '240rpx',
  250. }
  251. // 获取传递的参数
  252. onLoad(async (options) => {
  253. // 解析传递过来的参数对象
  254. const params = JSON.parse(options.params);
  255. const {
  256. volunteerId: id,
  257. serviceCategory: categoy,
  258. businessManagementId: manage
  259. } = params;
  260. // 将volunteerId赋值给响应式变量
  261. volunteerId.value = id;
  262. serviceCategory.value = categoy
  263. // 使用传递的参数调用 API
  264. const res = await getDetailsvolunteerId({
  265. volunteerId: id,
  266. serviceCategory: categoy,
  267. businessManagementId: manage,
  268. });
  269. // 将获取到的结果赋值给响应式变量
  270. listData.value = res.data || {};
  271. });
  272. // 选择日期
  273. const getListTime = async () => {
  274. const params = {
  275. volunteerId: Number(volunteerId.value),
  276. }
  277. const res = await volunteerwork(params)
  278. if (res.data) {
  279. console.log(res.data, '>>>>>res.data333');
  280. doorToDoorTimeArr.value = res.data
  281. const newRes = [res.data[0], res.data[res.data.length - 1]]
  282. doorToDoorTime.value = newRes
  283. startDisabled.value = doorToDoorTime.value[0]
  284. endDisabled.value = doorToDoorTime.value[1]
  285. }
  286. }
  287. // 获取志愿者排班时间
  288. const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
  289. console.log(date, '获取日期2')
  290. if (!volunteerId.value) {
  291. console.error('volunteerId 为空');
  292. return;
  293. }
  294. const params = {
  295. volunteerId: volunteerId.value,
  296. date
  297. };
  298. try {
  299. const res = await volunteergetTimesByDate(params);
  300. const TArr = res.data.map(item => {
  301. return {
  302. ...item,
  303. hours: item.reservationTime,
  304. timeStamp: new Date(date + ' ' + item.reservationTime).getTime() / 1000
  305. }
  306. })
  307. let arr = []
  308. doorToDoorTimeArr.value.forEach(() => {
  309. arr.push(TArr)
  310. })
  311. timeHostArr.value = arr
  312. } catch (error) {
  313. console.error('获取排班时间失败:', error);
  314. }
  315. };
  316. // 点击具体时间触发
  317. const getByTime = (timeObj) => {
  318. console.log('>>>>>>触发111');
  319. currentDate.value.push(timeObj.yearToDate)
  320. currentTime.value = timeObj.hours
  321. totalTimes.value += 1 // 记录点击次数
  322. }
  323. // 立即购买显示时执行
  324. const upPopupOpen = () => { //显示时初始化预存储信息数据
  325. totalTimes.value = 0
  326. currentTime.value = ''
  327. currentDate.value = []
  328. }
  329. // 确认购买
  330. const handlConfiRmpurchase = async () => {
  331. // 定义要发送的数据
  332. const orderData = {
  333. orders: {
  334. serviceOnePrice: onePrice.value, //需要传400死值返回给后端
  335. serviceTotalPrice: computeMoney.value, //需要传获取到的总价
  336. serviceCategory: serviceCategory.value, //大类别参数
  337. totalTimes: totalTimes.value, //点击的次数
  338. serviceStartDate: "2025-04-18",
  339. startTime: "8:00",
  340. serviceDuration: 4,
  341. paymentMethod: 1,
  342. addressId: 7,
  343. remark: "我是图图小淘气,面对世界很好奇!",
  344. volunteerId: volunteerId.value,
  345. skillDescribe: skillDescribe.value
  346. },
  347. workDateList: [
  348. // {
  349. // workDate: currentDate.value,//需要传获取到的时间,就是某个月份
  350. // }
  351. ]
  352. };
  353. currentDate.value.length && (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>