| | |
| | | <template> |
| | | <view class="content">
|
| | | <uniNavBar title="我的车辆" status-bar="true" class="header-bar" background-color="#fff" left-icon="back" color="#000" @clickLeft="goBack" >
|
| | | </uniNavBar>
|
| | | <!-- <div class="gap"></div> -->
|
| | | <view v-if="myCarList.length>0"> |
| | | <view class='cont' v-for="(i,index) in myCarList" :key="index" >
|
| | | <uni-icons class="del" v-show="isShowEdit" @click="delItem(i)" type="minus-filled" size="20" color="#ff0000"></uni-icons>
|
| | | <text>{{i}}</text> |
| | | </view> |
| | | </view>
|
| | | <view v-else class="tip">暂无车牌号,请联系管理员进行添加</view>
|
| | | <view class="content"> |
| | | <uniNavBar title="我的车辆" status-bar="true" class="header-bar" background-color="#fff" left-icon="back" color="#000" @clickLeft="goBack" > |
| | | </uniNavBar> |
| | | <!-- <div class="gap"></div> --> |
| | | <view v-if="myCarList.length>0"> |
| | | <view class='cont' v-for="(i,index) in myCarList" :key="index" > |
| | | <uni-icons class="del" v-show="isShowEdit" @click="delItem(i)" type="minus-filled" size="20" color="#ff0000"></uni-icons> |
| | | <text>{{i}}</text> |
| | | </view> |
| | | </view> |
| | | <view v-else class="tip">暂无车牌号,请联系管理员进行添加</view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | export default { |
| | | data() { |
| | | return {
|
| | | options:[{
|
| | | text: '删除',
|
| | | style: {
|
| | | backgroundColor: '#ff0000'
|
| | | }
|
| | | }],
|
| | | isShowEdit: false,
|
| | | isEditable: true,
|
| | | myCarList:[],
|
| | | return { |
| | | options:[{ |
| | | text: '删除', |
| | | style: { |
| | | backgroundColor: '#ff0000' |
| | | } |
| | | }], |
| | | isShowEdit: false, |
| | | isEditable: true, |
| | | myCarList:[], |
| | | } |
| | | }, |
| | | methods: { |
| | | async getCarList(){
|
| | | console.log(JSON.parse(uni.getStorageSync('user')));
|
| | | let {userId} = JSON.parse(uni.getStorageSync('user'));
|
| | | console.log(userId)
|
| | | let res = await this.$api.syncRequest({
|
| | | url: '/basic/api/user/myPlateNos?userId='+userId
|
| | | });
|
| | | if(res.data.success){
|
| | | this.myCarList = res.data.data;
|
| | | |
| | | }
|
| | | },
|
| | | updateStorage(){
|
| | | let user = JSON.parse(uni.getStorageSync('user'));
|
| | | user.plateNos = this.myCarList;
|
| | | debugger
|
| | | //localStorage.setItem('user',JSON.stringify(user));
|
| | | uni.setStorageSync('user',JSON.stringify(user))
|
| | | },
|
| | | goBack(){
|
| | | uni.navigateBack({
|
| | | delta: 1,
|
| | | animationType: 'pop-out',
|
| | | animationDuration: 200
|
| | | });
|
| | | async getCarList(){ |
| | | console.log(JSON.parse(uni.getStorageSync('user'))); |
| | | let {userId} = JSON.parse(uni.getStorageSync('user')); |
| | | console.log(userId) |
| | | let res = await this.$api.syncRequest({ |
| | | url: '/basic/api/user/myPlateNos?userId='+userId |
| | | }); |
| | | if(res.data.success){ |
| | | this.myCarList = res.data.data; |
| | | |
| | | } |
| | | }, |
| | | },
|
| | | mounted(){
|
| | | //this.getCarList();
|
| | | console.log(JSON.parse(uni.getStorageSync('user')))
|
| | | this.getCarList();
|
| | | },
|
| | | onShow(){
|
| | | console.log(JSON.parse(uni.getStorageSync('user')))
|
| | | this.getCarList();
|
| | | },
|
| | | onBackPress(e){
|
| | | console.log(e);
|
| | | uni.navigateTo({
|
| | | url:'/pages/mine/mine'
|
| | | })
|
| | | return true
|
| | | updateStorage(){ |
| | | let user = JSON.parse(uni.getStorageSync('user')); |
| | | user.plateNos = this.myCarList; |
| | | debugger |
| | | //localStorage.setItem('user',JSON.stringify(user)); |
| | | uni.setStorageSync('user',JSON.stringify(user)) |
| | | }, |
| | | goBack(){ |
| | | uni.navigateBack({ |
| | | delta: 1, |
| | | animationType: 'pop-out', |
| | | animationDuration: 200 |
| | | }); |
| | | }, |
| | | }, |
| | | mounted(){ |
| | | //this.getCarList(); |
| | | console.log(JSON.parse(uni.getStorageSync('user'))) |
| | | this.getCarList(); |
| | | }, |
| | | onShow(){ |
| | | console.log(JSON.parse(uni.getStorageSync('user'))) |
| | | this.getCarList(); |
| | | }, |
| | | onBackPress(e){ |
| | | console.log(e); |
| | | uni.navigateTo({ |
| | | url:'/pages/mine/mine' |
| | | }) |
| | | return true |
| | | }, |
| | | } |
| | | </script> |
| | | |
| | | <style> |
| | | .cont{
|
| | | line-height: 80rpx;
|
| | | height: 80rpx;
|
| | | padding-left: 40rpx;
|
| | | border-bottom: 1px solid #eee;
|
| | | }
|
| | | .tip{
|
| | | height: 100rpx;
|
| | | line-height: 100rpx;
|
| | | text-align: center;
|
| | | color: #999999;
|
| | | font-size: 14px;
|
| | | .cont{ |
| | | line-height: 80rpx; |
| | | height: 80rpx; |
| | | padding-left: 40rpx; |
| | | border-bottom: 1px solid #eee; |
| | | } |
| | | .tip{ |
| | | height: 100rpx; |
| | | line-height: 100rpx; |
| | | text-align: center; |
| | | color: #999999; |
| | | font-size: 14px; |
| | | } |
| | | </style> |