¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <view |
| | | class="u-text" |
| | | :class="[]" |
| | | v-if="show" |
| | | :style="{ |
| | | margin: margin, |
| | | justifyContent: align === 'left' ? 'flex-start' : align === 'center' ? 'center' : 'flex-end' |
| | | }" |
| | | @tap="clickHandler" |
| | | > |
| | | <text |
| | | :class="['u-text__price', type && `u-text__value--${type}`]" |
| | | v-if="mode === 'price'" |
| | | :style="[valueStyle]" |
| | | >ï¿¥</text |
| | | > |
| | | <view class="u-text__prefix-icon" v-if="prefixIcon"> |
| | | <u-icon |
| | | :name="prefixIcon" |
| | | :customStyle="$u.addStyle(iconStyle)" |
| | | ></u-icon> |
| | | </view> |
| | | <u-link |
| | | v-if="mode === 'link'" |
| | | :text="value" |
| | | :href="href" |
| | | underLine |
| | | ></u-link> |
| | | <template v-else-if="openType && isMp"> |
| | | <button |
| | | class="u-reset-button u-text__value" |
| | | :style="[valueStyle]" |
| | | :data-index="index" |
| | | :openType="openType" |
| | | @getuserinfo="onGetUserInfo" |
| | | @contact="onContact" |
| | | @getphonenumber="onGetPhoneNumber" |
| | | @error="onError" |
| | | @launchapp="onLaunchApp" |
| | | @opensetting="onOpenSetting" |
| | | :lang="lang" |
| | | :session-from="sessionFrom" |
| | | :send-message-title="sendMessageTitle" |
| | | :send-message-path="sendMessagePath" |
| | | :send-message-img="sendMessageImg" |
| | | :show-message-card="showMessageCard" |
| | | :app-parameter="appParameter" |
| | | > |
| | | {{ value }} |
| | | </button> |
| | | </template> |
| | | <text |
| | | v-else |
| | | class="u-text__value" |
| | | :style="[valueStyle]" |
| | | :class="[ |
| | | type && `u-text__value--${type}`, |
| | | lines && `u-line-${lines}` |
| | | ]" |
| | | >{{ value }}</text |
| | | > |
| | | <view class="u-text__suffix-icon" v-if="suffixIcon"> |
| | | <u-icon |
| | | :name="suffixIcon" |
| | | :customStyle="$u.addStyle(iconStyle)" |
| | | ></u-icon> |
| | | </view> |
| | | </view> |
| | | </template> |
| | | |
| | | <script> |
| | | import value from './value.js' |
| | | import button from '../../libs/mixin/button.js' |
| | | import openType from '../../libs/mixin/openType.js' |
| | | import props from './props.js' |
| | | /** |
| | | * Text ææ¬ |
| | | * @description æ¤ç»ä»¶éæäºææ¬ç±»å¨é¡¹ç®ä¸ç常ç¨åè½ï¼å
æ¬ç¶æï¼æ¨æçµè¯ï¼æ ¼å¼åæ¥æï¼*æ¿æ¢ï¼è¶
龿¥...çåè½ã æ¨å¤§å¯ä¸å¿
å¨ä½¿ç¨ç¹æ®ææ¬æ¶èªå·±å®ä¹ï¼textç»ä»¶å 乿¶µçæ¨è½ä½¿ç¨ç大é¨ååºæ¯ã |
| | | * @tutorial https://www.uviewui.com/components/loading.html |
| | | * @property {String} type 主é¢é¢è² |
| | | * @property {Boolean} show æ¯å¦æ¾ç¤ºï¼é»è®¤ true ï¼ |
| | | * @property {String | Number} text æ¾ç¤ºçå¼ |
| | | * @property {String} prefixIcon åç½®å¾æ |
| | | * @property {String} suffixIcon åç½®å¾æ |
| | | * @property {String} mode ææ¬å¤ççå¹é
æ¨¡å¼ text-æ®éææ¬ï¼price-ä»·æ ¼ï¼phone-ææºå·ï¼name-å§åï¼date-æ¥æï¼link-è¶
龿¥ |
| | | * @property {String} href mode=linkä¸ï¼é
ç½®ç龿¥ |
| | | * @property {String | Function} format æ ¼å¼åè§å |
| | | * @property {Boolean} call mode=phoneæ¶ï¼ç¹å»ææ¬æ¯å¦æ¨æçµè¯ï¼é»è®¤ false ï¼ |
| | | * @property {String} openType å°ç¨åºçæå¼æ¹å¼ |
| | | * @property {Boolean} bold æ¯å¦ç²ä½ï¼é»è®¤normalï¼é»è®¤ false ï¼ |
| | | * @property {Boolean} block æ¯å¦åç¶ï¼é»è®¤ false ï¼ |
| | | * @property {String | Number} lines ææ¬æ¾ç¤ºçè¡æ°ï¼å¦æè®¾ç½®ï¼è¶
åºæ¤è¡æ°ï¼å°ä¼æ¾ç¤ºçç¥å· |
| | | * @property {String} color ææ¬é¢è²ï¼é»è®¤ '#303133' ï¼ |
| | | * @property {String | Number} size åä½å¤§å°ï¼é»è®¤ 15 ï¼ |
| | | * @property {Object | String} iconStyle 徿 çæ ·å¼ ï¼é»è®¤ {fontSize: '15px'} ï¼ |
| | | * @property {String} decoration æåè£
饰ï¼ä¸å线ï¼ä¸å线çï¼å¯éå¼ none|underline|line-throughï¼é»è®¤ 'none' ï¼ |
| | | * @property {Object | String | Number} margin å¤è¾¹è·ï¼å¯¹è±¡ãåç¬¦ä¸²ï¼æ°å¼å½¢å¼åå¯ï¼é»è®¤ 0 ï¼ |
| | | * @property {String | Number} lineHeight ææ¬è¡é« |
| | | * @property {String} align ææ¬å¯¹é½æ¹å¼ï¼å¯éå¼left|center|rightï¼é»è®¤ 'left' ï¼ |
| | | * @property {String} wordWrap æåæ¢è¡ï¼å¯éå¼break-word|normal|anywhereï¼é»è®¤ 'normal' ï¼ |
| | | * @event {Function} click ç¹å»è§¦åäºä»¶ |
| | | * @example <u--text text="æç¨å年鿥,èµ´ä½ æåä¹çº¦"></u--text> |
| | | */ |
| | | export default { |
| | | name: 'u--text', |
| | | // #ifdef MP |
| | | mixins: [uni.$u.mpMixin, uni.$u.mixin, value, button, openType, props], |
| | | // #endif |
| | | // #ifndef MP |
| | | mixins: [uni.$u.mpMixin, uni.$u.mixin, value, props], |
| | | // #endif |
| | | computed: { |
| | | valueStyle() { |
| | | const style = { |
| | | textDecoration: this.decoration, |
| | | fontWeight: this.bold ? 'bold' : 'normal', |
| | | wordWrap: this.wordWrap, |
| | | fontSize: uni.$u.addUnit(this.size) |
| | | } |
| | | !this.type && (style.color = this.color) |
| | | this.isNvue && this.lines && (style.lines = this.lines) |
| | | this.lineHeight && |
| | | (style.lineHeight = uni.$u.addUnit(this.lineHeight)) |
| | | !this.isNvue && this.block && (style.display = 'block') |
| | | return uni.$u.deepMerge(style, uni.$u.addStyle(this.customStyle)) |
| | | }, |
| | | isNvue() { |
| | | let nvue = false |
| | | // #ifdef APP-NVUE |
| | | nvue = true |
| | | // #endif |
| | | return nvue |
| | | }, |
| | | isMp() { |
| | | let mp = false |
| | | // #ifdef MP |
| | | mp = true |
| | | // #endif |
| | | return mp |
| | | } |
| | | }, |
| | | data() { |
| | | return {} |
| | | }, |
| | | methods: { |
| | | clickHandler() { |
| | | // å¦æä¸ºææºå·æ¨¡å¼ï¼æ¨æçµè¯ |
| | | if (this.call && this.mode === 'phone') { |
| | | uni.makePhoneCall({ |
| | | phoneNumber: this.text |
| | | }) |
| | | } |
| | | this.$emit('click') |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style lang="scss" scoped> |
| | | @import '../../libs/css/components.scss'; |
| | | |
| | | .u-text { |
| | | @include flex(row); |
| | | align-items: center; |
| | | flex-wrap: nowrap; |
| | | flex: 1; |
| | | /* #ifndef APP-NVUE */ |
| | | width: 100%; |
| | | /* #endif */ |
| | | |
| | | &__price { |
| | | font-size: 14px; |
| | | color: $u-content-color; |
| | | } |
| | | |
| | | &__value { |
| | | font-size: 14px; |
| | | @include flex; |
| | | color: $u-content-color; |
| | | flex-wrap: wrap; |
| | | // flex: 1; |
| | | text-overflow: ellipsis; |
| | | align-items: center; |
| | | |
| | | &--primary { |
| | | color: $u-primary; |
| | | } |
| | | |
| | | &--warning { |
| | | color: $u-warning; |
| | | } |
| | | |
| | | &--success { |
| | | color: $u-success; |
| | | } |
| | | |
| | | &--info { |
| | | color: $u-info; |
| | | } |
| | | |
| | | &--error { |
| | | color: $u-error; |
| | | } |
| | | |
| | | &--main { |
| | | color: $u-main-color; |
| | | } |
| | | |
| | | &--content { |
| | | color: $u-content-color; |
| | | } |
| | | |
| | | &--tips { |
| | | color: $u-tips-color; |
| | | } |
| | | |
| | | &--light { |
| | | color: $u-light-color; |
| | | } |
| | | } |
| | | } |
| | | </style> |