小程序滑动单元格

项目场景:小程序用户管理列表,通过单元格滑动实现"密码重置"、"删除"功能。

技术框架:uniapp、uview3、ts

效果如下:

前端页面:

html 复制代码
<template>
	<view class="fui-wrap">
		<view class="fui-page__hd">
			<view class="fui-page__title">{{data.title}}</view>
			<view class="fui-page__desc">{{data.sub_title}}</view>
		</view>
		<view class="">

		</view>
		<view class="u-page__swipe-action-item" :bottomLeft="0" v-for="(item,index) in data.list">
			<up-swipe-action>
				<up-swipe-action-item :options="buttons" @click="click" :name="item.StfID">
					<view class="swipe-action u-border-top u-border-bottom">
						<view class="swipe-action__content">
							<text style="min-height: 150rpx;"
								class="swipe-action__content__text">{{item.StfName}}/{{item.StfFullName}}</text>
						</view>
					</view>
				</up-swipe-action-item>
			</up-swipe-action>
		</view>
	</view>
</template>

<script setup lang="ts">
	import { deluser_api, resetpwd_api, userlist_api } from '@/service/ZlfApi';
	import { onLoad, onUnload } from '@dcloudio/uni-app';
	import { ref } from 'vue';

	const buttons = ref([{
		text: '重置密码',
		style: {
			background: '#465CFF'
		}

	}, {
		text: '删除',
		style: {
			background: '#FF2B2B'
		}
	}])

	const data = ref({
		title: '用户管理',
		sub_title: '滑动重置密码、删除用户',
		list: [],
		// totalCount: 0,
	})

	onLoad(() => {
		list()
	})
	onUnload(() => {
		// uni.$off('manageRefresh') 
	})

	const click = (e : any) => {
		// console.log(index)
		let StfID = e.name
		if (e.index == 0) {
			// 重置密码
			resetpwd_api({ StfID: StfID }).then((res : any) => {
				if (res.code == 1) {
					uni.hideLoading()
					uni.showModal({
						title: '提示',
						content: res.msg,
						showCancel:false
					})
				} else {
					uni.showToast({
						icon: 'error',
						title: res.msg
					})
				}
			})
		}
		if (e.index == 1) {
			// 删除用户
			uni.showModal({
				title: '提示',
				content: '操作不可逆,确认删除?',
				success: function (res) {
					if (res.confirm) {
						// console.log('用户点击确定');
						deluser_api({ StfID: StfID }).then((res : any) => {
							if (res.code == 1) {
								uni.hideLoading()
								uni.showModal({
									title: '提示',
									content: res.msg,
									showCancel:false,
									success: function (res) {
											if (res.confirm) {
												list();
											}
										}
								})
							} else {
								uni.showToast({
									icon: 'error',
									title: res.msg
								})
							}
						})
					} else if (res.cancel) {
						// console.log('用户点击取消');
					}
				}
			});

		}
	}
	

	const list = async () => {
		// 发起请求,获取设备列表
		const res = await userlist_api()
		data.value.list = res.data
		console.log(data.value.list)
	}
</script>

<style lang="scss">
	.swipe-action {
		&__content {
			padding: 25rpx 0;

			&__text {
				font-size: 15px;
				color: $u-main-color;
				padding-left: 30rpx;
			}
		}
	}

	page {
		font-weight: normal;
		/* 非nvue端使用此变量改变list线条颜色,nvue端请查看文档 */
		/* --fui-color-border:#B2B2B2; */
	}

	.fui-section__title {
		margin-left: 32rpx;
	}

	.fui-list__item {
		flex: 1;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.fui-text__explain {
		font-size: 28rpx;
		color: #7F7F7F;
		flex-shrink: 0;
	}

	.fui-list__icon {
		width: 48rpx;
		height: 48rpx;
		margin-right: 24rpx;
	}
</style>
相关推荐
wx_ywyy67984 小时前
团购小程序区域化运营:多门店管理、配送范围设置与本地化活动开发
小程序·小程序开发·商城小程序·小程序制作·团购小程序·团购小程序开发·电商小程序
從南走到北4 小时前
JAVA同城服务场馆预约门店预约健身房瑜伽馆预约系统支持H5小程序APP源码
java·开发语言·小程序
韩立学长4 小时前
【开题答辩实录分享】以《智慧农业信息化服务平台小程序》为例进行答辩实录分享
数据库·spring boot·小程序
Lsx-codeShare5 小时前
一文读懂 Uniapp 小程序登录流程
前端·javascript·小程序·uni-app
低代码布道师6 小时前
医疗小程序08科室管理
低代码·小程序
00后程序员张7 小时前
接口调试从入门到精通,Fiddler抓包工具、代理配置与HTTPS抓包实战技巧
前端·ios·小程序·https·fiddler·uni-app·webview
说私域8 小时前
“开源链动2+1模式AI智能名片S2B2C商城小程序”赋能同城自媒体商家营销创新研究
人工智能·小程序·开源
说私域14 小时前
AI智能名片链动2+1模式S2B2C商城小程序在客服沟通中的应用与效果
人工智能·小程序
游戏开发爱好者81 天前
iOS IPA 上传工具全面解析,从 Transporter 到开心上架(Appuploader)命令行的高效上架实践
android·ios·小程序·https·uni-app·iphone·webview
阿里花盘1 天前
培训机构如何利用小程序线上引流招生?培训机构小程序开发教程
小程序