rescuerecords.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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" v-if="item.status == 1" @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-box1" 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. uni.showModal({
  287. title: '数据',
  288. content: data
  289. })
  290. obj.list = obj.list.concat(data);
  291. obj.page++;
  292. if (obj.limit == data.length) {
  293. obj.loadingType = 'more';
  294. } else {
  295. obj.loadingType = 'noMore';
  296. }
  297. }).catch(err => {
  298. uni.showModal({
  299. title: 'shibai',
  300. content:err
  301. })
  302. })
  303. },
  304. // 点击导航
  305. toNav(item, index) {
  306. console.log(item, index)
  307. let obj = this
  308. obj.latitude2 = item.latitude
  309. obj.longitude2 = item.longitude
  310. obj.address = item.address
  311. this.$refs.popup.open();
  312. },
  313. // 调用高德
  314. toGaodeMap() {
  315. let latitude = this.latitude2
  316. let longitude = this.longitude2
  317. let address = this.address
  318. console.log('选择高德', latitude, longitude, address)
  319. // window.location.href = 'https://uri.amap.com/marker?position=30.537043,120.567191&name=浙江省嘉兴市桐乡市高桥镇高桥大道51号'
  320. window.location.href = `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`
  321. // window.location.href = `http://uri.amap.com/navigation?from=114.02597366,22.54605355&to=114.029243,22.609562&mode=car&src=nyx_super`
  322. // http://uri.amap.com/navigation?from=" + fromLongitude + "," + fromLatitude + "&to="+ longitude + "," + latitude + "&mode=car&src=nyx_super
  323. },
  324. // 调用腾讯
  325. totengxunMap() {
  326. let latitude = this.latitude2
  327. let longitude = this.longitude2
  328. let address = this.address
  329. console.log('选择腾讯', latitude, longitude)
  330. window.location.href = `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  331. },
  332. // 调用百度
  333. tobaiDuMap() {
  334. let latitude = this.latitude2
  335. let longitude = this.longitude2
  336. let latitude6 = this.latitude4
  337. let longitude6 = this.longitude4
  338. let address = this.address
  339. console.log('选择百度', latitude, longitude)
  340. console.log('获取当前经纬度', latitude6, longitude6)
  341. window.location.href =
  342. `http://api.map.baidu.com/direction?origin=latlng:${latitude6},${longitude6}|name:我的位置&destination=${latitude},${longitude}&mode=driving&region=${ address }&output=html&src=webapp.baidu.openAPIdemo`
  343. //`bdapp://map/navi?location=${longitude},${latitude}&coord_type=gc02&title=${address}&content=${address}&output=html&src=andr.baidu.openAPIdemo `
  344. },
  345. // 拨打电话
  346. tocall(num) {
  347. console.log(num);
  348. uni.makePhoneCall({
  349. phoneNumber: num //仅为示例
  350. });
  351. },
  352. //同意
  353. agree(item, index) {
  354. let obj = this;
  355. uni.showModal({
  356. content: '是否要接受该求救?',
  357. success: res => {
  358. if (res.confirm) {
  359. change_rescue({
  360. id: item.id,
  361. status: 1
  362. }).then((data) => {
  363. obj.list[index].status = 1;
  364. console.log(obj.list[index].status);
  365. })
  366. }
  367. }
  368. });
  369. },
  370. //拒绝
  371. refuse(item, index) {
  372. let obj = this;
  373. uni.showModal({
  374. content: '是否要拒绝该求救?',
  375. success: res => {
  376. if (res.confirm) {
  377. change_rescue({
  378. id: item.id,
  379. status: 2
  380. }).then((data) => {
  381. obj.list[index].status = 2;
  382. console.log(item);
  383. })
  384. }
  385. }
  386. })
  387. },
  388. // @touchstart="touchS" @touchmove="touchM" :data-index="index" @touchend="touchE"
  389. // touchS(e) {
  390. // uni.showModal({
  391. // title: '执行touchS方法',
  392. // content: JSON.stringify(e)
  393. // })
  394. // if (e.touches.length == 1) {
  395. // //设置触摸起始点水平方向位置
  396. // this.startX = e.touches[0].clientX
  397. // // console.log(this.startX)
  398. // }
  399. // },
  400. // touchM(e) {
  401. // console.log('执行touchE方法', e)
  402. // uni.showModal({
  403. // title: '执行touchM方法',
  404. // content: JSON.stringify(e)
  405. // })
  406. // if (e.touches.length == 1) {
  407. // //手指移动时水平方向位置
  408. // var moveX = e.touches[0].clientX;
  409. // //手指起始点位置与移动期间的差值
  410. // var disX = this.startX - moveX;
  411. // var delBtnWidth = this.delBtnWidth;
  412. // var txtStyle = "";
  413. // if (disX == 0 || disX < 0) { //如果移动距离小于等于0,说明向右滑动,文本层位置不变
  414. // txtStyle = "left:0px";
  415. // } else if (disX > 0) { //移动距离大于0,文本层left值等于手指移动距离
  416. // txtStyle = "left:-" + disX + "px";
  417. // if (disX >= delBtnWidth) {
  418. // //控制手指移动距离最大值为删除按钮的宽度
  419. // txtStyle = "left:-" + delBtnWidth + "px";
  420. // }
  421. // }
  422. // //获取手指触摸的是哪一项
  423. // var index = e.currentTarget.dataset.index;
  424. // var list = this.list;
  425. // console.log(999, e.currentTarget.dataset)
  426. // // list[index].txtStyle = txtStyle;
  427. // // console.log(list[index].txtStyle)
  428. // //更新列表的状态
  429. // this.list = list;
  430. // }
  431. // },
  432. // touchE(e) {
  433. // console.log('执行touchE方法', e)
  434. // uni.showModal({
  435. // title: '执行touchE方法',
  436. // content: JSON.stringify(e)
  437. // })
  438. // if (e.changedTouches.length == 1) {
  439. // //手指移动结束后水平位置
  440. // var endX = e.changedTouches[0].clientX;
  441. // //触摸开始与结束,手指移动的距离
  442. // var disX = this.startX - endX;
  443. // var delBtnWidth = this.delBtnWidth;
  444. // //如果距离小于删除按钮的1/2,不显示删除按钮
  445. // var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "px" : "left:0px";
  446. // //获取手指触摸的是哪一项
  447. // var index = e.currentTarget.dataset.index;
  448. // var list = this.list;
  449. // // list[index].txtStyle = txtStyle;
  450. // // console.log(list[index].txtStyle)
  451. // //更新列表的状态{
  452. // this.list = list
  453. // }
  454. // }
  455. }
  456. }
  457. </script>
  458. <style lang="scss">
  459. .container {
  460. line-height: 1;
  461. background-color: #F8F6F6;
  462. .box {
  463. width: 730rpx;
  464. background: #FFFFFF;
  465. box-shadow: 0px 5rpx 5rpx 0px rgba(34, 24, 20, 0.06);
  466. border-radius: 10rpx;
  467. margin: 20rpx 10rpx 0;
  468. padding: 30rpx;
  469. position: relative;
  470. .box-top {
  471. margin-top: 20rpx;
  472. font-size: 28rpx;
  473. font-weight: 500;
  474. color: #333333;
  475. }
  476. .box-time {
  477. margin-top: 20rpx;
  478. font-size: 24rpx;
  479. font-weight: 500;
  480. color: #666666;
  481. }
  482. .box-1 {
  483. display: flex;
  484. justify-content: space-between;
  485. }
  486. .navImg {
  487. width: 50rpx;
  488. height: 50rpx;
  489. image {
  490. width: 50rpx;
  491. height: 50rpx;
  492. }
  493. .tip {
  494. margin-top: 6rpx;
  495. color: #7F7F7F;
  496. font-size: 21rpx;
  497. text-align: right;
  498. // background-color: pink;
  499. }
  500. }
  501. .box-sub-box1 {
  502. margin-top: 24rpx;
  503. .red-font {
  504. width: 175rpx;
  505. height: 59rpx;
  506. font-size: 28rpx;
  507. font-weight: 500;
  508. color: #F3392C;
  509. }
  510. }
  511. .box-sub-box {
  512. margin-top: 44rpx;
  513. display: flex;
  514. justify-content: space-between;
  515. padding: 0 80rpx;
  516. .sub-box1 {
  517. width: 175rpx;
  518. height: 59rpx;
  519. background:#F3392C;
  520. border-radius: 29rpx;
  521. font-size: 28rpx;
  522. font-weight: 500;
  523. color: #FFFFFF;
  524. display: flex;
  525. justify-content: center;
  526. align-items: center;
  527. }
  528. .sub-box2 {
  529. width: 175rpx;
  530. height: 59rpx;
  531. background: #F3F3F3;
  532. border-radius: 29rpx;
  533. font-size: 28rpx;
  534. font-weight: 500;
  535. color: #333333;
  536. display: flex;
  537. justify-content: center;
  538. align-items: center;
  539. }
  540. .sub-box3 {
  541. width: 200rpx;
  542. height: 59rpx;
  543. background: #F3392C;
  544. border-radius: 29rpx;
  545. font-size: 28rpx;
  546. font-weight: 500;
  547. color: #FFFFFF;
  548. display: flex;
  549. justify-content: center;
  550. align-items: center;
  551. .call {
  552. width: 28rpx;
  553. height: 40rpx;
  554. margin-right: 10rpx;
  555. }
  556. }
  557. }
  558. }
  559. .popup-box {
  560. width: 522rpx;
  561. height: 605rpx;
  562. background-color: #FFFFFF;
  563. border-radius: 20rpx;
  564. .img {
  565. border-radius: 20rpx 20rpx 0 0;
  566. width: 522rpx;
  567. height: 307rpx;
  568. image {
  569. border-radius: 20rpx 20rpx 0 0;
  570. width: 522rpx;
  571. height: 307rpx;
  572. }
  573. }
  574. .mian {
  575. display: flex;
  576. flex-direction: column;
  577. align-items: center;
  578. padding: 32rpx 32rpx;
  579. background-color: #FFFFFF;
  580. border-radius: 0 0 20rpx 20rpx;
  581. text-align: center;
  582. .delivery {
  583. font-size: 36rpx;
  584. color: #333333;
  585. // margin-top: 46rpx;
  586. }
  587. .nocancel {
  588. font-size: 30rpx;
  589. color: #999999;
  590. margin-top: 26rpx;
  591. }
  592. .comfirm-box {
  593. margin-top: 52rpx;
  594. display: flex;
  595. // margin-bottom: 32rpx;
  596. // justify-content: space-around;
  597. .cancel {
  598. display: flex;
  599. align-items: center;
  600. justify-content: center;
  601. width: 197rpx;
  602. height: 61rpx;
  603. border: 1px solid #C90F1B;
  604. border-radius: 31rpx;
  605. font-size: 24rpx;
  606. color: #C90F1B;
  607. }
  608. .comfirm {
  609. margin-left: 32rpx;
  610. display: flex;
  611. align-items: center;
  612. justify-content: center;
  613. width: 197rpx;
  614. height: 61rpx;
  615. background: #C90F1B;
  616. border-radius: 31px;
  617. font-size: 24rpx;
  618. color: #FFFFFF;
  619. }
  620. }
  621. }
  622. }
  623. .popup_row {
  624. width: 100%;
  625. height: 500rpx;
  626. background-color: #ffffff;
  627. border-radius: 20rpx 20rpx 0 0;
  628. display: flex;
  629. justify-content: center;
  630. align-items: center;
  631. .rows {
  632. width: 100%;
  633. padding: 0 24rpx;
  634. .rows-item {
  635. height: 80rpx;
  636. line-height: 80rpx;
  637. text-align: center;
  638. width: 100%;
  639. font-size: 32rpx;
  640. color: #303133;
  641. // border-bottom: 1rpx solid #f0f0f0;
  642. }
  643. // .row-1 {
  644. // margin: auto;
  645. // .first_aid {
  646. // width: 300rpx;
  647. // height: 300rpx;
  648. // }
  649. // }
  650. // .row-2 {
  651. // font-size: 38rpx;
  652. // margin-top: 20rpx;
  653. // }
  654. }
  655. }
  656. .remove {
  657. display: flex;
  658. border-radius: 0 12rpx 12rpx 0;
  659. align-items: center;
  660. justify-content: center;
  661. // margin-right: 22rpx;
  662. position: absolute;
  663. right: 0;
  664. top: 0;
  665. font-size: 30rpx;
  666. width: 110rpx;
  667. height: 100%;
  668. color: #FFFFFF;
  669. background-color: #C90F1B;
  670. ;
  671. }
  672. }
  673. </style>