WechatOwnerService/pages/parkingInfo/parkingInfo.vue
2022-03-18 19:20:00 +08:00

254 lines
6.3 KiB
Vue
Executable File

<template>
<view>
<view>
<view class="header_fixed">
<scroll-view class="bg-white nav">
<view class="flex text-center">
<view class="cu-item flex-sub" :class="item.code==code?'text-green cur':''" v-for="(item,index) in parkingType"
:key="index" @tap="switchParkingSpace(item)" :data-id="index">
{{item.name}}
</view>
</view>
</scroll-view>
</view>
<view v-if="noData == false" style="margin-top: 150upx;">
<view v-for="(item,index) in parkings" :key="index"
class="bg-white margin-bottom margin-right-xs radius margin-left-xs padding-top padding-left padding-right">
<view class="flex padding-bottom-xs solid-bottom justify-between">
<view>{{item.applyId}}</view>
<view class="text-gray" v-if="item.state == '2002'">
<!-- #ifdef H5 || MP-WEIXIN -->
<button class="cu-btn bg-red shadow-blur lgplus sharp" @click="payFee(item)">缴费</button>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<button class="cu-btn bg-red shadow-blur lgplus sharp" @click="payFee(item)">缴费</button>
<!-- #endif -->
</view>
</view>
<view class="flex margin-top-xs justify-between">
<view class="text-gray">车牌号</view>
<view class="text-gray">{{item.carNum}}</view>
</view>
<view class="flex margin-top-xs justify-between">
<view class="text-gray">车辆品牌</view>
<view class="text-gray">{{item.carBrand}}</view>
</view>
<view class="flex margin-top-xs justify-between">
<view class="text-gray">起租时间</view>
<view class="text-gray">{{item.createTime}}</view>
</view>
<view class="flex margin-top-xs justify-between">
<view class="text-gray">结租时间</view>
<view class="text-gray">{{item.endTime}}</view>
</view>
<view class="flex margin-top-xs justify-between">
<view class="text-gray">备注</view>
<view class="text-gray">{{item.remark}}</view>
</view>
</view>
</view>
<view v-else>
<no-data-page></no-data-page>
</view>
</view>
</view>
</template>
<script>
import context from '../../lib/java110/Java110Context.js';
const constant = context.constant;
import {
formatDate
} from '../../lib/java110/utils/DateUtil.js'
import noDataPage from '@/components/no-data-page/no-data-page.vue'
export default {
data() {
return {
parkingType: [{
"name": '待审核',
"code": 1001
}, {
"name": '待缴费',
"code": 2002
}, {
"name": '完成',
"code": 3003
}, {
"name": '申请失败',
"code": 4004
}],
code: '1001',
moreParkingSpaces: [],
needFefresh: true,
parkings:[],
communityId:'',
noData: false,
page: 1,
row: 20,
ownerId: '',
userId: '',
};
},
components: {
noDataPage
},
onLoad: function(options) {
context.onLoad(options);
// #ifdef MP-WEIXIN
let accountInfo = uni.getAccountInfoSync();
this.appId = accountInfo.miniProgram.appId;
// #endif
// #ifdef H5
this.appId = uni.getStorageSync(constant.mapping.W_APP_ID)
// #endif
},
onShow: function() {
let _that = this;
if (!this.needFefresh) {
this.needFefresh = true;
return;
}
context.getOwner(function(_owner) {
_that.communityId = _owner.communityId;
_that.ownerId = _owner.memberId;
_that.userId = _owner.userId;
_that.listParkingSpace();
});
},
methods: {
listParkingSpace: function() {
let _that = this;
context.request({
url: constant.url.queryOwnerCars,
header: context.getHeaders(),
method: "GET",
data: {
"page": this.page,
"row": this.row,
"communityId": this.communityId,
"state": this.code,
"applyPersonId":this.ownerId
},
success: (res) => {
let data = res.data.data;
if(data.length == 0){
this.noData = true;
}
this.parkings = data;
if(this.parkings.length > 0){
_that._loadParkingSpaceFee();
}
},
fail(res) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
});
},
_loadParkingSpaceFee: function() {
let _that = this;
let _objData = {
page: 1,
row: 30,
payerObjId: _that.parkings[0].carId,
communityId: _that.parkings[0].communityId
}
_that.moreParkingSpaces = [];
context.request({
url: constant.url.queryFeeByOwner,
header: context.getHeaders(),
method: "GET",
data: _objData, //动态数据
success: function(res) {
if (res.statusCode == 200) {
//成功情况下跳转
let _parkingSpaceFees = res.data.fees;
if (_parkingSpaceFees.length < 1) {
_that.noData = true;
}
_parkingSpaceFees.forEach(function(_fee) {
let _tmpEndTime = _fee.endTime.replace(/\-/g, "/")
let _endTime = new Date(_tmpEndTime);
_fee.endTime = formatDate(_endTime);
_fee.num = _that.parkings[0].num;
let _now = new Date();
if (_endTime > _now) {
_fee.feeStateName = '正常'
} else {
_fee.feeStateName = '欠费'
}
_that.moreParkingSpaces.push(_fee);
});
console.log(_that.moreParkingSpaces);
}
},
fail: function(e) {
wx.showToast({
title: "服务器异常了",
icon: 'none',
duration: 2000
})
}
});
},
switchParkingSpace: function(_parkingSpace) {
this.code = _parkingSpace.code;
this.noData = false;
this.listParkingSpace();
},
payFee: function(_item) {
let _moreParkingSpaces = this.moreParkingSpaces[0];
_moreParkingSpaces["carNum"]=this.parkings[0].carNum;
this.vc.navigateTo({
url: '/pages/payParkingApplyFee/payParkingApplyFee?fee=' + JSON.stringify(_moreParkingSpaces),
})
},
}
};
</script>
<style>
@import "./parkingInfo.css";
.solid-bottom::after {
border-bottom: 2upx solid rgba(0, 0, 0, 0.1);
}
.solid-top::after {
border-top: 2upx solid rgba(0, 0, 0, 0.1);
}
.margin-header-top {
height: 100upx;
}
/* #ifdef APP-PLUS || MP-WEIXIN */
.header_fixed {
position: fixed;
top: 0upx;
left: 0;
width: 100%;
z-index: 2;
}
/* #endif */
/* #ifdef H5 */
.header_fixed {
position: fixed;
top: 80upx;
left: 0;
width: 100%;
z-index: 2;
}
/* #endif */
</style>