uniapp 微信小程序 自定义弹框+picker下拉选择列表+输入表单:拒绝-选择理由弹窗

这篇具有很好参考价值的文章主要介绍了uniapp 微信小程序 自定义弹框+picker下拉选择列表+输入表单:拒绝-选择理由弹窗。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

效果:
微信小程序弹窗表单,uni-app,微信小程序,notepad++
微信小程序弹窗表单,uni-app,微信小程序,notepad++
微信小程序弹窗表单,uni-app,微信小程序,notepad++

1、template

<!-- 拒绝-选择理由弹窗-->
<view class="reason-popover" v-if="showReasonDialog">
	<view class="reason-modal">
		<view class="reason-title">
			<text>请选择拒绝理由</text>
		</view>
		<view class="reason-bd">
			<view class="select-picker">
				<picker @change="bindPickerChangeReason" :value="itemIndex" :range="listArray"
					range-key="dictLabel">
					<input class="select-input" type="text" placeholder="请选择" disabled="disabled"
						v-if="itemIndex == -1"></input>
					<view class="select-input" v-else :value="listArray[itemIndex].dictLabel">
						{{listArray[itemIndex].dictLabel}}
					</view>
				</picker>
			</view>
			<textarea placeholder="请填写理由" v-model="otherReason" class="other-reason"
				v-if="showOther"></textarea>
			<text class="tips">每月可拒绝3次,超过将进行监管</text>
		</view>
		<view class="reason-bottom-btn">
			<view class="common-btn" @click="closeReasonDialog">取消</view>
			<view class="common-btn confirm-btn" @click="toConfirm">确定</view>
		</view>
	</view>
</view>

2、data:

data() {
	return {
		// 拒绝理由
		itemIndex: -1,
		listArray: [],
		reasonName:'',//理由文本
		showReasonDialog: false, //是否显示拒绝弹框
		otherReason: '', //输入的理由
		showOther: false, //是否显示输入文本框
	}
}

3、methods:

// 点击拒绝-请求拒绝理由列表接口
toCancel: function() {
	uni.showLoading();
	var params = {
		url: "/***/***",
		method: "GET",
		data: {},
		callBack: res => {
			uni.hideLoading()
			this.listArray = res.data
			this.showReasonDialog = true //显示拒绝弹框
		}
	};
	http.request(params);
},
// 理由下拉列表
bindPickerChangeReason: function(e) {
	this.itemIndex = e.detail.value
	this.reasonIds = this.listArray[this.itemIndex].dictValue
	this.reasonName = this.listArray[this.itemIndex].dictLabel
	//当选择其他时,文本输入框显示,当选择非其他时输入框隐藏
	if (this.reasonName == "其他") {
		this.showOther = true
	}else{
		this.showOther = false 
	}
},
// 拒绝点击确定
toConfirm: function() {
	if (this.reasonName.length == 0) {
		uni.showToast({
			icon: 'none',
			title: "请选择拒绝理由",
		})
		return
	}
	//当选择其他时,如果未输入文本,则理由默认传“其他”,否则就传输入的文本值
	if (this.reasonName == "其他") {
		if(!this.otherReason){
			this.reasonName = "其他"
		}else{
			this.reasonName = this.otherReason
		}
	}
	
	uni.showLoading();
	var params = {
		url: "/****/****",
		method: "PUT",
		data: {
			orderId: this.orderId,
			driverRefuseReason: this.reasonName
		},
		callBack: res => {
			uni.hideLoading()
			this.showReasonDialog = false
			uni.showModal({
				title: "拒绝成功",
				content: "",
				confirmText: "确定",
				showCancel: false,
				success: (res) => {
					if (res.confirm) {
						//拒绝成功跳转订单列表页
						uni.reLaunch({
							url: '/pages/order/order'
						})
					}
				}
			})
		}
	};
	http.request(params);
},
// 关闭弹框
closeReasonDialog() {
	this.showReasonDialog = false
},

4、style文章来源地址https://www.toymoban.com/news/detail-807182.html

.reason-popover {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 10000;
	display: flex;
	display: -webkit-flex;
	justify-content: center;
	align-items: center;
	background-color: rgba(0, 0, 0, 0.5);
}

.reason-popover .reason-modal {
	position: relative;
	width: 640rpx;
	/* height: 575rpx; */
	border-radius: 16rpx;
	background: #fff;
	margin: 0 auto;
	padding: 64rpx 48rpx 112rpx 48rpx;
	box-sizing: border-box;
}

.reason-popover .reason-title {
	/* width: 313rpx;
	height: 90rpx; */
	margin: 0 auto;
	font-size: 32rpx;
	/* line-height: 45rpx; */
	text-align: center;
	color: #000;
	margin-bottom: 32rpx;
}

/* .close-img {
	position: absolute;
	top: 12rpx;
	right: 12rpx;
	width: 44rpx;
	height: 44rpx;
}

.close-img image {
	width: 100%;
	height: 100%;
} */
.reason-bd{
	/* width: 420rpx; */
	width: 100%;
	/* height: 640rpx; */
	margin: 0 auto;
	margin-bottom: 64rpx;
	
	/* line-height: 36rpx; */
	
}
.reason-bd .bd-title{
	color: #3DB86D;
}
.tips{
	margin: 0 auto;
	font-size: 36rpx;
	color: #3D3D3D;
	margin-top: 64rpx;
}
.reason-bd text{
	display: block;
}
.reason-bottom-btn{
	width: 100%;
	border-top:1rpx solid #E7E7E7;
	position: absolute;
	left: 0;
	bottom: 0;
	display: flex;
	justify-content: space-around;
	height: 112rpx;
	line-height: 112rpx;
	text-align: center;
}
.common-btn{
	width:320rpx;
	
}
.confirm-btn {
	border-left: 1rpx solid #E7E7E7;
	color: #5b6987;
	box-sizing: border-box;
}
.other-reason{
	width: 100%;
	height: 147rpx;
	border-radius: 8rpx;
	background: #F3F3F3;
	padding: 24rpx 24rpx 27rpx 24rpx;
	box-sizing: border-box;
	color: #3D3D3D;
	font-size: 32rpx;
	margin-top:20rpx;
}
.select-input{
	width:100%;
	height: 88rpx;
	line-height: 88rpx;
	border-radius: 10rpx;
	border: 1rpx solid #BDBDBD;
	padding-left: 22rpx;
	box-sizing:border-box;
}
.select-picker{
	border: 1rpx solid #BDBDBD;
}
.select-picker .select-input{
	border:none !important
}

到了这里,关于uniapp 微信小程序 自定义弹框+picker下拉选择列表+输入表单:拒绝-选择理由弹窗的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 微信小程序封装自定义van-dropdown-item 下拉选择框

    1.vant weapp虽然给我们提供了van-dropdown-item且美观的组件但是没有插槽无法自定义内容,限制了各位大神的操作,接下来我们先来了解他的使用在去封装自己的自定义 这是官方自己的效果! 下面来看看我们自己封装的组件 2.还能自定义搜索框等等是不是很奈斯! 接下来我们在

    2024年02月11日
    浏览(35)
  • 微信小程序 —— picker 组件, 下拉列表组件

    picker 组件的使用 自定义组件的创建和使用 微信小程序的语法,官方 wxss 库的使用 从底部弹起的滚动选择器 doc: https://developers.weixin.qq.com/miniprogram/dev/component/picker.html 通用属性: 属性 类型 默认值 必填 说明 mode string selector 否 选择器类型 disabled boolean false 否 是否禁用 bindca

    2024年04月27日
    浏览(29)
  • uniapp开发微信小程序底部地区选择弹框

    个人项目地址: SubTopH前端开发个人站 (自己开发的前端功能和UI组件,一些有趣的小功能,感兴趣的伙伴可以访问,欢迎提出更好的想法,私信沟通,网站属于静态页面) SubTopH前端开发个人站 https://subtop.gitee.io/subtoph.github.io/#/home 实现效果 功能介绍: 支持默认值直接显示

    2024年02月12日
    浏览(30)
  • 微信小程序chooseImage无法唤起选择弹框

    用uniapp打包发布的H5,在浏览器、开发者工具、IOS和部分安卓里都正常,但在微信小程序原生的web-view里,鸿蒙系统下无法唤起选择弹框(之前是可以的,最近鸿蒙更新了一下2.0.0.230就不行了)。无论是使用uni.chooseImage、还是uni-file-picker,都没反应。 原因:无论是chooseImage还是

    2024年02月05日
    浏览(48)
  • 微信小程序实现各类弹框、自定义弹框

    目录 wx.showModal  wx.showToast wx.showLoading wx.showActionSheet 自定义弹框 功能介绍:常用于显示需用户操作的信息框,用户可进行确认、取消或输入内容。 常用参数介绍: title:提示的标题: content:提示的内容: showCancel:是否显示取消按钮 cancelText:取消按钮的文字 confirmText:

    2024年01月18日
    浏览(45)
  • 【微信小程序】选择器组件picker

    picker组件是一种从底部向上弹起的滚动选择器。 在官方文档中,有提供五种类型的picker组件,如普通选择器,多列选择器,时间选择器,日期选择器和省市区选择器。 (猜测是,这些选择器时不同的且常用的某种类型,于是就产生固定的模版)。 而在写法上是这么写滴,

    2024年01月18日
    浏览(42)
  • 微信小程序picker多列选择器

    微信官方文档的的案例数据是写死,而且代码阅读性特别差 下面是我参考官方案例写的一个多列选择器,数据是都 动态获取 的 这是一个二列的选择器,如果需要三列的可以稍加修改一下 一、wxml 二、js 选择器中的数据都是 动态获取 的,只要将数据转成跟 data 中的数据格式

    2024年02月11日
    浏览(32)
  • 【微信小程序】picker 滚动选择器

    参考:picker | 微信开放文档 刚开始使用的是vantweap的picker,但是居然有蒙版还无法自定义样式。 Picker 选择器 - Vant Weapp 苦恼ing。最后看到原生组件有自定义蒙版样式,豁然开朗~ 激活项的蒙版在文字上方   利用relative的层级z-index:-1展示在文字下方。

    2024年02月16日
    浏览(29)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包