rescuerecords.vue 17 KB

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