微信小程序WeUI中half-screen-dialog底部弹窗相关问题

2024-01-18 14:40

本文主要是介绍微信小程序WeUI中half-screen-dialog底部弹窗相关问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

需求:
如图需要从页面底部弹出一个弹框,弹框里的内容超出最大高度时,可以滚动。
在这里插入图片描述

问题:

  1. 原生的组件关闭图标在左侧,需要通过样式改到右侧
  2. 原生的组件底部有footer按钮区域,需要通过样式隐藏掉
  3. 在弹框里使用区域滚动通过scroll-view 设置纵向滚动并给最大高度
  4. 设置title
  5. half-screen-dialog如果在子组件中引入,需要在pages父组件中的css文件里修改样式。在子组件中修改不生效

代码:

index.json

{"component": true,"usingComponents": {"compute-cart": "/components/computeCart","mp-half-screen-dialog": "weui-miniprogram/half-screen-dialog/half-screen-dialog"}
}

index.wxml

<mp-half-screen-dialog extClass='type-dialog' show="{{typeDialog}}" bindclose='toggleDialog'><view slot="title" style="text-align: left;"><text>{{curGoodsSpec.goodsName}} {{curGoodsSpec.spec}}</text></view><view class="model" slot="desc"><scroll-view class="scrollBox" scroll-y="true"><view class="" wx:for="{{curGoodsSpec.detailVos}}" wx:key="index"><view class="title">{{item.goodsSpec}}<view class="bestOffer" wx:if="{{item.bestOfferLabel}}"><image src="https://retail.benlai.com/fortune/images/bazaar/cheapestSingle.png" mode="widthFix" class="cheapestSingle"></image>单价最便宜</view></view><view class="goods-weight"><view class="goods-netWeight " style="margin-right: 24rpx;"><view class="weight-name {{item.isSelected ? 'goods-name-active' : ''}} {{curGoodsSpec.settlementType == 1 ? 'bordeRi' : ''}}">¥{{item.disSalePrice}}/件</view><view class="weight-num {{item.isSelected ? 'goods-num-active' : ''}}" wx:if="{{curGoodsSpec.settlementType !== 1}}">约¥{{item.netUnitPrice}}/斤</view></view></view></view></scroll-view><!-- 合计 --><view class="footer"><view class="footer-all">共计:<text class="totalIcon">¥</text><text class="totalMoney"> {{curGoodsSpec.totalSpecAmount}}</text></view><view class=""><!-- 不在售卖时间显示加减数量 --><view class="{{curGoodsSpec.goodsStatus == 1 ? 'priceinfo' : ''}} {{curGoodsSpec.goodsStatus == 5 ? 'out-sale-cart-btn' : ''}}"><compute-cartquantity="{{curGoodsSpec.cartQty}}"cur-stock="{{curGoodsSpec.curStock}}"from="cartpageSpec"goods-key="{{curGoodsSpec.goodsKey}}"goods-status="{{curGoodsSpec.goodsStatus}}"multiple="{{curGoodsSpec.multiple}}"bind:cb="bindCartItemChange"></compute-cart></view></view></view></view>
</mp-half-screen-dialog>

index.js

methods: {bindCartItemChange(e) {this.setData({curGoodsKey: e.detail.goodsKey})this.getGoodsSpecShow()},// 优惠加购toggleDialog(e) {this.setData({typeDialog: !this.data.typeDialog,curGoodsKey: e.detail})if (this.data.typeDialog) {this.getGoodsSpecShow()}},getGoodsSpecShow() {let params_ = {goodsKey: this.data.curGoodsKey,merchantNo: wx.getStorageSync("merchantNo")}goodsSpecShow(params_).then(data => {if (data) {this.setData({curGoodsSpec: data})}})},}

index.wxss

.goods-weight .weight-num {color: #666;background: #fff;border-radius: 0rpx 4rpx 4rpx 0rpx;border: 1rpx solid #CFCFCF;padding: 9rpx 12rpx;
}
.scrollBox {max-height: 580rpx;
}
.scrollBox .title {font-size: 28rpx;font-weight: 400;color: #999999;margin-bottom: 16rpx;display: flex;
}
.model {border-top: 2rpx solid #EEEEEE;padding-top: 32rpx;
}
.footer {padding: 24rpx 32rpx 0 32rpx;border-top: 2rpx solid #EEEEEE;display: flex;justify-content: space-between;
}
.footer .footer-all {font-size: 24rpx;font-weight: 400;color: #666666;line-height: 34rpx;
}
.footer .totalIcon {font-size: 24rpx;font-weight: 400;color: #FF0B0B;line-height: 34rpx;
}
.footer .totalMoney {font-size: 40rpx;font-weight: 600;color: #FF0B0B;line-height: 56rpx;
}
.scrollBox {padding: 0 32rpx;
}.priceinfo {text-align: right;
}
.out-sale-cart-btn {position: relative;z-index: 20;
}
.bestOffer {font-size: 24rpx;font-weight: 400;color: #FF0B0B;line-height: 34rpx;display: flex;margin-left: 8rpx;
}
.goods-weight .goods-name-active {color: #FA4F13;border: 1rpx solid #E66F22;background: #fdd8cf;
}
.goods-weight .goods-num-active {color: #FA4F13;border: 1rpx solid #E66F22;border-left: 0;
}

弹窗样式只能写在pages父组件中

/* half-screen-dialog ui组件样式只能写在pages里 */.type-dialog .weui-half-screen-dialog__ft {display: none !important;
}
.type-dialog .weui-half-screen-dialog__bd {padding-bottom: 20px;
}
.type-dialog {padding: 0;
}
.weui-half-screen-dialog__hd {padding: 0 32rpx;
}
/* 隐藏更多按钮避免关闭点击偶尔失效 */
.weui-half-screen-dialog .weui-icon-btn_more{display: none !important;
}
.weui-icon-btn_close {position: absolute;right: -680rpx;
}
.weui-half-screen-dialog__hd__main {padding-left: 0 !important;
}

参考文章:
微信小程序WeUI中half-screen-dialog的小问题
WeUI官方组件库:助力小程序高效设计与开发官方

这篇关于微信小程序WeUI中half-screen-dialog底部弹窗相关问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/619330

相关文章

Redis 热 key 和大 key 问题小结

《Redis热key和大key问题小结》:本文主要介绍Redis热key和大key问题小结,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、什么是 Redis 热 key?热 key(Hot Key)定义: 热 key 常见表现:热 key 的风险:二、

IntelliJ IDEA 中配置 Spring MVC 环境的详细步骤及问题解决

《IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决》:本文主要介绍IntelliJIDEA中配置SpringMVC环境的详细步骤及问题解决,本文分步骤结合实例给大... 目录步骤 1:创建 Maven Web 项目步骤 2:添加 Spring MVC 依赖1、保存后执行2、将新的依赖

Spring 中的循环引用问题解决方法

《Spring中的循环引用问题解决方法》:本文主要介绍Spring中的循环引用问题解决方法,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录什么是循环引用?循环依赖三级缓存解决循环依赖二级缓存三级缓存本章来聊聊Spring 中的循环引用问题该如何解决。这里聊

Spring Boot中JSON数值溢出问题从报错到优雅解决办法

《SpringBoot中JSON数值溢出问题从报错到优雅解决办法》:本文主要介绍SpringBoot中JSON数值溢出问题从报错到优雅的解决办法,通过修改字段类型为Long、添加全局异常处理和... 目录一、问题背景:为什么我的接口突然报错了?二、为什么会发生这个错误?1. Java 数据类型的“容量”限制

Python的time模块一些常用功能(各种与时间相关的函数)

《Python的time模块一些常用功能(各种与时间相关的函数)》Python的time模块提供了各种与时间相关的函数,包括获取当前时间、处理时间间隔、执行时间测量等,:本文主要介绍Python的... 目录1. 获取当前时间2. 时间格式化3. 延时执行4. 时间戳运算5. 计算代码执行时间6. 转换为指

关于MongoDB图片URL存储异常问题以及解决

《关于MongoDB图片URL存储异常问题以及解决》:本文主要介绍关于MongoDB图片URL存储异常问题以及解决方案,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录MongoDB图片URL存储异常问题项目场景问题描述原因分析解决方案预防措施js总结MongoDB图

SpringBoot项目中报错The field screenShot exceeds its maximum permitted size of 1048576 bytes.的问题及解决

《SpringBoot项目中报错ThefieldscreenShotexceedsitsmaximumpermittedsizeof1048576bytes.的问题及解决》这篇文章... 目录项目场景问题描述原因分析解决方案总结项目场景javascript提示:项目相关背景:项目场景:基于Spring

解决Maven项目idea找不到本地仓库jar包问题以及使用mvn install:install-file

《解决Maven项目idea找不到本地仓库jar包问题以及使用mvninstall:install-file》:本文主要介绍解决Maven项目idea找不到本地仓库jar包问题以及使用mvnin... 目录Maven项目idea找不到本地仓库jar包以及使用mvn install:install-file基

usb接口驱动异常问题常用解决方案

《usb接口驱动异常问题常用解决方案》当遇到USB接口驱动异常时,可以通过多种方法来解决,其中主要就包括重装USB控制器、禁用USB选择性暂停设置、更新或安装新的主板驱动等... usb接口驱动异常怎么办,USB接口驱动异常是常见问题,通常由驱动损坏、系统更新冲突、硬件故障或电源管理设置导致。以下是常用解决

Mysql如何解决死锁问题

《Mysql如何解决死锁问题》:本文主要介绍Mysql如何解决死锁问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录【一】mysql中锁分类和加锁情况【1】按锁的粒度分类全局锁表级锁行级锁【2】按锁的模式分类【二】加锁方式的影响因素【三】Mysql的死锁情况【1