taskDeatils.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view class="main">
  3. <view class="title">
  4. 任务信息
  5. </view>
  6. <view class="main_box">
  7. <view class="text">
  8. <view class="label">
  9. 管线名称
  10. </view>
  11. <view class="value">
  12. {{dataForm.lineName}}
  13. </view>
  14. </view>
  15. <view class="text">
  16. <view class="label">
  17. 管线单元名称
  18. </view>
  19. <view class="value">
  20. {{dataForm.lineUnitName}}
  21. </view>
  22. </view>
  23. <view class="text">
  24. <view class="label">
  25. 单元长度
  26. </view>
  27. <view class="value">
  28. {{dataForm.totalMileage}}km
  29. </view>
  30. </view>
  31. <view class="text">
  32. <view class="label">
  33. 创建时间
  34. </view>
  35. <view class="value">
  36. {{dataForm.createDate}}
  37. </view>
  38. </view>
  39. </view>
  40. <u-action-sheet :actions="list" :title="title" :show="show" @close='show=false'
  41. @select="selectClick"></u-action-sheet>
  42. <view class="btns">
  43. <u-button v-if="dataForm.isReceived==='0'" type='error' :plain="true" text="拒绝"
  44. @click="refuseTaskArrange"></u-button>
  45. <u-button v-if="dataForm.isReceived==='1'" type='error' :plain="true" text="取消任务"
  46. @click="cancelTaskArrange"></u-button>
  47. <u-button v-if="dataForm.isReceived==='0'&&isApp" type="primary" text="接受"
  48. @click="receiveTaskArrange"></u-button>
  49. <u-button class="custom-style" v-if="dataForm.isReceived==='6'" type="primary" text="完成"
  50. @click="completeTaskArrange"></u-button>
  51. <span style="margin-left: 15rpx;width: 300rpx;">
  52. <u-button class="custom-style" type="primary" text="导航到起飞点" @click="selectClick"></u-button>
  53. </span>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. export default {
  59. data() {
  60. return {
  61. title: '导航到起飞点',
  62. list: [{
  63. name: '高德',
  64. },
  65. {
  66. name: '百度',
  67. },
  68. ],
  69. show: false,
  70. dataForm: {},
  71. isApp: false,
  72. }
  73. },
  74. onLoad(x) {
  75. //#ifdef APP-PLUS
  76. this.isApp = true
  77. // #endif
  78. this.dataForm = JSON.parse(x.data)
  79. },
  80. methods: {
  81. selectClick(index) {
  82. this.changelang(this.dataForm.takeoffLongitude, this.dataForm.takeoffLatitude)
  83. // console.log(index);
  84. // if (index.name == '高德') {
  85. // } else {
  86. // this.toFly(this.dataForm.takeoffLongitude, this.dataForm.takeoffLatitude)
  87. // }
  88. },
  89. changelang(long, lat) {
  90. let that = this
  91. uni.request({
  92. url: `https://restapi.amap.com/v3/assistant/coordinate/convert?locations=${long},${lat}&coordsys=gps&key=74d5aa7c4270effe9a18d9cfa6149abf`,
  93. success(res) {
  94. console.log(res.data.locations);
  95. let locations = res.data.locations.split(',')
  96. that.toFly(locations[0], locations[1])
  97. },
  98. fail(fail) {
  99. console.log(fail);
  100. }
  101. })
  102. },
  103. toFly(lang, lat) {
  104. // 定义目的地的坐标和名称
  105. const latitude = lat; // 纬度
  106. const longitude = lang; // 经度
  107. const name = '起飞点'; // 地点名称
  108. const address = '起飞点'; // 地址
  109. // 调用uni.openLocation方法
  110. uni.openLocation({
  111. latitude: Number(latitude), // 目标纬度
  112. longitude: Number(longitude), // 目标经度
  113. name: name, // 地点名称
  114. // address: address, // 详细地址
  115. success: function() {
  116. console.log('成功打开地图');
  117. },
  118. fail: function(err) {
  119. console.error('打开地图失败', err);
  120. }
  121. });
  122. },
  123. refuseTaskArrange() {
  124. this.$api.to_http(`/task/zhkjwurenjitaskarrange/refuseTaskArrange/${this.dataForm.id}`).then((res) => {
  125. if (res.data.code != 0) {
  126. return uni.$u.toast(res.data.msg)
  127. }
  128. uni.showToast({
  129. title: '操作成功',
  130. icon: 'success'
  131. })
  132. setTimeout(() => {
  133. uni.navigateBack(-1)
  134. }, 500)
  135. })
  136. },
  137. cancelTaskArrange() {
  138. this.$api.to_http(`/task/zhkjwurenjitaskarrange/completeTaskArrange/${this.dataForm.id}/${0}`).then((
  139. res) => {
  140. if (res.data.code != 0) {
  141. return uni.$u.toast(res.data.msg)
  142. }
  143. uni.showToast({
  144. title: '操作成功',
  145. icon: 'success'
  146. })
  147. setTimeout(() => {
  148. uni.navigateBack(-1)
  149. }, 500)
  150. })
  151. },
  152. completeTaskArrange() {
  153. this.$api.to_http(`/task/zhkjwurenjitaskarrange/completeTaskArrange/${this.dataForm.id}`).then((res) => {
  154. if (res.data.code != 0) {
  155. return uni.$u.toast(res.data.msg)
  156. }
  157. uni.showToast({
  158. title: '操作成功',
  159. icon: 'success'
  160. })
  161. setTimeout(() => {
  162. uni.navigateBack(-1)
  163. }, 500)
  164. })
  165. },
  166. receiveTaskArrange() {
  167. let info = uni.getStorageSync('userInfo')
  168. let that = this
  169. that.dataForm.receivedUserId = info.id
  170. that.dataForm.receivedUserName = info.realName
  171. if (uni.getSystemInfoSync().platform === 'android' || uni.getSystemInfoSync().platform === 'ios') {
  172. const deviceId = plus.device.uuid;
  173. let mechId = deviceId.split(',')[0]
  174. that.dataForm.deviceId = mechId
  175. that.$api.to_http(`/task/zhkjwurenjitaskarrange/receiveTaskArrange`, that.dataForm, 'post').then((
  176. res) => {
  177. if (res.data.code != 0) {
  178. return uni.$u.toast(res.data.msg)
  179. }
  180. uni.showToast({
  181. title: '操作成功',
  182. icon: 'success'
  183. })
  184. setTimeout(() => {
  185. uni.navigateBack(-1)
  186. }, 500)
  187. })
  188. }
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="less" scoped>
  194. .btns {
  195. padding: 0 20rpx;
  196. box-sizing: border-box;
  197. position: fixed;
  198. width: 100%;
  199. bottom: 1%;
  200. display: flex;
  201. // grid-gap: 20rpx;
  202. // grid-template-columns: 1fr 1fr;
  203. }
  204. .title {
  205. color: #000;
  206. font-weight: bold;
  207. padding: 10rpx 20rpx;
  208. }
  209. .main_box {
  210. background: #fff;
  211. padding: 0rpx 20rpx;
  212. color: #323233;
  213. .text {
  214. display: flex;
  215. padding: 21rpx 0;
  216. margin: 8rpx 0;
  217. border-bottom: 1px solid rgb(235, 237, 240);
  218. font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Segoe UI, Arial, Roboto, "PingFang SC", "miui", "Hiragino Sans GB", "Microsoft Yahei", sans-serif;
  219. .label {
  220. width: 220rpx;
  221. }
  222. }
  223. }
  224. </style>