From 627c3e0a6920131d75eafa4646db373ccc936546 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 26 十月 2023 13:52:07 +0800
Subject: [PATCH] 小程序diamante
---
minipro_standard/uni_modules/uview-ui/components/u-icon/u-icon.vue | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 234 insertions(+), 0 deletions(-)
diff --git a/minipro_standard/uni_modules/uview-ui/components/u-icon/u-icon.vue b/minipro_standard/uni_modules/uview-ui/components/u-icon/u-icon.vue
new file mode 100644
index 0000000..9340328
--- /dev/null
+++ b/minipro_standard/uni_modules/uview-ui/components/u-icon/u-icon.vue
@@ -0,0 +1,234 @@
+<template>
+ <view
+ class="u-icon"
+ @tap="clickHandler"
+ :class="['u-icon--' + labelPos]"
+ >
+ <image
+ class="u-icon__img"
+ v-if="isImg"
+ :src="name"
+ :mode="imgMode"
+ :style="[imgStyle, $u.addStyle(customStyle)]"
+ ></image>
+ <text
+ v-else
+ class="u-icon__icon"
+ :class="uClasses"
+ :style="[iconStyle, $u.addStyle(customStyle)]"
+ :hover-class="hoverClass"
+ >{{icon}}</text>
+ <!-- 杩欓噷杩涜绌哄瓧绗︿覆鍒ゆ柇锛屽鏋滀粎浠呮槸v-if="label"锛屽彲鑳戒細鍑虹幇浼犻��0鐨勬椂鍊欙紝缁撴灉涔熸棤娉曟樉绀� -->
+ <text
+ v-if="label !== ''"
+ class="u-icon__label"
+ :style="{
+ color: labelColor,
+ fontSize: $u.addUnit(labelSize),
+ marginLeft: labelPos == 'right' ? $u.addUnit(space) : 0,
+ marginTop: labelPos == 'bottom' ? $u.addUnit(space) : 0,
+ marginRight: labelPos == 'left' ? $u.addUnit(space) : 0,
+ marginBottom: labelPos == 'top' ? $u.addUnit(space) : 0,
+ }"
+ >{{ label }}</text>
+ </view>
+</template>
+
+<script>
+ // #ifdef APP-NVUE
+ // nvue閫氳繃weex鐨刣om妯″潡寮曞叆瀛椾綋锛岀浉鍏虫枃妗e湴鍧�濡備笅锛�
+ // https://weex.apache.org/zh/docs/modules/dom.html#addrule
+ const fontUrl = 'https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf'
+ const domModule = weex.requireModule('dom')
+ domModule.addRule('fontFace', {
+ 'fontFamily': "uicon-iconfont",
+ 'src': `url('${fontUrl}')`
+ })
+ // #endif
+
+ // 寮曞叆鍥炬爣鍚嶇О锛屽凡缁忓搴旂殑unicode
+ import icons from './icons'
+
+ import props from './props.js';;
+
+ /**
+ * icon 鍥炬爣
+ * @description 鍩轰簬瀛椾綋鐨勫浘鏍囬泦锛屽寘鍚簡澶у鏁板父瑙佸満鏅殑鍥炬爣銆�
+ * @tutorial https://www.uviewui.com/components/icon.html
+ * @property {String} name 鍥炬爣鍚嶇О锛岃绀轰緥鍥炬爣闆�
+ * @property {String} color 鍥炬爣棰滆壊,鍙帴鍙椾富棰樿壊 锛堥粯璁� color['u-content-color'] 锛�
+ * @property {String | Number} size 鍥炬爣瀛椾綋澶у皬锛屽崟浣峱x 锛堥粯璁� '16px' 锛�
+ * @property {Boolean} bold 鏄惁鏄剧ず绮椾綋 锛堥粯璁� false 锛�
+ * @property {String | Number} index 鐐瑰嚮鍥炬爣鐨勬椂鍊欎紶閫掍簨浠跺嚭鍘荤殑index锛堢敤浜庡尯鍒嗙偣鍑讳簡鍝竴涓級
+ * @property {String} hoverClass 鍥炬爣鎸変笅鍘荤殑鏍峰紡绫伙紝鐢ㄦ硶鍚寀ni鐨剉iew缁勪欢鐨刪overClass鍙傛暟锛岃鎯呰瀹樼綉
+ * @property {String} customPrefix 鑷畾涔夋墿灞曞墠缂�锛屾柟渚跨敤鎴锋墿灞曡嚜宸辩殑鍥炬爣搴� 锛堥粯璁� 'uicon' 锛�
+ * @property {String | Number} label 鍥炬爣鍙充晶鐨刲abel鏂囧瓧
+ * @property {String} labelPos label鐩稿浜庡浘鏍囩殑浣嶇疆锛屽彧鑳絩ight鎴朾ottom 锛堥粯璁� 'right' 锛�
+ * @property {String | Number} labelSize label瀛椾綋澶у皬锛屽崟浣峱x 锛堥粯璁� '15px' 锛�
+ * @property {String} labelColor 鍥炬爣鍙充晶鐨刲abel鏂囧瓧棰滆壊 锛� 榛樿 color['u-content-color'] 锛�
+ * @property {String | Number} space label涓庡浘鏍囩殑璺濈锛屽崟浣峱x 锛堥粯璁� '3px' 锛�
+ * @property {String} imgMode 鍥剧墖鐨刴ode
+ * @property {String | Number} width 鏄剧ず鍥剧墖灏忓浘鏍囨椂鐨勫搴�
+ * @property {String | Number} height 鏄剧ず鍥剧墖灏忓浘鏍囨椂鐨勯珮搴�
+ * @property {String | Number} top 鍥炬爣鍦ㄥ瀭鐩存柟鍚戜笂鐨勫畾浣� 鐢ㄤ簬瑙e喅鏌愪簺鎯呭喌涓嬶紝璁╁浘鏍囧瀭鐩村眳涓殑鐢ㄩ�� 锛堥粯璁� 0 锛�
+ * @property {Boolean} stop 鏄惁闃绘浜嬩欢浼犳挱 锛堥粯璁� false 锛�
+ * @property {Object} customStyle icon鐨勬牱寮忥紝瀵硅薄褰㈠紡
+ * @event {Function} click 鐐瑰嚮鍥炬爣鏃惰Е鍙�
+ * @event {Function} touchstart 浜嬩欢瑙︽懜鏃惰Е鍙�
+ * @example <u-icon name="photo" color="#2979ff" size="28"></u-icon>
+ */
+ export default {
+ name: 'u-icon',
+ data() {
+ return {
+
+ }
+ },
+ mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
+ computed: {
+ uClasses() {
+ let classes = []
+ classes.push(this.customPrefix + '-' + this.name)
+ // // uView鐨勮嚜瀹氫箟鍥炬爣绫诲悕涓簎-iconfont
+ // if (this.customPrefix == 'uicon') {
+ // classes.push('u-iconfont')
+ // } else {
+ // classes.push(this.customPrefix)
+ // }
+ // 涓婚鑹诧紝閫氳繃绫婚厤缃�
+ if (this.color && uni.$u.config.type.includes(this.color)) classes.push('u-icon__icon--' + this.color)
+ // 闃块噷锛屽ご鏉★紝鐧惧害灏忕▼搴忛�氳繃鏁扮粍缁戝畾绫诲悕鏃讹紝鏃犳硶鐩存帴浣跨敤[a, b, c]鐨勫舰寮忥紝鍚﹀垯鏃犳硶璇嗗埆
+ // 鏁呴渶灏嗗叾鎷嗘垚涓�涓瓧绗︿覆鐨勫舰寮忥紝閫氳繃绌烘牸闅斿紑鍚勪釜绫诲悕
+ //#ifdef MP-ALIPAY || MP-TOUTIAO || MP-BAIDU
+ classes = classes.join(' ')
+ //#endif
+ return classes
+ },
+ iconStyle() {
+ let style = {}
+ style = {
+ fontSize: uni.$u.addUnit(this.size),
+ lineHeight: uni.$u.addUnit(this.size),
+ fontWeight: this.bold ? 'bold' : 'normal',
+ // 鏌愪簺鐗规畩鎯呭喌闇�瑕佽缃竴涓埌椤堕儴鐨勮窛绂伙紝鎵嶈兘鏇村ソ鐨勫瀭鐩村眳涓�
+ top: uni.$u.addUnit(this.top)
+ }
+ // 闈炰富棰樿壊鍊兼椂锛屾墠褰撲綔棰滆壊鍊�
+ if (this.color && !uni.$u.config.type.includes(this.color)) style.color = this.color
+
+ return style
+ },
+ // 鍒ゆ柇浼犲叆鐨刵ame灞炴�э紝鏄惁鍥剧墖璺緞锛屽彧瑕佸甫鏈�"/"鍧囪涓烘槸鍥剧墖褰㈠紡
+ isImg() {
+ return this.name.indexOf('/') !== -1
+ },
+ imgStyle() {
+ let style = {}
+ // 濡傛灉璁剧疆width鍜宧eight灞炴�э紝鍒欎紭鍏堜娇鐢紝鍚﹀垯浣跨敤size灞炴��
+ style.width = this.width ? uni.$u.addUnit(this.width) : uni.$u.addUnit(this.size)
+ style.height = this.height ? uni.$u.addUnit(this.height) : uni.$u.addUnit(this.size)
+ return style
+ },
+ // 閫氳繃鍥炬爣鍚嶏紝鏌ユ壘瀵瑰簲鐨勫浘鏍�
+ icon() {
+ // 濡傛灉鍐呯疆鐨勫浘鏍囦腑鎵句笉鍒板搴旂殑鍥炬爣锛屽氨鐩存帴杩斿洖name鍊硷紝鍥犱负鐢ㄦ埛鍙兘浼犲叆鐨勬槸unicode浠g爜
+ return icons['uicon-' + this.name] || this.name
+ }
+ },
+ methods: {
+ clickHandler(e) {
+ this.$emit('click', this.index)
+ // 鏄惁闃绘浜嬩欢鍐掓场
+ this.stop && this.preventEvent(e)
+ }
+ }
+ }
+</script>
+
+<style lang="scss" scoped>
+ @import "../../libs/css/components.scss";
+
+ // 鍙橀噺瀹氫箟
+ $u-icon-primary: $u-primary !default;
+ $u-icon-success: $u-success !default;
+ $u-icon-info: $u-info !default;
+ $u-icon-warning: $u-warning !default;
+ $u-icon-error: $u-error !default;
+ $u-icon-label-line-height:1 !default;
+
+ /* #ifndef APP-NVUE */
+ // 闈瀗vue涓嬪姞杞藉瓧浣�
+ @font-face {
+ font-family: 'uicon-iconfont';
+ src: url('https://at.alicdn.com/t/font_2225171_8kdcwk4po24.ttf') format('truetype');
+ }
+
+ /* #endif */
+
+ .u-icon {
+ /* #ifndef APP-NVUE */
+ display: flex;
+ /* #endif */
+ align-items: center;
+
+ &--left {
+ flex-direction: row-reverse;
+ align-items: center;
+ }
+
+ &--right {
+ flex-direction: row;
+ align-items: center;
+ }
+
+ &--top {
+ flex-direction: column-reverse;
+ justify-content: center;
+ }
+
+ &--bottom {
+ flex-direction: column;
+ justify-content: center;
+ }
+
+ &__icon {
+ font-family: uicon-iconfont;
+ position: relative;
+ @include flex;
+ align-items: center;
+
+ &--primary {
+ color: $u-icon-primary;
+ }
+
+ &--success {
+ color: $u-icon-success;
+ }
+
+ &--error {
+ color: $u-icon-error;
+ }
+
+ &--warning {
+ color: $u-icon-warning;
+ }
+
+ &--info {
+ color: $u-icon-info;
+ }
+ }
+
+ &__img {
+ /* #ifndef APP-NVUE */
+ height: auto;
+ will-change: transform;
+ /* #endif */
+ }
+
+ &__label {
+ /* #ifndef APP-NVUE */
+ line-height: $u-icon-label-line-height;
+ /* #endif */
+ }
+ }
+</style>
--
Gitblit v1.9.3