123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <template>
- <u-popup
- :blur="blur"
- mode="bottom"
- :border-radius="borderRadius"
- :popup="false"
- v-model="popupValue"
- :maskCloseAble="maskCloseAble"
- length="auto"
- :safeAreaInsetBottom="safeAreaInsetBottom"
- @close="popupClose"
- :z-index="uZIndex"
- >
- <view class="u-tips u-border-bottom" v-if="tips.text" :style="[tipsStyle]">
- <text>{{ tips.text }}</text>
- </view>
- <block v-for="(item, index) in list" :key="index">
- <view
- @touchmove.stop.prevent
- @tap="itemClick(index)"
- :style="[itemStyle(index)]"
- class="u-action-sheet-item u-line-1"
- :class="[index < list.length - 1 ? 'u-border-bottom' : '']"
- :hover-stay-time="150"
- >
- <text>{{ item[labelName] }}</text>
- <text class="u-action-sheet-item__subtext u-line-1" v-if="item.subText">
- {{ item.subText }}
- </text>
- </view>
- </block>
- <view class="u-gab" v-if="cancelBtn"></view>
- <view
- @touchmove.stop.prevent
- class="u-actionsheet-cancel u-action-sheet-item"
- hover-class="u-hover-class"
- :hover-stay-time="150"
- v-if="cancelBtn"
- @tap="close"
- >
- {{ cancelText }}
- </view>
- </u-popup>
- </template>
- <script>
- export default {
- name: "u-action-sheet",
- emits: ["update:modelValue", "input", "click", "close"],
- props: {
-
- value: {
- type: Boolean,
- default: false
- },
- modelValue: {
- type: Boolean,
- default: false
- },
-
- maskCloseAble: {
- type: Boolean,
- default: true
- },
-
- list: {
- type: Array,
- default() {
-
-
-
-
-
-
- return [];
- }
- },
-
- tips: {
- type: Object,
- default() {
- return {
- text: "",
- color: "",
- fontSize: "26"
- };
- }
- },
-
- cancelBtn: {
- type: Boolean,
- default: true
- },
-
- safeAreaInsetBottom: {
- type: Boolean,
- default: false
- },
-
- borderRadius: {
- type: [String, Number],
- default: 0
- },
-
- zIndex: {
- type: [String, Number],
- default: 0
- },
-
- cancelText: {
- type: String,
- default: "取消"
- },
-
- labelName: {
- type: String,
- default: "text"
- },
-
- blur: {
- type: [Number, String],
- default: 0
- }
- },
- computed: {
- valueCom() {
-
- return this.value;
-
-
- return this.modelValue;
-
- },
-
- tipsStyle() {
- let style = {};
- if (this.tips.color) style.color = this.tips.color;
- if (this.tips.fontSize) style.fontSize = this.tips.fontSize + "rpx";
- return style;
- },
-
- itemStyle() {
- return index => {
- let style = {};
- if (this.list[index].color) style.color = this.list[index].color;
- if (this.list[index].fontSize) style.fontSize = this.list[index].fontSize + "rpx";
-
- if (this.list[index].disabled) style.color = "#c0c4cc";
- return style;
- };
- },
- uZIndex() {
-
- return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
- }
- },
- data() {
- return {
- popupValue: false
- };
- },
- watch: {
- valueCom(v1, v2) {
- this.popupValue = v1;
- }
- },
- methods: {
-
- close() {
-
-
- this.popupClose();
- this.$emit("close");
- },
-
- popupClose() {
- this.$emit("input", false);
- this.$emit("update:modelValue", false);
- },
-
- itemClick(index) {
-
- if (this.list[index].disabled) return;
- this.$emit("click", index);
- this.$emit("input", false);
- this.$emit("update:modelValue", false);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- @import "../../libs/css/style.components.scss";
- .u-tips {
- font-size: 26rpx;
- text-align: center;
- padding: 34rpx 0;
- line-height: 1.5;
- color: $u-tips-color;
- }
- .u-action-sheet-item {
- @include vue-flex;
- line-height: 1;
- justify-content: center;
- align-items: center;
- font-size: 32rpx;
- padding: 34rpx 0;
- flex-direction: column;
- }
- .u-action-sheet-item__subtext {
- font-size: 24rpx;
- color: $u-tips-color;
- margin-top: 20rpx;
- }
- .u-gab {
- height: 12rpx;
- background-color: rgb(234, 234, 236);
- }
- .u-actionsheet-cancel {
- color: $u-main-color;
- }
- </style>
|