rescuerecords.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  1. <template>
  2. <view class="container">
  3. <uni-swipe-action>
  4. <uni-swipe-action-item :right-options="options" @click="bindClick" @change="swipeChange($event, item.sos_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" v-if="item.address">
  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" v-if="item.status == 1" @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. if (e.content.text == '取消') {
  272. console.log('点击了左侧取消按钮')
  273. } else {
  274. console.log('点击了右侧确认按钮')
  275. // this.$refs.popup1.open(this.tmp);
  276. this.open(this.id)
  277. }
  278. },
  279. swipeChange(e, id) {
  280. this.id = id
  281. console.log('id111111111', id)
  282. },
  283. // 确认删除吗?
  284. comfirm(id) {
  285. console.log(9999888, id)
  286. deleteList({
  287. id: this.id
  288. }).then(({
  289. data
  290. }) => {
  291. window.location.reload(); //重新刷新页面
  292. this.loadData()
  293. this.cancel()
  294. })
  295. },
  296. // 取消
  297. cancel() {
  298. this.$refs.popup1.close();
  299. },
  300. // 打开弹窗
  301. open(tmp) {
  302. console.log('打开弹窗', tmp)
  303. this.$refs.popup1.open(tmp)
  304. },
  305. async loadData() {
  306. let obj = this;
  307. if (obj.loadingType === 'noMore') {
  308. //防止重复加载
  309. return;
  310. }
  311. // 修改当前对象状态为加载中
  312. obj.loadingType = 'loading';
  313. getRescueList({
  314. page: obj.page,
  315. limit: obj.limit,
  316. type: 1
  317. }).then(({
  318. data
  319. }) => {
  320. obj.list = obj.list.concat(data);
  321. obj.page++;
  322. if (obj.limit == data.length) {
  323. obj.loadingType = 'more';
  324. } else {
  325. obj.loadingType = 'noMore';
  326. }
  327. })
  328. },
  329. // 点击导航
  330. toNav(item, index) {
  331. console.log(item, index)
  332. let obj = this
  333. obj.latitude2 = item.latitude
  334. obj.longitude2 = item.longitude
  335. obj.address = item.address
  336. this.$refs.popup.open();
  337. },
  338. // 调用高德
  339. toGaodeMap() {
  340. let latitude = this.latitude2
  341. let longitude = this.longitude2
  342. let address = this.address
  343. console.log('选择高德', latitude, longitude, address)
  344. window.location.href =
  345. `https://uri.amap.com/marker?position=${longitude},${latitude}&name=${address}`
  346. },
  347. // 调用腾讯
  348. totengxunMap() {
  349. let latitude = this.latitude2
  350. let longitude = this.longitude2
  351. let address = this.address
  352. console.log('选择腾讯', latitude, longitude)
  353. window.location.href =
  354. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  355. },
  356. // 高德坐标、腾讯坐标转百度坐标
  357. bd_encrypt(gg_lng, gg_lat) {
  358. var X_PI = Math.PI * 3000.0 / 180.0;
  359. var x = gg_lng,
  360. y = gg_lat;
  361. var z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI);
  362. var theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI);
  363. var bd_lng = z * Math.cos(theta) + 0.0065;
  364. var bd_lat = z * Math.sin(theta) + 0.006;
  365. return {
  366. bd_lat: bd_lat,
  367. bd_lng: bd_lng
  368. };
  369. },
  370. // 调用百度
  371. tobaiDuMap() {
  372. let latlon = this.bd_encrypt(this.longitude2, tthis.latitude2)
  373. let latlon1 = this.bd_encrypt(this.longitude4, this.latitude4)
  374. let latitude = latlon.bd_lat;
  375. let longitude = latlon.bd_lng;
  376. let latitude6 = latlon1.bd_lat;
  377. let longitude6 = latlon1.bd_lng;
  378. // let latitude = this.latitude2
  379. // let longitude = this.longitude2
  380. // let latitude6 = this.latitude4
  381. // let longitude6 = this.longitude4
  382. let address = this.address
  383. console.log('选择百度', latitude, longitude)
  384. console.log('获取当前经纬度', latitude6, longitude6)
  385. window.location.href =
  386. `http://api.map.baidu.com/direction?origin=latlng:${latitude6},${longitude6}|name:我的位置&destination=${latitude},${longitude}&mode=driving&region=${ address }&output=html&src=webapp.baidu.openAPIdemo`
  387. },
  388. // 拨打电话
  389. tocall(num) {
  390. console.log(num);
  391. uni.makePhoneCall({
  392. phoneNumber: num //仅为示例
  393. });
  394. },
  395. //同意
  396. agree(item, index) {
  397. let obj = this;
  398. uni.showModal({
  399. content: '是否要接受该求救?',
  400. success: res => {
  401. if (res.confirm) {
  402. changeRescue({
  403. status: 1,
  404. // process_remark: ,
  405. id: item.id,
  406. re_url: obj.$store.state.baseURL + '/index/#/pages/applic/helprecords'
  407. }).then((data) => {
  408. obj.list[index].status = 1;
  409. console.log(obj.list[index].status);
  410. })
  411. }
  412. }
  413. });
  414. },
  415. //拒绝
  416. refuse(item, index) {
  417. let obj = this;
  418. uni.showModal({
  419. content: '是否要拒绝该求救?',
  420. success: res => {
  421. if (res.confirm) {
  422. changeRescue({
  423. id: item.id,
  424. status: -1,
  425. re_url: obj.$store.state.baseURL + '/index/#/pages/applic/helprecords'
  426. }).then((data) => {
  427. obj.list[index].status = -1;
  428. console.log(item);
  429. })
  430. }
  431. }
  432. })
  433. },
  434. // @touchstart="touchS" @touchmove="touchM" :data-index="index" @touchend="touchE"
  435. // touchS(e) {
  436. // uni.showModal({
  437. // title: '执行touchS方法',
  438. // content: JSON.stringify(e)
  439. // })
  440. // if (e.touches.length == 1) {
  441. // //设置触摸起始点水平方向位置
  442. // this.startX = e.touches[0].clientX
  443. // // console.log(this.startX)
  444. // }
  445. // },
  446. // touchM(e) {
  447. // console.log('执行touchE方法', e)
  448. // uni.showModal({
  449. // title: '执行touchM方法',
  450. // content: JSON.stringify(e)
  451. // })
  452. // if (e.touches.length == 1) {
  453. // //手指移动时水平方向位置
  454. // var moveX = e.touches[0].clientX;
  455. // //手指起始点位置与移动期间的差值
  456. // var disX = this.startX - moveX;
  457. // var delBtnWidth = this.delBtnWidth;
  458. // var txtStyle = "";
  459. // if (disX == 0 || disX < 0) { //如果移动距离小于等于0,说明向右滑动,文本层位置不变
  460. // txtStyle = "left:0px";
  461. // } else if (disX > 0) { //移动距离大于0,文本层left值等于手指移动距离
  462. // txtStyle = "left:-" + disX + "px";
  463. // if (disX >= delBtnWidth) {
  464. // //控制手指移动距离最大值为删除按钮的宽度
  465. // txtStyle = "left:-" + delBtnWidth + "px";
  466. // }
  467. // }
  468. // //获取手指触摸的是哪一项
  469. // var index = e.currentTarget.dataset.index;
  470. // var list = this.list;
  471. // console.log(999, e.currentTarget.dataset)
  472. // // list[index].txtStyle = txtStyle;
  473. // // console.log(list[index].txtStyle)
  474. // //更新列表的状态
  475. // this.list = list;
  476. // }
  477. // },
  478. // touchE(e) {
  479. // console.log('执行touchE方法', e)
  480. // uni.showModal({
  481. // title: '执行touchE方法',
  482. // content: JSON.stringify(e)
  483. // })
  484. // if (e.changedTouches.length == 1) {
  485. // //手指移动结束后水平位置
  486. // var endX = e.changedTouches[0].clientX;
  487. // //触摸开始与结束,手指移动的距离
  488. // var disX = this.startX - endX;
  489. // var delBtnWidth = this.delBtnWidth;
  490. // //如果距离小于删除按钮的1/2,不显示删除按钮
  491. // var txtStyle = disX > delBtnWidth / 2 ? "left:-" + delBtnWidth + "px" : "left:0px";
  492. // //获取手指触摸的是哪一项
  493. // var index = e.currentTarget.dataset.index;
  494. // var list = this.list;
  495. // // list[index].txtStyle = txtStyle;
  496. // // console.log(list[index].txtStyle)
  497. // //更新列表的状态{
  498. // this.list = list
  499. // }
  500. // }
  501. }
  502. }
  503. </script>
  504. <style lang="scss">
  505. .container {
  506. line-height: 1;
  507. .box {
  508. width: 750rpx;
  509. background: #FFFFFF;
  510. box-shadow: 0px 5rpx 5rpx 0px rgba(34, 24, 20, 0.06);
  511. border-radius: 10rpx;
  512. margin: 20rpx auto 0;
  513. padding: 30rpx;
  514. position: relative;
  515. .box-top {
  516. font-size: 28rpx;
  517. font-weight: 500;
  518. color: #333333;
  519. }
  520. .box-time {
  521. margin-top: 20rpx;
  522. font-size: 24rpx;
  523. font-weight: 500;
  524. color: #666666;
  525. }
  526. .box-1 {
  527. display: flex;
  528. justify-content: space-between;
  529. }
  530. .navImg {
  531. width: 50rpx;
  532. height: 50rpx;
  533. image {
  534. width: 50rpx;
  535. height: 50rpx;
  536. }
  537. .tip {
  538. margin-top: 6rpx;
  539. color: #7F7F7F;
  540. font-size: 21rpx;
  541. text-align: right;
  542. // background-color: pink;
  543. }
  544. }
  545. .box-sub-box {
  546. margin-top: 44rpx;
  547. display: flex;
  548. justify-content: space-between;
  549. padding: 0 80rpx;
  550. .red-font {
  551. width: 175rpx;
  552. height: 59rpx;
  553. display: flex;
  554. justify-content: center;
  555. align-items: center;
  556. font-size: 28rpx;
  557. font-weight: 500;
  558. color: #C90F1B;
  559. }
  560. .sub-box1 {
  561. width: 175rpx;
  562. height: 59rpx;
  563. background: #C90F1B;
  564. border-radius: 29rpx;
  565. font-size: 28rpx;
  566. font-weight: 500;
  567. color: #FFFFFF;
  568. display: flex;
  569. justify-content: center;
  570. align-items: center;
  571. }
  572. .sub-box2 {
  573. width: 175rpx;
  574. height: 59rpx;
  575. background: #F3F3F3;
  576. border-radius: 29rpx;
  577. font-size: 28rpx;
  578. font-weight: 500;
  579. color: #333333;
  580. display: flex;
  581. justify-content: center;
  582. align-items: center;
  583. }
  584. .sub-box3 {
  585. width: 200rpx;
  586. height: 59rpx;
  587. background: #C90F1B;
  588. border-radius: 29rpx;
  589. font-size: 28rpx;
  590. font-weight: 500;
  591. color: #FFFFFF;
  592. display: flex;
  593. justify-content: center;
  594. align-items: center;
  595. .call {
  596. width: 28rpx;
  597. height: 40rpx;
  598. margin-right: 10rpx;
  599. }
  600. }
  601. }
  602. }
  603. .popup-box {
  604. width: 522rpx;
  605. height: 605rpx;
  606. background-color: #FFFFFF;
  607. border-radius: 20rpx;
  608. .img {
  609. border-radius: 20rpx 20rpx 0 0;
  610. width: 522rpx;
  611. height: 307rpx;
  612. image {
  613. border-radius: 20rpx 20rpx 0 0;
  614. width: 522rpx;
  615. height: 307rpx;
  616. }
  617. }
  618. .mian {
  619. display: flex;
  620. flex-direction: column;
  621. align-items: center;
  622. padding: 32rpx 32rpx;
  623. background-color: #FFFFFF;
  624. border-radius: 0 0 20rpx 20rpx;
  625. text-align: center;
  626. .delivery {
  627. font-size: 36rpx;
  628. color: #333333;
  629. // margin-top: 46rpx;
  630. }
  631. .nocancel {
  632. font-size: 30rpx;
  633. color: #999999;
  634. margin-top: 26rpx;
  635. }
  636. .comfirm-box {
  637. margin-top: 52rpx;
  638. display: flex;
  639. // margin-bottom: 32rpx;
  640. // justify-content: space-around;
  641. .cancel {
  642. display: flex;
  643. align-items: center;
  644. justify-content: center;
  645. width: 197rpx;
  646. height: 61rpx;
  647. border: 1px solid #C90F1B;
  648. border-radius: 31rpx;
  649. font-size: 24rpx;
  650. color: #C90F1B;
  651. }
  652. .comfirm {
  653. margin-left: 32rpx;
  654. display: flex;
  655. align-items: center;
  656. justify-content: center;
  657. width: 197rpx;
  658. height: 61rpx;
  659. background: #C90F1B;
  660. border-radius: 31px;
  661. font-size: 24rpx;
  662. color: #FFFFFF;
  663. }
  664. }
  665. }
  666. }
  667. .popup_row {
  668. width: 100%;
  669. height: 500rpx;
  670. background-color: #ffffff;
  671. border-radius: 20rpx 20rpx 0 0;
  672. display: flex;
  673. justify-content: center;
  674. align-items: center;
  675. .rows {
  676. width: 100%;
  677. padding: 0 24rpx;
  678. .rows-item {
  679. height: 80rpx;
  680. line-height: 80rpx;
  681. text-align: center;
  682. width: 100%;
  683. font-size: 32rpx;
  684. color: #303133;
  685. // border-bottom: 1rpx solid #f0f0f0;
  686. }
  687. // .row-1 {
  688. // margin: auto;
  689. // .first_aid {
  690. // width: 300rpx;
  691. // height: 300rpx;
  692. // }
  693. // }
  694. // .row-2 {
  695. // font-size: 38rpx;
  696. // margin-top: 20rpx;
  697. // }
  698. }
  699. }
  700. .remove {
  701. display: flex;
  702. border-radius: 0 12rpx 12rpx 0;
  703. align-items: center;
  704. justify-content: center;
  705. // margin-right: 22rpx;
  706. position: absolute;
  707. right: 0;
  708. top: 0;
  709. font-size: 30rpx;
  710. width: 110rpx;
  711. height: 100%;
  712. color: #FFFFFF;
  713. background-color: #C90F1B;
  714. ;
  715. }
  716. }
  717. </style>