rescuerecords.vue 17 KB

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