goodsDetails.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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. volunteerId.value = options.volunteerId; // 存储到响应式变量
  242. const res = await getDetailsvolunteerId(volunteerId.value)
  243. listData.value = res.data || {};
  244. });
  245. // 选择日期
  246. const getListTime = async () => {
  247. const params = {
  248. volunteerId: volunteerId.value,
  249. }
  250. const res = await volunteerwork(params)
  251. if (res.data) {
  252. doorToDoorTimeArr.value = res.data
  253. const newRes = [res.data[0], res.data[res.data.length - 1]]
  254. doorToDoorTime.value = newRes
  255. startDisabled.value = doorToDoorTime.value[0]
  256. endDisabled.value = doorToDoorTime.value[1]
  257. }
  258. }
  259. // 获取志愿者排班时间
  260. const getByDate = async (date = doorToDoorTimeArr.value[0]) => {
  261. if (!volunteerId.value) {
  262. console.error('volunteerId 为空');
  263. return;
  264. }
  265. const params = {
  266. volunteerId: volunteerId.value,
  267. date
  268. };
  269. try {
  270. const res = await volunteergetTimesByDate(params);
  271. const TArr = res.data.map(item => {
  272. return {
  273. ...item,
  274. hours: item.reservationTime,
  275. timeStamp: new Date(date + ' ' + item.reservationTime).getTime() / 1000
  276. }
  277. })
  278. let arr = []
  279. doorToDoorTimeArr.value.forEach(() => {
  280. arr.push(TArr)
  281. })
  282. timeHostArr.value = arr
  283. } catch (error) {
  284. console.error('获取排班时间失败:', error);
  285. }
  286. };
  287. // 确认购买
  288. const handlConfiRmpurchase = async () => {
  289. // 定义要发送的数据
  290. const orderData = {
  291. orders: {
  292. serviceOnePrice: 400.00,
  293. serviceTotalPrice: 2000.00,
  294. serviceCategory: 2,
  295. totalTimes: 5,
  296. serviceStartDate: "2025-05-22",
  297. serviceFinishDate: "2025-05-28",
  298. startTime: "8:00",
  299. serviceDuration: 4,
  300. paymentMethod: 1,
  301. addressId: 12,
  302. remark: "我是图图小淘气,面对世界很好奇!",
  303. volunteerId: 104
  304. },
  305. workDateList: [{
  306. workDate: "2025-05-23",
  307. workStartTime: "18:00",
  308. workEndTime: "20:00"
  309. },
  310. {
  311. workDate: "2025-05-24",
  312. workStartTime: "18:00",
  313. workEndTime: "20:00"
  314. },
  315. {
  316. workDate: "2025-05-25",
  317. workStartTime: "18:00",
  318. workEndTime: "20:00"
  319. },
  320. {
  321. workDate: "2025-05-26",
  322. workStartTime: "18:00",
  323. workEndTime: "20:00"
  324. }
  325. ]
  326. };
  327. try {
  328. const res = await ordersCreateOrder(orderData);
  329. if(res.code == 200){
  330. showNotify.value = true
  331. uni.reLaunch({
  332. url: '/pages/index'
  333. });
  334. }
  335. } catch (error) {
  336. console.error('支付失败', error);
  337. }
  338. };
  339. onMounted(async () => {
  340. await getListTime()
  341. getByDate()
  342. })
  343. </script>
  344. <style scoped>
  345. /* 主容器使用Flex布局 */
  346. .card-container {
  347. display: flex;
  348. position: relative;
  349. padding: 20rpx;
  350. align-items: flex-start;
  351. background-color: #fff;
  352. border-radius: 12rpx;
  353. }
  354. /* 左侧图片 */
  355. .card-image {
  356. width: 240rpx;
  357. height: 340rpx;
  358. border-radius: 12rpx;
  359. margin-right: 30rpx;
  360. flex-shrink: 0;
  361. }
  362. /* 中间信息区域 */
  363. .card-info {
  364. flex: 1;
  365. padding-right: 100rpx;
  366. }
  367. .Telephone {
  368. white-space: nowrap;
  369. margin-bottom: 24rpx;
  370. font-size: 28rpx;
  371. line-height: 1.6;
  372. color: #333;
  373. }
  374. .info-item {
  375. margin-bottom: 24rpx;
  376. font-size: 28rpx;
  377. line-height: 1.6;
  378. color: #333;
  379. }
  380. /* 右上角评分 */
  381. .card-rating {
  382. position: absolute;
  383. top: 20rpx;
  384. right: 20rpx;
  385. background-color: #f8f8f8;
  386. padding: 6rpx 16rpx;
  387. border-radius: 20rpx;
  388. font-size: 24rpx;
  389. color: #ff9900;
  390. font-weight: bold;
  391. }
  392. /* 固定在页面底部 */
  393. .Wrap-btn {
  394. /* display: flex; */
  395. /* justify-content: flex-end; */
  396. /* align-items: center; */
  397. position: fixed;
  398. bottom: 0;
  399. width: 100%;
  400. background-color: white;
  401. padding: 40rpx 20rpx;
  402. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1);
  403. }
  404. .Wrapper {
  405. display: flex;
  406. align-items: center;
  407. gap: 10rpx;
  408. margin-top: 10rpx;
  409. }
  410. .Wrapper-img {
  411. width: 50rpx;
  412. height: 50rpx;
  413. margin-left: 10rpx;
  414. }
  415. .Wrapper-content {
  416. color: rgba(16, 16, 16, 1);
  417. font-size: 25rpx;
  418. font-family: PingFangSC-regular;
  419. line-height: 20rpx;
  420. }
  421. .Wrap-content1 {
  422. display: flex;
  423. justify-content: flex-start;
  424. margin-left: 10rpx;
  425. margin-top: 10rpx;
  426. }
  427. .Wrap-info {
  428. display: flex;
  429. justify-content: flex-start;
  430. margin-left: 10rpx;
  431. margin-top: 25rpx;
  432. }
  433. .Wrap-content3 {
  434. margin-top: 25rpx;
  435. }
  436. .Wrap-content4 {
  437. margin-top: 25rpx;
  438. }
  439. .Wrap-content5 {
  440. display: flex;
  441. justify-content: flex-start;
  442. margin-left: 10rpx;
  443. margin-top: 25rpx;
  444. }
  445. .Wrap-content6 {
  446. margin-top: 25rpx;
  447. }
  448. .Wrap-detils-btn {
  449. display: flex;
  450. justify-content: flex-end;
  451. align-items: center;
  452. margin-top: 25rpx;
  453. /* position: fixed;
  454. bottom: 0;
  455. width: 100%;
  456. background-color: white;
  457. padding: 40rpx 20rpx;
  458. box-shadow: -2rpx 5rpx rgba(0, 0, 0, 0.1); */
  459. }
  460. .Wrap-Payment {
  461. padding: 30rpx;
  462. background-color: #fff;
  463. }
  464. .payment-header {
  465. display: flex;
  466. justify-content: space-between;
  467. align-items: center;
  468. padding: 20rpx 0;
  469. }
  470. .payment-title {
  471. font-size: 32rpx;
  472. font-weight: bold;
  473. }
  474. .payment-amount {
  475. font-size: 36rpx;
  476. color: #ff4d4f;
  477. font-weight: bold;
  478. }
  479. .payment-option {
  480. display: flex;
  481. justify-content: space-between;
  482. align-items: center;
  483. padding: 30rpx 0;
  484. }
  485. .option-left {
  486. display: flex;
  487. align-items: center;
  488. }
  489. .payment-icon {
  490. width: 80rpx;
  491. height: 80rpx;
  492. margin-right: 20rpx;
  493. }
  494. .option-text {
  495. font-size: 30rpx;
  496. font-weight: bold;
  497. }
  498. .other-payment {
  499. padding: 30rpx 0;
  500. color: #1890ff;
  501. font-size: 28rpx;
  502. }
  503. .terms-of-service {
  504. padding: 30rpx 0;
  505. font-size: 24rpx;
  506. color: #999;
  507. line-height: 1.5;
  508. }
  509. .confirm-button {
  510. margin-top: 40rpx;
  511. }
  512. </style>