orderdetails.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  1. <template>
  2. <view>
  3. <view class="address-container" @click="handleAddressClick">
  4. <view class="address-header">
  5. <!-- 左侧默认标签-->
  6. <!-- 中间收货人信息 -->
  7. <view class="contact-info">
  8. {{ listData.name || listData.cityName }}
  9. {{ listData.telephone }}
  10. </view>
  11. <!-- 右侧图标 -->
  12. <up-icon name="arrow-right" class="arrow-icon"></up-icon>
  13. </view>
  14. <!-- 下方地址信息 -->
  15. <view class="address-detail">
  16. {{ listData.provinceName }} {{ listData.cityName }}
  17. {{ listData.districtName }} {{ listData.address }}
  18. </view>
  19. </view>
  20. <view>
  21. <up-card title="服务信息" :head-style="{ height: '80rpx', padding: '20rpx' }">
  22. <template #body>
  23. <view class="card-container">
  24. <image class="card-image" :src="listData.volunteerPicture" mode="aspectFill">
  25. </image>
  26. <view class="card-info">
  27. <view class="info-item">服务类别:{{ listData.businessManagementName }}</view>
  28. <view class="info-item">服务时长:{{ listData.serviceDuration }}分钟</view>
  29. <view class="info-item">服务价格:{{ listData.serviceOnePrice }}</view>
  30. <view class="info-item">服务数量:{{ listData.singleQuantity}}{{ listData.businessUnit }}</view>
  31. <view class="info-itemIform">服务描述:{{ listData.businessDescribe }}</view>
  32. </view>
  33. <view class="card-rating">4.5 评分</view>
  34. </view>
  35. </template>
  36. </up-card>
  37. <up-card title="志愿者介绍" :head-style="{ height: '80rpx', padding: '20rpx' }">
  38. <template #body>
  39. <view class="card-container">
  40. <image class="card-image" :src="listData.volunteerPicture" mode="aspectFill">
  41. </image>
  42. <view class="card-info">
  43. <view class="info-item">{{ listData.volunteerName }}</view>
  44. <view class="info-item">年龄:{{ listData.age }}</view>
  45. <view class="Telephone">电话:{{ listData.phonenumber }}</view>
  46. <view class="info-item">住址:{{ listData.address }}</view>
  47. </view>
  48. <view class="card-rating">4.5 评分</view>
  49. </view>
  50. </template>
  51. </up-card>
  52. <up-card title="个人简介" :head-style="{ height: '80rpx', padding: '20rpx' }">
  53. <template #body>
  54. {{ listData.skillDescribe }}
  55. </template>
  56. </up-card>
  57. <up-card title="证书" :head-style="{ height: '80rpx', padding: '20rpx' }">
  58. <template #body>
  59. <view class="certificate-container" v-if="certificationPictures.length > 0">
  60. <image v-for="(image, index) in certificationPictures" :key="index" :src="image" mode="widthFix"
  61. class="certificate-img" @click="previewImage(image, certificationPictures)"></image>
  62. </view>
  63. <view v-else class="no-certificate">暂无证书</view>
  64. </template>
  65. </up-card>
  66. </view>
  67. <up-card v-for="(item, index) in listData.secondOrderList" :key="index" :title="'订单号'">
  68. <template #head>
  69. <view class="custom-order-title">
  70. <text>订单号:</text>
  71. <text class="order-number">{{ item.secondOutTradeNo }}</text>
  72. </view>
  73. </template>
  74. <template #body>
  75. <view class="list-item">
  76. <image :src="listData.volunteerPicture" mode="aspectFill" class="item-image">
  77. </image>
  78. <view class="item-info">
  79. <view class="info-line">
  80. 服务类别:{{ listData.businessManagementName }}
  81. </view>
  82. <text>服务价格:<text style="color: red">¥{{ item.serviceTotalPrice }}</text></text>
  83. <view class="info-item">服务数量:{{ listData.singleQuantity
  84. }}{{ listData.businessUnit }}</view>
  85. <text>服务状态:{{
  86. dictSortMap[item.orderStatus] || item.orderStatus
  87. }}</text>
  88. <view class="info-line">
  89. 预计开始服务日期:{{ item.workDate }}
  90. </view>
  91. <view class="info-line">
  92. 预计开始服务时间:{{ item.workStartTime }}
  93. </view>
  94. <view class="info-line">
  95. 预计结束服务时间:{{ item.workEndTime }}
  96. </view>
  97. </view>
  98. <view class="right-corner-container" v-if="item.orderStatus !== '1'">
  99. <up-button type="error" :text="item.score ? '查看评论' : '评论'" size="mini" @click="handlButClick(item)"
  100. :customStyle="hadlClickError"></up-button>
  101. </view>
  102. </view>
  103. </template>
  104. </up-card>
  105. </view>
  106. </template>
  107. <script setup>
  108. import { onLoad, onShow } from '@dcloudio/uni-app'
  109. import { ref, computed, onMounted } from 'vue'
  110. import { orderInfomainOrderId } from '@/api/userList.js'
  111. import { systemDictdaTalist } from '@/api/userList.js'
  112. import store from '@/store'
  113. const listData = ref({}) //志愿者详情数据
  114. const dataList = ref([])
  115. const orderStatus = ref(0)
  116. const score = ref(null)
  117. const mainOrderId = ref('') //志愿者ID
  118. const certificationPictures = computed(() => {
  119. if (listData.value.certificationPicture) {
  120. return listData.value.certificationPicture.split(',')
  121. }
  122. return []
  123. })
  124. const dictSortMap = computed(() => {
  125. let mapObj = {}
  126. dataList.value.forEach((item) => {
  127. mapObj[item.dictValue] = item.dictLabel
  128. })
  129. return mapObj
  130. })
  131. //获取用户订单列表状态
  132. async function getData() {
  133. try {
  134. const res = await systemDictdaTalist().catch((err) => {
  135. console.error('接口请求失败:', err)
  136. throw err // 重新抛出以进入 catch 块
  137. })
  138. dataList.value = res.rows
  139. } catch (e) {
  140. console.error('获取数据异常:', e) // 确保这里打印错误
  141. }
  142. }
  143. const handlButClick = (item) => {
  144. console.log(item, '》》》》》》 获取传递的 item');
  145. // 直接跳转到userComment页面并传递必要数据
  146. uni.navigateTo({
  147. url: `/pages_classify/pages/orderItem/userComment?secondOrderId=${item.secondOrderId}`
  148. });
  149. // 在跳转前存储必要数据
  150. uni.setStorage({
  151. key: 'orderDetailsData',
  152. data: {
  153. volunteerPicture: listData.value.volunteerPicture,
  154. businessManagementName: listData.value.businessManagementName,
  155. volunteerName: listData.value.volunteerName,
  156. volunteerInfoId: listData.value.volunteerInfoId,
  157. secondOrderId: item.secondOrderId
  158. },
  159. fail: (err) => {
  160. console.error('保存订单数据失败', err);
  161. }
  162. });
  163. }
  164. // 获取传递的参数
  165. onLoad(async (options) => {
  166. mainOrderId.value = options.mainOrderId
  167. const res = await orderInfomainOrderId(mainOrderId.value)
  168. // 检查是否有临时地址
  169. const tempAddress = store.state.user.tempSelectedAddress
  170. if (tempAddress) {
  171. // 合并临时地址和订单数据
  172. listData.value = {
  173. ...res.data,
  174. ...tempAddress
  175. }
  176. } else {
  177. listData.value = res.data
  178. }
  179. })
  180. // 添加 onShow 生命周期钩子
  181. onShow(async () => {
  182. // 从 store 获取临时地址
  183. const tempAddress = store.state.user.tempSelectedAddress
  184. if (tempAddress) {
  185. // 合并临时地址和订单数据
  186. listData.value = {
  187. ...listData.value,
  188. ...tempAddress
  189. }
  190. }
  191. })
  192. const hadlClickError = {
  193. width: '150rpx',
  194. height: '50rpx',
  195. marginTop: '70rpx',
  196. }
  197. // 预览图片
  198. const previewImage = (current, urls) => {
  199. uni.previewImage({
  200. current,
  201. urls,
  202. })
  203. }
  204. // 添加地址点击事件处理
  205. const handleAddressClick = () => {
  206. uni.navigateTo({
  207. url: '/pages_mine/pages/selectAddress/index'
  208. })
  209. }
  210. onMounted(() => {
  211. getData()
  212. })
  213. </script>
  214. <style scoped>
  215. .address-container {
  216. padding: 20rpx;
  217. border: 1rpx solid #eee;
  218. border-radius: 10rpx;
  219. }
  220. .address-header {
  221. display: flex;
  222. align-items: center;
  223. margin-bottom: 10rpx;
  224. }
  225. .contact-info {
  226. flex: 1;
  227. /* 占据剩余空间 */
  228. font-size: 28rpx;
  229. margin-left: 25rpx;
  230. }
  231. .arrow-icon {
  232. margin-left: auto;
  233. /* 将图标推到最右侧 */
  234. }
  235. .address-detail {
  236. font-size: 26rpx;
  237. color: #666;
  238. }
  239. .card-container {
  240. display: flex;
  241. position: relative;
  242. padding: 20rpx;
  243. align-items: flex-start;
  244. background-color: #fff;
  245. border-radius: 12rpx;
  246. }
  247. /* 左侧图片 */
  248. .card-image {
  249. width: 240rpx;
  250. height: 340rpx;
  251. border-radius: 12rpx;
  252. margin-right: 30rpx;
  253. flex-shrink: 0;
  254. }
  255. /* 中间信息区域 */
  256. .card-info {
  257. flex: 1;
  258. padding-right: 100rpx;
  259. }
  260. /* 中间信息区域 */
  261. .card-info {
  262. flex: 1;
  263. padding-right: 100rpx;
  264. }
  265. .Telephone {
  266. white-space: nowrap;
  267. margin-bottom: 24rpx;
  268. font-size: 28rpx;
  269. line-height: 1.6;
  270. color: #333;
  271. }
  272. .info-item {
  273. margin-bottom: 15rpx;
  274. font-size: 28rpx;
  275. line-height: 1.6;
  276. color: #333;
  277. }
  278. .info-itemIform{
  279. display: -webkit-box;
  280. -webkit-line-clamp: 3;
  281. -webkit-box-orient: vertical;
  282. overflow: hidden;
  283. text-overflow: ellipsis;
  284. margin-bottom: 15rpx;
  285. font-size: 28rpx;
  286. line-height: 1.6;
  287. color: #333;
  288. }
  289. /* 右上角评分 */
  290. .card-rating {
  291. position: absolute;
  292. top: 20rpx;
  293. right: 40rpx;
  294. background-color: #f8f8f8;
  295. padding: 6rpx 16rpx;
  296. border-radius: 20rpx;
  297. font-size: 24rpx;
  298. color: #ff9900;
  299. font-weight: bold;
  300. }
  301. /* 上课时间 */
  302. .Wrap-top {
  303. display: flex;
  304. justify-content: space-between;
  305. align-items: center;
  306. padding: 24rpx 20rpx 0rpx 24rpx;
  307. }
  308. .list-item {
  309. display: flex;
  310. padding: 24rpx;
  311. align-items: flex-start;
  312. gap: 24rpx;
  313. position: relative;
  314. }
  315. .item-image {
  316. width: 160rpx;
  317. height: 180rpx;
  318. border-radius: 16rpx;
  319. object-fit: cover;
  320. }
  321. .item-info {
  322. flex: 1;
  323. display: flex;
  324. flex-direction: column;
  325. gap: 14rpx;
  326. }
  327. .info-line {
  328. font-size: 28rpx;
  329. color: #333;
  330. line-height: 1.6;
  331. }
  332. .right-corner-container {
  333. display: flex;
  334. flex-direction: column;
  335. align-items: flex-end;
  336. }
  337. .certificate-container {
  338. display: flex;
  339. flex-wrap: wrap;
  340. gap: 20rpx;
  341. padding: 10rpx;
  342. }
  343. .certificate-img {
  344. width: 220rpx;
  345. height: 220rpx;
  346. border-radius: 8rpx;
  347. object-fit: cover;
  348. }
  349. .no-certificate {
  350. text-align: center;
  351. color: #999;
  352. padding: 30rpx;
  353. }
  354. .custom-order-title {
  355. display: flex;
  356. align-items: center;
  357. font-size: 28rpx;
  358. color: #303133;
  359. width: 100%;
  360. padding: 10rpx 0;
  361. }
  362. .order-number {
  363. word-break: break-all;
  364. flex: 1;
  365. }
  366. </style>