rescuerecords.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. <template>
  2. <view class="container">
  3. <uni-swipe-action>
  4. <uni-swipe-action-item :right-options="options" @click="bindClick" @change="swipeChange($event, item.id)"
  5. v-for="(item,index) in list">
  6. <view class="list">
  7. <view class="box">
  8. <view class="box-1">
  9. <view class="box-2">
  10. <view class="box-time">
  11. 求救时间:{{item.createtime | time}}
  12. </view>
  13. <view class="box-time">
  14. 救援地址:{{item.address}}
  15. </view>
  16. <view class="box-time" v-if="item.status == 1">
  17. 联系方式:{{item.user_phone}}
  18. </view>
  19. </view>
  20. <view class="navImg" @click="toNav(item, index)">
  21. <image src="../../static/img/img10.png" mode=""></image>
  22. <view class="tip">导航</view>
  23. </view>
  24. </view>
  25. <view class="box-sub-box" v-if="item.status == 0">
  26. <view class="sub-box1" @click="agree(item,index)">
  27. 接受
  28. </view>
  29. <view class="sub-box2" @click="refuse(item,index)">
  30. 拒绝
  31. </view>
  32. </view>
  33. <view class="box-sub-box" >
  34. <view class="red-font" v-if="item.status == 1">
  35. 已接受
  36. </view>
  37. <view class="red-font" v-if="item.status == -1">
  38. 已拒绝
  39. </view>
  40. <view class="sub-box3" @click="tocall(item.user_phone)">
  41. <image src="../../static/icon/call.png" mode="" class="call"></image>
  42. 拨打电话
  43. </view>
  44. </view>
  45. <!-- <view class="remove" @click="delItem">删除</view> -->
  46. </view>
  47. </view>
  48. </uni-swipe-action-item>
  49. </uni-swipe-action>
  50. <empty v-if="list.length === 0"></empty>
  51. <uni-load-more :status="loadingType"></uni-load-more>
  52. <uni-popup ref="popup" type="bottom" @click="close">
  53. <view class="popup_row">
  54. <view class="rows">
  55. <view class="rows-item" @click="toGaodeMap">
  56. 高德地图
  57. </view>
  58. <view class="rows-item" @click="tobaiDuMap">
  59. 百度地图
  60. </view>
  61. <view class="rows-item" @click="totengxunMap">
  62. 腾讯地图
  63. </view>
  64. </view>
  65. </view>
  66. </uni-popup>
  67. <uni-popup ref="popup1" type="center">
  68. <view class="popup-box">
  69. <view class="img">
  70. <image src="../../static/img/map.jpg" mode=""></image>
  71. </view>
  72. <view class="mian">
  73. <view class="delivery">
  74. 救援记录
  75. <!-- {{ i18n.qrhwsdm }} -->
  76. </view>
  77. <view class="nocancel">
  78. 确认删除该记录吗?
  79. <!-- {{ i18n.wfcx }} -->
  80. </view>
  81. <view class="comfirm-box">
  82. <view class="cancel" @click="cancel">
  83. 取消
  84. </view>
  85. <view class="comfirm" @click="comfirm(tmp)">
  86. 确认
  87. </view>
  88. </view>
  89. </view>
  90. </view>
  91. </uni-popup>
  92. </view>
  93. </template>
  94. <script>
  95. import {
  96. deleteList,
  97. getrescue,
  98. change_rescue
  99. } from '@/api/index.js';
  100. import {
  101. getRescueList,
  102. changeRescue,
  103. geocoder
  104. } from '@/api/category.js'
  105. import empty from '@/components/empty';
  106. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  107. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  108. import uniSwipeAction from '@/components/uni-swipe-action/uni-swipe-action.vue';
  109. import uniSwipeActionItem from '@/components/uni-swipe-action-item/uni-swipe-action-item.vue';
  110. export default {
  111. components: {
  112. empty,
  113. uniPopup,
  114. uniLoadMore,
  115. uniSwipeAction,
  116. uniSwipeActionItem
  117. },
  118. filters: {
  119. time(val) {
  120. let str = ''
  121. if (val) {
  122. var time = new Date(val * 1000);
  123. var y = time.getFullYear();
  124. var m = time.getMonth() + 1;
  125. var d = time.getDate();
  126. var h = time.getHours();
  127. var mm = time.getMinutes();
  128. var s = time.getSeconds();
  129. str = y + '-' + m + '-' + d + ' ' + h + ":" + mm
  130. console.log(str)
  131. }
  132. return str
  133. }
  134. },
  135. data() {
  136. return {
  137. id: '',
  138. tmp: '',
  139. options: [{
  140. text: '取消',
  141. style: {
  142. backgroundColor: '#007aff'
  143. }
  144. }, {
  145. text: '确认',
  146. style: {
  147. backgroundColor: '#C90F1B'
  148. }
  149. }],
  150. page: 1,
  151. limit: 10,
  152. list: [],
  153. loadingType: 'more',
  154. latitude2: '',
  155. longitude2: '',
  156. longitude4: '',
  157. latitude4: '',
  158. address: '',
  159. }
  160. },
  161. onLoad() {
  162. this.loadData();
  163. // this.getRescueList()
  164. let obj = this;
  165. try {
  166. let locationAddress
  167. // #ifdef H5
  168. let wxOjb = require('jweixin-module');
  169. locationAddress = wxOjb.getLocation;
  170. // #endif
  171. // #ifdef MP
  172. locationAddress = uni.getLocation;
  173. // #endif
  174. // #ifdef H5
  175. wxOjb.ready(() => {
  176. console.log('加载完毕注册事件');
  177. locationAddress({
  178. type: 'wgs84',
  179. success: function(res) {
  180. console.log('获取经纬度', res);
  181. obj.longitude4 = res.longitude
  182. obj.latitude4 = res.latitude
  183. // obj.loadData();
  184. },
  185. fail(e) {
  186. console.log('失败', e);
  187. window.location.reload();
  188. }
  189. });
  190. })
  191. // #endif
  192. // #ifdef MP
  193. locationAddress({
  194. type: 'wgs84',
  195. success: function(res) {
  196. console.log('获取经纬度', res);
  197. obj.longitude4 = res.longitude
  198. obj.latitude4 = res.latitude
  199. // obj.loadData();
  200. },
  201. fail(e) {
  202. console.log('失败', e);
  203. window.location.reload();
  204. }
  205. });
  206. // #endif
  207. } catch (e) {
  208. let locationAddress
  209. // #ifdef H5
  210. let wxOjb = require('jweixin-module');
  211. locationAddress = wxOjb.getLocation;
  212. // #endif
  213. // #ifdef MP
  214. locationAddress = uni.getLocation;
  215. // #endif
  216. // #ifdef H5
  217. wxOjb.ready(() => {
  218. console.log('加载完毕注册事件');
  219. locationAddress({
  220. type: 'wgs84',
  221. success: function(res) {
  222. console.log('获取经纬度', res);
  223. obj.longitude4 = res.longitude
  224. obj.latitude4 = res.latitude
  225. // obj.loadData();
  226. },
  227. fail(e) {
  228. console.log('失败', e);
  229. window.location.reload();
  230. }
  231. });
  232. })
  233. // #endif
  234. // #ifdef MP
  235. locationAddress({
  236. type: 'wgs84',
  237. success: function(res) {
  238. console.log('获取经纬度', res);
  239. obj.longitude4 = res.longitude
  240. obj.latitude4 = res.latitude
  241. // obj.loadData();
  242. },
  243. fail(e) {
  244. console.log('失败', e);
  245. window.location.reload();
  246. }
  247. });
  248. // #endif
  249. }
  250. },
  251. methods: {
  252. geocoder(lat, lon) {
  253. geocoder({
  254. latitude: lat,
  255. longitude: lon
  256. }).then(res => {
  257. console.log(res.data.result.address)
  258. return res.data.result.address
  259. })
  260. },
  261. getRescueList() {
  262. getRescueList({
  263. type: 1,
  264. page: 1,
  265. limit: 10
  266. }).then(res => {
  267. console.log(res)
  268. })
  269. },
  270. bindClick(e) {
  271. // console.log(333,e)
  272. // console.log('e.index',e.index)
  273. // console.log('this.tmp',this.tmp)
  274. // console.log('点击了' + (e.position === 'left' ? '左侧' : '右侧') + e.content.text + '按钮')
  275. if (e.content.text == '取消') {
  276. console.log('点击了左侧取消按钮')
  277. } else {
  278. console.log('点击了右侧确认按钮')
  279. // this.$refs.popup1.open(this.tmp);
  280. this.open(this.id)
  281. }
  282. },
  283. swipeChange(e, id) {
  284. // // console.log('当前状态:' + open + ',下标:' + index)
  285. // console.log('index',index)
  286. this.id = id
  287. console.log('id111111111', id)
  288. // if ( e == 'right' ) {
  289. // this.index = index
  290. // console.log('当前index值:',this.index)
  291. // }
  292. // // console.log(222,e)
  293. },
  294. // 确认删除吗?
  295. comfirm(id) {
  296. console.log(9999888, id)
  297. deleteList({
  298. id: this.id
  299. }).then(({
  300. data
  301. }) => {
  302. window.location.reload(); //重新刷新页面
  303. this.loadData()
  304. this.cancel()
  305. })
  306. },
  307. // 取消
  308. cancel() {
  309. this.$refs.popup1.close();
  310. },
  311. // 打开弹窗
  312. open(tmp) {
  313. console.log('打开弹窗', tmp)
  314. this.$refs.popup1.open(tmp)
  315. },
  316. // bindClick(){
  317. // console.log(2222)
  318. // },
  319. async loadData() {
  320. let obj = this;
  321. if (obj.loadingType === 'noMore') {
  322. //防止重复加载
  323. return;
  324. }
  325. // 修改当前对象状态为加载中
  326. obj.loadingType = 'loading';
  327. getRescueList({
  328. page: obj.page,
  329. limit: obj.limit,
  330. type: 1
  331. }).then(({
  332. data
  333. }) => {
  334. obj.list = obj.list.concat(data);
  335. obj.page++;
  336. if (obj.limit == data.length) {
  337. obj.loadingType = 'more';
  338. } else {
  339. obj.loadingType = 'noMore';
  340. }
  341. })
  342. // getrescue({
  343. // page: obj.page,
  344. // limit: obj.limit
  345. // }).then(({
  346. // data
  347. // }) => {
  348. // obj.list = obj.list.concat(data);
  349. // obj.page++;
  350. // if (obj.limit == data.length) {
  351. // obj.loadingType = 'more';
  352. // } else {
  353. // obj.loadingType = 'noMore';
  354. // }
  355. // })
  356. },
  357. // 点击导航
  358. toNav(item, index) {
  359. console.log(item, index)
  360. let obj = this
  361. obj.latitude2 = item.latitude
  362. obj.longitude2 = item.longitude
  363. obj.address = item.address
  364. this.$refs.popup.open();
  365. },
  366. // 调用高德
  367. toGaodeMap() {
  368. let latitude = this.latitude2
  369. let longitude = this.longitude2
  370. let address = this.address
  371. console.log('选择高德', latitude, longitude, address)
  372. // window.location.href = 'https://uri.amap.com/marker?position=30.537043,120.567191&name=浙江省嘉兴市桐乡市高桥镇高桥大道51号'
  373. window.location.href =
  374. `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`
  375. // window.location.href = `http://uri.amap.com/navigation?from=114.02597366,22.54605355&to=114.029243,22.609562&mode=car&src=nyx_super`
  376. // http://uri.amap.com/navigation?from=" + fromLongitude + "," + fromLatitude + "&to="+ longitude + "," + latitude + "&mode=car&src=nyx_super
  377. },
  378. // 调用腾讯
  379. totengxunMap() {
  380. let latitude = this.latitude2
  381. let longitude = this.longitude2
  382. let address = this.address
  383. console.log('选择腾讯', latitude, longitude)
  384. window.location.href =
  385. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  386. },
  387. // 调用百度
  388. tobaiDuMap() {
  389. let latitude = this.latitude2
  390. let longitude = this.longitude2
  391. let latitude6 = this.latitude4
  392. let longitude6 = this.longitude4
  393. let address = this.address
  394. console.log('选择百度', latitude, longitude)
  395. console.log('获取当前经纬度', latitude6, longitude6)
  396. window.location.href =
  397. `http://api.map.baidu.com/direction?origin=latlng:${latitude6},${longitude6}|name:我的位置&destination=${latitude},${longitude}&mode=driving&region=${ address }&output=html&src=webapp.baidu.openAPIdemo`
  398. //`bdapp://map/navi?location=${longitude},${latitude}&coord_type=gc02&title=${address}&content=${address}&output=html&src=andr.baidu.openAPIdemo `
  399. },
  400. // 拨打电话
  401. tocall(num) {
  402. console.log(num);
  403. uni.makePhoneCall({
  404. phoneNumber: num //仅为示例
  405. });
  406. },
  407. //同意
  408. agree(item, index) {
  409. let obj = this;
  410. uni.showModal({
  411. content: '是否要接受该求救?',
  412. success: res => {
  413. if (res.confirm) {
  414. changeRescue({
  415. status: 1,
  416. // process_remark: ,
  417. id: item.id,
  418. }).then((data) => {
  419. obj.list[index].status = 1;
  420. console.log(obj.list[index].status);
  421. })
  422. }
  423. }
  424. });
  425. },
  426. //拒绝
  427. refuse(item, index) {
  428. let obj = this;
  429. uni.showModal({
  430. content: '是否要拒绝该求救?',
  431. success: res => {
  432. if (res.confirm) {
  433. change_rescue({
  434. id: item.id,
  435. status: 2
  436. }).then((data) => {
  437. obj.list[index].status = 2;
  438. console.log(item);
  439. })
  440. }
  441. }
  442. })
  443. },
  444. // @touchstart="touchS" @touchmove="touchM" :data-index="index" @touchend="touchE"
  445. // touchS(e) {
  446. // uni.showModal({
  447. // title: '执行touchS方法',
  448. // content: JSON.stringify(e)
  449. // })
  450. // if (e.touches.length == 1) {
  451. // //设置触摸起始点水平方向位置
  452. // this.startX = e.touches[0].clientX
  453. // // console.log(this.startX)
  454. // }
  455. // },
  456. // touchM(e) {
  457. // console.log('执行touchE方法', e)
  458. // uni.showModal({
  459. // title: '执行touchM方法',
  460. // content: JSON.stringify(e)
  461. // })
  462. // if (e.touches.length == 1) {
  463. // //手指移动时水平方向位置
  464. // var moveX = e.touches[0].clientX;
  465. // //手指起始点位置与移动期间的差值
  466. // var disX = this.startX - moveX;
  467. // var delBtnWidth = this.delBtnWidth;
  468. // var txtStyle = "";
  469. // if (disX == 0 || disX < 0) { //如果移动距离小于等于0,说明向右滑动,文本层位置不变
  470. // txtStyle = "left:0px";
  471. // } else if (disX > 0) { //移动距离大于0,文本层left值等于手指移动距离
  472. // txtStyle = "left:-" + disX + "px";
  473. // if (disX >= delBtnWidth) {
  474. // //控制手指移动距离最大值为删除按钮的宽度
  475. // txtStyle = "left:-" + delBtnWidth + "px";
  476. // }
  477. // }
  478. // //获取手指触摸的是哪一项
  479. // var index = e.currentTarget.dataset.index;
  480. // var list = this.list;
  481. // console.log(999, e.currentTarget.dataset)
  482. // // list[index].txtStyle = txtStyle;
  483. // // console.log(list[index].txtStyle)
  484. // //更新列表的状态
  485. // this.list = list;
  486. // }
  487. // },
  488. // touchE(e) {
  489. // console.log('执行touchE方法', e)
  490. // uni.showModal({
  491. // title: '执行touchE方法',
  492. // content: JSON.stringify(e)
  493. // })
  494. // if (e.changedTouches.length == 1) {
  495. // //手指移动结束后水平位置
  496. // var endX = e.changedTouches[0].clientX;
  497. // //触摸开始与结束,手指移动的距离
  498. // var disX = this.startX - endX;
  499. // var delBtnWidth = this.delBtnWidth;
  500. // //如果距离小于删除按钮的1/2,不显示删除按钮
  501. // var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "px" : "left:0px";
  502. // //获取手指触摸的是哪一项
  503. // var index = e.currentTarget.dataset.index;
  504. // var list = this.list;
  505. // // list[index].txtStyle = txtStyle;
  506. // // console.log(list[index].txtStyle)
  507. // //更新列表的状态{
  508. // this.list = list
  509. // }
  510. // }
  511. }
  512. }
  513. </script>
  514. <style lang="scss">
  515. .container {
  516. line-height: 1;
  517. .box {
  518. width: 750rpx;
  519. background: #FFFFFF;
  520. box-shadow: 0px 5rpx 5rpx 0px rgba(34, 24, 20, 0.06);
  521. border-radius: 10rpx;
  522. margin: 20rpx auto 0;
  523. padding: 30rpx;
  524. position: relative;
  525. .box-top {
  526. font-size: 28rpx;
  527. font-weight: 500;
  528. color: #333333;
  529. }
  530. .box-time {
  531. margin-top: 20rpx;
  532. font-size: 24rpx;
  533. font-weight: 500;
  534. color: #666666;
  535. }
  536. .box-1 {
  537. display: flex;
  538. justify-content: space-between;
  539. }
  540. .navImg {
  541. width: 50rpx;
  542. height: 50rpx;
  543. image {
  544. width: 50rpx;
  545. height: 50rpx;
  546. }
  547. .tip {
  548. margin-top: 6rpx;
  549. color: #7F7F7F;
  550. font-size: 21rpx;
  551. text-align: right;
  552. // background-color: pink;
  553. }
  554. }
  555. .box-sub-box {
  556. margin-top: 44rpx;
  557. display: flex;
  558. justify-content: space-between;
  559. padding: 0 80rpx;
  560. .red-font {
  561. width: 175rpx;
  562. height: 59rpx;
  563. display: flex;
  564. justify-content: center;
  565. align-items: center;
  566. font-size: 28rpx;
  567. font-weight: 500;
  568. color: #C90F1B;
  569. }
  570. .sub-box1 {
  571. width: 175rpx;
  572. height: 59rpx;
  573. background: #C90F1B;
  574. border-radius: 29rpx;
  575. font-size: 28rpx;
  576. font-weight: 500;
  577. color: #FFFFFF;
  578. display: flex;
  579. justify-content: center;
  580. align-items: center;
  581. }
  582. .sub-box2 {
  583. width: 175rpx;
  584. height: 59rpx;
  585. background: #F3F3F3;
  586. border-radius: 29rpx;
  587. font-size: 28rpx;
  588. font-weight: 500;
  589. color: #333333;
  590. display: flex;
  591. justify-content: center;
  592. align-items: center;
  593. }
  594. .sub-box3 {
  595. width: 200rpx;
  596. height: 59rpx;
  597. background: #C90F1B;
  598. border-radius: 29rpx;
  599. font-size: 28rpx;
  600. font-weight: 500;
  601. color: #FFFFFF;
  602. display: flex;
  603. justify-content: center;
  604. align-items: center;
  605. .call {
  606. width: 28rpx;
  607. height: 40rpx;
  608. margin-right: 10rpx;
  609. }
  610. }
  611. }
  612. }
  613. .popup-box {
  614. width: 522rpx;
  615. height: 605rpx;
  616. background-color: #FFFFFF;
  617. border-radius: 20rpx;
  618. .img {
  619. border-radius: 20rpx 20rpx 0 0;
  620. width: 522rpx;
  621. height: 307rpx;
  622. image {
  623. border-radius: 20rpx 20rpx 0 0;
  624. width: 522rpx;
  625. height: 307rpx;
  626. }
  627. }
  628. .mian {
  629. display: flex;
  630. flex-direction: column;
  631. align-items: center;
  632. padding: 32rpx 32rpx;
  633. background-color: #FFFFFF;
  634. border-radius: 0 0 20rpx 20rpx;
  635. text-align: center;
  636. .delivery {
  637. font-size: 36rpx;
  638. color: #333333;
  639. // margin-top: 46rpx;
  640. }
  641. .nocancel {
  642. font-size: 30rpx;
  643. color: #999999;
  644. margin-top: 26rpx;
  645. }
  646. .comfirm-box {
  647. margin-top: 52rpx;
  648. display: flex;
  649. // margin-bottom: 32rpx;
  650. // justify-content: space-around;
  651. .cancel {
  652. display: flex;
  653. align-items: center;
  654. justify-content: center;
  655. width: 197rpx;
  656. height: 61rpx;
  657. border: 1px solid #C90F1B;
  658. border-radius: 31rpx;
  659. font-size: 24rpx;
  660. color: #C90F1B;
  661. }
  662. .comfirm {
  663. margin-left: 32rpx;
  664. display: flex;
  665. align-items: center;
  666. justify-content: center;
  667. width: 197rpx;
  668. height: 61rpx;
  669. background: #C90F1B;
  670. border-radius: 31px;
  671. font-size: 24rpx;
  672. color: #FFFFFF;
  673. }
  674. }
  675. }
  676. }
  677. .popup_row {
  678. width: 100%;
  679. height: 500rpx;
  680. background-color: #ffffff;
  681. border-radius: 20rpx 20rpx 0 0;
  682. display: flex;
  683. justify-content: center;
  684. align-items: center;
  685. .rows {
  686. width: 100%;
  687. padding: 0 24rpx;
  688. .rows-item {
  689. height: 80rpx;
  690. line-height: 80rpx;
  691. text-align: center;
  692. width: 100%;
  693. font-size: 32rpx;
  694. color: #303133;
  695. // border-bottom: 1rpx solid #f0f0f0;
  696. }
  697. // .row-1 {
  698. // margin: auto;
  699. // .first_aid {
  700. // width: 300rpx;
  701. // height: 300rpx;
  702. // }
  703. // }
  704. // .row-2 {
  705. // font-size: 38rpx;
  706. // margin-top: 20rpx;
  707. // }
  708. }
  709. }
  710. .remove {
  711. display: flex;
  712. border-radius: 0 12rpx 12rpx 0;
  713. align-items: center;
  714. justify-content: center;
  715. // margin-right: 22rpx;
  716. position: absolute;
  717. right: 0;
  718. top: 0;
  719. font-size: 30rpx;
  720. width: 110rpx;
  721. height: 100%;
  722. color: #FFFFFF;
  723. background-color: #C90F1B;
  724. ;
  725. }
  726. }
  727. </style>