123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- <template>
- <view class="container">
- <view class="list" v-for="(item,index) in list" :key='index'>
- <view class="box">
- <view class="box-top">
- 求救者姓名:{{item.name}}
- </view>
- <view class="box-time">
- 求救时间:{{item.add_time}}
- </view>
- <view class="box-sub-box" v-if="item.status==0">
- <view class="sub-box1" @click="agree(item,index)">
- 接受
- </view>
- <view class="sub-box2" @click="refuse(item,index)">
- 拒绝
- </view>
- </view>
- <view class="box-sub-box" v-if="item.status !==0">
- <view class="red-font" v-if="item.status == 1">
- 已接受
- </view>
- <view class="red-font" v-if="item.status == 2">
- 已拒绝
- </view>
- </view>
- </view>
- </view>
- <empty v-if="list.length === 0"></empty>
- <uni-load-more :status="loadingType"></uni-load-more>
- </view>
- </template>
- <script>
- import { getrescue ,change_rescue} from '@/api/index.js';
- import empty from '@/components/empty';
- import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
- export default{
- components: {
- empty,
- uniLoadMore
- },
- data(){
- return{
- page:1,
- limit:10,
- list:[],
- loadingType: 'more',
- }
- },
- onLoad() {
- this.loadData();
- },
- // 下拉加载
- onReachBottom() {
- this.loadData();
- },
- methods:{
- //同意
- agree(item,index){
- let obj = this;
- uni.showModal({
- content: '是否要接受该求救?',
- success: res => {
- if (res.confirm) {
- change_rescue({
- id:item.id,
- status:1
- }).then((data)=>{
- obj.list[index].status = 1;
- console.log(obj.list[index].status);
- })
-
-
-
- }
- }
- });
- },
- //拒绝
- refuse(item,index){
- let obj = this;
- uni.showModal({
- content: '是否要拒绝该求救?',
- success: res => {
- if (res.confirm) {
- change_rescue({
- id:item.id,
- status:2
- }).then((data)=>{
- obj.list[index].status = 2;
- console.log(item);
- })
-
-
-
- }
- }
- });
- },
- async loadData() {
- let obj = this;
- if (obj.loadingType === 'noMore') {
- //防止重复加载
- return;
- }
- // 修改当前对象状态为加载中
- obj.loadingType = 'loading';
- getrescue({
- page: obj.page,
- limit: obj.limit
- }).then(({ data }) => {
- obj.list = obj.list.concat(data);
- obj.page++;
- if (obj.limit == data.length) {
- obj.loadingType = 'more';
- } else {
- obj.loadingType = 'noMore';
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- .container{
- line-height: 1;
-
- .box{
- width: 710rpx;
- background: #FFFFFF;
- box-shadow: 0px 5rpx 5rpx 0px rgba(34, 24, 20, 0.06);
- border-radius: 10rpx;
- margin: 20rpx auto 0;
- padding: 30rpx;
- .box-top{
- font-size: 28rpx;
- font-weight: 500;
- color: #333333;
- }
- .box-time{
- margin-top: 20rpx;
- font-size: 24rpx;
- font-weight: 500;
- color: #666666;
- }
- .box-sub-box{
- margin-top: 44rpx;
- display: flex;
- justify-content: space-between;
- padding:0 80rpx;
- .red-font{
- font-size: 28rpx;
- font-weight: 500;
- color: #C90F1B;
- }
- .sub-box1{
- width: 175rpx;
- height: 59rpx;
- background: #C90F1B;
- border-radius: 29rpx;
- font-size: 28rpx;
- font-weight: 500;
- color: #FFFFFF;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- .sub-box2{
- width: 175rpx;
- height: 59rpx;
- background: #F3F3F3;
- border-radius: 29rpx;
- font-size: 28rpx;
- font-weight: 500;
- color: #333333;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- }
- }
-
- }
- </style>
|