123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <u-popup mode="bottom" :border-radius="borderRadius" :popup="false" v-model="value" :maskCloseAble="maskCloseAble"
- length="auto" :safeAreaInsetBottom="safeAreaInsetBottom" @close="popupClose" :z-index="uZIndex">
- <view class="u-tips u-border-bottom" v-if="tips.text" :style="[tipsStyle]">
- {{tips.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" :class="[index < list.length - 1 ? 'u-border-bottom' : '']"
- hover-class="u-hover-class" :hover-stay-time="150">
- {{item.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",
- props: {
-
- 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
- },
-
- value: {
- type: Boolean,
- default: false
- },
-
- borderRadius: {
- type: [String, Number],
- default: 0
- },
-
- zIndex: {
- type: [String, Number],
- default: 0
- },
-
- cancelText: {
- type: String,
- default: '取消'
- }
- },
- computed: {
-
- 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';
- return style;
- }
- },
- uZIndex() {
-
- return this.zIndex ? this.zIndex : this.$u.zIndex.popup;
- }
- },
- methods: {
-
- close() {
-
-
- this.popupClose();
- this.$emit('close');
- },
-
- popupClose() {
- this.$emit('input', false);
- },
-
- itemClick(index) {
- this.$emit('click', index);
- this.$emit('input', false);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .u-tips {
- font-size: 26rpx;
- text-align: center;
- padding: 34rpx 0;
- line-height: 1;
- color: $u-tips-color;
- }
- .u-action-sheet-item {
- display: flex;
- line-height: 1;
- justify-content: center;
- align-items: center;
- font-size: 34rpx;
- padding: 34rpx 0;
- }
- .u-gab {
- height: 12rpx;
- background-color: rgb(234, 234, 236);
- }
- .u-actionsheet-cancel {
- color: $u-main-color;
- }
- </style>
|