| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 | 
							- <template>
 
- 	<view @touchmove.stop.prevent>
 
- 		<view class="yc-fab-box ycFly_o" :class="{'yc-fab-right':!left || (left && right)}" :style="{left:getLeft(),right:getRight(),bottom:bottom+'rpx'}">
 
- 			<view class="yc-fab-btn" :class="{'yc-visible':isOpen,'yc-fab-hidden':hidden}">
 
- 				<view class="yc-fab-item-box" :class="{'yc-fab-item-left':left && !right && item.imgUrl}" v-for="(item,index) in btnList"
 
- 				 :key="index" @tap.stop="handleClick(index)">
 
- 					<view :class="[left && !right?'yc-text-left':'yc-text-right']" v-if="item.imgUrl" :style="{fontSize:item.fontSize+'rpx',color:item.color}">{{item.text || ""}}</view>
 
- 					<view class="yc-fab-item" :style="{width:width+'rpx',height:height+'rpx',background:item.bgColor || bgColor,borderRadius:radius}">
 
- 						<view class="yc-fab-title" v-if="!item.imgUrl" :style="{fontSize:item.fontSize+'rpx',color:item.color}">{{item.text || ""}}</view>
 
- 						<image :src="item.imgUrl" class="yc-fab-img" v-else :style="{width:item.imgWidth+'rpx',height:item.imgHeight+'rpx'}"></image>
 
- 					</view>
 
- 				</view>
 
- 			</view>
 
- 			<view class="yc-fab-item" :class="{'yc-active':isOpen}" :style="{width:width+'rpx',height:height+'rpx',borderRadius:radius,background:bgColor,color:color}"
 
- 			 @tap.stop="handleClick(-1)">
 
- 				<view class="yc-fab-icon yc-icon-plus" v-if="!icon && !text"></view>
 
- 				<view class="yc-fab-icon" v-if="text && !icon">{{text}}</view>
 
- 				<view class="yc-fab-icon" v-if="icon" :style="{opacity:0.5,backgroundSize:'contain',width:width+'rpx',height:height+'rpx',borderRadius:radius,backgroundImage: 'url('+icon+')'}"></view>
 
- 			</view>
 
- 		</view>
 
- 		<view class="yc-fab-mask" :class="{'yc-visible':isOpen}" @tap="handleClickCancel"></view>
 
- 	</view>
 
- </template>
 
- <script>
 
- 	//拓展出来的按钮不应多于6个,否则违反了作为悬浮按钮的快速、高效的原则
 
- 	export default {
 
- 		name: "tuiFab",
 
- 		props: {
 
- 			//rpx 为0时值为auto
 
- 			left: {
 
- 				type: Number,
 
- 				default: 0
 
- 			},
 
- 			//rpx 当为0时且left不为0,值为auto
 
- 			right: {
 
- 				type: Number,
 
- 				default: 80
 
- 			},
 
- 			//rpx bottom值
 
- 			bottom: {
 
- 				type: Number,
 
- 				default: 100
 
- 			},
 
- 			//默认按钮 宽度 rpx
 
- 			width: {
 
- 				type: Number,
 
- 				default: 108
 
- 			},
 
- 			//默认按钮 高度 rpx
 
- 			height: {
 
- 				type: Number,
 
- 				default: 108
 
- 			},
 
- 			//圆角值
 
- 			radius: {
 
- 				type: String,
 
- 				default: "50%"
 
- 			},
 
- 			//默认按钮背景颜色
 
- 			bgColor: {
 
- 				type: String,
 
- 				default: "#435257"
 
- 			},
 
- 			//字体颜色
 
- 			color: {
 
- 				type: String,
 
- 				default: "#fff"
 
- 			},
 
- 			//拓展按钮
 
- 			// bgColor: "#5677fc",
 
- 			// //图标/图片地址
 
- 			// imgUrl: "/static/images/fab/fab_reward.png",
 
- 			// //图片高度 rpx
 
- 			// imgHeight: 60,
 
- 			// //图片宽度 rpx
 
- 			// imgWidth: 60,
 
- 			// //名称
 
- 			// text: "名称",
 
- 			// //字体大小
 
- 			// fontSize: 30,
 
- 			// //字体颜色
 
- 			// color: "#fff"
 
- 			btnList: {
 
- 				type: Array,
 
- 				default () {
 
- 					return []
 
- 				}
 
- 			},
 
- 			//点击遮罩 是否可关闭
 
- 			maskClosable: {
 
- 				type: Boolean,
 
- 				default: true
 
- 			},
 
- 			//icon
 
- 			icon : '',
 
- 			text : '',
 
- 		},
 
- 		data() {
 
- 			return {
 
- 				isOpen: false,
 
- 				hidden: true,
 
- 				timer: null
 
- 			};
 
- 		},
 
- 		mounted() {
 
- 			if (this.icon) {
 
- 				this.bgColor = '';
 
- 			}
 
- 		},
 
- 		methods: {
 
- 			getLeft() {
 
- 				let val = "auto"
 
- 				if (this.left && !this.right) {
 
- 					val = this.left + 'rpx'
 
- 				}
 
- 				return val
 
- 			},
 
- 			getRight() {
 
- 				let val = this.right + 'rpx'
 
- 				if (this.left && !this.right) {
 
- 					val = "auto"
 
- 				}
 
- 				return val
 
- 			},
 
- 			handleClick: function(index) {
 
- 				this.hidden = false
 
- 				clearTimeout(this.timer)
 
- 				if (index == -1 && this.btnList.length) {
 
- 					this.isOpen = !this.isOpen
 
- 				} else {
 
- 					this.$emit("click", {
 
- 						index: index
 
- 					})
 
- 					this.isOpen = false
 
- 				}
 
- 				if (!this.isOpen) {
 
- 					this.timer = setTimeout(() => {
 
- 						this.hidden = true
 
- 					}, 200)
 
- 				}
 
- 			},
 
- 			handleClickCancel: function() {
 
- 				if (!this.maskClosable) return;
 
- 				this.isOpen = false
 
- 			}
 
- 		},
 
- 		beforeDestroy() {
 
- 			clearTimeout(this.timer)
 
- 			this.timer = null
 
- 		}
 
- 	}
 
- </script>
 
- <style>
 
- 	@font-face {
 
- 		font-family: 'tuifab';
 
- 		src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAAAREAA0AAAAABnAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAEKAAAABoAAAAciPExJUdERUYAAAQIAAAAHgAAAB4AKQAKT1MvMgAAAaAAAABCAAAAVjyBSAVjbWFwAAAB9AAAAD4AAAFCAA/pvmdhc3AAAAQAAAAACAAAAAj//wADZ2x5ZgAAAkAAAABRAAAAYFkYQQNoZWFkAAABMAAAADAAAAA2Fm5OF2hoZWEAAAFgAAAAHQAAACQH3QOFaG10eAAAAeQAAAAPAAAAEAwAAANsb2NhAAAC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AAAAFgAAAAIAAQADAAMAAQAEAAAAAgAAAAB42mNgYGBkAIKrS9Q5QPTNZa18MBoAPbcFzgAA) format('woff');
 
- 		font-weight: normal;
 
- 		font-style: normal;
 
- 	}
 
- 	.yc-fab-icon {
 
- 		font-family: "tuifab" !important;
 
- 		font-style: normal;
 
- 		-webkit-font-smoothing: antialiased;
 
- 		-moz-osx-font-smoothing: grayscale;
 
- 		padding: 10rpx;
 
- 	}
 
- 	.yc-icon-plus:before {
 
- 		content: "\e613";
 
- 	}
 
- 	.yc-fab-box {
 
- 		display: flex;
 
- 		justify-content: center;
 
- 		flex-direction: column;
 
- 		position: fixed;
 
- 		z-index: 99997;
 
- 	}
 
- 	.yc-fab-right {
 
- 		align-items: flex-end;
 
- 	}
 
- 	.yc-fab-btn {
 
- 		transform: scale(0);
 
- 		transition: all 0.2s ease-in-out;
 
- 		opacity: 0;
 
- 		visibility: hidden;
 
- 	}
 
- 	.yc-fab-hidden {
 
- 		height: 0;
 
- 		width: 0;
 
- 	}
 
- 	.yc-fab-item-box {
 
- 		display: flex;
 
- 		align-items: center;
 
- 		justify-content: flex-end;
 
- 		padding-bottom: 40rpx;
 
- 	}
 
- 	.yc-fab-item-left {
 
- 		flex-flow: row-reverse;
 
- 	}
 
- 	.yc-fab-title {
 
- 		width: 90%;
 
- 		text-align: center;
 
- 		white-space: nowrap;
 
- 		overflow: hidden;
 
- 		text-overflow: ellipsis;
 
- 	}
 
- 	.yc-text-left {
 
- 		padding-left: 28rpx;
 
- 	}
 
- 	.yc-text-right {
 
- 		padding-right: 28rpx;
 
- 	}
 
- 	.yc-fab-img {
 
- 		display: block;
 
- 	}
 
- 	.yc-fab-item {
 
- 		display: flex;
 
- 		align-items: center;
 
- 		justify-content: center;
 
- 		box-shadow: 0 0 5px 2px rgba(0, 0, 0, 0.1);
 
- 		transition: all 0.2s linear;
 
- 	}
 
- 	.yc-radius {
 
- 		border-radius: 50%;
 
- 	}
 
- 	.yc-active {
 
- 		transform: rotate(135deg);
 
- 	}
 
- 	.yc-fab-mask {
 
- 		position: fixed;
 
- 		top: 0;
 
- 		left: 0;
 
- 		right: 0;
 
- 		bottom: 0;
 
- 		background: rgba(0, 0, 0, 0.75);
 
- 		z-index: 99996;
 
- 		transition: all 0.2s ease-in-out;
 
- 		opacity: 0;
 
- 		visibility: hidden;
 
- 	}
 
- 	.yc-visible {
 
- 		visibility: visible;
 
- 		opacity: 1;
 
- 		transform: scale(1);
 
- 	}
 
- </style>
 
 
  |