index.vue 9.1 KB

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