goodsDetails.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  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">
  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;">¥300000</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"
  75. @getByDate=getByDate></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">取消</up-button>
  84. <up-button type="error" shape="circle" :customStyle="wrapqx" @click="handleBuy">购买</up-button>
  85. </view>
  86. </up-popup>
  87. </view>
  88. <up-popup v-model:show="showSum">
  89. <view class="Wrap-Payment">
  90. <!-- 支付金额 -->
  91. <view class="payment-header">
  92. <text class="payment-title">现在支付</text>
  93. <text class="payment-amount">¥159.02</text>
  94. </view>
  95. <up-line></up-line>
  96. <!-- 钱包支付选项 -->
  97. <view class="payment-option">
  98. <view class="option-left">
  99. <image src="../../static/my/钱包.png" class="payment-icon"></image>
  100. <text class="option-text">钱包</text>
  101. </view>
  102. <up-radio-group v-model="radiovalue1" placement="column" @change="groupChange">
  103. <up-radio :customStyle="{marginLeft: 'auto'}" v-for="(item, index) in radiolist1" :key="index"
  104. :label="item.name" :name="item.name"></up-radio>
  105. </up-radio-group>
  106. </view>
  107. <up-line></up-line>
  108. <!-- 微信支付选项 -->
  109. <view class="payment-option">
  110. <view class="option-left">
  111. <image src="../../static/微信支付.png" class="payment-icon"></image>
  112. <text class="option-text">微信支付</text>
  113. </view>
  114. <up-radio :customStyle="{marginLeft: 'auto'}" v-for="(item, index) in radiolist2" :key="index"
  115. :label="item.name" :name="item.name"></up-radio>
  116. </view>
  117. <up-line></up-line>
  118. <!-- 其他支付方式 -->
  119. <view class="other-payment">
  120. 其他方式支付 >
  121. </view>
  122. <!-- 条款说明 -->
  123. <view class="terms-of-service">
  124. 我同意购买守则,取消政策和退款政策,我也同意支付以下所示的总金额(含服务费)。
  125. </view>
  126. <!-- 确认按钮 -->
  127. <view class="confirm-button">
  128. <up-button type="primary" text="确认购买 · ¥159.20" @click="handlConfiRmpurchase"></up-button>
  129. </view>
  130. </view>
  131. </up-popup>
  132. <up-notify message="支付成功" :show="showNotify"></up-notify>
  133. </view>
  134. </template>
  135. <script setup>
  136. import {
  137. onLoad
  138. } from '@dcloudio/uni-app'
  139. import {
  140. onMounted,
  141. ref,
  142. nextTick,
  143. reactive
  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 value = ref(''); //备注响应式
  155. const volunteerId = ref(''); // 存储志愿者ID
  156. const doorToDoorTimeArr = ref([]) // 完整时间范围
  157. const doorToDoorTime = ref([]) // 只具备开始、结束 时间
  158. const timeHostArr = ref([]) // 时间段数组
  159. const startDisabled = ref('')
  160. const endDisabled = ref('')
  161. const time = ref('')
  162. const listData = ref({})
  163. const show = ref(false); //立即购买
  164. const showSum = ref(false);
  165. const showNotify = ref(false) //支付成功提示
  166. // 定义方法
  167. function open() {
  168. // 打开逻辑,比如设置 show 为 true
  169. show.value = true;
  170. }
  171. function close() {
  172. // 关闭逻辑,设置 show 为 false
  173. show.value = false;
  174. }
  175. // 定义方法
  176. function openSum() {
  177. // 打开逻辑,比如设置 show 为 true
  178. showSum.value = true;
  179. }
  180. function closeSum() {
  181. // 关闭逻辑,设置 show 为 false
  182. showSum.value = false;
  183. }
  184. const handleBuy = () => {
  185. show.value = false; // 关闭第一个弹框
  186. showSum.value = true; // 打开第二个弹框
  187. };
  188. // 底部数据
  189. const options = ref([{
  190. icon: 'headphones',
  191. text: '客服'
  192. },
  193. {
  194. icon: 'shop',
  195. text: '收藏',
  196. },
  197. ]);
  198. const buttonGroup = ref([{
  199. text: '立即购买',
  200. backgroundColor: 'red',
  201. color: '#fff'
  202. }]);
  203. // 方法
  204. const onClick = (e) => {
  205. uni.showToast({
  206. title: `点击${e.content.text}`,
  207. icon: 'none'
  208. });
  209. };
  210. const buttonClick = (e) => {
  211. // console.log(e);
  212. // options.value[2].info++;
  213. show.value = true; // 打开弹框
  214. };
  215. // Radio 单选框数据
  216. const radiolist1 = reactive([{
  217. name: '',
  218. disabled: false,
  219. },
  220. ]);
  221. // up-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  222. const radiovalue1 = ref('苹果');
  223. const groupChange = (n) => {
  224. console.log('groupChange', n);
  225. };
  226. const radioChange = (n) => {
  227. console.log('radioChange', n);
  228. };
  229. // 修改详情页底部样式
  230. const customStyle = {
  231. height: '70rpx',
  232. paddingLeft: '30rpx',
  233. width: '540rpx'
  234. }
  235. const wrapqx = {
  236. // height: '70rpx',
  237. width: '240rpx',
  238. }
  239. // 获取传递的参数
  240. onLoad(async (options) => {
  241. // 解析传递过来的参数对象
  242. const params = JSON.parse(options.params);
  243. const {
  244. volunteerId,
  245. serviceCategory
  246. } = params; // 解构出 volunteerId 和 serviceCategory
  247. // 使用传递的参数调用 API
  248. const res = await getDetailsvolunteerId({
  249. volunteerId,
  250. serviceCategory
  251. });
  252. // 将获取到的结果赋值给响应式变量
  253. listData.value = res.data || {};
  254. });
  255. // 获取志愿者排班时间
  256. const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
  257. console.log(date, '获取日期2')
  258. if (!volunteerId.value) {
  259. console.error('volunteerId 为空');
  260. return;
  261. }
  262. const params = {
  263. volunteerId: volunteerId.value,
  264. date
  265. };
  266. try {
  267. const res = await volunteergetTimesByDate(params);
  268. const TArr = res.data.map(item => {
  269. return {
  270. ...item,
  271. hours: item.reservationTime,
  272. timeStamp: new Date(date + ' ' + item.reservationTime).getTime() / 1000
  273. }
  274. })
  275. let arr = []
  276. doorToDoorTimeArr.value.forEach(() => {
  277. arr.push(TArr)
  278. })
  279. timeHostArr.value = arr
  280. } catch (error) {
  281. console.error('获取排班时间失败:', error);
  282. }
  283. };
  284. // 选择日期
  285. const getListTime = async () => {
  286. const params = {
  287. volunteerId: volunteerId.value,
  288. }
  289. const res = await volunteerwork(params)
  290. if (res.data) {
  291. doorToDoorTimeArr.value = res.data
  292. const newRes = [res.data[0], res.data[res.data.length - 1]]
  293. doorToDoorTime.value = newRes
  294. startDisabled.value = doorToDoorTime.value[0]
  295. endDisabled.value = doorToDoorTime.value[1]
  296. }
  297. }
  298. // 确认购买
  299. const handlConfiRmpurchase = async () => {
  300. // 定义要发送的数据
  301. const orderData = {
  302. orders: {
  303. serviceOnePrice: 400.00,
  304. serviceTotalPrice: 2000.00,
  305. serviceCategory: 2,
  306. totalTimes: 5,
  307. serviceStartDate: "2025-05-22",
  308. serviceFinishDate: "2025-05-28",
  309. startTime: "8:00",
  310. serviceDuration: 4,
  311. paymentMethod: 1,
  312. addressId: 12,
  313. remark: "我是图图小淘气,面对世界很好奇!",
  314. volunteerId: 104
  315. },
  316. workDateList: [{
  317. workDate: "2025-05-23",
  318. workStartTime: "18:00",
  319. workEndTime: "20:00"
  320. },
  321. {
  322. workDate: "2025-05-24",
  323. workStartTime: "18:00",
  324. workEndTime: "20:00"
  325. },
  326. {
  327. workDate: "2025-05-25",
  328. workStartTime: "18:00",
  329. workEndTime: "20:00"
  330. },
  331. {
  332. workDate: "2025-05-26",
  333. workStartTime: "18:00",
  334. workEndTime: "20:00"
  335. }
  336. ]
  337. };
  338. try {
  339. const res = await ordersCreateOrder(orderData);
  340. if (res.code == 200) {
  341. showNotify.value = true
  342. uni.reLaunch({
  343. url: '/pages/index'
  344. });
  345. }
  346. } catch (error) {
  347. console.error('支付失败', error);
  348. }
  349. };
  350. onMounted(async () => {
  351. await getListTime()
  352. getByDate()
  353. })
  354. </script>
  355. <style scoped>
  356. /* 主容器使用Flex布局 */
  357. .card-container {
  358. display: flex;
  359. position: relative;
  360. padding: 20rpx;
  361. align-items: flex-start;
  362. background-color: #fff;
  363. border-radius: 12rpx;
  364. }
  365. /* 左侧图片 */
  366. .card-image {
  367. width: 240rpx;
  368. height: 340rpx;
  369. border-radius: 12rpx;
  370. margin-right: 30rpx;
  371. flex-shrink: 0;
  372. }
  373. /* 中间信息区域 */
  374. .card-info {
  375. flex: 1;
  376. padding-right: 100rpx;
  377. }
  378. .Telephone {
  379. white-space: nowrap;
  380. margin-bottom: 24rpx;
  381. font-size: 28rpx;
  382. line-height: 1.6;
  383. color: #333;
  384. }
  385. .info-item {
  386. margin-bottom: 24rpx;
  387. font-size: 28rpx;
  388. line-height: 1.6;
  389. color: #333;
  390. }
  391. /* 右上角评分 */
  392. .card-rating {
  393. position: absolute;
  394. top: 20rpx;
  395. right: 20rpx;
  396. background-color: #f8f8f8;
  397. padding: 6rpx 16rpx;
  398. border-radius: 20rpx;
  399. font-size: 24rpx;
  400. color: #ff9900;
  401. font-weight: bold;
  402. }
  403. /* 固定在页面底部 */
  404. .Wrap-btn {
  405. /* display: flex; */
  406. /* justify-content: flex-end; */
  407. /* align-items: center; */
  408. position: fixed;
  409. bottom: 0;
  410. width: 100%;
  411. background-color: white;
  412. padding: 40rpx 20rpx;
  413. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1);
  414. }
  415. .Wrapper {
  416. display: flex;
  417. align-items: center;
  418. gap: 10rpx;
  419. margin-top: 10rpx;
  420. }
  421. .Wrapper-img {
  422. width: 50rpx;
  423. height: 50rpx;
  424. margin-left: 10rpx;
  425. }
  426. .Wrapper-content {
  427. color: rgba(16, 16, 16, 1);
  428. font-size: 25rpx;
  429. font-family: PingFangSC-regular;
  430. line-height: 20rpx;
  431. }
  432. .Wrap-content1 {
  433. display: flex;
  434. justify-content: flex-start;
  435. margin-left: 10rpx;
  436. margin-top: 10rpx;
  437. }
  438. .Wrap-info {
  439. display: flex;
  440. justify-content: flex-start;
  441. margin-left: 10rpx;
  442. margin-top: 25rpx;
  443. }
  444. .Wrap-content3 {
  445. margin-top: 25rpx;
  446. }
  447. .Wrap-content4 {
  448. margin-top: 25rpx;
  449. }
  450. .Wrap-content5 {
  451. display: flex;
  452. justify-content: flex-start;
  453. margin-left: 10rpx;
  454. margin-top: 25rpx;
  455. }
  456. .Wrap-content6 {
  457. margin-top: 25rpx;
  458. }
  459. .Wrap-detils-btn {
  460. display: flex;
  461. justify-content: flex-end;
  462. align-items: center;
  463. margin-top: 25rpx;
  464. /* position: fixed;
  465. bottom: 0;
  466. width: 100%;
  467. background-color: white;
  468. padding: 40rpx 20rpx;
  469. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1); */
  470. }
  471. .Wrap-Payment {
  472. padding: 30rpx;
  473. background-color: #fff;
  474. }
  475. .payment-header {
  476. display: flex;
  477. justify-content: space-between;
  478. align-items: center;
  479. padding: 20rpx 0;
  480. }
  481. .payment-title {
  482. font-size: 32rpx;
  483. font-weight: bold;
  484. }
  485. .payment-amount {
  486. font-size: 36rpx;
  487. color: #ff4d4f;
  488. font-weight: bold;
  489. }
  490. .payment-option {
  491. display: flex;
  492. justify-content: space-between;
  493. align-items: center;
  494. padding: 30rpx 0;
  495. }
  496. .option-left {
  497. display: flex;
  498. align-items: center;
  499. }
  500. .payment-icon {
  501. width: 80rpx;
  502. height: 80rpx;
  503. margin-right: 20rpx;
  504. }
  505. .option-text {
  506. font-size: 30rpx;
  507. font-weight: bold;
  508. }
  509. .other-payment {
  510. padding: 30rpx 0;
  511. color: #1890ff;
  512. font-size: 28rpx;
  513. }
  514. .terms-of-service {
  515. padding: 30rpx 0;
  516. font-size: 24rpx;
  517. color: #999;
  518. line-height: 1.5;
  519. }
  520. .confirm-button {
  521. margin-top: 40rpx;
  522. }
  523. </style>