Blame view

uni_modules/uview-plus/components/u-toolbar/u-toolbar.vue 2.43 KB
a2702f6d   刘淇   巡查计划
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
  <template>
  	<view
  		class="u-toolbar"
  		@touchmove.stop.prevent="noop"
  		v-if="show"
  	>
  		<view
  			class="u-toolbar__left"
  		>
  			<view
  				class="u-toolbar__cancel__wrapper"
  				hover-class="u-hover-class"
  			>
  				<text
  					class="u-toolbar__wrapper__cancel"
  					@tap="cancel"
  					:style="{
  						color: cancelColor
  					}"
  				>{{ cancelText }}</text>
  			</view>
  		</view>
  		<text
  			class="u-toolbar__title u-line-1"
  			v-if="title"
  		>{{ title }}</text>
  		<view
  			class="u-toolbar__right"
  		>
  			<view
  				v-if="!rightSlot"
  				class="u-toolbar__confirm__wrapper"
  				hover-class="u-hover-class"
  			>
  				<text
  					class="u-toolbar__wrapper__confirm"
  					@tap="confirm"
  					:style="{
  					color: confirmColor
  				}"
  				>{{ confirmText }}</text>
  			</view>
  			<template v-else>
  				<slot name="right">
  				</slot>
  			</template>
  		</view>
  	</view>
  </template>
  
  <script>
  	import { props } from './props';
  	import { mpMixin } from '../../libs/mixin/mpMixin';
  	import { mixin } from '../../libs/mixin/mixin';
  	/**
  	 * Toolbar 工具条
  	 * @description 
  	 * @tutorial https://uview-plus.jiangruyi.com/components/toolbar.html
  	 * @property {Boolean}	show			是否展示工具条(默认 true 
  	 * @property {String}	cancelText		取消按钮的文字(默认 '取消' 
  	 * @property {String}	confirmText		确认按钮的文字(默认 '确认' 
  	 * @property {String}	cancelColor		取消按钮的颜色(默认 '#909193' 
  	 * @property {String}	confirmColor	确认按钮的颜色(默认 '#3c9cff' 
  	 * @property {String}	title			标题文字
  	 * @event {Function} 
  	 * @example 
  	 */
  	export default {
  		name: 'u-toolbar',
  		mixins: [mpMixin, mixin, props],
  		emits: ["confirm", "cancel"],
  		created() {
  			// console.log(this.$slots)
  		},
  		methods: {
  			// 点击取消按钮
  			cancel() {
  				this.$emit('cancel')
  			},
  			// 点击确定按钮
  			confirm() {
  				this.$emit('confirm')
  			}
  		},
  	}
  </script>
  
  <style lang="scss" scoped>
  
  	.u-toolbar {
  		height: 42px;
  		@include flex;
  		justify-content: space-between;
  		align-items: center;
  
  		&__wrapper {
  			&__cancel {
  				color: $u-tips-color;
  				font-size: 15px;
  				padding: 0 15px;
  			}
  		}
  
  		&__title {
  			color: $u-main-color;
  			padding: 0 60rpx;
  			font-size: 16px;
  			font-weight: bold;
  			flex: 1;
  			text-align: center;
  		}
  
  		&__wrapper {
  			&__left,
  			&__right {
  				@include flex;
  			}
  			&__confirm {
  				color: $u-primary;
  				font-size: 15px;
  				padding: 0 15px;
  			}
  		}
  	}
  </style>