not-started.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <script setup>
  2. import { getExpertConsultInfoApi } from '@/api/expert'
  3. import { postExpertConsultReceiveApi } from '@/api/expert'
  4. import { useCdn } from '@/composables/use-cdn'
  5. const { cdnUrl } = useCdn('/elevator/2024/11/images')
  6. const noAgreeHandler = () => {
  7. uni.navigateBack({
  8. delta: 1
  9. })
  10. }
  11. const agreeHandler = async () => {
  12. const { id } = options.value
  13. const { latitude: lat, longitude: lng } = locations.value
  14. const { error, result } = await postExpertConsultReceiveApi({
  15. id,
  16. // consultType: 3,
  17. lat,
  18. lng
  19. })
  20. if (error) {
  21. return uni.$u.toast(result.msg)
  22. }
  23. uni.$u.toast('接单成功')
  24. setTimeout(() => {
  25. uni.navigateBack({
  26. delta: 1
  27. })
  28. }, 1500)
  29. }
  30. const options = ref({})
  31. onLoad(async (e) => {
  32. options.value = e
  33. })
  34. const locations = ref({
  35. latitude: 30.59276,
  36. longitude: 114.30525
  37. })
  38. const getLocation = () => {
  39. uni.getLocation({
  40. type: 'gcj02',
  41. success: ({ latitude, longitude }) => {
  42. locations.value = {
  43. latitude,
  44. longitude
  45. }
  46. }
  47. })
  48. }
  49. onMounted(() => {
  50. getLocation()
  51. })
  52. const dataDetail = ref({})
  53. const getWorkDataInfo = async () => {
  54. const { error, data } = await getExpertConsultInfoApi(options.value)
  55. if (!error) {
  56. dataDetail.value = data
  57. }
  58. }
  59. onMounted(() => {
  60. getWorkDataInfo()
  61. })
  62. const marker = ref({
  63. id: 1,
  64. latitude: 30.59276,
  65. longitude: 114.30525,
  66. iconPath: `${cdnUrl}/position.png`,
  67. width: 35,
  68. height: 35,
  69. callout: {
  70. height: 50,
  71. padding: 5,
  72. fontSize: 20,
  73. borderWidth: 1,
  74. borderRadius: 10,
  75. bgColor: '#ffffff',
  76. display: 'ALWAYS',
  77. textAlign: 'center',
  78. anchorX: 0,
  79. anchorY: 0,
  80. content: ''
  81. }
  82. })
  83. watchEffect(() => {
  84. const { latitude, longitude } = locations.value
  85. marker.value.latitude = latitude
  86. marker.value.longitude = longitude
  87. const { elevatorName } = dataDetail.value
  88. marker.value.callout.content = elevatorName
  89. })
  90. </script>
  91. <template>
  92. <view w-full h-100vh relative bg="#FFFFFF">
  93. <map
  94. id="map"
  95. class="map"
  96. style="width: 100%; height: 100%"
  97. :markers="[marker]"
  98. :show-location="true"
  99. :latitude="locations.latitude"
  100. :longitude="locations.longitude"
  101. ></map>
  102. <cover-view
  103. absolute
  104. w-200
  105. h-80
  106. lh-80
  107. text-center
  108. bottom-150
  109. left-80
  110. rounded-40
  111. border-solid
  112. border-1
  113. border-gray
  114. bg="#FFF"
  115. @tap="noAgreeHandler"
  116. >
  117. 不接单
  118. </cover-view>
  119. <cover-view
  120. absolute
  121. w-200
  122. h-80
  123. lh-80
  124. text-center
  125. bottom-150
  126. rounded-40
  127. border-solid
  128. border-1
  129. border-gray
  130. bg="#4395D5"
  131. color="#FFFFFF"
  132. right-80
  133. @tap="agreeHandler"
  134. >
  135. 接单
  136. </cover-view>
  137. </view>
  138. </template>