rescuerecords.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="container">
  3. <view class="list" v-for="(item,index) in list" :key='index'>
  4. <view class="box">
  5. <view class="box-top">
  6. 求救者姓名:{{item.name}}
  7. </view>
  8. <view class="box-time">
  9. 求救时间:{{item.add_time}}
  10. </view>
  11. <view class="box-sub-box" v-if="item.status==0">
  12. <view class="sub-box1" @click="agree(item,index)">
  13. 接受
  14. </view>
  15. <view class="sub-box2" @click="refuse(item,index)">
  16. 拒绝
  17. </view>
  18. </view>
  19. <view class="box-sub-box" v-if="item.status !==0">
  20. <view class="red-font" v-if="item.status == 1">
  21. 已接受
  22. </view>
  23. <view class="red-font" v-if="item.status == 2">
  24. 已拒绝
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <empty v-if="list.length === 0"></empty>
  30. <uni-load-more :status="loadingType"></uni-load-more>
  31. </view>
  32. </template>
  33. <script>
  34. import { getrescue ,change_rescue} from '@/api/index.js';
  35. import empty from '@/components/empty';
  36. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  37. export default{
  38. components: {
  39. empty,
  40. uniLoadMore
  41. },
  42. data(){
  43. return{
  44. page:1,
  45. limit:10,
  46. list:[],
  47. loadingType: 'more',
  48. }
  49. },
  50. onLoad() {
  51. this.loadData();
  52. },
  53. // 下拉加载
  54. onReachBottom() {
  55. this.loadData();
  56. },
  57. methods:{
  58. //同意
  59. agree(item,index){
  60. let obj = this;
  61. uni.showModal({
  62. content: '是否要接受该求救?',
  63. success: res => {
  64. if (res.confirm) {
  65. change_rescue({
  66. id:item.id,
  67. status:1
  68. }).then((data)=>{
  69. obj.list[index].status = 1;
  70. console.log(obj.list[index].status);
  71. })
  72. }
  73. }
  74. });
  75. },
  76. //拒绝
  77. refuse(item,index){
  78. let obj = this;
  79. uni.showModal({
  80. content: '是否要拒绝该求救?',
  81. success: res => {
  82. if (res.confirm) {
  83. change_rescue({
  84. id:item.id,
  85. status:2
  86. }).then((data)=>{
  87. obj.list[index].status = 2;
  88. console.log(item);
  89. })
  90. }
  91. }
  92. });
  93. },
  94. async loadData() {
  95. let obj = this;
  96. if (obj.loadingType === 'noMore') {
  97. //防止重复加载
  98. return;
  99. }
  100. // 修改当前对象状态为加载中
  101. obj.loadingType = 'loading';
  102. getrescue({
  103. page: obj.page,
  104. limit: obj.limit
  105. }).then(({ data }) => {
  106. obj.list = obj.list.concat(data);
  107. obj.page++;
  108. if (obj.limit == data.length) {
  109. obj.loadingType = 'more';
  110. } else {
  111. obj.loadingType = 'noMore';
  112. }
  113. })
  114. }
  115. }
  116. }
  117. </script>
  118. <style lang="scss">
  119. .container{
  120. line-height: 1;
  121. .box{
  122. width: 710rpx;
  123. background: #FFFFFF;
  124. box-shadow: 0px 5rpx 5rpx 0px rgba(34, 24, 20, 0.06);
  125. border-radius: 10rpx;
  126. margin: 20rpx auto 0;
  127. padding: 30rpx;
  128. .box-top{
  129. font-size: 28rpx;
  130. font-weight: 500;
  131. color: #333333;
  132. }
  133. .box-time{
  134. margin-top: 20rpx;
  135. font-size: 24rpx;
  136. font-weight: 500;
  137. color: #666666;
  138. }
  139. .box-sub-box{
  140. margin-top: 44rpx;
  141. display: flex;
  142. justify-content: space-between;
  143. padding:0 80rpx;
  144. .red-font{
  145. font-size: 28rpx;
  146. font-weight: 500;
  147. color: #C90F1B;
  148. }
  149. .sub-box1{
  150. width: 175rpx;
  151. height: 59rpx;
  152. background: #C90F1B;
  153. border-radius: 29rpx;
  154. font-size: 28rpx;
  155. font-weight: 500;
  156. color: #FFFFFF;
  157. display: flex;
  158. justify-content: center;
  159. align-items: center;
  160. }
  161. .sub-box2{
  162. width: 175rpx;
  163. height: 59rpx;
  164. background: #F3F3F3;
  165. border-radius: 29rpx;
  166. font-size: 28rpx;
  167. font-weight: 500;
  168. color: #333333;
  169. display: flex;
  170. justify-content: center;
  171. align-items: center;
  172. }
  173. }
  174. }
  175. }
  176. </style>