uniapp 结合uview ActionSheet操作菜单实现状态修改

uniapp yekong

uniapp微信小程序开发,需要进行菜单操作,并更新状态
uniapp 结合uview ActionSheet操作菜单实现状态修改

<template>
	<view class="listitem" @click="goadd(item)">
		<div class="listitemTitle">
			<div class="listitemTitlel">{{item.CarNum}}</div>
			<div class="listitemTitler" @click.stop="show=true">
				<div class="jinyong" v-if="item.Status==0">禁用</div>
				<div class="qiyong" v-if="item.Status==1">启用</div>
				<div class="jinyong" v-if="item.Status==2">失效</div>
				<div class="jinyong" v-if="item.Status==3">挂失</div>
			</div>
		</div>
		<div class="listitemcenter">
			<div class="listitemcenterl">
				<div class="label">
					车主
				</div>
				<div class="desc">
					{{item.CarMain}}
				</div>
			</div>
			<div class="listitemcenterl">
				<div class="label">
					电话
				</div>
				<div class="desc">
					{{item.Mobile}}
				</div>
			</div>
		</div>
		<!-- 		<div class="address">
			{{item.Address}}
		</div> -->
		<u-action-sheet @close="show=false" cancelText="取消" :actions="list" @select="selectClick" :title="title"
			:show="show">
		</u-action-sheet>

		<showToast ref="showToast"></showToast>

	</view>
</template>

<script>
	import {
		SetCardStatus
	} from '@/config/api.js'
	export default {
		components: {},
		data() {
			return {
				CompanyId: 0,
				style: {
					// 字符串的形式
					p: 'font-size:28rpx;',
					span: 'font-size: 28rpx;',
				},
				show: false,
				list: [{
						id: 0,
						name: '禁用'
					},
					{
						id: 1,
						name: '启用'
					},
					{
						id: 2,
						name: '失效'
					},
					{
						id: 3,
						name: '挂失'
					}
				],
			}
		},
		props: {
			item: {
				type: Object,
				default () {
					return {};
				}
			}
		},
		computed: {

		},
		mounted() {
			this.AccountId = JSON.parse(uni.getStorageSync('userData')).Id
		},
		methods: {
			goadd(item) {
				uni.setStorageSync('companyManagementData', item)
				uni.navigateTo({
					url: '/pages/home/enterprise/companyManagement/add/add'
				})
			},
			gettype(e) {
				console.log(e)
				this.type = e.value[0]
			},
			getshow() {
				this.show = true
			},
			selectClick(e) {
				console.log(e)
				this.SetCardStatus(e.id)
			},
			SetCardStatus(State) {
				var that = this;
				SetCardStatus({
					params: {
						AccountId: that.AccountId,
						Id: that.item.Id,
						CardStatus: State,
					},
					custom: {
						auth: true
					}
				}).then(res => {
					if (res.Code == 200) {
						that.$refs['showToast'].success('状态更新成功');
						that.$emit('getdata', State)
					}
				}).catch(err => {

				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.listitem {
		margin: 0 auto;
		width: calc(694rpx - 64rpx);
		background: #FFFFFF;
		border-radius: 20rpx;
		padding: 32rpx;
		margin-bottom: 24rpx;

		.listitemTitle {
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #272A5F;
			width: 100%;
			overflow: hidden;
			white-space: nowrap;
			text-overflow: ellipsis;
			display: flex;
			justify-content: space-between;
			align-items: center;
			flex-wrap: nowrap;
			flex-direction: row;
			align-content: flex-start;
		}

		.listitemcenter {
			width: 630rpx;
			height: 139rpx;
			background: rgba(#4087FF, 0.05);
			border-radius: 12rpx;
			margin-top: 28rpx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			flex-wrap: nowrap;
			flex-direction: row;
			align-content: flex-start;

			.listitemcenterl {
				width: calc(50% - 32rpx);
				margin-left: 32rpx;

				.label {
					font-size: 24rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #6F7197;
				}

				.desc {
					font-size: 30rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #141852;
				}
			}

			.listitemcenterl:nth-child(1) {
				border-right: 1rpx solid #E8EBF2;
			}
		}

		.address {
			font-size: 26rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #5B5D85;
			margin-top: 28rpx;
		}
	}

	.qiyong {
		width: 72rpx;
		height: 40rpx;
		background: rgba(26, 196, 81, 0.05);
		border-radius: 8rpx;
		border: 2rpx solid #D2F0DC;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: nowrap;
		background: #F5FCF8;
		font-size: 24rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #45C36F;
		flex-direction: row;
		align-content: flex-start;
	}

	.jinyong {
		width: 72rpx;
		height: 40rpx;
		background: rgba(26, 196, 81, 0.05);
		border-radius: 8rpx;
		border: 2rpx solid #FEC8C7;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: nowrap;
		background: #FFF3F3;
		font-size: 24rpx;
		font-family: PingFangSC-Medium, PingFang SC;
		font-weight: 500;
		color: #FA1B1B;
		flex-direction: row;
		align-content: flex-start;
	}
</style>

喜欢