index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  1. <!-- 订单详情 -->
  2. <template>
  3. <view>
  4. <view class="order-detail">
  5. <view class="service-info">
  6. <PositioningMap :address="detaile.address" />
  7. </view>
  8. <view class="user-info order-card">
  9. <view class="handle-user">
  10. <view class="handle-user-left">
  11. <img
  12. src="/static/serverImg/mine/user.png"
  13. alt=""
  14. style="width: 96rpx; height: 96rpx; margin-right: 32rpx"
  15. />
  16. <view class="handle-user-info">
  17. <view class="user-name">{{ detaile.name }}</view>
  18. <view class="user-id" style="display: flex"
  19. >服务类别:<dict-tag
  20. :options="lrr_service_category"
  21. :value="detaile.serviceCategory"
  22. /></view>
  23. </view>
  24. </view>
  25. <view class="user-phone" @click="onPhone(detaile.telephone)">
  26. <up-icon name="phone" color="#fff" size="25"></up-icon>
  27. </view>
  28. </view>
  29. <view class="handle-adress">
  30. <up-icon
  31. name="map"
  32. color="rgba(156, 163, 175, 1)"
  33. size="20"
  34. ></up-icon>
  35. <view class="adress-text">{{ detaile.address }}</view>
  36. <up-icon
  37. name="pushpin"
  38. color="rgba(221, 94, 69, 1)"
  39. size="25"
  40. ></up-icon>
  41. </view>
  42. <view>
  43. <view>服务次数:{{ detaile.singleQuantity }}次</view>
  44. <view>服务开始时间:{{ detaile.workStartTime }}</view>
  45. <view>服务结束时间:{{ detaile.workEndTime }}</view>
  46. </view>
  47. <view class="handle-remark">
  48. <view class="remark-title">备注</view>
  49. <view class="remark-text">{{ detaile.remark || '暂无备注' }}</view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="footer-g">
  54. <view class="handle-start" v-if="orderStatus && serveTimes">
  55. 服务已开始:<text class="handle-time">{{ dateData }}</text>
  56. </view>
  57. <Slide ref="verify" @change="change" :sliderText="slideData" />
  58. </view>
  59. </view>
  60. </template>
  61. <script setup>
  62. import { ref } from 'vue'
  63. import { onLoad, onUnload } from '@dcloudio/uni-app'
  64. import { getVolunteerOrderInfo, getTimesByDate } from '@/api/volunteer.js'
  65. import PositioningMap from '@/pages_classify/components/PositioningMap/index.vue'
  66. import Slide from '@/pages_classify/components/Slide/index.vue'
  67. import { useDict } from '@/utils/dict.js'
  68. import DictTag from '@/components/DictTag/index.vue'
  69. import { wxMakePhoneCall } from '@/utils/wxRequest.js'
  70. import { computed } from 'vue'
  71. const secondOrderId = ref('')
  72. const detaile = ref({})
  73. const verify = ref(null)
  74. const { lrr_service_category } = useDict('lrr_service_category')
  75. const orderStatus = ref(false) //false:未开始服务 true:服务已开始,待上传图片
  76. const onPhone = (phone) => {
  77. if (phone) {
  78. wxMakePhoneCall(phone)
  79. }
  80. }
  81. const dateData = ref('00:00:00')
  82. let timer = null
  83. const slideData = computed(() => {
  84. //服务已开始,待上传图片
  85. if (orderStatus.value) {
  86. return {
  87. successText: '服务已完成',
  88. startText: '拖动滑块结束服务',
  89. successColor: '#f64a1f',
  90. btnText: '上传照片',
  91. }
  92. }
  93. return {
  94. successText: '服务已开始',
  95. startText: '拖动滑块开始服务',
  96. successColor: '#72c13f',
  97. btnText: '开始',
  98. }
  99. })
  100. const getOrderDetail = async () => {
  101. try {
  102. uni.showLoading({
  103. title: '数据加载中...',
  104. })
  105. const res = await getVolunteerOrderInfo({
  106. secondOrderId: secondOrderId.value,
  107. })
  108. // Update to match the actual data structure where properties are at the top level
  109. detaile.value = { ...res.data, serveTimes: res.data.updateTime || null }
  110. if (res.data.orderStatus === '3') {
  111. orderStatus.value = true
  112. }
  113. if (res.data.updateTime) {
  114. timer = setInterval(() => {
  115. const timeDiff = Math.abs(new Date() - new Date(res.data.updateTime))
  116. const units = {
  117. day: Math.floor(timeDiff / (1000 * 60 * 60 * 24)),
  118. hour: Math.floor(timeDiff / (1000 * 60 * 60)),
  119. minute: Math.floor(timeDiff / (1000 * 60)),
  120. second: Math.floor(timeDiff / 1000),
  121. }
  122. // 默认返回完整格式
  123. const hours = units.hour % 24
  124. const minutes = units.minute % 60
  125. const seconds = units.second % 60
  126. dateData.value = `${hours}小时${minutes}分钟${seconds}秒`
  127. }, 1000)
  128. }
  129. } catch (error) {
  130. console.log('error', error)
  131. uni.showToast({
  132. title: error.msg,
  133. icon: 'error',
  134. })
  135. } finally {
  136. uni.hideLoading()
  137. }
  138. }
  139. const change = (e) => {
  140. if (e.state && !orderStatus.value) {
  141. getTimesByDate(secondOrderId.value).then((res) => {
  142. if (res.code === 200) {
  143. uni.showToast({
  144. title: '已开始服务',
  145. icon: 'success',
  146. success: () => {
  147. verify.value.initialization()
  148. // 验证成功
  149. orderStatus.value = true
  150. },
  151. })
  152. }
  153. })
  154. }
  155. if (e.state && orderStatus.value) {
  156. uni.showToast({
  157. title: '操作成功',
  158. icon: 'success',
  159. success: () => {
  160. setTimeout(() => {
  161. uni.redirectTo({
  162. url: `/pages_classify/pages/order/index?secondOrderId=${secondOrderId.value}`,
  163. })
  164. }, 800)
  165. },
  166. })
  167. }
  168. }
  169. onLoad((options) => {
  170. secondOrderId.value = options.secondOrderId
  171. getOrderDetail()
  172. })
  173. onUnload(() => {
  174. clearInterval(timer)
  175. timer = null
  176. })
  177. </script>
  178. <style lang="scss" scoped>
  179. .order-detail {
  180. position: fixed;
  181. top: 0;
  182. left: 0;
  183. right: 0;
  184. bottom: 280rpx;
  185. overflow-y: auto;
  186. .order-card {
  187. border-radius: 8px;
  188. background: rgba(255, 255, 255, 1);
  189. padding: 12px;
  190. margin-bottom: 12px;
  191. }
  192. .font-title {
  193. margin-bottom: 12px;
  194. }
  195. .user-box {
  196. display: flex;
  197. .user-img {
  198. width: 65.8px;
  199. height: 65.8px;
  200. margin-right: 12px;
  201. }
  202. }
  203. .register-box {
  204. display: flex;
  205. margin-bottom: 12px;
  206. .register-img {
  207. width: 90px;
  208. height: 90px;
  209. margin-right: 12px;
  210. }
  211. }
  212. .info-list {
  213. flex: 1;
  214. font-size: 14px;
  215. font-weight: 500;
  216. letter-spacing: 0px;
  217. line-height: 23.27px;
  218. color: rgba(51, 51, 51, 1);
  219. }
  220. .price {
  221. font-size: 18px;
  222. font-weight: 500;
  223. color: rgba(246, 74, 31, 1);
  224. .price-yuan {
  225. font-size: 13px;
  226. font-weight: 700;
  227. color: rgba(246, 74, 31, 1);
  228. }
  229. }
  230. .upload-img {
  231. height: 68px;
  232. width: 68px;
  233. margin-right: 12px;
  234. margin-bottom: 12px;
  235. }
  236. .upload-box {
  237. display: flex;
  238. flex-wrap: wrap;
  239. .upload-img-item {
  240. position: relative;
  241. .delete-icon {
  242. position: absolute;
  243. top: -7px;
  244. right: 7px;
  245. z-index: 1;
  246. }
  247. }
  248. }
  249. .phone {
  250. color: #3c9cff;
  251. }
  252. }
  253. .handle-user {
  254. display: flex;
  255. align-items: center;
  256. justify-content: space-between;
  257. .handle-user-left {
  258. display: flex;
  259. align-items: center;
  260. .handle-user-info {
  261. .user-name {
  262. font-size: 32rpx;
  263. font-weight: 400;
  264. color: rgba(17, 24, 39, 1);
  265. }
  266. .user-id {
  267. font-size: 28rpx;
  268. font-weight: 400;
  269. color: rgba(107, 114, 128, 1);
  270. }
  271. }
  272. }
  273. .user-phone {
  274. display: flex;
  275. align-items: center;
  276. justify-content: center;
  277. width: 80rpx;
  278. height: 80rpx;
  279. border-radius: 50%;
  280. background: rgba(221, 94, 69, 1);
  281. }
  282. }
  283. .handle-adress {
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-between;
  287. margin-top: 38rpx;
  288. .adress-text {
  289. flex: 1;
  290. text-align: left;
  291. padding-left: 24rpx;
  292. }
  293. }
  294. .handle-remark {
  295. margin-top: 30rpx;
  296. .remark-title {
  297. font-size: 28rpx;
  298. font-weight: 400;
  299. color: rgba(17, 24, 39, 1);
  300. margin-bottom: 20rpx;
  301. }
  302. .remark-text {
  303. border-radius: 16rpx;
  304. background: rgba(249, 250, 251, 1);
  305. padding: 32rpx;
  306. font-size: 32rpx;
  307. font-weight: 400;
  308. line-height: 48rpx;
  309. color: rgba(75, 85, 99, 1);
  310. }
  311. }
  312. .handle-start {
  313. margin-bottom: 30rpx;
  314. font-size: 32rpx;
  315. font-weight: 400;
  316. color: rgba(75, 85, 99, 1);
  317. text-align: center;
  318. .handle-time {
  319. font-size: 32rpx;
  320. font-weight: 400;
  321. color: rgba(17, 24, 39, 1);
  322. }
  323. }
  324. .footer-g {
  325. padding: 12px;
  326. position: absolute;
  327. bottom: 18px;
  328. left: 0px;
  329. right: 0px;
  330. background: rgba(255, 255, 255, 1);
  331. }
  332. </style>