123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <template>
- <view class="carbox">
- <view class="flex1 cartop">
- <box-list :datainfo="list" type="mycar" :clcxList="clcxList" @getDetail="getDetail" @getDelFn="getDelFn"></box-list>
- <view class="cartips flexc mt16 mb16" @click="getChargeFn">
- <view class="tit flex1">当前有车辆<text class="co025">充电中…</text></view>
- <image :src="rimg"></image>
- </view>
- </view>
- <view class="plr12 flex0">
- <view class="rhbtn" @click="getAddFn">添加车辆</view>
- </view>
- <loading></loading>
- </view>
- </template>
- <script>
- import config from '@/config'
- const baseUrl = config.baseUrl
- import boxList from "@/mine/components/box/list.vue"
- import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
- import {carList,carDel} from "@/api/work/car.js"
- import {getDictionaryFn} from "@/api/system/user.js"
- export default{
- components:{boxList},
- data(){
- return{
- rimg: require('@/mine/static/house/rimg.png'),
- list:[],
- pageSize: 10,
- pageNum: 1,
- reachflag: true,
- wtdt:'',
- clcxList:[]
- }
- },
- onUnload() {
- uni.$off('carlist')
- },
- onLoad: function() {
- uni.$on('carlist',(res)=>{
- this.getDataFn()
- })
- this.init()
- this.getDataFn()
- },
- // 上拉触底加载更多触发事件
- onReachBottom() {
- if (this.reachflag) {
- this.pageNum++
- this.getDataFn()
- }
- },
- methods:{
- checkPermi, checkRole,
- init(){
- // 车型
- getDictionaryFn('cartype').then(res=>{
- if(res.code==200){
- this.clcxList = res.data.map(v => {
- return {
- dictLabel: v.dictLabel,
- dictValue: v.dictValue
- }
- })
- }
- })
- },
- getDelFn(data){
- var that=this;
- carDel(data).then(res=>{
- if(res.code==200){
- this.$toast("删除成功");
- setTimeout(function(){
- that.getDataFn()
- },1500)
- }
- })
- },
- getAddFn(){
- this.$tab.navigateTo("/mine/pages/car/addcar")
- },
- getDetail(id){
- this.$tab.navigateTo("/mine/pages/car/addcar?id="+id)
- },
- getChargeFn(){
- this.$tab.navigateTo("/mine/pages/car/charge")
- },
- getDataFn(){
- var params={
- pageSize:this.pageSize,
- pageNum: this.pageNum,
- }
- carList(params).then(res=>{
- if(res.code==200){
- if (res.rows.length < this.pageSize) {
- this.reachflag = false
- this.wtdt = '到底了~';
- } else {
- var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
- if (num < res.total) {
- this.reachflag = true
- this.wtdt = ''
- } else {
- this.reachflag = false
- this.wtdt = '到底了~';
- }
- }
- var newArr=JSON.parse(JSON.stringify(res.rows))
- newArr.forEach(ite=>{
- ite.right=0;
- })
- if (this.pageNum == 1) {
- this.list = newArr;
- } else {
- this.list = this.list.concat(newArr)
- }
- }else{
- this.$toast(res.msg)
- }
- })
-
- },
- }
- }
- </script>
- <style>
- page{background: #F3F3F0;}
- </style>
- <style lang="scss" scoped>
- .carbox{display: flex;flex-direction: column;min-height: 100vh;padding: 22rpx 18rpx 100rpx;
- .cartop{overflow: auto;}
- .cartips{background: #FFFFFF;border-radius: 20rpx;height: 98rpx;padding: 0 24rpx;
- image{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;}
- .tit{font-weight: bold;font-size: 26rpx;color: #272727;}
- }
- }
- </style>
|