1111
This commit is contained in:
-155
@@ -1,155 +0,0 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const _sfc_main = {
|
||||
name: "u-dropdown",
|
||||
mixins: [common_vendor.mpMixin, common_vendor.mixin, common_vendor.props$12],
|
||||
data() {
|
||||
return {
|
||||
showDropdown: true,
|
||||
// 是否打开下来菜单,
|
||||
menuList: [],
|
||||
// 显示的菜单
|
||||
active: false,
|
||||
// 下拉菜单的状态
|
||||
// 当前是第几个菜单处于激活状态,小程序中此处不能写成false或者"",否则后续将current赋值为0,
|
||||
// 无能的TX没有使用===而是使用==判断,导致程序认为前后二者没有变化,从而不会触发视图更新
|
||||
current: 99999,
|
||||
// 外层内容的样式,初始时处于底层,且透明
|
||||
contentStyle: {
|
||||
zIndex: -1,
|
||||
opacity: 0
|
||||
},
|
||||
// 让某个菜单保持高亮的状态
|
||||
highlightIndex: 99999,
|
||||
contentHeight: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 下拉出来部分的样式
|
||||
popupStyle() {
|
||||
let style = {};
|
||||
style.transform = `translateY(${this.active ? 0 : "-100%"})`;
|
||||
style["transition-duration"] = this.duration / 1e3 + "s";
|
||||
style.borderRadius = `0 0 ${common_vendor.addUnit(this.borderRadius)} ${common_vendor.addUnit(this.borderRadius)}`;
|
||||
return style;
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.children = [];
|
||||
},
|
||||
mounted() {
|
||||
this.getContentHeight();
|
||||
},
|
||||
emits: ["open", "close"],
|
||||
methods: {
|
||||
addUnit: common_vendor.addUnit,
|
||||
init() {
|
||||
this.menuList = [];
|
||||
this.children.map((child) => {
|
||||
child.init();
|
||||
});
|
||||
},
|
||||
// 点击菜单
|
||||
menuClick(index) {
|
||||
if (this.menuList[index].disabled)
|
||||
return;
|
||||
if (index === this.current && this.closeOnClickSelf) {
|
||||
this.close();
|
||||
setTimeout(() => {
|
||||
this.children[index].active = false;
|
||||
}, this.duration);
|
||||
return;
|
||||
}
|
||||
this.open(index);
|
||||
},
|
||||
// 打开下拉菜单
|
||||
open(index) {
|
||||
if (this.contentHeight < 1)
|
||||
this.getContentHeight();
|
||||
this.contentStyle = {
|
||||
zIndex: 11
|
||||
};
|
||||
this.active = true;
|
||||
this.current = index;
|
||||
this.children.map((val, idx) => {
|
||||
val.active = index == idx ? true : false;
|
||||
});
|
||||
this.$emit("open", this.current);
|
||||
},
|
||||
// 设置下拉菜单处于收起状态
|
||||
close() {
|
||||
this.$emit("close", this.current);
|
||||
this.active = false;
|
||||
this.current = 99999;
|
||||
this.contentStyle = {
|
||||
zIndex: -1,
|
||||
opacity: 0
|
||||
};
|
||||
},
|
||||
// 点击遮罩
|
||||
maskClick() {
|
||||
if (!this.closeOnClickMask)
|
||||
return;
|
||||
this.close();
|
||||
},
|
||||
// 外部手动设置某个菜单高亮
|
||||
highlight(index = void 0) {
|
||||
this.highlightIndex = index !== void 0 ? index : 99999;
|
||||
},
|
||||
// 获取下拉菜单内容的高度
|
||||
getContentHeight() {
|
||||
let windowHeight = common_vendor.getWindowInfo().windowHeight;
|
||||
this.$uGetRect(".u-dropdown__menu").then((res) => {
|
||||
this.contentHeight = windowHeight - res.bottom;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!Array) {
|
||||
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
|
||||
_easycom_u_icon2();
|
||||
}
|
||||
const _easycom_u_icon = () => "../u-icon/u-icon.js";
|
||||
if (!Math) {
|
||||
_easycom_u_icon();
|
||||
}
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return {
|
||||
a: common_vendor.f($data.menuList, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item.title),
|
||||
b: item.disabled ? "#c0c4cc" : index === $data.current || $data.highlightIndex == index ? _ctx.activeColor : _ctx.inactiveColor,
|
||||
c: "d45d1d94-0-" + i0,
|
||||
d: common_vendor.p({
|
||||
["custom-style"]: {
|
||||
display: "flex"
|
||||
},
|
||||
name: _ctx.menuIcon,
|
||||
size: $options.addUnit(_ctx.menuIconSize),
|
||||
color: index === $data.current || $data.highlightIndex == index ? _ctx.activeColor : "#c0c4cc"
|
||||
}),
|
||||
e: index === $data.current ? 1 : "",
|
||||
f: index,
|
||||
g: common_vendor.o(($event) => $options.menuClick(index), index)
|
||||
};
|
||||
}),
|
||||
b: $options.addUnit(_ctx.titleSize),
|
||||
c: $options.addUnit(_ctx.height),
|
||||
d: _ctx.borderBottom ? 1 : "",
|
||||
e: common_vendor.o(() => {
|
||||
}),
|
||||
f: common_vendor.s($options.popupStyle),
|
||||
g: common_vendor.s($data.contentStyle),
|
||||
h: common_vendor.s({
|
||||
transition: `opacity ${_ctx.duration / 1e3}s linear`,
|
||||
top: $options.addUnit(_ctx.height),
|
||||
height: $data.contentHeight + "px"
|
||||
}),
|
||||
i: common_vendor.o((...args) => $options.maskClick && $options.maskClick(...args)),
|
||||
j: common_vendor.o(() => {
|
||||
})
|
||||
};
|
||||
}
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-d45d1d94"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/uview-plus/components/u-dropdown/u-dropdown.js.map
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"u-icon": "../u-icon/u-icon"
|
||||
}
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
<view class="u-dropdown data-v-d45d1d94"><view style="{{'height:' + c}}" class="{{['u-dropdown__menu', 'data-v-d45d1d94', d && 'u-border-bottom']}}"><view wx:for="{{a}}" wx:for-item="item" wx:key="f" class="u-dropdown__menu__item data-v-d45d1d94" catchtap="{{item.g}}"><view class="u-flex u-flex-row data-v-d45d1d94"><text class="u-dropdown__menu__item__text data-v-d45d1d94" style="{{'color:' + item.b + ';' + ('font-size:' + b)}}">{{item.a}}</text><view class="{{['u-dropdown__menu__item__arrow', 'data-v-d45d1d94', item.e && 'u-dropdown__menu__item__arrow--rotate']}}"><u-icon wx:if="{{item.d}}" class="data-v-d45d1d94" u-i="{{item.c}}" bind:__l="__l" u-p="{{item.d}}"></u-icon></view></view></view></view><view class="u-dropdown__content data-v-d45d1d94" style="{{g + ';' + h}}" bindtap="{{i}}" catchtouchmove="{{j}}"><view catchtap="{{e}}" class="u-dropdown__content__popup data-v-d45d1d94" style="{{f}}"><slot></slot></view><view class="u-dropdown__content__mask data-v-d45d1d94"></view></view></view>
|
||||
-109
@@ -1,109 +0,0 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
.u-empty.data-v-d45d1d94,
|
||||
.u-empty__wrap.data-v-d45d1d94,
|
||||
.u-tabs.data-v-d45d1d94,
|
||||
.u-tabs__wrapper.data-v-d45d1d94,
|
||||
.u-tabs__wrapper__scroll-view-wrapper.data-v-d45d1d94,
|
||||
.u-tabs__wrapper__scroll-view.data-v-d45d1d94,
|
||||
.u-tabs__wrapper__nav.data-v-d45d1d94,
|
||||
.u-tabs__wrapper__nav__line.data-v-d45d1d94,
|
||||
.up-empty.data-v-d45d1d94,
|
||||
.up-empty__wrap.data-v-d45d1d94,
|
||||
.up-tabs.data-v-d45d1d94,
|
||||
.up-tabs__wrapper.data-v-d45d1d94,
|
||||
.up-tabs__wrapper__scroll-view-wrapper.data-v-d45d1d94,
|
||||
.up-tabs__wrapper__scroll-view.data-v-d45d1d94,
|
||||
.up-tabs__wrapper__nav.data-v-d45d1d94,
|
||||
.up-tabs__wrapper__nav__line.data-v-d45d1d94 {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex-shrink: 0;
|
||||
flex-grow: 0;
|
||||
flex-basis: auto;
|
||||
align-items: stretch;
|
||||
align-content: flex-start;
|
||||
}
|
||||
.u-dropdown.data-v-d45d1d94 {
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
}
|
||||
.u-dropdown__menu.data-v-d45d1d94 {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
position: relative;
|
||||
z-index: 11;
|
||||
height: 80rpx;
|
||||
}
|
||||
.u-dropdown__menu__item.data-v-d45d1d94 {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.u-dropdown__menu__item .u-flex-row.data-v-d45d1d94 {
|
||||
flex-direction: row;
|
||||
}
|
||||
.u-dropdown__menu__item__text.data-v-d45d1d94 {
|
||||
font-size: 28rpx;
|
||||
color: #606266;
|
||||
}
|
||||
.u-dropdown__menu__item__arrow.data-v-d45d1d94 {
|
||||
margin-left: 6rpx;
|
||||
transition: transform 0.3s;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
.u-dropdown__menu__item__arrow--rotate.data-v-d45d1d94 {
|
||||
transform: rotate(180deg);
|
||||
}
|
||||
.u-dropdown__content.data-v-d45d1d94 {
|
||||
position: absolute;
|
||||
z-index: 8;
|
||||
width: 100%;
|
||||
left: 0px;
|
||||
bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
.u-dropdown__content__mask.data-v-d45d1d94 {
|
||||
position: absolute;
|
||||
z-index: 9;
|
||||
background: rgba(0, 0, 0, 0.3);
|
||||
width: 100%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
.u-dropdown__content__popup.data-v-d45d1d94 {
|
||||
position: relative;
|
||||
z-index: 10;
|
||||
transition: transform 0.3s;
|
||||
transform: translate3D(0, -100%, 0);
|
||||
overflow: hidden;
|
||||
}
|
||||
Reference in New Issue
Block a user