rescue.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view class="container-box">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <view class="container" v-if="tabCurrentIndex == 0">
  7. <view class="swiper-box">
  8. <scroll-view scroll-y class="cate-list" @scrolltolower="RescueData">
  9. <view class="nodata" v-if="RescueList.length == 0">
  10. <image src="/static/img/img011.png"></image>
  11. <!-- <view class="text">暂时没有数据哦!</view> -->
  12. </view>
  13. <view @click="navTo('/pages/record/details?id=' + item.id)" v-for="(item, index) in RescueList" class="content-box">
  14. <view class="flex">
  15. <view class="item">
  16. <view class="name" v-if="item.status == 0 || item.status == 2">求救者姓名:求救者{{ item.caller_id }}</view>
  17. <view class="name" v-if="item.status == 1 || item.status == 3">求救者姓名:{{ item.caller_nickname }}</view>
  18. <view class="phone" v-if="item.status == 1 || item.status == 3">手机号:{{ item.caller_mobile }}</view>
  19. <!-- <view class="addr">救援地址:{{item.address}}</view> -->
  20. <view class="time">求救时间:{{ item.createtime }}</view>
  21. </view>
  22. <view class="item-addr" v-if="item.status == 1">点击进入导航</view>
  23. </view>
  24. <view class="box-btn flex" v-if="item.status == 0">
  25. <view class="accept" @click.stop="access(item)">接受</view>
  26. <view class="refuse" @click.stop="refuse(item)">拒绝</view>
  27. </view>
  28. <view class="tpl" v-if="item.status != 0">{{ item.status_text }}</view>
  29. <view class="call-btn flex" v-if="item.status == 1">
  30. <view class="payPhone flex" @click.stop="Tocall(item)">
  31. <image src="/static/img/phone1.png" mode="widthFix"></image>
  32. <text>拨打电话</text>
  33. </view>
  34. <view class="payVideo flex" @click.stop="TocallVideo(item)" >
  35. <image src="/static/img/video1.png" mode="widthFix"></image>
  36. <text>视频通话</text>
  37. </view>
  38. </view>
  39. </view>
  40. <uni-load-more :status="loadingType"></uni-load-more>
  41. </scroll-view>
  42. </view>
  43. </view>
  44. <view class="container" v-if="tabCurrentIndex == 1">
  45. <view class="swiper-box">
  46. <scroll-view class="cate-list" scroll-y @scrolltolower="HpleData">
  47. <view class="nodata" v-if="HpleList.length == 0"><image src="/static/img/img011.png"></image></view>
  48. <view v-for="(item, index) in HpleList" class="content-box">
  49. <view class="item">
  50. <view class="name" v-if="item.status == 0 || item.status == 2">救援者姓名:救援者{{ item.helper }}</view>
  51. <view class="name" v-if="item.status == 1 || item.status == 3">救援者姓名:{{ item.helper_nickname }}</view>
  52. <view class="phone" v-if="item.status == 1 || item.status == 3">手机号:{{ item.helper_mobile }}</view>
  53. <view class="time">救援时间:{{ item.createtime }}</view>
  54. </view>
  55. <view class="tpl">{{ item.status_text }}</view>
  56. <view class="call-btn flex" v-if="item.status == 1">
  57. <view class="payPhone flex" @click.stop="Tocall1(item)">
  58. <image src="/static/img/phone1.png" mode="widthFix"></image>
  59. <text>拨打电话</text>
  60. </view>
  61. <view class="payVideo flex" @click.stop="TocallVideo(item)" >
  62. <image src="/static/img/video1.png" mode="widthFix"></image>
  63. <text>视频通话</text>
  64. </view>
  65. </view>
  66. </view>
  67. <uni-load-more :status="loadingType1"></uni-load-more>
  68. </scroll-view>
  69. </view>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import { mapState, mapMutations } from 'vuex';
  75. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  76. import empty from '@/components/empty';
  77. import { toMySosList, accessSos, refuseSos, mySosList } from '@/api/record.js';
  78. import { getTime } from '@/utils/rocessor.js';
  79. import { getUserInfo } from '@/api/login.js';
  80. // 引入实时通信
  81. export default {
  82. components: {
  83. uniLoadMore,
  84. empty
  85. },
  86. computed: {
  87. ...mapState(['userInfo'])
  88. },
  89. data() {
  90. return {
  91. tabCurrentIndex: 0,
  92. navList: [
  93. {
  94. id: 1,
  95. text: '救援记录'
  96. },
  97. {
  98. id: 2,
  99. text: '求救记录'
  100. }
  101. ],
  102. HpleList: [],
  103. RescueList: [],
  104. limit: 4, //每次加载数据条数
  105. page: 1, //当前页数
  106. page1: 1,
  107. loadingType: 'more', //加载更多状态
  108. loadingType1: 'more', //加载更多状态
  109. loading: 0
  110. };
  111. },
  112. onLoad() {
  113. this.loadBaseData()
  114. },
  115. onShow() {
  116. this.page = 1;
  117. this.loadingType = 'more';
  118. this.RescueList = [];
  119. this.RescueData();
  120. },
  121. //下拉刷新
  122. // onPullDownRefresh() {
  123. // this.page1 = 1;
  124. // this.page = 1;
  125. // this.RescueData('refresh');
  126. // this.HpleData('refresh');
  127. // },
  128. methods: {
  129. ...mapMutations(['setUserInfo','logout']),
  130. // 加载初始数据
  131. loadBaseData() {
  132. let obj = this;
  133. getUserInfo({}).then(({ data }) => {
  134. obj.setUserInfo(data.user);
  135. }).catch((e) => {
  136. obj.logout()
  137. });
  138. },
  139. //我的救援列表
  140. async RescueData(source) {
  141. let obj = this;
  142. if (source != 'refresh') {
  143. //没有更多数据直接跳出方法
  144. if (obj.loadingType === 'nomore') {
  145. return;
  146. } else {
  147. // 设置当前为数据载入中
  148. obj.loadingType = 'loading';
  149. }
  150. } else {
  151. //当重新加载数据时更新状态为可继续添加数据
  152. obj.loadingType = 'more';
  153. }
  154. toMySosList({
  155. status: -1,
  156. page: obj.page,
  157. limit: obj.limit
  158. })
  159. .then(({ data }) => {
  160. if (source === 'refresh') {
  161. obj.RescueList = [];
  162. }
  163. let arr = data.map(e => {
  164. e.createtime = getTime(e.createtime);
  165. return e;
  166. });
  167. obj.RescueList = obj.RescueList.concat(arr);
  168. //判断是否还有下一页,有是more 没有是nomore
  169. if (obj.limit == arr.length) {
  170. obj.page++;
  171. obj.loadingType = 'more';
  172. } else {
  173. obj.loadingType = 'nomore';
  174. }
  175. // 判断是否为刷新数据
  176. if (source == 'refresh') {
  177. // 判断是否为点击搜索按钮跳转加载
  178. if (obj.loading == 1) {
  179. uni.hideLoading();
  180. } else {
  181. uni.stopPullDownRefresh();
  182. }
  183. }
  184. console.log(obj.loadingType, 'zuihou');
  185. })
  186. .catch(e => {
  187. obj.loadingType = 'nomore';
  188. uni.stopPullDownRefresh();
  189. uni.hideLoading();
  190. });
  191. },
  192. //我的求救列表
  193. async HpleData(source) {
  194. //这里是将订单挂载到tab列表下
  195. let obj = this;
  196. if (source != 'refresh') {
  197. //没有更多数据直接跳出方法
  198. if (obj.loadingType1 === 'nomore') {
  199. return;
  200. } else {
  201. // 设置当前为数据载入中
  202. obj.loadingType1 = 'loading';
  203. }
  204. } else {
  205. //当重新加载数据时更新状态为可继续添加数据
  206. obj.loadingType1 = 'more';
  207. }
  208. mySosList({
  209. status: -1,
  210. page: obj.page1,
  211. limit: obj.limit
  212. })
  213. .then(({ data }) => {
  214. if (source === 'refresh') {
  215. obj.HpleList = [];
  216. }
  217. let arr = data.map(e => {
  218. e.createtime = getTime(e.createtime);
  219. return e;
  220. });
  221. obj.HpleList = obj.HpleList.concat(arr);
  222. //判断是否还有下一页,有是more 没有是nomore
  223. if (obj.limit == arr.length) {
  224. obj.page1++;
  225. obj.loadingType1 = 'more';
  226. } else {
  227. obj.loadingType1 = 'nomore';
  228. }
  229. // 判断是否为刷新数据
  230. if (source == 'refresh') {
  231. // 判断是否为点击搜索按钮跳转加载
  232. if (obj.loading == 1) {
  233. uni.hideLoading();
  234. } else {
  235. uni.stopPullDownRefresh();
  236. }
  237. }
  238. })
  239. .catch(e => {
  240. obj.loadingType1 = 'nomore';
  241. uni.stopPullDownRefresh();
  242. uni.hideLoading();
  243. });
  244. },
  245. //顶部tab点击
  246. tabClick(index) {
  247. this.tabCurrentIndex = index;
  248. if (this.tabCurrentIndex == 0) {
  249. this.page = 1;
  250. this.loadingType = 'more';
  251. this.RescueData('refresh');
  252. }
  253. if (this.tabCurrentIndex == 1) {
  254. this.page1 = 1;
  255. this.loadingType1 = 'more';
  256. this.HpleData('refresh');
  257. }
  258. },
  259. //swiper 切换
  260. // changeTab(e) {
  261. // this.tabCurrentIndex = e.target.current;
  262. // this.loadData('tabChange');
  263. // },
  264. //拨打电话
  265. Tocall(item) {
  266. uni.makePhoneCall({
  267. phoneNumber: item.caller_mobile
  268. });
  269. },
  270. Tocall1(item) {
  271. uni.makePhoneCall({
  272. phoneNumber: item.helper_mobile
  273. });
  274. },
  275. //拨打电话
  276. TocallVideo(item) {
  277. let obj = this;
  278. console.log( obj.userInfo);
  279. uni.navigateTo({
  280. url: '/pagesA/record/call?userId=' + obj.userInfo.id + '&roomId=' + item.id
  281. });
  282. },
  283. access(item) {
  284. let obj = this;
  285. uni.showModal({
  286. title: '提示',
  287. content: '您确定要接受求救吗',
  288. success: function(res) {
  289. if (res.confirm) {
  290. accessSos({
  291. id: item.id
  292. })
  293. .then(data => {
  294. obj.$api.msg(data.msg);
  295. obj.page = 1;
  296. obj.RescueData('refresh');
  297. obj.HpleData('refresh');
  298. })
  299. .catch(e => {
  300. obj.$api.msg(e.message);
  301. obj.page = 1;
  302. obj.RescueData('refresh');
  303. obj.HpleData('refresh');
  304. });
  305. } else if (res.cancel) {
  306. console.log('用户点击取消');
  307. }
  308. }
  309. });
  310. },
  311. refuse(item) {
  312. let obj = this;
  313. uni.showModal({
  314. title: '提示',
  315. content: '您确定要拒绝求救吗?',
  316. success: function(res) {
  317. if (res.confirm) {
  318. refuseSos({
  319. id: item.id
  320. })
  321. .then(data => {
  322. console.log(data.msg, 77);
  323. obj.$api.msg(data.msg);
  324. obj.page = 1;
  325. obj.RescueData('refresh');
  326. obj.HpleData('refresh');
  327. })
  328. .catch(e => {
  329. obj.$api.msg(e.message);
  330. obj.page = 1;
  331. obj.RescueData('refresh');
  332. obj.HpleData('refresh');
  333. });
  334. } else if (res.cancel) {
  335. console.log('用户点击取消');
  336. }
  337. }
  338. });
  339. },
  340. navTo(url) {
  341. uni.navigateTo({
  342. url
  343. });
  344. }
  345. }
  346. };
  347. </script>
  348. <style lang="scss">
  349. page {
  350. background: #f8f6f6;
  351. height: 100%;
  352. .container {
  353. width: 100%;
  354. height: 100%;
  355. .swiper-box {
  356. height: 85vh;
  357. padding-top: 25rpx;
  358. .cate-list {
  359. height: 100%;
  360. }
  361. }
  362. }
  363. }
  364. .navbar {
  365. display: flex;
  366. height: 40px;
  367. background: #fff;
  368. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  369. position: relative;
  370. z-index: 10;
  371. .nav-item {
  372. flex: 1;
  373. display: flex;
  374. justify-content: center;
  375. align-items: center;
  376. height: 100%;
  377. font-size: 15px;
  378. color: $font-color-dark;
  379. position: relative;
  380. &.current {
  381. color: $font-color;
  382. &:after {
  383. content: '';
  384. position: absolute;
  385. left: 50%;
  386. bottom: 0;
  387. transform: translateX(-50%);
  388. width: 44px;
  389. height: 0;
  390. border-bottom: 2px solid #bc253a;
  391. }
  392. }
  393. }
  394. }
  395. .nodata {
  396. width: 430rpx;
  397. margin: 0rpx auto;
  398. padding-top: 80rpx;
  399. image {
  400. width: 430rpx;
  401. height: 337rpx;
  402. }
  403. .text {
  404. text-align: center;
  405. color: #999999;
  406. font-size: 26rpx;
  407. }
  408. }
  409. .swiper-box {
  410. height: calc(100% - 40px);
  411. }
  412. .list-scroll-content {
  413. height: 100%;
  414. }
  415. .navbar {
  416. overflow: hidden;
  417. white-space: nowrap;
  418. background: #fff;
  419. padding: 0rpx 25rpx;
  420. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  421. .nav-item {
  422. text-align: center;
  423. display: inline-block;
  424. height: 100%;
  425. font-size: 28rpx;
  426. color: $font-color-dark;
  427. position: relative;
  428. width: 25%;
  429. padding: 25rpx 0rpx;
  430. &.current {
  431. color: #ff6666;
  432. &:after {
  433. content: '';
  434. position: absolute;
  435. left: 50%;
  436. bottom: 0;
  437. transform: translateX(-50%);
  438. width: 35px;
  439. height: 0;
  440. border-bottom: 2px solid #ff6666;
  441. }
  442. }
  443. }
  444. }
  445. .content-box {
  446. width: 90%;
  447. margin: 0rpx auto;
  448. background-color: #ffffff;
  449. border-radius: 15rpx;
  450. padding: 47rpx 30rpx;
  451. font-size: 24rpx;
  452. line-height: 60rpx;
  453. color: #666666;
  454. margin-bottom: 25rpx;
  455. }
  456. .item {
  457. .name {
  458. font-size: 28rpx;
  459. color: #333333;
  460. font-weight: 500;
  461. }
  462. }
  463. .item-addr{
  464. background-color: #8DD64C;
  465. border-radius: 50rpx;
  466. padding: 8rpx 25rpx;
  467. color: #FFFFFF;
  468. }
  469. .call-btn {
  470. padding-top: 25rpx;
  471. font-size: 30rpx !important;
  472. color: #FFFFFF;
  473. .payPhone {
  474. background-color: #FF5050;
  475. border-radius: 50rpx;
  476. padding: 8rpx 25rpx;
  477. border: 1px solid #ff4f4f;
  478. border-radius: 99rpx;
  479. }
  480. .payPhone {
  481. border-right: 1px solid #ff4f4f;
  482. padding: 0rpx 30rpx;
  483. align-self: stretch ;
  484. image {
  485. width: 60rpx;
  486. height: 60rpx;
  487. margin-right: 15rpx;
  488. }
  489. }
  490. .payVideo {
  491. background-color: #3686FD;
  492. border-radius: 50rpx;
  493. padding: 8rpx 25rpx;
  494. image {
  495. width: 60rpx;
  496. height: 48rpx;
  497. margin-right: 15rpx;
  498. }
  499. }
  500. }
  501. .box-btn {
  502. width: 80%;
  503. margin: 0rpx auto;
  504. margin-top: 30rpx;
  505. text-align: center;
  506. .accept {
  507. background: #ff4f4f;
  508. color: #ffffff;
  509. padding: 0rpx 30rpx;
  510. width: 35%;
  511. }
  512. .refuse {
  513. background: #f3f3f3;
  514. width: 35%;
  515. padding: 0rpx 30rpx;
  516. }
  517. }
  518. .tpl {
  519. font-size: 28rpx;
  520. font-weight: bold;
  521. color: rgba(255, 79, 79, 1);
  522. }
  523. </style>