code
stringlengths
1
1.05M
repo_name
stringlengths
6
83
path
stringlengths
3
242
language
stringclasses
222 values
license
stringclasses
20 values
size
int64
1
1.05M
export default { props: { value: { type: [String, Number], default: '' }, modelValue: { type: [String, Number], default: '' }, // 键盘弹起时,是否自动上推页面 adjustPosition: { type: Boolean, default: true }, // 最大输入长度 maxlength: { type: [String, Number], default: 6 }, // 是否用圆点填充 dot: { type: Boolean, default: false }, // 显示模式,box-盒子模式,line-底部横线模式 mode: { type: String, default: 'box' }, // 是否细边框 hairline: { type: Boolean, default: false }, // 字符间的距离 space: { type: [String, Number], default: 10 }, // 是否自动获取焦点 focus: { type: Boolean, default: false }, // 字体是否加粗 bold: { type: Boolean, default: false }, // 字体颜色 color: { type: String, default: '#606266' }, // 字体大小 fontSize: { type: [String, Number], default: 18 }, // 输入框的大小,宽等于高 size: { type: [String, Number], default: 35 }, // 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true disabledKeyboard: { type: Boolean, default: false }, // 边框和线条颜色 borderColor: { type: String, default: '#c9cacc' }, // 是否禁止输入"."符号 disabledDot: { type: Boolean, default: true }, ...uni.$uv?.props?.codeInput } }
2301_77169380/AppruanjianApk
uni_modules/uv-code-input/components/uv-code-input/props.js
JavaScript
unknown
1,464
<template> <view class="uv-code-input"> <view class="uv-code-input__item" :style="[itemStyle(index)]" v-for="(item, index) in codeLength" :key="index" > <view class="uv-code-input__item__dot" v-if="dot && codeArray.length > index" ></view> <text v-else :style="{ fontSize: $uv.addUnit(fontSize), fontWeight: bold ? 'bold' : 'normal', color: color }" >{{codeArray[index]}}</text> <view class="uv-code-input__item__line" v-if="mode === 'line'" :style="[lineStyle]" ></view> <!-- #ifndef APP-PLUS --> <view v-if="isFocus && codeArray.length === index" :style="{backgroundColor: color}" class="uv-code-input__item__cursor"></view> <!-- #endif --> </view> <input :disabled="disabledKeyboard" type="number" :focus="focus" :value="inputValue" :maxlength="maxlength" :adjustPosition="adjustPosition" class="uv-code-input__input" @input="inputHandler" :style="{ height: $uv.addUnit(size) }" @focus="isFocus = true" @blur="isFocus = false" /> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * CodeInput 验证码输入 * @description 该组件一般用于验证用户短信验证码的场景,也可以结合uvui的键盘组件使用 * @tutorial https://www.uvui.cn/components/codeInput.html * @property {String | Number} value / v-model 预置值 * @property {String | Number} maxlength 最大输入长度 (默认 6 ) * @property {Boolean} dot 是否用圆点填充 (默认 false ) * @property {String} mode 显示模式,box-盒子模式,line-底部横线模式 (默认 'box' ) * @property {Boolean} hairline 是否细边框 (默认 false ) * @property {String | Number} space 字符间的距离 (默认 10 ) * @property {Boolean} focus 是否自动获取焦点 (默认 false ) * @property {Boolean} bold 字体和输入横线是否加粗 (默认 false ) * @property {String} color 字体颜色 (默认 '#606266' ) * @property {String | Number} fontSize 字体大小,单位px (默认 18 ) * @property {String | Number} size 输入框的大小,宽等于高 (默认 35 ) * @property {Boolean} disabledKeyboard 是否隐藏原生键盘,如果想用自定义键盘的话,需设置此参数为true (默认 false ) * @property {String} borderColor 边框和线条颜色 (默认 '#c9cacc' ) * @property {Boolean} disabledDot 是否禁止输入"."符号 (默认 true ) * * @event {Function} change 输入内容发生改变时触发,具体见上方说明 value:当前输入的值 * @event {Function} finish 输入字符个数达maxlength值时触发,见上方说明 value:当前输入的值 * @example <uv-code-input v-model="value4" :focus="true"></uv-code-input> */ export default { name: 'uv-code-input', mixins: [mpMixin, mixin, props], data() { return { inputValue: '', isFocus: this.focus } }, created() { const value = String(this.value) || String(this.modelValue); this.inputValue = String(value).substring(0, this.maxlength); }, watch: { value(newVal) { // 转为字符串,超出部分截掉 this.inputValue = String(newVal).substring(0, this.maxlength); if (this.disabledKeyboard) { this.customInput(); } }, modelValue(newVal) { // 转为字符串,超出部分截掉 this.inputValue = String(newVal).substring(0, this.maxlength); if (this.disabledKeyboard) { this.customInput(); } } }, computed: { // 根据长度,循环输入框的个数,因为头条小程序数值不能用于v-for codeLength() { return new Array(Number(this.maxlength)) }, // 循环item的样式 itemStyle() { return index => { const addUnit = this.$uv.addUnit const style = { width: addUnit(this.size), height: addUnit(this.size) } // 盒子模式下,需要额外进行处理 if (this.mode === 'box') { // 设置盒子的边框,如果是细边框,则设置为0.5px宽度 style.border = `${this.hairline ? 0.5 : 1}px solid ${this.borderColor}` // 如果盒子间距为0的话 if (this.$uv.getPx(this.space) === 0) { // 给第一和最后一个盒子设置圆角 if (index === 0) { style.borderTopLeftRadius = '3px' style.borderBottomLeftRadius = '3px' } if (index === this.codeLength.length - 1) { style.borderTopRightRadius = '3px' style.borderBottomRightRadius = '3px' } // 最后一个盒子的右边框需要保留 if (index !== this.codeLength.length - 1) { style.borderRight = 'none' } } } if (index !== this.codeLength.length - 1) { // 设置验证码字符之间的距离,通过margin-right设置,最后一个字符,无需右边框 style.marginRight = addUnit(this.space) } else { // 最后一个盒子的有边框需要保留 style.marginRight = 0 } return style } }, // 将输入的值,转为数组,给item历遍时,根据当前的索引显示数组的元素 codeArray() { return String(this.inputValue).split('') }, // 下划线模式下,横线的样式 lineStyle() { const style = {} style.height = this.hairline ? '1px' : '4px' style.width = this.$uv.addUnit(this.size) // 线条模式下,背景色即为边框颜色 style.backgroundColor = this.borderColor return style } }, methods: { // 监听输入框的值发生变化 inputHandler(e) { const value = e.detail.value this.inputValue = value // 是否允许输入“.”符号 if (this.disabledDot) { this.$nextTick(() => { this.inputValue = value.replace('.', '') }) } // 未达到maxlength之前,发送change事件,达到后发送finish事件 this.$emit('change', value) // 修改通过v-model双向绑定的值 this.$emit('input', value) this.$emit('update:modelValue', value) // 达到用户指定输入长度时,发出完成事件 if (String(value).length >= Number(this.maxlength)) { this.$emit('finish', value) } }, // 自定义键盘输入值监听 customInput() { const value = this.inputValue; // 是否允许输入“.”符号 if (this.disabledDot) { this.$nextTick(() => { this.inputValue = value.replace('.', '') }) } // 未达到maxlength之前,发送change事件,达到后发送finish事件 this.$emit('change', value) // 达到用户指定输入长度时,发出完成事件 if (String(value).length >= Number(this.maxlength)) { this.$emit('finish', value) } } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-code-input-cursor-width: 1px; $uv-code-input-cursor-height: 40%; $uv-code-input-cursor-animation-duration: 1s; $uv-code-input-cursor-animation-name: uv-cursor-flicker; .uv-code-input { @include flex; position: relative; overflow: hidden; &__item { @include flex; justify-content: center; align-items: center; position: relative; &__text { font-size: 15px; color: $uv-content-color; } &__dot { width: 7px; height: 7px; border-radius: 100px; background-color: $uv-content-color; } &__line { position: absolute; bottom: 0; height: 4px; border-radius: 100px; width: 40px; background-color: $uv-content-color; } /* #ifndef APP-PLUS */ &__cursor { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: $uv-code-input-cursor-width; height: $uv-code-input-cursor-height; animation: $uv-code-input-cursor-animation-duration uv-cursor-flicker infinite; } /* #endif */ } &__input { // 之所以需要input输入框,是因为有它才能唤起键盘 // 这里将它设置为两倍的屏幕宽度,再将左边的一半移出屏幕,为了不让用户看到输入的内容 position: absolute; left: -750rpx; width: 1500rpx; top: 0; background-color: transparent; text-align: left; } } /* #ifndef APP-PLUS */ @keyframes uv-cursor-flicker { 0% { opacity: 0; } 50% { opacity: 1; } 100% { opacity: 0; } } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-code-input/components/uv-code-input/uv-code-input.vue
Vue
unknown
8,647
export default { props: { // 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number value: { type: [String, Number, Array, null], default: null }, // 是否手风琴模式 accordion: { type: Boolean, default: false }, // 是否显示外边框 border: { type: Boolean, default: true }, ...uni.$uv?.props?.collapse } }
2301_77169380/AppruanjianApk
uni_modules/uv-collapse/components/uv-collapse/props.js
JavaScript
unknown
406
<template> <view class="uv-collapse"> <uv-line v-if="border"></uv-line> <slot /> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * collapse 折叠面板 * @description 通过折叠面板收纳内容区域 * @tutorial https://www.uvui.cn/components/collapse.html * @property {String | Number | Array} value 当前展开面板的name,非手风琴模式:[<string | number>],手风琴模式:string | number * @property {Boolean} accordion 是否手风琴模式( 默认 false ) * @property {Boolean} border 是否显示外边框 ( 默认 true ) * @event {Function} change 当前激活面板展开时触发(如果是手风琴模式,参数activeNames类型为String,否则为Array) * @example <uv-collapse></uv-collapse> */ export default { name: "uv-collapse", mixins: [mpMixin, mixin, props], watch: { needInit() { this.init() }, // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件 parentData() { if (this.children.length) { this.children.map(child => { // 判断子组件(uv-checkbox)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值) typeof(child.updateParentData) === 'function' && child.updateParentData() }) } } }, created() { this.children = [] }, computed: { needInit() { // 通过computed,同时监听accordion和value值的变化 // 再通过watch去执行init()方法,进行再一次的初始化 return [this.accordion, this.value] } }, methods: { // 重新初始化一次内部的所有子元素 init() { this.children.map(child => { child.init() }) }, /** * collapse-item被点击时触发,由collapse统一处理各子组件的状态 * @param {Object} target 被操作的面板的实例 */ onChange(target) { let changeArr = [] this.children.map((child, index) => { // 如果是手风琴模式,将其他的折叠面板收起来 if (this.accordion) { child.expanded = child === target ? !target.expanded : false child.setContentAnimate() } else { if(child === target) { child.expanded = !child.expanded child.setContentAnimate() } } // 拼接change事件中,数组元素的状态 changeArr.push({ // 如果没有定义name属性,则默认返回组件的index索引 name: child.name || index, status: child.expanded ? 'open' : 'close' }) }) this.$emit('change', changeArr) this.$emit(target.expanded ? 'open' : 'close', target.name) } } } </script>
2301_77169380/AppruanjianApk
uni_modules/uv-collapse/components/uv-collapse/uv-collapse.vue
Vue
unknown
2,836
export default { props: { // 标题 title: { type: String, default: '' }, // 标题右侧内容 value: { type: String, default: '' }, // 标题下方的描述信息 label: { type: String, default: '' }, // 是否禁用折叠面板 disabled: { type: Boolean, default: false }, // 是否展示右侧箭头并开启点击反馈 isLink: { type: Boolean, default: true }, // 是否开启点击反馈 clickable: { type: Boolean, default: true }, // 是否显示内边框 border: { type: Boolean, default: true }, // 标题的对齐方式 align: { type: String, default: 'left' }, // 唯一标识符 name: { type: [String, Number], default: '' }, // 标题左侧图片,可为绝对路径的图片或内置图标 icon: { type: String, default: '' }, // 面板展开收起的过渡时间,单位ms duration: { type: Number, default: 300 }, ...uni.$uv?.props?.collapseItem } }
2301_77169380/AppruanjianApk
uni_modules/uv-collapse/components/uv-collapse-item/props.js
JavaScript
unknown
1,005
<template> <view class="uv-collapse-item"> <uv-cell :title="title" :value="value" :label="label" :icon="icon" :isLink="isLink" :clickable="clickable" :border="parentData.border && showBorder" @click="clickHandler" :arrowDirection="expanded ? 'up' : 'down'" :disabled="disabled" > <!-- #ifndef MP-WEIXIN --> <!-- 微信小程序不支持,因为微信中不支持 <slot name="title" slot="title" />的写法 --> <template slot="title"> <slot name="title"></slot> </template> <template slot="icon"> <slot name="icon"></slot> </template> <template slot="value"> <slot name="value"></slot> </template> <template slot="right-icon"> <slot name="right-icon"></slot> </template> <!-- #endif --> </uv-cell> <view class="uv-collapse-item__content" :animation="animationData" ref="animation" > <view class="uv-collapse-item__content__text content-class" :id="elId" :ref="elId" ><slot /></view> </view> <uv-line v-if="parentData.border"></uv-line> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; // #ifdef APP-NVUE const animation = uni.requireNativePlugin('animation') const dom = uni.requireNativePlugin('dom') // #endif /** * collapseItem 折叠面板Item * @description 通过折叠面板收纳内容区域(搭配uv-collapse使用) * @tutorial https://www.uvui.cn/components/collapse.html * @property {String} title 标题 * @property {String} value 标题右侧内容 * @property {String} label 标题下方的描述信息 * @property {Boolean} disbled 是否禁用折叠面板 ( 默认 false ) * @property {Boolean} isLink 是否展示右侧箭头并开启点击反馈 ( 默认 true ) * @property {Boolean} clickable 是否开启点击反馈 ( 默认 true ) * @property {Boolean} border 是否显示内边框 ( 默认 true ) * @property {String} align 标题的对齐方式 ( 默认 'left' ) * @property {String | Number} name 唯一标识符 * @property {String} icon 标题左侧图片,可为绝对路径的图片或内置图标 * @event {Function} change 某个item被打开或者收起时触发 * @example <uv-collapse-item :title="item.head" v-for="(item, index) in itemList" :key="index">{{item.body}}</uv-collapse-item> */ export default { name: "uv-collapse-item", mixins: [mpMixin, mixin, props], data() { return { elId: '', // uni.createAnimation的导出数据 animationData: {}, // 是否展开状态 expanded: false, // 根据expanded确定是否显示border,为了控制展开时,cell的下划线更好的显示效果,进行一定时间的延时 showBorder: false, // 是否动画中,如果是则不允许继续触发点击 animating: false, // 父组件uv-collapse的参数 parentData: { accordion: false, border: false } }; }, watch: { expanded(n) { clearTimeout(this.timer) this.timer = null // 这里根据expanded的值来进行一定的延时,是为了cell的下划线更好的显示效果 this.timer = setTimeout(() => { this.showBorder = n }, n ? 10 : 290) } }, created() { this.elId = this.$uv.guid(); }, mounted() { this.init() }, methods: { // 异步获取内容,或者动态修改了内容时,需要重新初始化 init() { // 初始化数据 this.updateParentData() if (!this.parent) { return this.$uv.error('uv-collapse-item必须要搭配uv-collapse组件使用') } const { value, accordion, children = [] } = this.parent if (accordion) { if (this.$uv.test.array(value)) { return this.$uv.error('手风琴模式下,uv-collapse组件的value参数不能为数组') } this.expanded = this.name == value } else { if (!this.$uv.test.array(value) && value !== null) { return this.$uv.error('非手风琴模式下,uv-collapse组件的value参数必须为数组') } this.expanded = (value || []).some(item => item == this.name) } // 设置组件的展开或收起状态 this.$nextTick(function() { this.setContentAnimate() }) }, updateParentData() { // 此方法在mixin中 this.getParentData('uv-collapse') }, async setContentAnimate() { // 每次面板打开或者收起时,都查询元素尺寸 // 好处是,父组件从服务端获取内容后,变更折叠面板后可以获得最新的高度 const rect = await this.queryRect() const height = this.expanded ? rect.height : 0 this.animating = true // #ifdef APP-NVUE const ref = this.$refs['animation'].ref animation.transition(ref, { styles: { height: height + 'px' }, duration: this.duration, // 必须设置为true,否则会到面板收起或展开时,页面其他元素不会随之调整它们的布局 needLayout: true, timingFunction: 'ease-in-out', }, () => { this.animating = false }) // #endif // #ifndef APP-NVUE const animation = uni.createAnimation({ timingFunction: 'ease-in-out', }); animation .height(height) .step({ duration: this.duration, }) .step() // 导出动画数据给面板的animationData值 this.animationData = animation.export() // 标识动画结束 this.$uv.sleep(this.duration).then(() => { this.animating = false }) // #endif }, // 点击collapsehead头部 clickHandler() { if (this.disabled && this.animating) return // 设置本组件为相反的状态 this.parent && this.parent.onChange(this) }, // 查询内容高度 queryRect() { // #ifndef APP-NVUE // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同 return new Promise(resolve => { this.$uvGetRect(`#${this.elId}`).then(size => { resolve(size) }) }) // #endif // #ifdef APP-NVUE // nvue下,使用dom模块查询元素高度 // 返回一个promise,让调用此方法的主体能使用then回调 return new Promise(resolve => { dom.getComponentRect(this.$refs[this.elId], res => { resolve(res.size) }) }) // #endif } }, }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-collapse-item { &__content { overflow: hidden; height: 0; &__text { padding: 12px 15px; color: $uv-content-color; font-size: 14px; line-height: 18px; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-collapse/components/uv-collapse-item/uv-collapse-item.vue
Vue
unknown
6,820
export default { props: { // 倒计时时长,单位ms time: { type: [String, Number], default: 0 }, // 时间格式,DD-日,HH-时,mm-分,ss-秒,SSS-毫秒 format: { type: String, default: 'HH:mm:ss' }, // 是否自动开始倒计时 autoStart: { type: Boolean, default: true }, // 是否展示毫秒倒计时 millisecond: { type: Boolean, default: false }, ...uni.$uv?.props?.countDown } }
2301_77169380/AppruanjianApk
uni_modules/uv-count-down/components/uv-count-down/props.js
JavaScript
unknown
453
// 补0,如1 -> 01 function padZero(num, targetLength = 2) { let str = `${num}` while (str.length < targetLength) { str = `0${str}` } return str } const SECOND = 1000 const MINUTE = 60 * SECOND const HOUR = 60 * MINUTE const DAY = 24 * HOUR export function parseTimeData(time) { const days = Math.floor(time / DAY) const hours = Math.floor((time % DAY) / HOUR) const minutes = Math.floor((time % HOUR) / MINUTE) const seconds = Math.floor((time % MINUTE) / SECOND) const milliseconds = Math.floor(time % SECOND) return { days, hours, minutes, seconds, milliseconds } } export function parseFormat(format, timeData) { let { days, hours, minutes, seconds, milliseconds } = timeData // 如果格式化字符串中不存在DD(天),则将天的时间转为小时中去 if (format.indexOf('DD') === -1) { hours += days * 24 } else { // 对天补0 format = format.replace('DD', padZero(days)) } // 其他同理于DD的格式化处理方式 if (format.indexOf('HH') === -1) { minutes += hours * 60 } else { format = format.replace('HH', padZero(hours)) } if (format.indexOf('mm') === -1) { seconds += minutes * 60 } else { format = format.replace('mm', padZero(minutes)) } if (format.indexOf('ss') === -1) { milliseconds += seconds * 1000 } else { format = format.replace('ss', padZero(seconds)) } return format.replace('SSS', padZero(milliseconds, 3)) } export function isSameSecond(time1, time2) { return Math.floor(time1 / 1000) === Math.floor(time2 / 1000) }
2301_77169380/AppruanjianApk
uni_modules/uv-count-down/components/uv-count-down/utils.js
JavaScript
unknown
1,735
<template> <view class="uv-count-down" :style="[$uv.addStyle(customStyle)]"> <slot> <text class="uv-count-down__text">{{ formattedTime }}</text> </slot> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; import { isSameSecond, parseFormat, parseTimeData } from './utils'; /** * uv-count-down 倒计时 * @description 该组件一般使用于某个活动的截止时间上,通过数字的变化,给用户明确的时间感受,提示用户进行某一个行为操作。 * @tutorial https://www.uvui.cn/components/countDown.html * @property {String | Number} time 倒计时时长,单位ms (默认 0 ) * @property {String} format 时间格式,DD-日,HH-时,mm-分,ss-秒,SSS-毫秒 (默认 'HH:mm:ss' ) * @property {Boolean} autoStart 是否自动开始倒计时 (默认 true ) * @property {Boolean} millisecond 是否展示毫秒倒计时 (默认 false ) * @event {Function} finish 倒计时结束时触发 * @event {Function} change 倒计时变化时触发 * @event {Function} start 开始倒计时 * @event {Function} pause 暂停倒计时 * @event {Function} reset 重设倒计时,若 auto-start 为 true,重设后会自动开始倒计时 * @example <uv-count-down :time="time"></uv-count-down> */ export default { name: 'uv-count-down', mixins: [mpMixin, mixin, props], data() { return { timer: null, // 各单位(天,时,分等)剩余时间 timeData: parseTimeData(0), // 格式化后的时间,如"03:23:21" formattedTime: '0', // 倒计时是否正在进行中 runing: false, endTime: 0, // 结束的毫秒时间戳 remainTime: 0, // 剩余的毫秒时间 } }, watch: { time(n) { this.reset() } }, mounted() { this.init() }, methods: { init() { this.reset() }, // 开始倒计时 start() { if (this.runing) return // 标识为进行中 this.runing = true // 结束时间戳 = 此刻时间戳 + 剩余的时间 this.endTime = Date.now() + this.remainTime this.toTick() }, // 根据是否展示毫秒,执行不同操作函数 toTick() { if (this.millisecond) { this.microTick() } else { this.macroTick() } }, macroTick() { this.clearTimeout() // 每隔一定时间,更新一遍定时器的值 // 同时此定时器的作用也能带来毫秒级的更新 this.timer = setTimeout(() => { // 获取剩余时间 const remain = this.getRemainTime() // 重设剩余时间 if (!isSameSecond(remain, this.remainTime) || remain === 0) { this.setRemainTime(remain) } // 如果剩余时间不为0,则继续检查更新倒计时 if (this.remainTime !== 0) { this.macroTick() } }, 30) }, microTick() { this.clearTimeout() this.timer = setTimeout(() => { this.setRemainTime(this.getRemainTime()) if (this.remainTime !== 0) { this.microTick() } }, 50) }, // 获取剩余的时间 getRemainTime() { // 取最大值,防止出现小于0的剩余时间值 return Math.max(this.endTime - Date.now(), 0) }, // 设置剩余的时间 setRemainTime(remain) { this.remainTime = remain // 根据剩余的毫秒时间,得出该有天,小时,分钟等的值,返回一个对象 const timeData = parseTimeData(remain) this.$emit('change', timeData) // 得出格式化后的时间 this.formattedTime = parseFormat(this.format, timeData) // 如果时间已到,停止倒计时 if (remain <= 0) { this.pause() this.$emit('finish') } }, // 重置倒计时 reset() { this.pause() this.remainTime = this.time this.setRemainTime(this.remainTime) if (this.autoStart) { this.start() } }, // 暂停倒计时 pause() { this.runing = false; this.clearTimeout() }, // 清空定时器 clearTimeout() { clearTimeout(this.timer) this.timer = null } }, // #ifdef VUE2 beforeDestroy() { this.clearTimeout() }, // #endif // #ifdef VUE3 unmounted() { this.clearTimeout() } // #endif } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-count-down-text-color: $uv-content-color !default; $uv-count-down-text-font-size: 15px !default; $uv-count-down-text-line-height: 22px !default; .uv-count-down { &__text { color: $uv-count-down-text-color; font-size: $uv-count-down-text-font-size; line-height: $uv-count-down-text-line-height; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-count-down/components/uv-count-down/uv-count-down.vue
Vue
unknown
4,827
export default { props: { // 开始的数值,默认从0增长到某一个数 startVal: { type: [String, Number], default: 0 }, // 要滚动的目标数值,必须 endVal: { type: [String, Number], default: 0 }, // 滚动到目标数值的动画持续时间,单位为毫秒(ms) duration: { type: [String, Number], default: 2000 }, // 设置数值后是否自动开始滚动 autoplay: { type: Boolean, default: true }, // 要显示的小数位数 decimals: { type: [String, Number], default: 0 }, // 是否在即将到达目标数值的时候,使用缓慢滚动的效果 useEasing: { type: Boolean, default: true }, // 十进制分割 decimal: { type: [String, Number], default: '.' }, // 字体颜色 color: { type: String, default: '#606266' }, // 字体大小 fontSize: { type: [String, Number], default: 22 }, // 是否加粗字体 bold: { type: Boolean, default: false }, // 千位分隔符,类似金额的分割(¥23,321.05中的",") separator: { type: String, default: '' }, ...uni.$uv?.props?.countTo } }
2301_77169380/AppruanjianApk
uni_modules/uv-count-to/components/uv-count-to/props.js
JavaScript
unknown
1,160
<template> <text class="uv-count-num" :style="[{ fontSize: $uv.addUnit(fontSize), fontWeight: bold ? 'bold' : 'normal', color: color },$uv.addStyle(customStyle)]" >{{ displayValue }}</text> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * countTo 数字滚动 * @description 该组件一般用于需要滚动数字到某一个值的场景,目标要求是一个递增的值。 * @tutorial https://www.uvui.cn/components/countTo.html * @property {String | Number} startVal 开始的数值,默认从0增长到某一个数(默认 0 ) * @property {String | Number} endVal 要滚动的目标数值,必须 (默认 0 ) * @property {String | Number} duration 滚动到目标数值的动画持续时间,单位为毫秒(ms) (默认 2000 ) * @property {Boolean} autoplay 设置数值后是否自动开始滚动 (默认 true ) * @property {String | Number} decimals 要显示的小数位数,见官网说明(默认 0 ) * @property {Boolean} useEasing 滚动结束时,是否缓动结尾,见官网说明(默认 true ) * @property {String} decimal 十进制分割 ( 默认 "." ) * @property {String} color 字体颜色( 默认 '#606266' ) * @property {String | Number} fontSize 字体大小,单位px( 默认 22 ) * @property {Boolean} bold 字体是否加粗(默认 false ) * @property {String} separator 千位分隔符,见官网说明 * @event {Function} end 数值滚动到目标值时触发 * @example <uv-count-to ref="uCountTo" :end-val="endVal" :autoplay="autoplay"></uv-count-to> */ export default { name: 'uv-count-to', data() { return { localStartVal: this.startVal, displayValue: this.formatNumber(this.startVal), printVal: null, paused: false, // 是否暂停 localDuration: Number(this.duration), startTime: null, // 开始的时间 timestamp: null, // 时间戳 remaining: null, // 停留的时间 rAF: null, lastTime: 0 // 上一次的时间 }; }, mixins: [mpMixin, mixin, props], computed: { countDown() { return this.startVal > this.endVal; } }, watch: { startVal() { this.autoplay && this.start(); }, endVal() { this.autoplay && this.start(); } }, mounted() { this.autoplay && this.start(); }, methods: { easingFn(t, b, c, d) { return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b; }, requestAnimationFrame(callback) { const currTime = new Date().getTime(); // 为了使setTimteout的尽可能的接近每秒60帧的效果 const timeToCall = Math.max(0, 16 - (currTime - this.lastTime)); const id = setTimeout(() => { callback(currTime + timeToCall); }, timeToCall); this.lastTime = currTime + timeToCall; return id; }, cancelAnimationFrame(id) { clearTimeout(id); }, // 开始滚动数字 start() { this.localStartVal = this.startVal; this.startTime = null; this.localDuration = this.duration; this.paused = false; this.rAF = this.requestAnimationFrame(this.count); }, // 暂定状态,从暂停状态开始滚动;或者滚动状态下,暂停 restart() { if (this.paused) { this.resume(); this.paused = false; } else { this.stop(); this.paused = true; } }, // 暂停 stop() { this.cancelAnimationFrame(this.rAF); this.paused = true; }, // 重新开始(暂停的情况下) resume() { if (!this.remaining) return; this.startTime = 0; this.localDuration = this.remaining; this.localStartVal = this.printVal; this.requestAnimationFrame(this.count); }, // 重置 reset() { this.startTime = null; this.cancelAnimationFrame(this.rAF); this.displayValue = this.formatNumber(this.startVal); }, count(timestamp) { if (!this.startTime) this.startTime = timestamp; this.timestamp = timestamp; const progress = timestamp - this.startTime; this.remaining = this.localDuration - progress; if (this.useEasing) { if (this.countDown) { this.printVal = this.localStartVal - this.easingFn(progress, 0, this.localStartVal - this.endVal, this.localDuration); } else { this.printVal = this.easingFn(progress, this.localStartVal, this.endVal - this.localStartVal, this.localDuration); } } else { if (this.countDown) { this.printVal = this.localStartVal - (this.localStartVal - this.endVal) * (progress / this.localDuration); } else { this.printVal = this.localStartVal + (this.endVal - this.localStartVal) * (progress / this.localDuration); } } if (this.countDown) { this.printVal = this.printVal < this.endVal ? this.endVal : this.printVal; } else { this.printVal = this.printVal > this.endVal ? this.endVal : this.printVal; } this.displayValue = this.formatNumber(this.printVal) || 0; if (progress < this.localDuration) { this.rAF = this.requestAnimationFrame(this.count); } else { this.$emit('end'); } }, // 判断是否数字 isNumber(val) { return !isNaN(parseFloat(val)); }, formatNumber(num) { // 将num转为Number类型,因为其值可能为字符串数值,调用toFixed会报错 num = Number(num); num = num.toFixed(Number(this.decimals)); num += ''; const x = num.split('.'); let x1 = x[0]; const x2 = x.length > 1 ? `${this.decimal}${x[1]}` : ''; const rgx = /(\d+)(\d{3})/; if (this.separator && !this.isNumber(this.separator)) { while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + this.separator + '$2'); } } return x1 + x2; }, destroyed() { this.cancelAnimationFrame(this.rAF); } } }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-count-num { /* #ifndef APP-NVUE */ display: inline-flex; /* #endif */ text-align: center; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-count-to/components/uv-count-to/uv-count-to.vue
Vue
unknown
5,952
export default { props: { value: { type: [String, Number], default: '' }, modelValue: { type: [String, Number], default: '' }, // 是否打开组件 show: { type: Boolean, default: false }, // 是否展示顶部的操作栏 showToolbar: { type: Boolean, default: true }, // 顶部标题 title: { type: String, default: '' }, // 展示格式,mode=date为日期选择,mode=time为时间选择,mode=year-month为年月选择,mode=datetime为日期时间选择 mode: { type: String, default: 'datetime' }, // 可选的最大时间 maxDate: { type: Number, // 最大默认值为后10年 default: new Date(new Date().getFullYear() + 10, 0, 1).getTime() }, // 可选的最小时间 minDate: { type: Number, // 最小默认值为前10年 default: new Date(new Date().getFullYear() - 10, 0, 1).getTime() }, // 可选的最小小时,仅mode=time有效 minHour: { type: Number, default: 0 }, // 可选的最大小时,仅mode=time有效 maxHour: { type: Number, default: 23 }, // 可选的最小分钟,仅mode=time有效 minMinute: { type: Number, default: 0 }, // 可选的最大分钟,仅mode=time有效 maxMinute: { type: Number, default: 59 }, // 选项过滤函数 filter: { type: [Function, null], default: null }, // 选项格式化函数 formatter: { type: [Function, null], default: null }, // 是否显示加载中状态 loading: { type: Boolean, default: false }, // 各列中,单个选项的高度 itemHeight: { type: [String, Number], default: 44 }, // 取消按钮的文字 cancelText: { type: String, default: '取消' }, // 确认按钮的文字 confirmText: { type: String, default: '确认' }, // 取消按钮的颜色 cancelColor: { type: String, default: '#909193' }, // 确认按钮的颜色 confirmColor: { type: String, default: '#3c9cff' }, // 每列中可见选项的数量 visibleItemCount: { type: [String, Number], default: 5 }, // 是否允许点击遮罩关闭选择器 closeOnClickOverlay: { type: Boolean, default: true }, // 是否允许点击确认关闭选择器 closeOnClickConfirm: { type: Boolean, default: true }, // 是否清空上次选择内容 clearDate: { type: Boolean, default: false }, // 圆角 round: { type: [String, Number], default: 0 }, ...uni.$uv?.props?.datetimePicker } }
2301_77169380/AppruanjianApk
uni_modules/uv-datetime-picker/components/uv-datetime-picker/props.js
JavaScript
unknown
2,539
<template> <uv-picker ref="picker" :closeOnClickOverlay="closeOnClickOverlay" :closeOnClickConfirm="closeOnClickConfirm" :columns="columns" :title="title" :itemHeight="itemHeight" :showToolbar="showToolbar" :visibleItemCount="visibleItemCount" :defaultIndex="innerDefaultIndex" :cancelText="cancelText" :confirmText="confirmText" :cancelColor="cancelColor" :confirmColor="confirmColor" :round="round" @close="close" @cancel="cancel" @confirm="confirm" @change="change" > </uv-picker> </template> <script> function times(n, iteratee) { let index = -1 const result = Array(n < 0 ? 0 : n) while (++index < n) { result[index] = iteratee(index) } return result } import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; import dayjs from '@/uni_modules/uv-ui-tools/libs/util/dayjs.js' /** * DatetimePicker 时间日期选择器 * @description 此选择器用于时间日期 * @tutorial https://www.uvui.cn/components/datetimePicker.html * @property {Boolean} showToolbar 是否显示顶部的操作栏 ( 默认 true ) * @property {String | Number} value 绑定值 * @property {String} title 顶部标题 * @property {String} mode 展示格式 mode=date为日期选择,mode=time为时间选择,mode=year-month为年月选择,mode=datetime为日期时间选择 ( 默认 ‘datetime ) * @property {Number} maxDate 可选的最大时间 默认值为后10年 * @property {Number} minDate 可选的最小时间 默认值为前10年 * @property {Number} minHour 可选的最小小时,仅mode=time有效 ( 默认 0 ) * @property {Number} maxHour 可选的最大小时,仅mode=time有效 ( 默认 23 ) * @property {Number} minMinute 可选的最小分钟,仅mode=time有效 ( 默认 0 ) * @property {Number} maxMinute 可选的最大分钟,仅mode=time有效 ( 默认 59 ) * @property {Function} filter 选项过滤函数 * @property {Function} formatter 选项格式化函数 * @property {Boolean} loading 是否显示加载中状态 ( 默认 false ) * @property {String | Number} itemHeight 各列中,单个选项的高度 ( 默认 44 ) * @property {String} cancelText 取消按钮的文字 ( 默认 '取消' ) * @property {String} confirmText 确认按钮的文字 ( 默认 '确认' ) * @property {String} cancelColor 取消按钮的颜色 ( 默认 '#909193' ) * @property {String} confirmColor 确认按钮的颜色 ( 默认 '#3c9cff' ) * @property {String | Number} visibleItemCount 每列中可见选项的数量 ( 默认 5 ) * @property {Boolean} closeOnClickOverlay 是否允许点击遮罩关闭选择器 ( 默认 true ) * @property {String | Number} round 圆角 ( 默认 0 ) * @event {Function} close 关闭选择器时触发 * @event {Function} confirm 点击确定按钮,返回当前选择的值 * @event {Function} change 当选择值变化时触发 * @event {Function} cancel 点击取消按钮 * @example <uv-datetime-picker ref="datetimepicker" :value="value1" mode="datetime" ></uv-datetime-picker> */ export default { name: 'uv-datetime-picker', emits: ['close', 'cancel', 'confirm', 'input', 'change', 'update:modelValue'], mixins: [mpMixin, mixin, props], data() { return { columns: [], innerDefaultIndex: [], innerFormatter: (type, value) => value } }, watch: { propsChange() { this.$uv.sleep(100).then(res=>{ this.init() }) } }, computed: { // 如果以下这些变量发生了变化,意味着需要重新初始化各列的值 propsChange() { const propsValue = this.value || this.modelValue; return [this.mode, this.maxDate, this.minDate, this.minHour, this.maxHour, this.minMinute, this.maxMinute, this.filter, propsValue] } }, mounted() { this.init() }, methods: { init() { this.getValue(); this.updateColumnValue(this.innerValue) }, getValue() { const propsValue = this.value || this.modelValue; this.innerValue = this.correctValue(propsValue) }, // 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用 setFormatter(e) { this.innerFormatter = e }, open() { this.$refs.picker.open(); // 解决打开的前一次和当前日期错乱的BUG setTimeout(()=>{ this.getValue(); this.updateColumnValue(this.innerValue); },10) }, close() { this.$emit('close'); }, // 点击工具栏的取消按钮 cancel() { this.$emit('cancel') }, // 点击工具栏的确定按钮 confirm() { this.$emit('confirm', { value: this.innerValue, mode: this.mode }) if(!this.clearDate) { this.$emit('input', this.innerValue) this.$emit('update:modelValue', this.innerValue) } }, //用正则截取输出值,当出现多组数字时,抛出错误 intercept(e, type) { let judge = e.match(/\d+/g) //判断是否掺杂数字 if (judge.length > 1) { this.$uv.error("请勿在过滤或格式化函数时添加数字") return 0 } else if (type && judge[0].length == 4) { //判断是否是年份 return judge[0] } else if (judge[0].length > 2) { this.$uv.error("请勿在过滤或格式化函数时添加数字") return 0 } else { return judge[0] } }, // 列发生变化时触发 change(e) { const { indexs, values } = e let selectValue = '' if (this.mode === 'time') { // 根据value各列索引,从各列数组中,取出当前时间的选中值 selectValue = `${this.intercept(values[0][indexs[0]])}:${this.intercept(values[1][indexs[1]])}` } else if (this.mode === 'year') { const year = parseInt(this.intercept(values[0][indexs[0]], 'year')); selectValue = Number(new Date(year, 0)); } else { // 将选择的值转为数值,比如'03'转为数值的3,'2019'转为数值的2019 const year = parseInt(this.intercept(values[0][indexs[0]], 'year')) const month = parseInt(this.intercept(values[1][indexs[1]])) let date = parseInt(values[2] ? this.intercept(values[2][indexs[2]]) : 1) let hour = 0, minute = 0 // 此月份的最大天数 const maxDate = dayjs(`${year}-${month}`).daysInMonth() // year-month模式下,date不会出现在列中,设置为1,为了符合后边需要减1的需求 if (this.mode === 'year-month') { date = 1 } // 不允许超过maxDate值 date = Math.min(maxDate, date) if (this.mode === 'datetime') { hour = parseInt(this.intercept(values[3][indexs[3]])) minute = parseInt(this.intercept(values[4][indexs[4]])) } // 转为时间模式 selectValue = Number(new Date(year, month - 1, date, hour, minute)) } // 取出准确的合法值,防止超越边界的情况 selectValue = this.correctValue(selectValue) this.innerValue = selectValue this.updateColumnValue(selectValue) // 发出change时间,value为当前选中的时间戳 this.$emit('change', { value: selectValue, mode: this.mode }) }, // 更新各列的值,进行补0、格式化等操作 updateColumnValue(value) { this.innerValue = value this.updateColumns() this.updateIndexs(value) }, // 更新索引 updateIndexs(value) { let values = [] const formatter = this.formatter || this.innerFormatter; if (this.mode === 'time') { // 将time模式的时间用:分隔成数组 const timeArr = value.split(':') // 使用formatter格式化方法进行管道处理 values = [formatter('hour', timeArr[0]), formatter('minute', timeArr[1])] } else { const date = new Date(value) values = [ formatter('year', `${dayjs(value).year()}`), // 月份补0 formatter('month', this.$uv.padZero(dayjs(value).month() + 1)) ] if (this.mode === 'date') { // date模式,需要添加天列 values.push(formatter('day', this.$uv.padZero(dayjs(value).date()))) } if (this.mode === 'datetime') { // 数组的push方法,可以写入多个参数 values.push(formatter('day', this.$uv.padZero(dayjs(value).date())), formatter('hour', this.$uv.padZero(dayjs(value).hour())), formatter('minute', this.$uv.padZero(dayjs(value).minute()))) } } // 根据当前各列的所有值,从各列默认值中找到默认值在各列中的索引 const indexs = this.columns.map((column, index) => { // 通过取大值,可以保证不会出现找不到索引的-1情况 return Math.max(0, column.findIndex(item => item === values[index])) }) this.$nextTick(()=>{ this.$uv.sleep(100).then(res=>{ this.$refs.picker.setIndexs(indexs,true); }) }) }, // 更新各列的值 updateColumns() { const formatter = this.formatter || this.innerFormatter // 获取各列的值,并且map后,对各列的具体值进行补0操作 const results = this.getOriginColumns().map((column) => column.values.map((value) => formatter(column.type, value))) this.columns = results }, getOriginColumns() { // 生成各列的值 const results = this.getRanges().map(({ type, range }) => { let values = times(range[1] - range[0] + 1, (index) => { let value = range[0] + index value = type === 'year' ? `${value}` : this.$uv.padZero(value) return value }) // 进行过滤 if (this.filter) { values = this.filter(type, values) } return { type, values } }) return results }, // 通过最大值和最小值生成数组 generateArray(start, end) { return Array.from(new Array(end + 1).keys()).slice(start) }, // 得出合法的时间 correctValue(value) { const isDateMode = this.mode !== 'time' if (isDateMode && !this.$uv.test.date(value)) { // 如果是日期类型,但是又没有设置合法的当前时间的话,使用最小时间为当前时间 value = this.minDate } else if (!isDateMode && !value) { // 如果是时间类型,而又没有默认值的话,就用最小时间 value = `${this.$uv.padZero(this.minHour)}:${this.$uv.padZero(this.minMinute)}` } // 时间类型 if (!isDateMode) { if (String(value).indexOf(':') === -1) return this.$uv.error('时间错误,请传递如12:24的格式') let [hour, minute] = value.split(':') // 对时间补零,同时控制在最小值和最大值之间 hour = this.$uv.padZero(this.$uv.range(this.minHour, this.maxHour, Number(hour))) minute = this.$uv.padZero(this.$uv.range(this.minMinute, this.maxMinute, Number(minute))) return `${ hour }:${ minute }` } else { // 如果是日期格式,控制在最小日期和最大日期之间 value = dayjs(value).isBefore(dayjs(this.minDate)) ? this.minDate : value value = dayjs(value).isAfter(dayjs(this.maxDate)) ? this.maxDate : value return value } }, // 获取每列的最大和最小值 getRanges() { if (this.mode === 'time') { return [{ type: 'hour', range: [this.minHour, this.maxHour], }, { type: 'minute', range: [this.minMinute, this.maxMinute], }, ]; } const { maxYear, maxDate, maxMonth, maxHour, maxMinute, } = this.getBoundary('max', this.innerValue); const { minYear, minDate, minMonth, minHour, minMinute, } = this.getBoundary('min', this.innerValue); const result = [{ type: 'year', range: [minYear, maxYear], }, { type: 'month', range: [minMonth, maxMonth], }, { type: 'day', range: [minDate, maxDate], }, { type: 'hour', range: [minHour, maxHour], }, { type: 'minute', range: [minMinute, maxMinute], }, ]; if (this.mode === 'date') result.splice(3, 2); if (this.mode === 'year-month') result.splice(2, 3); if (this.mode === 'year') result.splice(1, 4); return result; }, // 根据minDate、maxDate、minHour、maxHour等边界值,判断各列的开始和结束边界值 getBoundary(type, innerValue) { const value = new Date(innerValue) const boundary = new Date(this[`${type}Date`]) const year = dayjs(boundary).year() let month = 1 let date = 1 let hour = 0 let minute = 0 if (type === 'max') { month = 12 // 月份的天数 date = dayjs(value).daysInMonth() hour = 23 minute = 59 } // 获取边界值,逻辑是:当年达到了边界值(最大或最小年),就检查月允许的最大和最小值,以此类推 if (dayjs(value).year() === year) { month = dayjs(boundary).month() + 1 if (dayjs(value).month() + 1 === month) { date = dayjs(boundary).date() if (dayjs(value).date() === date) { hour = dayjs(boundary).hour() if (dayjs(value).hour() === hour) { minute = dayjs(boundary).minute() } } } } return { [`${type}Year`]: year, [`${type}Month`]: month, [`${type}Date`]: date, [`${type}Hour`]: hour, [`${type}Minute`]: minute } }, }, } </script>
2301_77169380/AppruanjianApk
uni_modules/uv-datetime-picker/components/uv-datetime-picker/uv-datetime-picker.vue
Vue
unknown
13,327
export default { props: { // 是否虚线 dashed: { type: Boolean, default: false }, // 是否细线 hairline: { type: Boolean, default: true }, // 是否以点替代文字,优先于text字段起作用 dot: { type: Boolean, default: false }, // 内容文本的位置,left-左边,center-中间,right-右边 textPosition: { type: String, default: 'center' }, // 文本内容 text: { type: [String, Number], default: '' }, // 文本大小 textSize: { type: [String, Number], default: 14 }, // 文本颜色 textColor: { type: String, default: '#909399' }, // 线条颜色 lineColor: { type: String, default: '#dcdfe6' }, ...uni.$uv?.props?.divider } }
2301_77169380/AppruanjianApk
uni_modules/uv-divider/components/uv-divider/props.js
JavaScript
unknown
755
<template> <view class="uv-divider" :style="[$uv.addStyle(customStyle)]" @tap="click" > <uv-line :color="lineColor" :customStyle="leftLineStyle" :hairline="hairline" :dashed="dashed"></uv-line> <text v-if="dot" class="uv-divider__dot" >●</text> <text v-else-if="text" class="uv-divider__text" :style="[textStyle]" >{{text}}</text> <uv-line :color="lineColor" :customStyle="rightLineStyle" :hairline="hairline" :dashed="dashed" ></uv-line> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * divider 分割线 * @description 区隔内容的分割线,一般用于页面底部"没有更多"的提示。 * @tutorial https://www.uvui.cn/components/divider.html * @property {Boolean} dashed 是否虚线 (默认 false ) * @property {Boolean} hairline 是否细线 (默认 true ) * @property {Boolean} dot 是否以点替代文字,优先于text字段起作用 (默认 false ) * @property {String} textPosition 内容文本的位置,left-左边,center-中间,right-右边 (默认 'center' ) * @property {String | Number} text 文本内容 * @property {String | Number} textSize 文本大小 (默认 14) * @property {String} textColor 文本颜色 (默认 '#909399' ) * @property {String} lineColor 线条颜色 (默认 '#dcdfe6' ) * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function} click divider组件被点击时触发 * @example <uv-divider :color="color">锦瑟无端五十弦</uv-divider> */ export default { name: 'uv-divider', mixins: [mpMixin, mixin, props], emits: ['click'], computed: { textStyle() { const style = {} style.fontSize = this.$uv.addUnit(this.textSize) style.color = this.textColor return style }, // 左边线条的的样式 leftLineStyle() { const style = {} // 如果是在左边,设置左边的宽度为固定值 if (this.textPosition === 'left') { style.width = '80rpx' } else { style.flex = 1 } return style }, // 右边线条的的样式 rightLineStyle() { const style = {} // 如果是在右边,设置右边的宽度为固定值 if (this.textPosition === 'right') { style.width = '80rpx' } else { style.flex = 1 } return style } }, methods: { // divider组件被点击时触发 click() { this.$emit('click'); } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; $uv-divider-margin: 15px 0 !default; $uv-divider-text-margin: 0 15px !default; $uv-divider-dot-font-size: 12px !default; $uv-divider-dot-margin: 0 12px !default; $uv-divider-dot-color: #c0c4cc !default; .uv-divider { @include flex; flex-direction: row; align-items: center; margin: $uv-divider-margin; &__text { margin: $uv-divider-text-margin; } &__dot { font-size: $uv-divider-dot-font-size; margin: $uv-divider-dot-margin; color: $uv-divider-dot-color; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-divider/components/uv-divider/uv-divider.vue
Vue
unknown
3,242
<template> <uv-sticky :disabled="!isSticky"> <view ref="dropDownRef" class="uv-drop-down" :style="[$uv.addStyle(customStyle)]"> <slot></slot> </view> </uv-sticky> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'; import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'; // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom'); // #endif /** * DropDown 下拉框 * @description 下拉筛选 * @tutorial https://ext.dcloud.net.cn/plugin?name=uv-drop-down * @property {String | Number} sign 组件唯一标识,需要手动传 * @property {Boolean} is-sticky = [true|false] 是否吸顶 * @property {Array} default-value 默认值,表示参数value属于这里面的值,就说明是未选中即是默认展示的值。eg:上面示例中的{label: '全部',value: 'all'} 即是默认值。后续处理逻辑也可以根据是否是其中值进行过滤。 * @property {String} textSize 每项字体大小 * @property {String} textColor 每项文本颜色 * @property {String} textActiveSize 每项选中状态字体大小 * @property {String} textActiveColor 每项选中状态文本颜色 * @property {Object} extraIcon 每项右侧图标 * @property {Object} extraActiveIcon 每项选中后右侧图标 */ export default { name: 'uv-drop-down', mixins: [mpMixin, mixin], emits: ['click'], props: { isSticky: { type: Boolean, default: true }, sign: { type: [String, Number], default: 'UVDROPDOWN' }, defaultValue: { type: Array, default: () => [0, '0', 'all'] }, textSize: { type: String, default: '30rpx' }, textColor: { type: String, default: '#333' }, textActiveSize: { type: String, default: '30rpx' }, textActiveColor: { type: String, default: '#3c9cff' }, extraIcon: { type: Object, default () { return { name: 'arrow-down', size: '30rpx', color: '#333' } } }, extraActiveIcon: { type: Object, default () { return { name: 'arrow-up', size: '30rpx', color: '#3c9cff' } } } }, computed: { parentData() { return [this.defaultValue, this.textSize, this.textColor, this.textActiveColor, this.textActiveSize, this.extraIcon, this.extraActiveIcon, this.sign, this.clickHandler]; } }, mounted() { this.init(); }, methods: { init() { uni.$emit(`${this.sign}_CLICKMENU`, { show: false }); this.$nextTick(async () => { const rect = await this.queryRect(); uni.$emit(`${this.sign}_GETRECT`, rect); }) }, // 查询内容高度 queryRect() { // #ifndef APP-NVUE // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同 return new Promise(resolve => { this.$uvGetRect(`.uv-drop-down`).then(size => { resolve(size) }) }) // #endif // #ifdef APP-NVUE // nvue下,使用dom模块查询元素高度 // 返回一个promise,让调用此方法的主体能使用then回调 return new Promise(resolve => { dom.getComponentRect(this.$refs.dropDownRef, res => { res.size.top = res.size.top <= 0 ? 0 : res.size.top; resolve(res.size) }) }) // #endif }, clickHandler(data) { this.$emit('click', data); } } } </script> <style scoped lang="scss"> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-drop-down { @include flex; justify-content: space-between; background-color: #fff; border-bottom: 1px solid #dadbde; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-drop-down/components/uv-drop-down/uv-drop-down.vue
Vue
unknown
3,639
<template> <view class="uv-drop-down-item" @click="clickHandler"> <uv-text :text="label" :size="getTextStyle.size" :color="getTextStyle.color" lines="1" :custom-style="{marginRight: '10rpx',maxWidth:'200rpx'}"></uv-text> <uv-icon :name="getDownIcon.name" :size="getDownIcon.size" :color="getDownIcon.color" v-if="[1,'1'].indexOf(type)==-1"></uv-icon> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'; import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'; /** * DropDown 下拉框 * @description 下拉筛选 * @tutorial https://ext.dcloud.net.cn/plugin?name=uv-drop-down * @property {String | Number} name 字段标识 * @property {String | Number} type 类型 1 没有筛选项,直接进行选中和不选中 2 有多个选项 * @property {String | Number} label 筛选项的文本 * @property {Boolean} isDrop 该项是否打开 */ export default { name: 'uv-drop-down-item', mixins: [mpMixin, mixin], emits: ['click'], props: { name: { type: [String, Number], default: '' }, // 类型 1 没有筛选项,直接进行选中和不选中 2 有多个选项 type: { type: [String, Number], default: '2' }, // 筛选的文本 label: { type: [String], default: '' }, // 筛选值 value: { type: [String, Number, null], default: '' }, // 是否下拉菜单打开 isDrop: { type: Boolean, default: false } }, data() { return { parentData: { defaultValue: [0, '0', 'all'], textSize: '30rpx', textColor: '#333', textActiveSize: '30rpx', textActiveColor: '#3c9cff', extraIcon: {}, extraActiveIcon: {}, sign: '', clickHandler: Function }, active: false, isDroped: false, elId: '' } }, watch: { isDrop: { handler(newVal) { this.isDroped = newVal; }, immediate: true }, value: { handler(newVal) { this.$nextTick(()=>{ this.active = this.parentData.defaultValue.indexOf(newVal) == -1; }) }, immediate: true } }, computed: { getDownIcon() { const style = { size: '30rpx', color: '#333', ...this.parentData.extraIcon } if (this.active || this.isDroped) { style.color = this.parentData.extraActiveIcon?.color ? this.parentData.extraActiveIcon?.color : '#3c9cff'; style.size = this.parentData.extraActiveIcon?.size ? this.parentData.extraActiveIcon?.size : '30rpx'; } if (this.isDroped) { style.name = this.parentData.extraActiveIcon?.name; } return style; }, getTextStyle() { const style = { size: this.parentData.textSize, color: this.parentData.textColor }; if (this.active || this.isDroped) { style.size = this.parentData.textActiveSize; style.color = this.parentData.textActiveColor; } return style; } }, created() { this.init(); }, methods: { init() { this.elId = this.$uv.guid(); this.getParentData('uv-drop-down'); if (!this.parent) { this.$uv.error('uv-drop-down必须搭配uv-drop-down-item组件使用'); } uni.$on('HANDLE_DROPDOWN_ONE', id => { if (this.isDroped && this.elId != id) { this.isDroped = false; } }) uni.$on(`${this.parentData.sign}_CLOSEPOPUP`, async () => { if (this.isDroped) { this.isDroped = false; } }) }, async clickHandler() { let data = {}; uni.$emit('HANDLE_DROPDOWN_ONE', this.elId); switch (+this.type) { case 1: this.active = !this.active; data = { name: this.name, active: this.active, type: this.type }; break; case 2: this.isDroped = !this.isDroped; data = { name: this.name, active: this.isDroped, type: this.type }; break; } this.parentData.clickHandler(data); this.$emit('click', data); uni.$emit(`${this.parentData.sign}_CLICKMENU`, { show: +this.type > 1 && this.isDroped }); } } } </script> <style scoped lang="scss"> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-drop-down-item { @include flex; align-items: center; padding: 20rpx; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-drop-down/components/uv-drop-down-item/uv-drop-down-item.vue
Vue
unknown
4,268
<template> <view class="uv-drop-down-popup"> <uv-transition :show="show" mode="fade" :duration="300" :custom-style="overlayStyle" @click="clickOverlay"> <view class="uv-dp__container" ref="uvDPContainer" :style="{height: `${height}px`}" @click.stop="blockClick"> <view class="uv-dp__container__list" ref="uvDPList"> <slot> <view class="uv-dp__container__list--item" v-for="(item,index) in list" :key="index" @click="clickHandler(item,index)" :style="[itemCustomStyle(index)]"> <uv-text :text="item[keyName]" :size="getTextSize(index)" :color="getTextColor(index)"></uv-text> </view> </slot> </view> </view> </uv-transition> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'; import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'; // #ifdef APP-NVUE const animation = uni.requireNativePlugin('animation'); const dom = uni.requireNativePlugin('dom'); // #endif /** * DropDownPopup 下拉框 * @description 下拉筛选框 * @tutorial https://ext.dcloud.net.cn/plugin?name=uv-drop-down * @property {String | Number} name 字段标识 * @property {String | Number} zIndex 弹出层的层级 * @property {String | Number} opacity 遮罩层的透明度 * @property {Boolean} clickOverlayOnClose 是否允许点击遮罩层关闭弹窗 * @property {Object} currentDropItem 当前下拉筛选菜单对象 * @property {String} keyName 指定从当前下拉筛选菜单对象元素中读取哪个属性作为文本展示 */ export default { name: 'uv-drop-down-popup', mixins: [mpMixin, mixin], props: { sign: { type: [String, Number], default: 'UVDROPDOWN' }, zIndex: { type: [Number, String], default: 999 }, opacity: { type: [Number, String], default: 0.5 }, clickOverlayOnClose: { type: Boolean, default: true }, // 当前下拉选项对象 currentDropItem: { type: Object, default () { return { activeIndex: 0, child: [] } } }, keyName: { type: String, default: 'label' } }, data() { return { show: false, rect: {}, height: 0 } }, computed: { overlayStyle() { let { height = 0, top = 0 } = this.rect; // #ifdef H5 top += this.$uv.sys().windowTop; // #endif const style = { position: 'fixed', top: `${top+height}px`, left: 0, right: 0, zIndex: this.zIndex, bottom: 0, 'background-color': `rgba(0, 0, 0, ${this.opacity})` } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) }, list() { try { return Array.isArray(this.currentDropItem.child) ? this.currentDropItem.child : []; } catch (e) { return []; } }, getTextColor(index) { return index => { const active = this.currentDropItem.activeIndex == index; const color = this.currentDropItem.color; const activeColor = this.currentDropItem.activeColor; if (active) { return activeColor ? activeColor : '#3c9cff'; } return color ? color : '#333'; } }, getTextSize(index) { return index => { const active = this.currentDropItem.activeIndex == index; const size = this.currentDropItem.size; const activeSize = this.currentDropItem.activeSize; if (active) { return activeSize ? activeSize : '30rpx'; } return size ? size : '30rpx'; } }, itemCustomStyle() { return index => { const active = this.currentDropItem.activeIndex == index; const style = {}; if (active && this.currentDropItem.itemActiveCustomStyle) { return this.$uv.deepMerge(style, this.$uv.addStyle(this.currentDropItem.itemActiveCustomStyle)); } if (this.currentDropItem.itemCustomStyle) { return this.$uv.deepMerge(style, this.$uv.addStyle(this.currentDropItem.itemCustomStyle)) } return style; } } }, created() { this.init(); }, methods: { blockClick() {}, clickHandler(item, index) { this.currentDropItem.activeIndex = index; this.$emit('clickItem', item); this.close(); }, init() { uni.$off(`${this.sign}_GETRECT`); uni.$on(`${this.sign}_GETRECT`, rect => { this.rect = rect; }) uni.$off(`${this.sign}_CLICKMENU`); uni.$on(`${this.sign}_CLICKMENU`, async res => { if (res.show) { this.open(); } else { this.close(); } }) }, open() { this.show = true; this.$nextTick(async () => { // #ifndef H5 || MP-WEIXIN await this.$uv.sleep(60); // #endif const res = await this.queryRect(); // #ifndef APP-NVUE this.height = res.height; // #endif // #ifdef APP-NVUE this.animation(res.height); // #endif this.$emit('popupChange', { show: true }); }) }, close() { if(!this.show) return; this.height = 0; // #ifndef APP-NVUE this.height = 0; // #endif // #ifdef APP-NVUE this.animation(0); // #endif this.show = false; uni.$emit(`${this.sign}_CLOSEPOPUP`); this.$emit('popupChange', { show: false }); }, clickOverlay() { if (this.clickOverlayOnClose) { this.close(); } }, // 查询内容高度 queryRect() { // #ifndef APP-NVUE // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同 return new Promise(resolve => { this.$uvGetRect(`.uv-dp__container__list`).then(size => { resolve(size) }) }) // #endif // #ifdef APP-NVUE // nvue下,使用dom模块查询元素高度 // 返回一个promise,让调用此方法的主体能使用then回调 return new Promise(resolve => { dom.getComponentRect(this.$refs.uvDPList, res => { resolve(res.size) }) }) // #endif }, // nvue下设置高度 animation(height, duration = 200) { // #ifdef APP-NVUE const ref = this.$refs['uvDPContainer']; animation.transition(ref, { styles: { height: `${height}px` }, duration }) // #endif } } } </script> <style scoped lang="scss"> .uv-dp__container { /* #ifndef APP-NVUE */ overflow: hidden; transition: all .15s; /* #endif */ background-color: #fff; } .uv-dp__container__list { &--item { padding: 20rpx 60rpx; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-drop-down/components/uv-drop-down-popup/uv-drop-down-popup.vue
Vue
unknown
6,389
export default { props: { // 内置图标名称,或图片路径,建议绝对路径 icon: { type: String, default: '' }, // 提示文字 text: { type: String, default: '' }, // 文字颜色 textColor: { type: String, default: '#c0c4cc' }, // 文字大小 textSize: { type: [String, Number], default: 14 }, // 图标的颜色 iconColor: { type: String, default: '#c0c4cc' }, // 图标的大小 iconSize: { type: [String, Number], default: 90 }, // 选择预置的图标类型 mode: { type: String, default: 'data' }, // 图标宽度,单位px width: { type: [String, Number], default: 160 }, // 图标高度,单位px height: { type: [String, Number], default: 160 }, // 是否显示组件 show: { type: Boolean, default: true }, // 组件距离上一个元素之间的距离,默认px单位 marginTop: { type: [String, Number], default: 0 }, ...uni.$uv?.props?.empty } }
2301_77169380/AppruanjianApk
uni_modules/uv-empty/components/uv-empty/props.js
JavaScript
unknown
1,013
<template> <view class="uv-empty" :style="[emptyStyle]" v-if="show" > <uv-icon v-if="!isImg" :name="mode === 'message' ? 'chat' : `empty-${mode}`" :size="iconSize" :color="iconColor" margin-top="14" ></uv-icon> <image v-else :style="{ width: $uv.addUnit(width), height: $uv.addUnit(height) }" :src="icon" mode="widthFix" ></image> <text class="uv-empty__text" :style="[textStyle]" >{{text ? text : icons[mode]}}</text> <view class="uv-empty__wrap"> <slot /> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * empty 内容为空 * @description 该组件用于需要加载内容,但是加载的第一页数据就为空,提示一个"没有内容"的场景, 我们精心挑选了十几个场景的图标,方便您使用。 * @tutorial https://www.uvui.cn/components/empty.html * @property {String} icon 内置图标名称,或图片路径,建议绝对路径 * @property {String} text 提示文字 * @property {String} textColor 文字颜色 (默认 '#c0c4cc' ) * @property {String | Number} textSize 文字大小 (默认 14 ) * @property {String} iconColor 图标的颜色 (默认 '#c0c4cc' ) * @property {String | Number} iconSize 图标的大小 (默认 90 ) * @property {String} mode 选择预置的图标类型 (默认 'data' ) * @property {String | Number} width 图标宽度,单位px (默认 160 ) * @property {String | Number} height 图标高度,单位px (默认 160 ) * @property {Boolean} show 是否显示组件 (默认 true ) * @property {String | Number} marginTop 组件距离上一个元素之间的距离,默认px单位 (默认 0 ) * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function} click 点击组件时触发 * @event {Function} close 点击关闭按钮时触发 * @example <uv-empty text="所谓伊人,在水一方" mode="list"></uv-empty> */ export default { name: "uv-empty", mixins: [mpMixin, mixin, props], data() { return { icons: { car: '购物车为空', page: '页面不存在', search: '没有搜索结果', address: '没有收货地址', 'wifi-off': '没有WiFi', order: '订单为空', coupon: '没有优惠券', favor: '暂无收藏', permission: '无权限', history: '无历史记录', news: '无新闻列表', message: '消息列表为空', list: '列表为空', data: '数据为空', comment: '暂无评论', } } }, computed: { // 组件样式 emptyStyle() { const style = {} style.marginTop = this.$uv.addUnit(this.marginTop) // 合并customStyle样式,此参数通过mixin中的props传递 return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) }, // 文本样式 textStyle() { const style = {} style.color = this.textColor style.fontSize = this.$uv.addUnit(this.textSize) return style }, // 判断icon是否图片路径 isImg() { const isBase64 = this.icon.indexOf('data:') > -1 && this.icon.indexOf('base64') > -1; return this.icon.indexOf('/') !== -1 || isBase64; } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; $uv-empty-text-margin-top: 20rpx !default; $uv-empty-slot-margin-top: 20rpx !default; .uv-empty { @include flex; flex-direction: column; justify-content: center; align-items: center; &__text { @include flex; justify-content: center; align-items: center; margin-top: $uv-empty-text-margin-top; } } .uv-slot-wrap { @include flex; justify-content: center; align-items: center; margin-top: $uv-empty-slot-margin-top; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-empty/components/uv-empty/uv-empty.vue
Vue
unknown
3,954
export default { props: { // 当前form的需要验证字段的集合 model: { type: Object, default: () => ({}) }, // 验证规则 rules: { type: [Object, Function, Array], default: () => ({}) }, // 有错误时的提示方式,message-提示信息,toast-进行toast提示 // border-bottom-下边框呈现红色,none-无提示 errorType: { type: String, default: 'message' }, // 是否显示表单域的下划线边框 borderBottom: { type: Boolean, default: true }, // label的位置,left-左边,top-上边 labelPosition: { type: String, default: 'left' }, // label的宽度,单位px labelWidth: { type: [String, Number], default: 45 }, // lable字体的对齐方式 labelAlign: { type: String, default: 'left' }, // lable的样式,对象形式 labelStyle: { type: Object, default: () => ({}) }, ...uni.$uv?.props?.form } }
2301_77169380/AppruanjianApk
uni_modules/uv-form/components/uv-form/props.js
JavaScript
unknown
940
<template> <view class="uv-form"> <slot /> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from "./props.js"; import Schema from "./valid.js"; // 去除警告信息 Schema.warning = function() {}; /** * Form 表单 * @description 此组件一般用于表单场景,可以配置Input输入框,Select弹出框,进行表单验证等。 * @tutorial https://www.uvui.cn/components/form.html * @property {Object} model 当前form的需要验证字段的集合 * @property {Object | Function | Array} rules 验证规则 * @property {String} errorType 错误的提示方式,见上方说明 ( 默认 message ) * @property {Boolean} borderBottom 是否显示表单域的下划线边框 ( 默认 true ) * @property {String} labelPosition 表单域提示文字的位置,left-左侧,top-上方 ( 默认 'left' ) * @property {String | Number} labelWidth 提示文字的宽度,单位px ( 默认 45 ) * @property {String} labelAlign lable字体的对齐方式 ( 默认 ‘left' ) * @property {Object} labelStyle lable的样式,对象形式 * @example <uv-form labelPosition="left" :model="model1" :rules="rules" ref="form1"></uv-form> */ export default { name: "uv-form", mixins: [mpMixin, mixin, props], provide() { return { uForm: this, }; }, data() { return { formRules: {}, // 规则校验器 validator: {}, // 原始的model快照,用于resetFields方法重置表单时使用 originalModel: null, }; }, watch: { // 监听规则的变化 rules: { immediate: true, handler(n) { this.setRules(n); }, }, // 监听属性的变化,通知子组件uv-form-item重新获取信息 propsChange(n) { if (this.children?.length) { this.children.map((child) => { // 判断子组件(uv-form-item)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值) typeof child.updateParentData == "function" && child.updateParentData(); }); } }, // 监听model的初始值作为重置表单的快照 model: { immediate: true, handler(n) { if (!this.originalModel) { this.originalModel = this.$uv.deepClone(n); } }, }, }, computed: { propsChange() { return [ this.errorType, this.borderBottom, this.labelPosition, this.labelWidth, this.labelAlign, this.labelStyle, ]; }, }, created() { // 存储当前form下的所有uv-form-item的实例 // 不能定义在data中,否则微信小程序会造成循环引用而报错 this.children = []; }, methods: { // 手动设置校验的规则,如果规则中有函数的话,微信小程序中会过滤掉,所以只能手动调用设置规则 setRules(rules) { // 判断是否有规则 if (Object.keys(rules).length === 0) return; if (process.env.NODE_ENV === 'development' && Object.keys(this.model).length === 0) { this.$uv.error('设置rules,model必须设置!如果已经设置,请刷新页面。'); return; }; this.formRules = rules; // 重新将规则赋予Validator this.validator = new Schema(rules); }, // 清空所有uv-form-item组件的内容,本质上是调用了uv-form-item组件中的resetField()方法 resetFields() { this.resetModel(); }, // 重置model为初始值的快照 resetModel(obj) { // 历遍所有uv-form-item,根据其prop属性,还原model的原始快照 this.children.map((child) => { const prop = child?.prop; const value = this.$uv.getProperty(this.originalModel, prop); this.$uv.setProperty(this.model, prop, value); }); }, // 清空校验结果 clearValidate(props) { props = [].concat(props); this.children.map((child) => { // 如果uv-form-item的prop在props数组中,则清除对应的校验结果信息 if (props[0] === undefined || props.includes(child.prop)) { child.message = null; } }); }, // 对部分表单字段进行校验 async validateField(value, callback, event = null) { // $nextTick是必须的,否则model的变更,可能会延后于此方法的执行 this.$nextTick(() => { // 校验错误信息,返回给回调方法,用于存放所有form-item的错误信息 const errorsRes = []; // 如果为字符串,转为数组 value = [].concat(value); // 历遍children所有子form-item this.children.map((child) => { // 用于存放form-item的错误信息 const childErrors = []; if (value.includes(child.prop)) { // 获取对应的属性,通过类似'a.b.c'的形式 const propertyVal = this.$uv.getProperty( this.model, child.prop ); // 属性链数组 const propertyChain = child.prop.split("."); const propertyName = propertyChain[propertyChain.length - 1]; const rule = this.formRules[child.prop]; // 如果不存在对应的规则,直接返回,否则校验器会报错 if (!rule) return; // rule规则可为数组形式,也可为对象形式,此处拼接成为数组 const rules = [].concat(rule); // 对rules数组进行校验 for (let i = 0; i < rules.length; i++) { const ruleItem = rules[i]; // 将uv-form-item的触发器转为数组形式 const trigger = [].concat(ruleItem?.trigger); // 如果是有传入触发事件,但是此form-item却没有配置此触发器的话,不执行校验操作 if (event && !trigger.includes(event)) continue; // 实例化校验对象,传入构造规则 const validator = new Schema({ [propertyName]: ruleItem, }); validator.validate({ [propertyName]: propertyVal, }, (errors, fields) => { if (this.$uv.test.array(errors)) { errorsRes.push(...errors); childErrors.push(...errors); } this.$nextTick(() => { child.message = childErrors[0]?.message ? childErrors[0]?.message : null; }) } ); } } }); // 执行回调函数 typeof callback === "function" && callback(errorsRes); }); }, // 校验全部数据 validate(callback) { return new Promise((resolve, reject) => { // $nextTick是必须的,否则model的变更,可能会延后于validate方法 this.$nextTick(() => { // 获取所有form-item的prop,交给validateField方法进行校验 const formItemProps = this.children.map( (item) => item.prop ); this.validateField(formItemProps, (errors) => { if (errors.length) { // 如果错误提示方式为toast,则进行提示 this.errorType === 'toast' && this.$uv.toast(errors[0].message) reject(errors) } else { resolve(true) } }); }); }); }, }, }; </script>
2301_77169380/AppruanjianApk
uni_modules/uv-form/components/uv-form/uv-form.vue
Vue
unknown
7,213
function _extends() { _extends = Object.assign || function (target) { for (let i = 1; i < arguments.length; i++) { const source = arguments[i] for (const key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key] } } } return target } return _extends.apply(this, arguments) } /* eslint no-console:0 */ const formatRegExp = /%[sdj%]/g let warning = function warning() {} // don't print warning message when in production env or node runtime if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV !== 'production' && typeof window !== 'undefined' && typeof document !== 'undefined') { warning = function warning(type, errors) { if (typeof console !== 'undefined' && console.warn) { if (errors.every((e) => typeof e === 'string')) { console.warn(type, errors) } } } } function convertFieldsError(errors) { if (!errors || !errors.length) return null const fields = {} errors.forEach((error) => { const { field } = error fields[field] = fields[field] || [] fields[field].push(error) }) return fields } function format() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key] } let i = 1 const f = args[0] const len = args.length if (typeof f === 'function') { return f.apply(null, args.slice(1)) } if (typeof f === 'string') { let str = String(f).replace(formatRegExp, (x) => { if (x === '%%') { return '%' } if (i >= len) { return x } switch (x) { case '%s': return String(args[i++]) case '%d': return Number(args[i++]) case '%j': try { return JSON.stringify(args[i++]) } catch (_) { return '[Circular]' } break default: return x } }) for (let arg = args[i]; i < len; arg = args[++i]) { str += ` ${arg}` } return str } return f } function isNativeStringType(type) { return type === 'string' || type === 'url' || type === 'hex' || type === 'email' || type === 'pattern' } function isEmptyValue(value, type) { if (value === undefined || value === null) { return true } if (type === 'array' && Array.isArray(value) && !value.length) { return true } if (isNativeStringType(type) && typeof value === 'string' && !value) { return true } return false } function asyncParallelArray(arr, func, callback) { const results = [] let total = 0 const arrLength = arr.length function count(errors) { results.push.apply(results, errors) total++ if (total === arrLength) { callback(results) } } arr.forEach((a) => { func(a, count) }) } function asyncSerialArray(arr, func, callback) { let index = 0 const arrLength = arr.length function next(errors) { if (errors && errors.length) { callback(errors) return } const original = index index += 1 if (original < arrLength) { func(arr[original], next) } else { callback([]) } } next([]) } function flattenObjArr(objArr) { const ret = [] Object.keys(objArr).forEach((k) => { ret.push.apply(ret, objArr[k]) }) return ret } function asyncMap(objArr, option, func, callback) { if (option.first) { const _pending = new Promise((resolve, reject) => { const next = function next(errors) { callback(errors) return errors.length ? reject({ errors, fields: convertFieldsError(errors) }) : resolve() } const flattenArr = flattenObjArr(objArr) asyncSerialArray(flattenArr, func, next) }) _pending.catch((e) => e) return _pending } let firstFields = option.firstFields || [] if (firstFields === true) { firstFields = Object.keys(objArr) } const objArrKeys = Object.keys(objArr) const objArrLength = objArrKeys.length let total = 0 const results = [] const pending = new Promise((resolve, reject) => { const next = function next(errors) { results.push.apply(results, errors) total++ if (total === objArrLength) { callback(results) return results.length ? reject({ errors: results, fields: convertFieldsError(results) }) : resolve() } } if (!objArrKeys.length) { callback(results) resolve() } objArrKeys.forEach((key) => { const arr = objArr[key] if (firstFields.indexOf(key) !== -1) { asyncSerialArray(arr, func, next) } else { asyncParallelArray(arr, func, next) } }) }) pending.catch((e) => e) return pending } function complementError(rule) { return function (oe) { if (oe && oe.message) { oe.field = oe.field || rule.fullField return oe } return { message: typeof oe === 'function' ? oe() : oe, field: oe.field || rule.fullField } } } function deepMerge(target, source) { if (source) { for (const s in source) { if (source.hasOwnProperty(s)) { const value = source[s] if (typeof value === 'object' && typeof target[s] === 'object') { target[s] = { ...target[s], ...value } } else { target[s] = value } } } } return target } /** * Rule for validating required fields. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function required(rule, value, source, errors, options, type) { if (rule.required && (!source.hasOwnProperty(rule.field) || isEmptyValue(value, type || rule.type))) { errors.push(format(options.messages.required, rule.fullField)) } } /** * Rule for validating whitespace. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function whitespace(rule, value, source, errors, options) { if (/^\s+$/.test(value) || value === '') { errors.push(format(options.messages.whitespace, rule.fullField)) } } /* eslint max-len:0 */ const pattern = { // http://emailregex.com/ email: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/, url: new RegExp( '^(?!mailto:)(?:(?:http|https|ftp)://|//)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-*)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$', 'i' ), hex: /^#?([a-f0-9]{6}|[a-f0-9]{3})$/i } var types = { integer: function integer(value) { return /^(-)?\d+$/.test(value); }, float: function float(value) { return /^(-)?\d+(\.\d+)?$/.test(value); }, array: function array(value) { return Array.isArray(value) }, regexp: function regexp(value) { if (value instanceof RegExp) { return true } try { return !!new RegExp(value) } catch (e) { return false } }, date: function date(value) { return typeof value.getTime === 'function' && typeof value.getMonth === 'function' && typeof value.getYear === 'function' }, number: function number(value) { if (isNaN(value)) { return false } // 修改源码,将字符串数值先转为数值 return typeof +value === 'number' }, object: function object(value) { return typeof value === 'object' && !types.array(value) }, method: function method(value) { return typeof value === 'function' }, email: function email(value) { return typeof value === 'string' && !!value.match(pattern.email) && value.length < 255 }, url: function url(value) { return typeof value === 'string' && !!value.match(pattern.url) }, hex: function hex(value) { return typeof value === 'string' && !!value.match(pattern.hex) } } /** * Rule for validating the type of a value. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function type(rule, value, source, errors, options) { if (rule.required && value === undefined) { required(rule, value, source, errors, options) return } const custom = ['integer', 'float', 'array', 'regexp', 'object', 'method', 'email', 'number', 'date', 'url', 'hex'] const ruleType = rule.type if (custom.indexOf(ruleType) > -1) { if (!types[ruleType](value)) { errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type)) } // straight typeof check } else if (ruleType && typeof value !== rule.type) { errors.push(format(options.messages.types[ruleType], rule.fullField, rule.type)) } } /** * Rule for validating minimum and maximum allowed values. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function range(rule, value, source, errors, options) { const len = typeof rule.len === 'number' const min = typeof rule.min === 'number' const max = typeof rule.max === 'number' // 正则匹配码点范围从U+010000一直到U+10FFFF的文字(补充平面Supplementary Plane) const spRegexp = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g let val = value let key = null const num = typeof value === 'number' const str = typeof value === 'string' const arr = Array.isArray(value) if (num) { key = 'number' } else if (str) { key = 'string' } else if (arr) { key = 'array' } // if the value is not of a supported type for range validation // the validation rule rule should use the // type property to also test for a particular type if (!key) { return false } if (arr) { val = value.length } if (str) { // 处理码点大于U+010000的文字length属性不准确的bug,如"𠮷𠮷𠮷".lenght !== 3 val = value.replace(spRegexp, '_').length } if (len) { if (val !== rule.len) { errors.push(format(options.messages[key].len, rule.fullField, rule.len)) } } else if (min && !max && val < rule.min) { errors.push(format(options.messages[key].min, rule.fullField, rule.min)) } else if (max && !min && val > rule.max) { errors.push(format(options.messages[key].max, rule.fullField, rule.max)) } else if (min && max && (val < rule.min || val > rule.max)) { errors.push(format(options.messages[key].range, rule.fullField, rule.min, rule.max)) } } const ENUM = 'enum' /** * Rule for validating a value exists in an enumerable list. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function enumerable(rule, value, source, errors, options) { rule[ENUM] = Array.isArray(rule[ENUM]) ? rule[ENUM] : [] if (rule[ENUM].indexOf(value) === -1) { errors.push(format(options.messages[ENUM], rule.fullField, rule[ENUM].join(', '))) } } /** * Rule for validating a regular expression pattern. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param source The source object being validated. * @param errors An array of errors that this rule may add * validation errors to. * @param options The validation options. * @param options.messages The validation messages. */ function pattern$1(rule, value, source, errors, options) { if (rule.pattern) { if (rule.pattern instanceof RegExp) { // if a RegExp instance is passed, reset `lastIndex` in case its `global` // flag is accidentally set to `true`, which in a validation scenario // is not necessary and the result might be misleading rule.pattern.lastIndex = 0 if (!rule.pattern.test(value)) { errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern)) } } else if (typeof rule.pattern === 'string') { const _pattern = new RegExp(rule.pattern) if (!_pattern.test(value)) { errors.push(format(options.messages.pattern.mismatch, rule.fullField, value, rule.pattern)) } } } } const rules = { required, whitespace, type, range, enum: enumerable, pattern: pattern$1 } /** * Performs validation for string types. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function string(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value, 'string') && !rule.required) { return callback() } rules.required(rule, value, source, errors, options, 'string') if (!isEmptyValue(value, 'string')) { rules.type(rule, value, source, errors, options) rules.range(rule, value, source, errors, options) rules.pattern(rule, value, source, errors, options) if (rule.whitespace === true) { rules.whitespace(rule, value, source, errors, options) } } } callback(errors) } /** * Validates a function. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function method(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (value !== undefined) { rules.type(rule, value, source, errors, options) } } callback(errors) } /** * Validates a number. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function number(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (value === '') { value = undefined } if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (value !== undefined) { rules.type(rule, value, source, errors, options) rules.range(rule, value, source, errors, options) } } callback(errors) } /** * Validates a boolean. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function _boolean(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (value !== undefined) { rules.type(rule, value, source, errors, options) } } callback(errors) } /** * Validates the regular expression type. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function regexp(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (!isEmptyValue(value)) { rules.type(rule, value, source, errors, options) } } callback(errors) } /** * Validates a number is an integer. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function integer(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (value !== undefined) { rules.type(rule, value, source, errors, options) rules.range(rule, value, source, errors, options) } } callback(errors) } /** * Validates a number is a floating point number. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function floatFn(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (value !== undefined) { rules.type(rule, value, source, errors, options) rules.range(rule, value, source, errors, options) } } callback(errors) } /** * Validates an array. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function array(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value, 'array') && !rule.required) { return callback() } rules.required(rule, value, source, errors, options, 'array') if (!isEmptyValue(value, 'array')) { rules.type(rule, value, source, errors, options) rules.range(rule, value, source, errors, options) } } callback(errors) } /** * Validates an object. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function object(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (value !== undefined) { rules.type(rule, value, source, errors, options) } } callback(errors) } const ENUM$1 = 'enum' /** * Validates an enumerable list. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function enumerable$1(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (value !== undefined) { rules[ENUM$1](rule, value, source, errors, options) } } callback(errors) } /** * Validates a regular expression pattern. * * Performs validation when a rule only contains * a pattern property but is not declared as a string type. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function pattern$2(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value, 'string') && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (!isEmptyValue(value, 'string')) { rules.pattern(rule, value, source, errors, options) } } callback(errors) } function date(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) if (!isEmptyValue(value)) { let dateObject if (typeof value === 'number') { dateObject = new Date(value) } else { dateObject = value } rules.type(rule, dateObject, source, errors, options) if (dateObject) { rules.range(rule, dateObject.getTime(), source, errors, options) } } } callback(errors) } function required$1(rule, value, callback, source, options) { const errors = [] const type = Array.isArray(value) ? 'array' : typeof value rules.required(rule, value, source, errors, options, type) callback(errors) } function type$1(rule, value, callback, source, options) { const ruleType = rule.type const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value, ruleType) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options, ruleType) if (!isEmptyValue(value, ruleType)) { rules.type(rule, value, source, errors, options) } } callback(errors) } /** * Performs validation for any type. * * @param rule The validation rule. * @param value The value of the field on the source object. * @param callback The callback function. * @param source The source object being validated. * @param options The validation options. * @param options.messages The validation messages. */ function any(rule, value, callback, source, options) { const errors = [] const validate = rule.required || !rule.required && source.hasOwnProperty(rule.field) if (validate) { if (isEmptyValue(value) && !rule.required) { return callback() } rules.required(rule, value, source, errors, options) } callback(errors) } const validators = { string, method, number, boolean: _boolean, regexp, integer, float: floatFn, array, object, enum: enumerable$1, pattern: pattern$2, date, url: type$1, hex: type$1, email: type$1, required: required$1, any } function newMessages() { return { default: 'Validation error on field %s', required: '%s is required', enum: '%s must be one of %s', whitespace: '%s cannot be empty', date: { format: '%s date %s is invalid for format %s', parse: '%s date could not be parsed, %s is invalid ', invalid: '%s date %s is invalid' }, types: { string: '%s is not a %s', method: '%s is not a %s (function)', array: '%s is not an %s', object: '%s is not an %s', number: '%s is not a %s', date: '%s is not a %s', boolean: '%s is not a %s', integer: '%s is not an %s', float: '%s is not a %s', regexp: '%s is not a valid %s', email: '%s is not a valid %s', url: '%s is not a valid %s', hex: '%s is not a valid %s' }, string: { len: '%s must be exactly %s characters', min: '%s must be at least %s characters', max: '%s cannot be longer than %s characters', range: '%s must be between %s and %s characters' }, number: { len: '%s must equal %s', min: '%s cannot be less than %s', max: '%s cannot be greater than %s', range: '%s must be between %s and %s' }, array: { len: '%s must be exactly %s in length', min: '%s cannot be less than %s in length', max: '%s cannot be greater than %s in length', range: '%s must be between %s and %s in length' }, pattern: { mismatch: '%s value %s does not match pattern %s' }, clone: function clone() { const cloned = JSON.parse(JSON.stringify(this)) cloned.clone = this.clone return cloned } } } const messages = newMessages() /** * Encapsulates a validation schema. * * @param descriptor An object declaring validation rules * for this schema. */ function Schema(descriptor) { this.rules = null this._messages = messages this.define(descriptor) } Schema.prototype = { messages: function messages(_messages) { if (_messages) { this._messages = deepMerge(newMessages(), _messages) } return this._messages }, define: function define(rules) { if (!rules) { throw new Error('Cannot configure a schema with no rules') } if (typeof rules !== 'object' || Array.isArray(rules)) { throw new Error('Rules must be an object') } this.rules = {} let z let item for (z in rules) { if (rules.hasOwnProperty(z)) { item = rules[z] this.rules[z] = Array.isArray(item) ? item : [item] } } }, validate: function validate(source_, o, oc) { const _this = this if (o === void 0) { o = {} } if (oc === void 0) { oc = function oc() {} } let source = source_ let options = o let callback = oc if (typeof options === 'function') { callback = options options = {} } if (!this.rules || Object.keys(this.rules).length === 0) { if (callback) { callback() } return Promise.resolve() } function complete(results) { let i let errors = [] let fields = {} function add(e) { if (Array.isArray(e)) { let _errors errors = (_errors = errors).concat.apply(_errors, e) } else { errors.push(e) } } for (i = 0; i < results.length; i++) { add(results[i]) } if (!errors.length) { errors = null fields = null } else { fields = convertFieldsError(errors) } callback(errors, fields) } if (options.messages) { let messages$1 = this.messages() if (messages$1 === messages) { messages$1 = newMessages() } deepMerge(messages$1, options.messages) options.messages = messages$1 } else { options.messages = this.messages() } let arr let value const series = {} const keys = options.keys || Object.keys(this.rules) keys.forEach((z) => { arr = _this.rules[z] value = source[z] arr.forEach((r) => { let rule = r if (typeof rule.transform === 'function') { if (source === source_) { source = { ...source } } value = source[z] = rule.transform(value) } if (typeof rule === 'function') { rule = { validator: rule } } else { rule = { ...rule } } rule.validator = _this.getValidationMethod(rule) rule.field = z rule.fullField = rule.fullField || z rule.type = _this.getType(rule) if (!rule.validator) { return } series[z] = series[z] || [] series[z].push({ rule, value, source, field: z }) }) }) const errorFields = {} return asyncMap(series, options, (data, doIt) => { const { rule } = data let deep = (rule.type === 'object' || rule.type === 'array') && (typeof rule.fields === 'object' || typeof rule.defaultField === 'object') deep = deep && (rule.required || !rule.required && data.value) rule.field = data.field function addFullfield(key, schema) { return { ...schema, fullField: `${rule.fullField}.${key}` } } function cb(e) { if (e === void 0) { e = [] } let errors = e if (!Array.isArray(errors)) { errors = [errors] } if (!options.suppressWarning && errors.length) { Schema.warning('async-validator:', errors) } if (errors.length && rule.message) { errors = [].concat(rule.message) } errors = errors.map(complementError(rule)) if (options.first && errors.length) { errorFields[rule.field] = 1 return doIt(errors) } if (!deep) { doIt(errors) } else { // if rule is required but the target object // does not exist fail at the rule level and don't // go deeper if (rule.required && !data.value) { if (rule.message) { errors = [].concat(rule.message).map(complementError(rule)) } else if (options.error) { errors = [options.error(rule, format(options.messages.required, rule.field))] } else { errors = [] } return doIt(errors) } let fieldsSchema = {} if (rule.defaultField) { for (const k in data.value) { if (data.value.hasOwnProperty(k)) { fieldsSchema[k] = rule.defaultField } } } fieldsSchema = { ...fieldsSchema, ...data.rule.fields } for (const f in fieldsSchema) { if (fieldsSchema.hasOwnProperty(f)) { const fieldSchema = Array.isArray(fieldsSchema[f]) ? fieldsSchema[f] : [fieldsSchema[f]] fieldsSchema[f] = fieldSchema.map(addFullfield.bind(null, f)) } } const schema = new Schema(fieldsSchema) schema.messages(options.messages) if (data.rule.options) { data.rule.options.messages = options.messages data.rule.options.error = options.error } schema.validate(data.value, data.rule.options || options, (errs) => { const finalErrors = [] if (errors && errors.length) { finalErrors.push.apply(finalErrors, errors) } if (errs && errs.length) { finalErrors.push.apply(finalErrors, errs) } doIt(finalErrors.length ? finalErrors : null) }) } } let res if (rule.asyncValidator) { res = rule.asyncValidator(rule, data.value, cb, data.source, options) } else if (rule.validator) { res = rule.validator(rule, data.value, cb, data.source, options) if (res === true) { cb() } else if (res === false) { cb(rule.message || `${rule.field} fails`) } else if (res instanceof Array) { cb(res) } else if (res instanceof Error) { cb(res.message) } } if (res && res.then) { res.then(() => cb(), (e) => cb(e)) } }, (results) => { complete(results) }) }, getType: function getType(rule) { if (rule.type === undefined && rule.pattern instanceof RegExp) { rule.type = 'pattern' } if (typeof rule.validator !== 'function' && rule.type && !validators.hasOwnProperty(rule.type)) { throw new Error(format('Unknown rule type %s', rule.type)) } return rule.type || 'string' }, getValidationMethod: function getValidationMethod(rule) { if (typeof rule.validator === 'function') { return rule.validator } const keys = Object.keys(rule) const messageIndex = keys.indexOf('message') if (messageIndex !== -1) { keys.splice(messageIndex, 1) } if (keys.length === 1 && keys[0] === 'required') { return validators.required } return validators[this.getType(rule)] || false } } Schema.register = function register(type, validator) { if (typeof validator !== 'function') { throw new Error('Cannot register a validator by type, validator is not a function') } validators[type] = validator } Schema.warning = warning Schema.messages = messages export default Schema // # sourceMappingURL=index.js.map
2301_77169380/AppruanjianApk
uni_modules/uv-form/components/uv-form/valid.js
JavaScript
unknown
38,962
export default { props: { // input的label提示语 label: { type: String, default: '' }, // 绑定的值 prop: { type: String, default: '' }, // 是否显示表单域的下划线边框 borderBottom: { type: [Boolean], default: false }, // label的位置,left-左边,top-上边 labelPosition: { type: String, default: '' }, // label的宽度,单位px labelWidth: { type: [String, Number], default: '' }, // 右侧图标 rightIcon: { type: String, default: '' }, // 左侧图标 leftIcon: { type: String, default: '' }, // 是否显示左边的必填星号,只作显示用,具体校验必填的逻辑,请在rules中配置 required: { type: Boolean, default: false }, leftIconStyle: { type: [String, Object], default: '' }, ...uni.$uv?.props?.formItem } }
2301_77169380/AppruanjianApk
uni_modules/uv-form/components/uv-form-item/props.js
JavaScript
unknown
875
<template> <view class="uv-form-item"> <view class="uv-form-item__body" @tap="clickHandler" :style="[$uv.addStyle(customStyle), { flexDirection: (labelPosition || parentData.labelPosition) === 'left' ? 'row' : 'column' }]" > <!-- 微信小程序中,将一个参数设置空字符串,结果会变成字符串"true" --> <slot name="label"> <view class="uv-form-item__body__left" v-if="required || leftIcon || label" :style="{ width: $uv.addUnit(labelWidth || parentData.labelWidth), marginBottom: parentData.labelPosition === 'left' ? 0 : '5px', }" > <!-- 为了块对齐 --> <view class="uv-form-item__body__left__content"> <!-- nvue不支持伪元素before --> <text v-if="required" class="uv-form-item__body__left__content__required" >*</text> <view class="uv-form-item__body__left__content__icon" v-if="leftIcon" > <uv-icon :name="leftIcon" :custom-style="leftIconStyle" ></uv-icon> </view> <text class="uv-form-item__body__left__content__label" :style="[parentData.labelStyle, { justifyContent: parentData.labelAlign === 'left' ? 'flex-start' : parentData.labelAlign === 'center' ? 'center' : 'flex-end' }]" >{{ label }}</text> </view> </view> </slot> <view class="uv-form-item__body__right"> <view class="uv-form-item__body__right__content"> <view class="uv-form-item__body__right__content__slot"> <slot /> </view> <view class="item__body__right__content__icon"> <slot name="right" /> </view> </view> </view> </view> <slot name="error"> <uv-transition :show="true" :duration="100" mode="fade" v-if="!!message && parentData.errorType === 'message'" > <text class="uv-form-item__body__right__message" :style="{ marginLeft: $uv.addUnit(parentData.labelPosition === 'top' ? 0 : (labelWidth || parentData.labelWidth)) }" >{{ message }}</text> </uv-transition> </slot> <uv-line v-if="borderBottom" :color="message && parentData.errorType === 'border-bottom' ? '#f56c6c' : '#d6d7d9'" ></uv-line> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * Form 表单 * @description 此组件一般用于表单场景,可以配置Input输入框,Select弹出框,进行表单验证等。 * @tutorial https://www.uvui.cn/components/form.html * @property {String} label input的label提示语 * @property {String} prop 绑定的值 * @property {String | Boolean} borderBottom 是否显示表单域的下划线边框 * @property {String | Number} labelWidth label的宽度,单位px * @property {String} rightIcon 右侧图标 * @property {String} leftIcon 左侧图标 * @property {String | Object} leftIconStyle 左侧图标的样式 * @property {Boolean} required 是否显示左边的必填星号,只作显示用,具体校验必填的逻辑,请在rules中配置 (默认 false ) * * @example <uv-form-item label="姓名" prop="userInfo.name" borderBottom ref="item1"></uv-form-item> */ export default { name: 'uv-form-item', emits: ['click'], mixins: [mpMixin, mixin, props], data() { return { // 错误提示语 message: '', parentData: { // 提示文本的位置 labelPosition: 'left', // 提示文本对齐方式 labelAlign: 'left', // 提示文本的样式 labelStyle: {}, // 提示文本的宽度 labelWidth: 45, // 错误提示方式 errorType: 'message' } } }, created() { this.init() }, methods: { init() { // 父组件的实例 this.updateParentData() if (!this.parent) { this.$uv.error('uv-form-item需要结合uv-form组件使用') } }, // 获取父组件的参数 updateParentData() { // 此方法写在mixin中 this.getParentData('uv-form'); }, // 移除uv-form-item的校验结果 clearValidate() { this.message = null }, // 清空当前的组件的校验结果,并重置为初始值 resetField() { // 找到原始值 const value = this.$uv.getProperty(this.parent.originalModel, this.prop) // 将uv-form的model的prop属性链还原原始值 this.$uv.setProperty(this.parent.model, this.prop, value) // 移除校验结果 this.message = null }, // 点击组件 clickHandler() { this.$emit('click') } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-form-item { @include flex(column); font-size: 14px; color: $uv-main-color; &__body { @include flex; padding: 10px 0; &__left { @include flex; align-items: center; &__content { position: relative; @include flex; align-items: center; padding-right: 10rpx; flex: 1; &__icon { margin-right: 8rpx; } &__required { position: absolute; left: -9px; color: $uv-error; line-height: 20px; font-size: 20px; top: 3px; } &__label { @include flex; align-items: center; flex: 1; color: $uv-main-color; font-size: 15px; } } } &__right { flex: 1; &__content { @include flex; align-items: center; flex: 1; &__slot { flex: 1; /* #ifndef MP */ @include flex; align-items: center; /* #endif */ } &__icon { margin-left: 10rpx; color: $uv-light-color; font-size: 30rpx; } } &__message__box { height: 16px; line-height: 16px; } &__message { margin-top: -6px; line-height: 24px; font-size: 12px; color: $uv-error; } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-form/components/uv-form-item/uv-form-item.vue
Vue
unknown
6,046
export default { props: { // 背景颜色(默认transparent) bgColor: { type: String, default: 'transparent' }, // 分割槽高度,单位px(默认20) height: { type: [String, Number], default: 20 }, // 与上一个组件的距离 marginTop: { type: [String, Number], default: 0 }, // 与下一个组件的距离 marginBottom: { type: [String, Number], default: 0 }, ...uni.$uv?.props?.gap } }
2301_77169380/AppruanjianApk
uni_modules/uv-gap/components/uv-gap/props.js
JavaScript
unknown
454
<template> <view class="uv-gap" :style="[gapStyle]"></view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * gap 间隔槽 * @description 该组件一般用于内容块之间的用一个灰色块隔开的场景,方便用户风格统一,减少工作量 * @tutorial https://www.uvui.cn/components/gap.html * @property {String} bgColor 背景颜色 (默认 'transparent' ) * @property {String | Number} height 分割槽高度,单位px (默认 20 ) * @property {String | Number} marginTop 与前一个组件的距离,单位px( 默认 0 ) * @property {String | Number} marginBottom 与后一个组件的距离,单位px (默认 0 ) * @property {Object} customStyle 定义需要用到的外部样式 * * @example <uv-gap height="80" bg-color="#bbb"></uv-gap> */ export default { name: "uv-gap", mixins: [mpMixin, mixin,props], computed: { gapStyle() { const style = { backgroundColor: this.bgColor, height: this.$uv.addUnit(this.height), marginTop: this.$uv.addUnit(this.marginTop), marginBottom: this.$uv.addUnit(this.marginBottom), } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } } }; </script>
2301_77169380/AppruanjianApk
uni_modules/uv-gap/components/uv-gap/uv-gap.vue
Vue
unknown
1,375
export default { props: { // 分成几列 col: { type: [String, Number], default: 3 }, // 是否显示边框 border: { type: Boolean, default: false }, // 宫格对齐方式,表现为数量少的时候,靠左,居中,还是靠右 align: { type: String, default: 'left' }, ...uni.$uv?.props?.grid } }
2301_77169380/AppruanjianApk
uni_modules/uv-grid/components/uv-grid/props.js
JavaScript
unknown
346
<template> <view class="uv-grid" ref='uv-grid' :style="[gridStyle]" > <slot /> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * grid 宫格布局 * @description 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式。 * @tutorial https://www.uvui.cn/components/grid.html * @property {String | Number} col 宫格的列数(默认 3 ) * @property {Boolean} border 是否显示宫格的边框(默认 false ) * @property {String} align 宫格对齐方式,表现为数量少的时候,靠左,居中,还是靠右 (默认 'left' ) * @property {Object} customStyle 定义需要用到的外部样式 * @event {Function} click 点击宫格触发 * @example <uv-grid :col="3" @click="click"></uv-grid> */ export default { name: 'uv-grid', mixins: [mpMixin, mixin, props], emits: ['click'], data() { return { index: 0, width: 0 } }, watch: { // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件 parentData() { if (this.children.length) { this.children.map(child => { // 判断子组件(uv-radio)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值) typeof(child.updateParentData) == 'function' && child.updateParentData(); }) } }, }, created() { // 如果将children定义在data中,在微信小程序会造成循环引用而报错 this.children = [] }, computed: { // 计算父组件的值是否发生变化 parentData() { return [this.hoverClass, this.col, this.size, this.border]; }, // 宫格对齐方式 gridStyle() { let style = {}; switch (this.align) { case 'left': style.justifyContent = 'flex-start'; break; case 'center': style.justifyContent = 'center'; break; case 'right': style.justifyContent = 'flex-end'; break; default: style.justifyContent = 'flex-start'; }; return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)); } }, methods: { // 此方法由uv-grid-item触发,用于在uv-grid发出事件 childClick(name) { this.$emit('click', name) } } }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; $uv-grid-width:100% !default; .uv-grid { /* #ifdef MP */ width: $uv-grid-width; position: relative; box-sizing: border-box; overflow: hidden; display: block; /* #endif */ justify-content: center; @include flex; flex-wrap: wrap; align-items: center; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-grid/components/uv-grid/uv-grid.vue
Vue
unknown
2,919
export default { props: { // 宫格的name name: { type: [String, Number, null], default: null }, // 背景颜色 bgColor: { type: String, default: 'transparent' }, ...uni.$uv?.props?.gridItem } }
2301_77169380/AppruanjianApk
uni_modules/uv-grid/components/uv-grid-item/props.js
JavaScript
unknown
224
<template> <!-- #ifndef APP-NVUE --> <view class="uv-grid-item" hover-class="uv-grid-item--hover-class" :hover-stay-time="200" @tap="clickHandler" :class="classes" :style="[itemStyle]" > <slot /> </view> <!-- #endif --> <!-- #ifdef APP-NVUE --> <view class="uv-grid-item" :hover-stay-time="200" @tap="clickHandler" :class="classes" :style="[itemStyle]" > <slot /> </view> <!-- #endif --> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * gridItem 提示 * @description 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式。搭配uv-grid使用 * @tutorial https://www.uvui.cn/components/grid.html * @property {String | Number} name 宫格的name ( 默认 null ) * @property {String} bgColor 宫格的背景颜色 (默认 'transparent' ) * @property {Object} customStyle 自定义样式,对象形式 * @event {Function} click 点击宫格触发 * @example <uv-grid-item></uv-grid-item> */ export default { name: "uv-grid-item", mixins: [mpMixin, mixin, props], emits: ['$uvGridItem','click'], data() { return { parentData: { col: 3, // 父组件划分的宫格数 border: true, // 是否显示边框,根据父组件决定 }, // #ifdef APP-NVUE width: 0, // nvue下才这么计算,vue下放到computed中,否则会因为延时造成闪烁 // #endif classes: [], // 类名集合,用于判断是否显示右边和下边框 }; }, created() { // 父组件的实例 this.updateParentData() }, mounted() { this.init() }, computed: { // #ifndef APP-NVUE // vue下放到computed中,否则会因为延时造成闪烁 width() { return 100 / Number(this.parentData.col) + '%' }, // #endif itemStyle() { const style = { background: this.bgColor, width: this.width } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } }, methods: { init() { // 用于在父组件uv-grid的children中被添加入子组件时, // 重新计算item的边框 uni.$on('$uvGridItem', () => { this.gridItemClasses() }) // #ifdef APP-NVUE // 获取元素该有的长度,nvue下要延时才准确 this.$nextTick(function(){ this.getItemWidth() }) // #endif // 发出事件,通知所有的grid-item都重新计算自己的边框 uni.$emit('$uvGridItem') this.gridItemClasses() }, // 获取父组件的参数 updateParentData() { // 此方法写在mixin中 this.getParentData('uv-grid'); }, clickHandler() { let name = this.name // 如果没有设置name属性,历遍父组件的children数组,判断当前的元素是否和本实例this相等,找出当前组件的索引 const children = this.parent?.children if(children && this.name === null) { name = children.findIndex(child => child === this) } // 调用父组件方法,发出事件 this.parent && this.parent.childClick(name) this.$emit('click', name) }, async getItemWidth() { // 如果是nvue,不能使用百分比,只能使用固定宽度 let width = 0 if(this.parent) { // 获取父组件宽度后,除以栅格数,得出每个item的宽度 const parentWidth = await this.getParentWidth() width = parentWidth / Number(this.parentData.col) + 'px' } this.width = width }, // 获取父元素的尺寸 getParentWidth() { // #ifdef APP-NVUE // 返回一个promise,让调用者可以用await同步获取 const dom = uni.requireNativePlugin('dom') return new Promise(resolve => { // 调用父组件的ref dom.getComponentRect(this.parent.$refs['uv-grid'], res => { resolve(res.size.width) }) }) // #endif }, gridItemClasses() { if(this.parentData.border) { let classes = [] this.parent.children.map((child, index) =>{ if(this === child) { const len = this.parent.children.length // 贴近右边屏幕边沿的child,并且最后一个(比如只有横向2个的时候),无需右边框 if((index + 1) % this.parentData.col !== 0 && index + 1 !== len) { classes.push('uv-border-right') } // 总的宫格数量对列数取余的值 // 如果取余后,值为0,则意味着要将最后一排的宫格,都不需要下边框 const lessNum = len % this.parentData.col === 0 ? this.parentData.col : len % this.parentData.col // 最下面的一排child,无需下边框 if(index < len - lessNum) { classes.push('uv-border-bottom') } } }) // 支付宝,头条小程序无法动态绑定一个数组类名,否则解析出来的结果会带有",",而导致失效 // #ifdef MP-ALIPAY || MP-TOUTIAO classes = classes.join(' ') // #endif this.classes = classes } } }, // #ifdef VUE2 beforeDestroy() { // 移除事件监听,释放性能 uni.$off('$uvGridItem') }, // #endif // #ifdef VUE3 unmounted() { // 移除事件监听,释放性能 uni.$off('$uvGridItem') } // #endif }; </script> <style lang="scss" scoped> $show-border: 1; $show-border-right: 1; $show-border-bottom: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-grid-item-hover-class-opcatiy:.5 !default; $uv-grid-item-margin-top:1rpx !default; $uv-grid-item-border-right-width:0.5px !default; $uv-grid-item-border-bottom-width:0.5px !default; $uv-grid-item-border-right-color:$uv-border-color !default; $uv-grid-item-border-bottom-color:$uv-border-color !default; .uv-grid-item { align-items: center; justify-content: center; position: relative; flex-direction: column; /* #ifndef APP-NVUE */ box-sizing: border-box; display: flex; /* #endif */ /* #ifdef MP */ position: relative; float: left; /* #endif */ /* #ifdef MP-WEIXIN */ margin-top:$uv-grid-item-margin-top; /* #endif */ &--hover-class { opacity:$uv-grid-item-hover-class-opcatiy; } } /* #ifdef APP-NVUE */ // 由于nvue不支持组件内引入app.vue中再引入的样式,所以需要写在这里 .uv-border-right { border-right-width:$uv-grid-item-border-right-width; border-color: $uv-grid-item-border-right-color; } .uv-border-bottom { border-bottom-width:$uv-grid-item-border-bottom-width; border-color:$uv-grid-item-border-bottom-color; } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-grid/components/uv-grid-item/uv-grid-item.vue
Vue
unknown
6,871
export default { 'uvicon-level': 'e68f', 'uvicon-checkbox-mark': 'e659', 'uvicon-folder': 'e694', 'uvicon-movie': 'e67c', 'uvicon-star-fill': 'e61e', 'uvicon-star': 'e618', 'uvicon-phone-fill': 'e6ac', 'uvicon-phone': 'e6ba', 'uvicon-apple-fill': 'e635', 'uvicon-backspace': 'e64d', 'uvicon-attach': 'e640', 'uvicon-empty-data': 'e671', 'uvicon-empty-address': 'e68a', 'uvicon-empty-favor': 'e662', 'uvicon-empty-car': 'e657', 'uvicon-empty-order': 'e66b', 'uvicon-empty-list': 'e672', 'uvicon-empty-search': 'e677', 'uvicon-empty-permission': 'e67d', 'uvicon-empty-news': 'e67e', 'uvicon-empty-history': 'e685', 'uvicon-empty-coupon': 'e69b', 'uvicon-empty-page': 'e60e', 'uvicon-empty-wifi-off': 'e6cc', 'uvicon-reload': 'e627', 'uvicon-order': 'e695', 'uvicon-server-man': 'e601', 'uvicon-search': 'e632', 'uvicon-more-dot-fill': 'e66f', 'uvicon-scan': 'e631', 'uvicon-map': 'e665', 'uvicon-map-fill': 'e6a8', 'uvicon-tags': 'e621', 'uvicon-tags-fill': 'e613', 'uvicon-eye': 'e664', 'uvicon-eye-fill': 'e697', 'uvicon-eye-off': 'e69c', 'uvicon-eye-off-outline': 'e688', 'uvicon-mic': 'e66d', 'uvicon-mic-off': 'e691', 'uvicon-calendar': 'e65c', 'uvicon-trash': 'e623', 'uvicon-trash-fill': 'e6ce', 'uvicon-play-left': 'e6bf', 'uvicon-play-right': 'e6b3', 'uvicon-minus': 'e614', 'uvicon-plus': 'e625', 'uvicon-info-circle': 'e69f', 'uvicon-info-circle-fill': 'e6a7', 'uvicon-question-circle': 'e622', 'uvicon-question-circle-fill': 'e6bc', 'uvicon-close': 'e65a', 'uvicon-checkmark': 'e64a', 'uvicon-checkmark-circle': 'e643', 'uvicon-checkmark-circle-fill': 'e668', 'uvicon-setting': 'e602', 'uvicon-setting-fill': 'e6d0', 'uvicon-heart': 'e6a2', 'uvicon-heart-fill': 'e68b', 'uvicon-camera': 'e642', 'uvicon-camera-fill': 'e650', 'uvicon-more-circle': 'e69e', 'uvicon-more-circle-fill': 'e684', 'uvicon-chat': 'e656', 'uvicon-chat-fill': 'e63f', 'uvicon-bag': 'e647', 'uvicon-error-circle': 'e66e', 'uvicon-error-circle-fill': 'e655', 'uvicon-close-circle': 'e64e', 'uvicon-close-circle-fill': 'e666', 'uvicon-share': 'e629', 'uvicon-share-fill': 'e6bb', 'uvicon-share-square': 'e6c4', 'uvicon-shopping-cart': 'e6cb', 'uvicon-shopping-cart-fill': 'e630', 'uvicon-bell': 'e651', 'uvicon-bell-fill': 'e604', 'uvicon-list': 'e690', 'uvicon-list-dot': 'e6a9', 'uvicon-zhifubao-circle-fill': 'e617', 'uvicon-weixin-circle-fill': 'e6cd', 'uvicon-weixin-fill': 'e620', 'uvicon-qq-fill': 'e608', 'uvicon-qq-circle-fill': 'e6b9', 'uvicon-moments-circel-fill': 'e6c2', 'uvicon-moments': 'e6a0', 'uvicon-car': 'e64f', 'uvicon-car-fill': 'e648', 'uvicon-warning-fill': 'e6c7', 'uvicon-warning': 'e6c1', 'uvicon-clock-fill': 'e64b', 'uvicon-clock': 'e66c', 'uvicon-edit-pen': 'e65d', 'uvicon-edit-pen-fill': 'e679', 'uvicon-email': 'e673', 'uvicon-email-fill': 'e683', 'uvicon-minus-circle': 'e6a5', 'uvicon-plus-circle': 'e603', 'uvicon-plus-circle-fill': 'e611', 'uvicon-file-text': 'e687', 'uvicon-file-text-fill': 'e67f', 'uvicon-pushpin': 'e6d1', 'uvicon-pushpin-fill': 'e6b6', 'uvicon-grid': 'e68c', 'uvicon-grid-fill': 'e698', 'uvicon-play-circle': 'e6af', 'uvicon-play-circle-fill': 'e62a', 'uvicon-pause-circle-fill': 'e60c', 'uvicon-pause': 'e61c', 'uvicon-pause-circle': 'e696', 'uvicon-gift-fill': 'e6b0', 'uvicon-gift': 'e680', 'uvicon-kefu-ermai': 'e660', 'uvicon-server-fill': 'e610', 'uvicon-coupon-fill': 'e64c', 'uvicon-coupon': 'e65f', 'uvicon-integral': 'e693', 'uvicon-integral-fill': 'e6b1', 'uvicon-home-fill': 'e68e', 'uvicon-home': 'e67b', 'uvicon-account': 'e63a', 'uvicon-account-fill': 'e653', 'uvicon-thumb-down-fill': 'e628', 'uvicon-thumb-down': 'e60a', 'uvicon-thumb-up': 'e612', 'uvicon-thumb-up-fill': 'e62c', 'uvicon-lock-fill': 'e6a6', 'uvicon-lock-open': 'e68d', 'uvicon-lock-opened-fill': 'e6a1', 'uvicon-lock': 'e69d', 'uvicon-red-packet': 'e6c3', 'uvicon-photo-fill': 'e6b4', 'uvicon-photo': 'e60d', 'uvicon-volume-off-fill': 'e6c8', 'uvicon-volume-off': 'e6bd', 'uvicon-volume-fill': 'e624', 'uvicon-volume': 'e605', 'uvicon-download': 'e670', 'uvicon-arrow-up-fill': 'e636', 'uvicon-arrow-down-fill': 'e638', 'uvicon-play-left-fill': 'e6ae', 'uvicon-play-right-fill': 'e6ad', 'uvicon-arrow-downward': 'e634', 'uvicon-arrow-leftward': 'e63b', 'uvicon-arrow-rightward': 'e644', 'uvicon-arrow-upward': 'e641', 'uvicon-arrow-down': 'e63e', 'uvicon-arrow-right': 'e63c', 'uvicon-arrow-left': 'e646', 'uvicon-arrow-up': 'e633', 'uvicon-skip-back-left': 'e6c5', 'uvicon-skip-forward-right': 'e61f', 'uvicon-arrow-left-double': 'e637', 'uvicon-man': 'e675', 'uvicon-woman': 'e626', 'uvicon-en': 'e6b8', 'uvicon-twitte': 'e607', 'uvicon-twitter-circle-fill': 'e6cf' }
2301_77169380/AppruanjianApk
uni_modules/uv-icon/components/uv-icon/icons.js
JavaScript
unknown
4,750
export default { props: { // 图标类名 name: { type: String, default: '' }, // 图标颜色,可接受主题色 color: { type: String, default: '#606266' }, // 字体大小,单位px size: { type: [String, Number], default: '16px' }, // 是否显示粗体 bold: { type: Boolean, default: false }, // 点击图标的时候传递事件出去的index(用于区分点击了哪一个) index: { type: [String, Number], default: null }, // 触摸图标时的类名 hoverClass: { type: String, default: '' }, // 自定义扩展前缀,方便用户扩展自己的图标库 customPrefix: { type: String, default: 'uvicon' }, // 图标右边或者下面的文字 label: { type: [String, Number], default: '' }, // label的位置,只能右边或者下边 labelPos: { type: String, default: 'right' }, // label的大小 labelSize: { type: [String, Number], default: '15px' }, // label的颜色 labelColor: { type: String, default: '#606266' }, // label与图标的距离 space: { type: [String, Number], default: '3px' }, // 图片的mode imgMode: { type: String, default: 'aspectFit' }, // 用于显示图片小图标时,图片的宽度 width: { type: [String, Number], default: '' }, // 用于显示图片小图标时,图片的高度 height: { type: [String, Number], default: '' }, // 用于解决某些情况下,让图标垂直居中的用途 top: { type: [String, Number], default: 0 }, // 是否阻止事件传播 stop: { type: Boolean, default: false }, ...uni.$uv?.props?.icon } }
2301_77169380/AppruanjianApk
uni_modules/uv-icon/components/uv-icon/props.js
JavaScript
unknown
1,701
<template> <view class="uv-icon" @tap="clickHandler" :class="['uv-icon--' + labelPos]" > <image class="uv-icon__img" v-if="isImg" :src="name" :mode="imgMode" :style="[imgStyle, $uv.addStyle(customStyle)]" ></image> <text v-else class="uv-icon__icon" :class="uClasses" :style="[iconStyle, $uv.addStyle(customStyle)]" :hover-class="hoverClass" >{{icon}}</text> <!-- 这里进行空字符串判断,如果仅仅是v-if="label",可能会出现传递0的时候,结果也无法显示 --> <text v-if="label !== ''" class="uv-icon__label" :style="{ color: labelColor, fontSize: $uv.addUnit(labelSize), marginLeft: labelPos == 'right' ? $uv.addUnit(space) : 0, marginTop: labelPos == 'bottom' ? $uv.addUnit(space) : 0, marginRight: labelPos == 'left' ? $uv.addUnit(space) : 0, marginBottom: labelPos == 'top' ? $uv.addUnit(space) : 0 }" >{{ label }}</text> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' // #ifdef APP-NVUE // nvue通过weex的dom模块引入字体,相关文档地址如下: // https://weex.apache.org/zh/docs/modules/dom.html#addrule import iconUrl from './uvicons.ttf'; const domModule = weex.requireModule('dom') domModule.addRule('fontFace', { 'fontFamily': "uvicon-iconfont", 'src': "url('" + iconUrl + "')" }) // #endif // 引入图标名称,已经对应的unicode import icons from './icons'; import props from './props.js'; /** * icon 图标 * @description 基于字体的图标集,包含了大多数常见场景的图标。 * @tutorial https://www.uvui.cn/components/icon.html * @property {String} name 图标名称,见示例图标集 * @property {String} color 图标颜色,可接受主题色 (默认 color['uv-content-color'] ) * @property {String | Number} size 图标字体大小,单位px (默认 '16px' ) * @property {Boolean} bold 是否显示粗体 (默认 false ) * @property {String | Number} index 点击图标的时候传递事件出去的index(用于区分点击了哪一个) * @property {String} hoverClass 图标按下去的样式类,用法同uni的view组件的hoverClass参数,详情见官网 * @property {String} customPrefix 自定义扩展前缀,方便用户扩展自己的图标库 (默认 'uicon' ) * @property {String | Number} label 图标右侧的label文字 * @property {String} labelPos label相对于图标的位置,只能right或bottom (默认 'right' ) * @property {String | Number} labelSize label字体大小,单位px (默认 '15px' ) * @property {String} labelColor 图标右侧的label文字颜色 ( 默认 color['uv-content-color'] ) * @property {String | Number} space label与图标的距离,单位px (默认 '3px' ) * @property {String} imgMode 图片的mode * @property {String | Number} width 显示图片小图标时的宽度 * @property {String | Number} height 显示图片小图标时的高度 * @property {String | Number} top 图标在垂直方向上的定位 用于解决某些情况下,让图标垂直居中的用途 (默认 0 ) * @property {Boolean} stop 是否阻止事件传播 (默认 false ) * @property {Object} customStyle icon的样式,对象形式 * @event {Function} click 点击图标时触发 * @event {Function} touchstart 事件触摸时触发 * @example <uv-icon name="photo" color="#2979ff" size="28"></uv-icon> */ export default { name: 'uv-icon', emits: ['click'], mixins: [mpMixin, mixin, props], data() { return { colorType: [ 'primary', 'success', 'info', 'error', 'warning' ] } }, computed: { uClasses() { let classes = [] classes.push(this.customPrefix) classes.push(this.customPrefix + '-' + this.name) // 主题色,通过类配置 if (this.color && this.colorType.includes(this.color)) classes.push('uv-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: this.$uv.addUnit(this.size), lineHeight: this.$uv.addUnit(this.size), fontWeight: this.bold ? 'bold' : 'normal', // 某些特殊情况需要设置一个到顶部的距离,才能更好的垂直居中 top: this.$uv.addUnit(this.top) } // 非主题色值时,才当作颜色值 if (this.color && !this.colorType.includes(this.color)) style.color = this.color return style }, // 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式 isImg() { const isBase64 = this.name.indexOf('data:') > -1 && this.name.indexOf('base64') > -1; return this.name.indexOf('/') !== -1 || isBase64; }, imgStyle() { let style = {} // 如果设置width和height属性,则优先使用,否则使用size属性 style.width = this.width ? this.$uv.addUnit(this.width) : this.$uv.addUnit(this.size) style.height = this.height ? this.$uv.addUnit(this.height) : this.$uv.addUnit(this.size) return style }, // 通过图标名,查找对应的图标 icon() { // 如果内置的图标中找不到对应的图标,就直接返回name值,因为用户可能传入的是unicode代码 const code = icons['uvicon-' + this.name]; // #ifdef APP-NVUE if(!code) { return code ? unescape(`%u${code}`) : ['uvicon'].indexOf(this.customPrefix) > -1 ? unescape(`%u${this.name}`) : ''; } // #endif return code ? unescape(`%u${code}`) : ['uvicon'].indexOf(this.customPrefix) > -1 ? this.name : ''; } }, methods: { clickHandler(e) { this.$emit('click', this.index) // 是否阻止事件冒泡 this.stop && this.preventEvent(e) } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; // 变量定义 $uv-icon-primary: $uv-primary !default; $uv-icon-success: $uv-success !default; $uv-icon-info: $uv-info !default; $uv-icon-warning: $uv-warning !default; $uv-icon-error: $uv-error !default; $uv-icon-label-line-height: 1 !default; /* #ifndef APP-NVUE */ // 非nvue下加载字体 @font-face { font-family: 'uvicon-iconfont'; src: url('./uvicons.ttf') format('truetype'); } /* #endif */ .uv-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: uvicon-iconfont; position: relative; @include flex; align-items: center; &--primary { color: $uv-icon-primary; } &--success { color: $uv-icon-success; } &--error { color: $uv-icon-error; } &--warning { color: $uv-icon-warning; } &--info { color: $uv-icon-info; } } &__img { /* #ifndef APP-NVUE */ height: auto; will-change: transform; /* #endif */ } &__label { /* #ifndef APP-NVUE */ line-height: $uv-icon-label-line-height; /* #endif */ } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-icon/components/uv-icon/uv-icon.vue
Vue
unknown
7,703
export default { props: { // 图片地址 src: { type: String, default: '' }, // 裁剪模式 mode: { type: String, default: 'aspectFill' }, // 宽度,单位任意 width: { type: [String, Number], default: '300' }, // 高度,单位任意 height: { type: [String, Number], default: '225' }, // 图片形状,circle-圆形,square-方形 shape: { type: String, default: 'square' }, // 圆角,单位任意 radius: { type: [String, Number], default: 0 }, // 是否懒加载,微信小程序、App、百度小程序、字节跳动小程序 lazyLoad: { type: Boolean, default: true }, // 是否开启observer懒加载,nvue不生效 observeLazyLoad: { type: Boolean, default: false }, // 开启长按图片显示识别微信小程序码菜单 showMenuByLongpress: { type: Boolean, default: true }, // 加载中的图标,或者小图片 loadingIcon: { type: String, default: 'photo' }, // 加载失败的图标,或者小图片 errorIcon: { type: String, default: 'error-circle' }, // 是否显示加载中的图标或者自定义的slot showLoading: { type: Boolean, default: true }, // 是否显示加载错误的图标或者自定义的slot showError: { type: Boolean, default: true }, // 是否需要淡入效果 fade: { type: Boolean, default: true }, // 只支持网络资源,只对微信小程序有效 webp: { type: Boolean, default: false }, // 过渡时间,单位ms duration: { type: [String, Number], default: 500 }, // 背景颜色,用于深色页面加载图片时,为了和背景色融合 bgColor: { type: String, default: '#f3f4f6' }, // nvue模式下 是否直接显示,在uv-list等cell下面使用就需要设置 cellChild: { type: Boolean, default: false }, ...uni.$uv?.props?.image } }
2301_77169380/AppruanjianApk
uni_modules/uv-image/components/uv-image/props.js
JavaScript
unknown
1,941
<template> <uv-transition v-if="show" :show="show" mode="fade" :duration="fade ? duration : 0" :cell-child="cellChild" :custom-style="wrapStyle" > <view class="uv-image" :class="[`uv-image--${elIndex}`]" @tap="onClick" :style="[wrapStyle, backgroundStyle]" > <image v-if="!isError && observeShow" :src="src" :mode="mode" @error="onErrorHandler" @load="onLoadHandler" :show-menu-by-longpress="showMenuByLongpress" :lazy-load="lazyLoad" class="uv-image__image" :style="[imageStyle]" :webp="webp" ></image> <view v-if="showLoading && loading" class="uv-image__loading" :style="{ borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius), backgroundColor: bgColor, width: $uv.addUnit(width), height: $uv.addUnit(height) }" > <slot name="loading"> <uv-icon :name="loadingIcon" :width="width" :height="height" ></uv-icon> </slot> </view> <view v-if="showError && isError && !loading" class="uv-image__error" :style="{ borderRadius: shape == 'circle' ? '50%' : $uv.addUnit(radius), width: $uv.addUnit(width), height: $uv.addUnit(height) }" > <slot name="error"> <uv-icon :name="errorIcon" :width="width" :height="height" ></uv-icon> </slot> </view> </view> </uv-transition> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * Image 图片 * @description 此组件为uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。 * @tutorial https://www.uvui.cn/components/image.html * @property {String} src 图片地址 * @property {String} mode 裁剪模式,见官网说明 (默认 'aspectFill' ) * @property {String | Number} width 宽度,单位任意,如果为数值,则为px单位 (默认 '300' ) * @property {String | Number} height 高度,单位任意,如果为数值,则为px单位 (默认 '225' ) * @property {String} shape 图片形状,circle-圆形,square-方形 (默认 'square' ) * @property {String | Number} radius 圆角值,单位任意,如果为数值,则为px单位 (默认 0 ) * @property {Boolean} lazyLoad 是否懒加载,仅微信小程序、App、百度小程序、字节跳动小程序有效 (默认 true ) * @property {Boolean} showMenuByLongpress 是否开启长按图片显示识别小程序码菜单,仅微信小程序有效 (默认 true ) * @property {String} loadingIcon 加载中的图标,或者小图片 (默认 'photo' ) * @property {String} errorIcon 加载失败的图标,或者小图片 (默认 'error-circle' ) * @property {Boolean} showLoading 是否显示加载中的图标或者自定义的slot (默认 true ) * @property {Boolean} showError 是否显示加载错误的图标或者自定义的slot (默认 true ) * @property {Boolean} fade 是否需要淡入效果 (默认 true ) * @property {Boolean} webp 只支持网络资源,只对微信小程序有效 (默认 false ) * @property {String | Number} duration 搭配fade参数的过渡时间,单位ms (默认 500 ) * @property {String} bgColor 背景颜色,用于深色页面加载图片时,为了和背景色融合 (默认 '#f3f4f6' ) * @property {Object} customStyle 定义需要用到的外部样式 * @event {Function} click 点击图片时触发 * @event {Function} error 图片加载失败时触发 * @event {Function} load 图片加载成功时触发 * @example <uv-image width="100%" height="300px" :src="src"></uv-image> */ export default { name: 'uv-image', emits: ['click','load','error'], mixins: [mpMixin, mixin, props], data() { return { // 图片是否加载错误,如果是,则显示错误占位图 isError: false, // 初始化组件时,默认为加载中状态 loading: true, // 图片加载完成时,去掉背景颜色,因为如果是png图片,就会显示灰色的背景 backgroundStyle: {}, // 用于fade模式的控制组件显示与否 show: false, // 是否开启图片出现在可视范围进行加载(另一种懒加载) observeShow: !this.observeLazyLoad, elIndex: '', // 因为props的值无法修改,故需要一个中间值 imgWidth: this.width, // 因为props的值无法修改,故需要一个中间值 imgHeight: this.height, thresholdValue: 50 }; }, watch: { src: { immediate: true, handler(n) { if (!n) { // 如果传入null或者'',或者false,或者undefined,标记为错误状态 this.isError = true } else { this.isError = false; this.loading = true; } } }, width(newVal){ // 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态 this.show = false; this.$uv.sleep(2).then(res=>{ this.show = true; }); this.imgWidth = newVal; }, height(newVal){ // 这样做的目的是避免在更新时候,某些平台动画会恢复关闭状态 this.show = false; this.$uv.sleep(2).then(res=>{ this.show = true; }); this.imgHeight = newVal; } }, computed: { wrapStyle() { let style = {}; // 通过调用addUnit()方法,如果有单位,如百分比,px单位等,直接返回,如果是纯粹的数值,则加上rpx单位 if(this.mode !== 'heightFix') { style.width = this.$uv.addUnit(this.imgWidth); } if(this.mode !== 'widthFix') { style.height = this.$uv.addUnit(this.imgHeight); } // 如果是显示圆形,设置一个很多的半径值即可 style.borderRadius = this.shape == 'circle' ? '10000px' : this.$uv.addUnit(this.radius) // 如果设置圆角,必须要有hidden,否则可能圆角无效 style.overflow = this.radius > 0 ? 'hidden' : 'visible' return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)); }, imageStyle() { let style = {}; style.borderRadius = this.shape == 'circle' ? '10000px' : this.$uv.addUnit(this.radius); // #ifdef APP-NVUE style.width = this.$uv.addUnit(this.imgWidth); style.height = this.$uv.addUnit(this.imgHeight); // #endif return style; } }, created() { this.elIndex = this.$uv.guid(); this.observer = {} this.observerName = 'lazyLoadContentObserver' }, mounted() { this.show = true; this.$nextTick(()=>{ if(this.observeLazyLoad) this.observerFn(); }) }, methods: { // 点击图片 onClick() { this.$emit('click') }, // 图片加载失败 onErrorHandler(err) { this.loading = false this.isError = true this.$emit('error', err) }, // 图片加载完成,标记loading结束 onLoadHandler(event) { if(this.mode == 'widthFix') this.imgHeight = 'auto' if(this.mode == 'heightFix') this.imgWidth = 'auto' this.loading = false this.isError = false this.$emit('load', event) this.removeBgColor() }, // 移除图片的背景色 removeBgColor() { // 淡入动画过渡完成后,将背景设置为透明色,否则png图片会看到灰色的背景 this.backgroundStyle = { backgroundColor: 'transparent' }; }, // 观察图片是否在可见视口 observerFn(){ // 在需要用到懒加载的页面,在触发底部的时候触发tOnLazyLoadReachBottom事件,保证所有图片进行加载 this.$nextTick(() => { uni.$once('onLazyLoadReachBottom', () => { if (!this.observeShow) this.observeShow = true }) }) setTimeout(() => { // #ifndef APP-NVUE this.disconnectObserver(this.observerName) const contentObserver = uni.createIntersectionObserver(this) contentObserver.relativeToViewport({ bottom: this.thresholdValue }).observe(`.uv-image--${this.elIndex}`, (res) => { if (res.intersectionRatio > 0) { // 懒加载状态改变 this.observeShow = true // 如果图片已经加载,去掉监听,减少性能消耗 this.disconnectObserver(this.observerName) } }) this[this.observerName] = contentObserver // #endif // #ifdef APP-NVUE this.observeShow = true; // #endif }, 50) }, disconnectObserver(observerName) { const observer = this[observerName] observer && observer.disconnect() } } }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-image-error-top:0px !default; $uv-image-error-left:0px !default; $uv-image-error-width:100% !default; $uv-image-error-hight:100% !default; $uv-image-error-background-color:$uv-bg-color !default; $uv-image-error-color:$uv-tips-color !default; $uv-image-error-font-size: 46rpx !default; .uv-image { position: relative; transition: opacity 0.5s ease-in-out; &__image { width: 100%; height: 100%; } &__loading, &__error { position: absolute; top: $uv-image-error-top; left: $uv-image-error-left; width: $uv-image-error-width; height: $uv-image-error-hight; @include flex; align-items: center; justify-content: center; background-color: $uv-image-error-background-color; color: $uv-image-error-color; font-size: $uv-image-error-font-size; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-image/components/uv-image/uv-image.vue
Vue
unknown
9,683
export default { props: { // 列表锚点文本内容 text: { type: [String, Number], default: '' }, // 列表锚点文字颜色 color: { type: String, default: '#606266' }, // 列表锚点文字大小,单位默认px size: { type: [String, Number], default: 14 }, // 列表锚点背景颜色 bgColor: { type: String, default: '#dedede' }, // 列表锚点高度,单位默认px height: { type: [String, Number], default: 32 }, ...uni.$uv?.props?.indexAnchor } }
2301_77169380/AppruanjianApk
uni_modules/uv-index-list/components/uv-index-anchor/props.js
JavaScript
unknown
527
<template> <!-- #ifdef APP-NVUE --> <header> <!-- #endif --> <view :class="['uv-index-anchor',{'uv-index-anchor-sticky': parentData.sticky}]" :ref="`uv-index-anchor-${text}`" :style="{ height: $uv.addUnit(height), backgroundColor: bgColor }" > <text class="uv-index-anchor__text" :style="{ fontSize: $uv.addUnit(size), color: color }" >{{ text }}</text> </view> <!-- #ifdef APP-NVUE --> </header> <!-- #endif --> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') // #endif /** * IndexAnchor 列表锚点 * @description * @tutorial https://www.uvui.cn/components/indexList.html * @property {String | Number} text 列表锚点文本内容 * @property {String} color 列表锚点文字颜色 ( 默认 '#606266' ) * @property {String | Number} size 列表锚点文字大小,单位默认px ( 默认 14 ) * @property {String} bgColor 列表锚点背景颜色 ( 默认 '#dedede' ) * @property {String | Number} height 列表锚点高度,单位默认px ( 默认 32 ) * @example <uv-index-anchor :text="indexList[index]"></uv-index-anchor> */ export default { name: 'uv-index-anchor', mixins: [mpMixin, mixin, props], data() { return { parentData: { sticky: true } } }, created() { this.init() }, methods: { init() { // 此处会活动父组件实例,并赋值给实例的parent属性 const indexList = this.$uv.$parent.call(this, 'uv-index-list') if (!indexList) { return this.$uv.error('uv-index-anchor必须要搭配uv-index-list组件使用') } this.parentData.sticky = indexList.sticky; // 将当前实例放入到uv-index-list中 indexList.anchors.push(this) const indexListItem = this.$uv.$parent.call(this, 'uv-index-item') // #ifndef APP-NVUE // 只有在非nvue下,uv-index-anchor才是嵌套在uv-index-item中的 if (!indexListItem) { return this.$uv.error('uv-index-anchor必须要搭配uv-index-item组件使用') } // 设置uv-index-item的id为anchor的text标识符,因为非nvue下滚动列表需要依赖scroll-view滚动到元素的特性 indexListItem.id = this.text.charCodeAt(0) // #endif } }, } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-index-anchor { @include flex; align-items: center; padding-left: 15px; z-index: 1; &-sticky { position: sticky; top: 0; } &__text { @include flex; align-items: center; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-index-list/components/uv-index-anchor/uv-index-anchor.vue
Vue
unknown
2,736
<template> <!-- #ifdef APP-NVUE --> <cell ref="uv-index-item"> <!-- #endif --> <view class="uv-index-item" :id="`uv-index-item-${id}`" :class="[`uv-index-item-${id}`]" > <slot /> </view> <!-- #ifdef APP-NVUE --> </cell> <!-- #endif --> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' // #ifdef APP-NVUE // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度 const dom = uni.requireNativePlugin('dom') // #endif /** * IndexItem * @description * @tutorial https://www.uvui.cn/components/indexList.html * @property {String} * @event {Function} * @example */ export default { name: 'uv-index-item', mixins: [mpMixin, mixin], data() { return { // 本组件到滚动条顶部的距离 top: 0, height: 0, id: '' } }, created() { // 子组件uv-index-anchor的实例 this.anchor = {} }, mounted() { this.init() }, methods: { init() { // 此处会活动父组件实例,并赋值给实例的parent属性 this.getParentData('uv-index-list') if (!this.parent) { return this.$uv.error('uv-index-item必须要搭配uv-index-list组件使用') } this.$uv.sleep().then(() =>{ this.getIndexItemRect().then(size => { // 由于对象的引用特性,此处会同时生效到父组件的children数组的本实例的top属性中,供父组件判断读取 this.top = Math.ceil(size.top) this.height = Math.ceil(size.height) }) }) }, getIndexItemRect() { return new Promise(resolve => { // #ifndef APP-NVUE this.$uvGetRect('.uv-index-item').then(size => { resolve(size) }) // #endif // #ifdef APP-NVUE const ref = this.$refs['uv-index-item'] dom.getComponentRect(ref, res => { resolve(res.size) }) // #endif }) } }, } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; </style>
2301_77169380/AppruanjianApk
uni_modules/uv-index-list/components/uv-index-item/uv-index-item.vue
Vue
unknown
2,131
export default { props: { // 右边锚点非激活的颜色 inactiveColor: { type: String, default: '#606266' }, // 右边锚点激活的颜色 activeColor: { type: String, default: '#5677fc' }, // 索引字符列表,数组形式 indexList: { type: Array, default: () => [] }, // 是否开启锚点自动吸顶 sticky: { type: Boolean, default: true }, // 自定义导航栏的高度 customNavHeight: { type: [String, Number], default: 0 }, ...uni.$uv?.props?.indexList } }
2301_77169380/AppruanjianApk
uni_modules/uv-index-list/components/uv-index-list/props.js
JavaScript
unknown
539
<template> <view class="uv-index-list"> <!-- #ifdef APP-NVUE --> <list :scrollTop="scrollTop" enable-back-to-top :offset-accuracy="1" :style="{ maxHeight: $uv.addUnit(scrollViewHeight,'px') }" @scroll="scrollHandler" ref="uvList" > <cell ref="header"> <slot name="header" /> </cell> <slot /> <cell> <slot name="footer" /> </cell> </list> <!-- #endif --> <!-- #ifndef APP-NVUE --> <scroll-view :scrollTop="scrollTop" :scrollIntoView="scrollIntoView" :offset-accuracy="1" :style="{ maxHeight: $uv.addUnit(scrollViewHeight,'px') }" scroll-y @scroll="scrollHandler" ref="uvList" > <view> <slot name="header" /> </view> <slot /> <view> <slot name="footer" /> </view> </scroll-view> <!-- #endif --> <view class="uv-index-list__letter" ref="uv-index-list__letter" :style="{ top: $uv.addUnit(letterInfo.top || 100 ,'px') }" @touchstart="touchStart" @touchmove.stop.prevent="touchMove" @touchend.stop.prevent="touchEnd" @touchcancel.stop.prevent="touchEnd" > <view class="uv-index-list__letter__item" v-for="(item, index) in uIndexList" :key="index" :style="{ backgroundColor: activeIndex === index ? activeColor : 'transparent' }" > <text class="uv-index-list__letter__item__index" :style="{color: activeIndex === index ? '#fff' : inactiveColor}" >{{ item }}</text> </view> </view> <uv-transition mode="fade" :show="touching" :customStyle="{ position: 'fixed', right: '40px', top: $uv.addUnit(indicatorTop,'px'), zIndex: 2 }" > <view class="uv-index-list__indicator__box"> <view class="uv-index-list__indicator" :class="['uv-index-list__indicator--show']" :style="{ height: $uv.addUnit(indicatorHeight,'px'), width: $uv.addUnit(indicatorHeight,'px') }" > <text class="uv-index-list__indicator__text">{{ uIndexList[activeIndex] }}</text> </view> </view> </uv-transition> </view> </template> <script> const indexList = () => { const indexList = []; const charCodeOfA = 'A'.charCodeAt(0); for (let i = 0; i < 26; i++) { indexList.push(String.fromCharCode(charCodeOfA + i)); } return indexList; } import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; // #ifdef APP-NVUE // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度 const dom = uni.requireNativePlugin('dom') // #endif /** * IndexList 索引列表 * @description 通过折叠面板收纳内容区域 * @tutorial https://www.uvui.cn/components/indexList.html * @property {String} inactiveColor 右边锚点非激活的颜色 ( 默认 '#606266' ) * @property {String} activeColor 右边锚点激活的颜色 ( 默认 '#5677fc' ) * @property {Array} indexList 索引字符列表,数组形式 * @property {Boolean} sticky 是否开启锚点自动吸顶 ( 默认 true ) * @property {String | Number} customNavHeight 自定义导航栏的高度 ( 默认 0 ) * */ export default { name: 'uv-index-list', mixins: [mpMixin, mixin, props], // #ifdef MP-WEIXIN // 将自定义节点设置成虚拟的,更加接近Vue组件的表现,能更好的使用flex属性 options: { virtualHost: true }, // #endif data() { return { // 当前正在被选中的字母索引 activeIndex: -1, touchmoveIndex: 1, // 索引字母的信息 letterInfo: { height: 0, itemHeight: 0, top: 0 }, // 设置字母指示器的高度,后面为了让指示器跟随字母,并将尖角部分指向字母的中部,需要依赖此值 indicatorHeight: 50, // 字母放大指示器的top值,为了让其指向当前激活的字母 // indicatorTop: 0 // 当前是否正在被触摸状态 touching: false, // 滚动条顶部top值 scrollTop: 0, // scroll-view的高度 scrollViewHeight: 0, // 系统信息 sys: '', scrolling: false, scrollIntoView: '', hasHeight: 0, timer: 0, disTap: false } }, computed: { // 如果有传入外部的indexList锚点数组则使用,否则使用内部生成A-Z字母 uIndexList() { return this.indexList.length ? this.indexList : indexList() }, // 字母放大指示器的top值,为了让其指向当前激活的字母 indicatorTop() { const { top, itemHeight } = this.letterInfo return Math.floor(top + itemHeight * this.activeIndex + itemHeight / 2 - this.indicatorHeight / 2) - 8 } }, watch: { // 监听字母索引的变化,重新设置尺寸 uIndexList: { immediate: true, handler() { this.$uv.sleep().then(() => { this.setIndexListLetterInfo() }) } } }, created() { this.sys = this.$uv.sys() this.children = [] this.anchors = [] this.init() }, mounted() { this.setIndexListLetterInfo() }, methods: { init() { // 设置列表的高度为整个屏幕的高度 //减去this.customNavHeight,并将this.scrollViewHeight设置为maxHeight //解决当uv-index-list组件放在tabbar页面时,scroll-view内容较少时,还能滚动 this.scrollViewHeight = this.sys.windowHeight - this.$uv.getPx(this.customNavHeight) }, // 索引列表被触摸 touchStart(e) { // 获取触摸点信息 const touchStart = e.changedTouches[0] if (!touchStart || this.disTap) return this.touching = true const { pageY } = touchStart // 根据当前触摸点的坐标,获取当前触摸的为第几个字母 const currentIndex = this.getIndexListLetter(pageY) this.setValueForTouch(currentIndex) }, // 索引字母列表被触摸滑动中 touchMove(e) { // 获取触摸点信息 let touchMove = e.changedTouches[0] if (!touchMove || this.disTap) return; // 滑动结束后迅速开始第二次滑动时候 touching 为 false 造成不显示 indicator 问题 if (!this.touching) { this.touching = true } const { pageY } = touchMove const currentIndex = this.getIndexListLetter(pageY) this.setValueForTouch(currentIndex) }, // 触摸结束 touchEnd(e) { // 延时一定时间后再隐藏指示器,为了让用户看的更直观,同时也是为了消除快速切换uv-transition的show带来的影响 this.$uv.sleep(300).then(() => { this.touching = false }) this.$emit('select',this.activeIndex); }, // 获取索引列表的尺寸以及单个字符的尺寸信息 getIndexListLetterRect() { return new Promise(resolve => { // 延时一定时间,以获取dom尺寸 // #ifndef APP-NVUE this.$uvGetRect('.uv-index-list__letter').then(size => { resolve(size) }) // #endif // #ifdef APP-NVUE const ref = this.$refs['uv-index-list__letter'] dom.getComponentRect(ref, res => { resolve(res.size) }) // #endif }) }, // 设置indexList索引的尺寸信息 setIndexListLetterInfo() { this.getIndexListLetterRect().then(size => { const { top, height } = size const windowHeight = this.$uv.sys().windowHeight; let customNavHeight = 0 // 消除各端导航栏非原生和原生导致的差异,让索引列表字母对屏幕垂直居中 if (this.customNavHeight == 0) { // #ifdef H5 customNavHeight = this.$uv.sys().windowTop // #endif // #ifndef H5 // 在非H5中,为原生导航栏,其高度不算在windowHeight内,这里设置为负值,后面相加时变成减去其高度的一半 customNavHeight = 0 // #endif } else { customNavHeight = this.$uv.getPx(this.customNavHeight) } this.letterInfo = { height, // 为了让字母列表对屏幕绝对居中,让其对导航栏进行修正,也即往上偏移导航栏的一半高度 top: (windowHeight - height) / 2 + customNavHeight / 2, itemHeight: Math.floor(height / this.uIndexList.length) } }) }, // 获取当前被触摸的索引字母 getIndexListLetter(pageY) { const { top, height, itemHeight } = this.letterInfo // 对H5的pageY进行修正,这是由于uni-app自作多情在H5中将触摸点的坐标跟H5的导航栏结合导致的问题 // #ifdef H5 pageY += this.$uv.sys().windowTop // #endif // #ifdef APP-NVUE pageY += top // #endif // 对第一和最后一个字母做边界处理,因为用户可能在字母列表上触摸到两端的尽头后依然继续滑动 if (pageY < top) { return 0 } else if (pageY >= top + height) { // 如果超出了,取最后一个字母 return this.uIndexList.length - 1 } else { // 将触摸点的Y轴偏移值,减去索引字母的top值,除以每个字母的高度,即可得到当前触摸点落在哪个字母上 return Math.floor((pageY - top) / itemHeight); } }, // 设置各项由触摸而导致变化的值 setValueForTouch(currentIndex) { // 如果偏移量太小,前后得出的会是同一个索引字母,为了防抖,进行返回 if (currentIndex === this.activeIndex) return this.activeIndex = currentIndex // #ifndef APP-NVUE || MP-WEIXIN // 在非nvue中,由于anchor和item都在uv-index-item中,所以需要对index-item进行偏移 this.scrollIntoView = `uv-index-item-${this.uIndexList[currentIndex].charCodeAt(0)}` // #endif // #ifdef MP-WEIXIN // 微信小程序下,scroll-view的scroll-into-view属性无法对slot中的内容的id生效,只能通过设置scrollTop的形式去移动滚动条 this.scrollTop = this.children[currentIndex].top // #endif // #ifdef APP-NVUE // 在nvue中,由于cell和header为同级元素,所以实际是需要对header(anchor)进行偏移 const anchor = `uv-index-anchor-${this.uIndexList[currentIndex]}` dom.scrollToElement(this.anchors[currentIndex].$refs[anchor], { offset: 0, animated: false }) // #endif }, getHeaderRect() { // 获取header slot的高度,因为list组件中获取元素的尺寸是没有top值的 return new Promise(resolve => { dom.getComponentRect(this.$refs.header, res => { resolve(res.size) }) }) }, // scroll-view的滚动事件 async scrollHandler(e) { if (this.touching || this.scrolling) return // 每过一定时间取样一次,减少资源损耗以及可能带来的卡顿 this.scrolling = true this.disTap = true; clearTimeout(this.timer); this.timer = setTimeout(()=>{ this.disTap = false; },200) this.$uv.sleep(30).then(() => { this.scrolling = false }) let scrollTop = 0 const len = this.children.length let children = this.children const anchors = this.anchors const customNavHeight = this.$uv.getPx(this.customNavHeight); // #ifdef APP-NVUE // nvue下获取的滚动条偏移为负数,需要转为正数 scrollTop = Math.abs(e.contentOffset.y) // 获取header slot的尺寸信息 const header = await this.getHeaderRect() // item的top值,在nvue下,模拟出的anchor的top,类似非nvue下的index-item的top let top = header.height // 由于list组件无法获取cell的top值,这里通过header slot和各个item之间的height,模拟出类似非nvue下的位置信息 children = this.children.map((item, index) => { if(item.height>0) this.hasHeight = item.height; item.height = item.height>0?item.height:this.hasHeight; const child = { height: item.height, top } // 进行累加,给下一个item提供计算依据 top += item.height + anchors[index].height return child }) // #endif // #ifndef APP-NVUE // 非nvue通过detail获取滚动条位移 scrollTop = e.detail.scrollTop // #endif for (let i = 0; i < len; i++) { const item = children[i], nextItem = children[i + 1] // 如果滚动条高度小于第一个item的top值,此时无需设置任意字母为高亮 if (scrollTop + customNavHeight <= children[0].top || scrollTop >= children[len - 1].top + children[len - 1].height) { this.activeIndex = -1 break } else if (!nextItem) { // 当不存在下一个item时,意味着历遍到了最后一个 this.activeIndex = len - 1 break } else if (scrollTop + customNavHeight > item.top && scrollTop + customNavHeight < nextItem.top) { this.activeIndex = i break } } }, }, } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-index-list { &__letter { position: fixed; right: 0; text-align: center; z-index: 3; padding: 0 6px; &__item { width: 16px; height: 16px; border-radius: 100px; margin: 1px 0; @include flex; align-items: center; justify-content: center; &--active { background-color: $uv-primary; } &__index { font-size: 12px; text-align: center; line-height: 12px; } } } &__indicator__box { width: 65px; height: 65px; padding: 6px; transform: rotate(-45deg); } &__indicator { width: 50px; height: 50px; border-radius: 100px 100px 0 100px; text-align: center; color: #ffffff; background-color: #c9c9c9; @include flex; justify-content: center; align-items: center; &__text { font-size: 28px; line-height: 28px; font-weight: bold; color: #fff; transform: rotate(45deg); text-align: center; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-index-list/components/uv-index-list/uv-index-list.vue
Vue
unknown
13,961
export default { props: { value: { type: [String, Number], default: '' }, modelValue: { type: [String, Number], default: '' }, // 输入框类型 // number-数字输入键盘,app-vue下可以输入浮点数,app-nvue和小程序平台下只能输入整数 // idcard-身份证输入键盘,微信、支付宝、百度、QQ小程序 // digit-带小数点的数字键盘,App的nvue页面、微信、支付宝、百度、头条、QQ小程序 // text-文本输入键盘 type: { type: String, default: 'text' }, // 是否禁用输入框 disabled: { type: Boolean, default: false }, // 禁用状态时的背景色 disabledColor: { type: String, default: '#f5f7fa' }, // 是否显示清除控件 clearable: { type: Boolean, default: false }, // 是否密码类型 password: { type: Boolean, default: false }, // 最大输入长度,设置为 -1 的时候不限制最大长度 maxlength: { type: [String, Number], default: -1 }, // 输入框为空时的占位符 placeholder: { type: String, default: null }, // 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ placeholderClass: { type: String, default: 'input-placeholder' }, // 指定placeholder的样式 placeholderStyle: { type: [String, Object], default: 'color: #c0c4cc' }, // 设置右下角按钮的文字,有效值:send|search|next|go|done,兼容性详见uni-app文档 // https://uniapp.dcloud.io/component/input // https://uniapp.dcloud.io/component/textarea confirmType: { type: String, default: 'done' }, // 点击键盘右下角按钮时是否保持键盘不收起,H5无效 confirmHold: { type: Boolean, default: false }, // focus时,点击页面的时候不收起键盘,微信小程序有效 holdKeyboard: { type: Boolean, default: false }, // 自动获取焦点 // 在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点 focus: { type: Boolean, default: false }, // 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效 autoBlur: { type: Boolean, default: false }, // 指定focus时光标的位置 cursor: { type: [String, Number], default: -1 }, // 输入框聚焦时底部与键盘的距离 cursorSpacing: { type: [String, Number], default: 30 }, // 光标起始位置,自动聚集时有效,需与selection-end搭配使用 selectionStart: { type: [String, Number], default: -1 }, // 光标结束位置,自动聚集时有效,需与selection-start搭配使用 selectionEnd: { type: [String, Number], default: -1 }, // 键盘弹起时,是否自动上推页面 adjustPosition: { type: Boolean, default: true }, // 输入框内容对齐方式,可选值为:left|center|right inputAlign: { type: String, default: 'left' }, // 输入框字体的大小 fontSize: { type: [String, Number], default: '14px' }, // 输入框字体颜色 color: { type: String, default: '#303133' }, // 输入框前置图标 prefixIcon: { type: String, default: '' }, // 前置图标样式,对象或字符串 prefixIconStyle: { type: [String, Object], default: '' }, // 输入框后置图标 suffixIcon: { type: String, default: '' }, // 后置图标样式,对象或字符串 suffixIconStyle: { type: [String, Object], default: '' }, // 边框类型,surround-四周边框,bottom-底部边框,none-无边框 border: { type: String, default: 'surround' }, // 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会 readonly: { type: Boolean, default: false }, // 输入框形状,circle-圆形,square-方形 shape: { type: String, default: 'square' }, // 用于处理或者过滤输入框内容的方法 formatter: { type: [Function, null], default: null }, // 是否忽略组件内对文本合成系统事件的处理 ignoreCompositionEvent: { type: Boolean, default: true }, ...uni.$uv?.props?.input } }
2301_77169380/AppruanjianApk
uni_modules/uv-input/components/uv-input/props.js
JavaScript
unknown
4,324
<template> <view class="uv-input" :class="inputClass" :style="[wrapperStyle]"> <view class="uv-input__content"> <view class="uv-input__content__prefix-icon"> <slot name="prefix"> <uv-icon v-if="prefixIcon" :name="prefixIcon" size="18" :customStyle="prefixIconStyle" ></uv-icon> </slot> </view> <view class="uv-input__content__field-wrapper" @click="clickHandler"> <!-- 根据uni-app的input组件文档,H5和APP中只要声明了password参数(无论true还是false),type均失效,此时 为了防止type=number时,又存在password属性,type无效,此时需要设置password为undefined --> <input class="uv-input__content__field-wrapper__field" :style="[inputStyle]" :type="type" :focus="focus" :cursor="cursor" :value="innerValue" :auto-blur="autoBlur" :disabled="disabled || readonly" :maxlength="maxlength" :placeholder="placeholder" :placeholder-style="placeholderStyle" :placeholder-class="placeholderClass" :confirm-type="confirmType" :confirm-hold="confirmHold" :hold-keyboard="holdKeyboard" :cursor-spacing="cursorSpacing" :adjust-position="adjustPosition" :selection-end="selectionEnd" :selection-start="selectionStart" :password="password || type === 'password' || undefined" :ignoreCompositionEvent="ignoreCompositionEvent" @input="onInput" @blur="onBlur" @focus="onFocus" @confirm="onConfirm" @keyboardheightchange="onkeyboardheightchange" /> </view> <view class="uv-input__content__clear" v-if="isShowClear" @tap="onClear" > <uv-icon name="close" size="11" color="#ffffff" customStyle="line-height: 12px" ></uv-icon> </view> <view class="uv-input__content__subfix-icon"> <slot name="suffix"> <uv-icon v-if="suffixIcon" :name="suffixIcon" size="18" :customStyle="suffixIconStyle" ></uv-icon> </slot> </view> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from "./props.js"; /** * Input 输入框 * @description 此组件为一个输入框,默认没有边框和样式,是专门为配合表单组件uv-form而设计的,利用它可以快速实现表单验证,输入内容,下拉选择等功能。 * @tutorial https://www.uvui.cn/components/input.html * @property {String | Number} value 输入的值 * @property {String} type 输入框类型,见上方说明 ( 默认 'text' ) * @property {Boolean} fixed 如果 textarea 是在一个 position:fixed 的区域,需要显示指定属性 fixed 为 true,兼容性:微信小程序、百度小程序、字节跳动小程序、QQ小程序 ( 默认 false ) * @property {Boolean} disabled 是否禁用输入框 ( 默认 false ) * @property {String} disabledColor 禁用状态时的背景色( 默认 '#f5f7fa' ) * @property {Boolean} clearable 是否显示清除控件 ( 默认 false ) * @property {Boolean} password 是否密码类型 ( 默认 false ) * @property {String | Number} maxlength 最大输入长度,设置为 -1 的时候不限制最大长度 ( 默认 -1 ) * @property {String} placeholder 输入框为空时的占位符 * @property {String} placeholderClass 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' ) * @property {String | Object} placeholderStyle 指定placeholder的样式,字符串/对象形式,如"color: red;" * @property {Boolean} showWordLimit 是否显示输入字数统计,只在 type ="text"或type ="textarea"时有效 ( 默认 false ) * @property {String} confirmType 设置右下角按钮的文字,兼容性详见uni-app文档 ( 默认 'done' ) * @property {Boolean} confirmHold 点击键盘右下角按钮时是否保持键盘不收起,H5无效 ( 默认 false ) * @property {Boolean} holdKeyboard focus时,点击页面的时候不收起键盘,微信小程序有效 ( 默认 false ) * @property {Boolean} focus 自动获取焦点,在 H5 平台能否聚焦以及软键盘是否跟随弹出,取决于当前浏览器本身的实现。nvue 页面不支持,需使用组件的 focus()、blur() 方法控制焦点 ( 默认 false ) * @property {Boolean} autoBlur 键盘收起时,是否自动失去焦点,目前仅App3.0.0+有效 ( 默认 false ) * @property {Boolean} disableDefaultPadding 是否去掉 iOS 下的默认内边距,仅微信小程序,且type=textarea时有效 ( 默认 false ) * @property {String | Number} cursor 指定focus时光标的位置( 默认 -1 ) * @property {String | Number} cursorSpacing 输入框聚焦时底部与键盘的距离 ( 默认 30 ) * @property {String | Number} selectionStart 光标起始位置,自动聚集时有效,需与selection-end搭配使用 ( 默认 -1 ) * @property {String | Number} selectionEnd 光标结束位置,自动聚集时有效,需与selection-start搭配使用 ( 默认 -1 ) * @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面 ( 默认 true ) * @property {String} inputAlign 输入框内容对齐方式( 默认 'left' ) * @property {String | Number} fontSize 输入框字体的大小 ( 默认 '15px' ) * @property {String} color 输入框字体颜色 ( 默认 '#303133' ) * @property {Function} formatter 内容式化函数 * @property {String} prefixIcon 输入框前置图标 * @property {String | Object} prefixIconStyle 前置图标样式,对象或字符串 * @property {String} suffixIcon 输入框后置图标 * @property {String | Object} suffixIconStyle 后置图标样式,对象或字符串 * @property {String} border 边框类型,surround-四周边框,bottom-底部边框,none-无边框 ( 默认 'surround' ) * @property {Boolean} readonly 是否只读,与disabled不同之处在于disabled会置灰组件,而readonly则不会 ( 默认 false ) * @property {String} shape 输入框形状,circle-圆形,square-方形 ( 默认 'square' ) * @property {Object} customStyle 定义需要用到的外部样式 * @property {Boolean} ignoreCompositionEvent 是否忽略组件内对文本合成系统事件的处理。 * @example <uv-input v-model="value" :password="true" suffix-icon="lock-fill" /> */ export default { name: "uv-input", mixins: [mpMixin, mixin, props], data() { return { // 输入框的值 innerValue: "", // 是否处于获得焦点状态 focused: false, // 过滤处理方法 innerFormatter: value => value } }, created() { // #ifdef VUE2 this.innerValue = this.value; // #endif // #ifdef VUE3 this.innerValue = this.modelValue; // #endif }, watch: { value(newVal){ this.innerValue = newVal; }, modelValue(newVal){ this.innerValue = newVal; } }, computed: { // 是否显示清除控件 isShowClear() { const { clearable, readonly, focused, innerValue } = this; return !!clearable && !readonly && !!focused && innerValue !== ""; }, // 组件的类名 inputClass() { let classes = [], { border, disabled, shape } = this; border === "surround" && (classes = classes.concat(["uv-border", "uv-input--radius"])); classes.push(`uv-input--${shape}`); border === "bottom" && (classes = classes.concat([ "uv-border-bottom", "uv-input--no-radius", ])); return classes.join(" "); }, // 组件的样式 wrapperStyle() { const style = {}; // 禁用状态下,被背景色加上对应的样式 if (this.disabled) { style.backgroundColor = this.disabledColor; } // 无边框时,去除内边距 if (this.border === "none") { style.padding = "0"; } else { // 由于uni-app的iOS开发者能力有限,导致需要分开写才有效 style.paddingTop = "6px"; style.paddingBottom = "6px"; style.paddingLeft = "9px"; style.paddingRight = "9px"; } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)); }, // 输入框的样式 inputStyle() { const style = { color: this.color, fontSize: this.$uv.addUnit(this.fontSize), textAlign: this.inputAlign }; // #ifndef APP-NVUE if(this.disabled || this.readonly) { style['pointer-events'] = 'none'; } // #endif return style; } }, methods: { // 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用 setFormatter(e) { this.innerFormatter = e }, // 当键盘输入时,触发input事件 onInput(e) { let { value = "" } = e.detail || {}; // 格式化过滤方法 const formatter = this.formatter || this.innerFormatter const formatValue = formatter(value) // 为了避免props的单向数据流特性,需要先将innerValue值设置为当前值,再在$nextTick中重新赋予设置后的值才有效 this.innerValue = value this.$nextTick(() => { this.innerValue = formatValue; this.valueChange(); }) }, // 输入框失去焦点时触发 onBlur(event) { this.$emit("blur", event.detail.value); // H5端的blur会先于点击清除控件的点击click事件触发,导致focused // 瞬间为false,从而隐藏了清除控件而无法被点击到 this.$uv.sleep(100).then(() => { this.focused = false; }); // 尝试调用uv-form的验证方法 this.$uv.formValidate(this, "blur"); }, // 输入框聚焦时触发 onFocus(event) { this.focused = true; this.$emit("focus"); }, // 点击完成按钮时触发 onConfirm(event) { this.$emit("confirm", this.innerValue); }, // 键盘高度发生变化的时候触发此事件 // 兼容性:微信小程序2.7.0+、App 3.1.0+ onkeyboardheightchange(e) { this.$emit("keyboardheightchange",e); }, // 内容发生变化,进行处理 valueChange() { if(this.isClear) this.innerValue = ''; const value = this.innerValue; this.$nextTick(() => { this.$emit("input", value); this.$emit("update:modelValue", value); this.$emit("change", value); // 尝试调用uv-form的验证方法 this.$uv.formValidate(this, "change"); }); }, // 点击清除控件 onClear() { this.innerValue = ""; this.isClear = true; this.$uv.sleep(200).then(res=>{ this.isClear = false; }) this.$nextTick(() => { this.$emit("clear"); this.valueChange(); }); }, /** * 在安卓nvue上,事件无法冒泡 * 在某些时间,我们希望监听uv-from-item的点击事件,此时会导致点击uv-form-item内的uv-input后 * 无法触发uv-form-item的点击事件,这里通过手动调用uv-form-item的方法进行触发 */ clickHandler() { // #ifdef APP-NVUE if (this.$uv.os() === "android") { const formItem = this.$uv.$parent.call(this, "uv-form-item"); if (formItem) { formItem.clickHandler(); } } // #endif } } } </script> <style lang="scss" scoped> $show-border: 1; $show-border-surround: 1; $show-border-bottom: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-input { @include flex(row); align-items: center; justify-content: space-between; flex: 1; &--radius, &--square { border-radius: 4px; } &--no-radius { border-radius: 0; } &--circle { border-radius: 100px; } &__content { flex: 1; @include flex(row); align-items: center; justify-content: space-between; &__field-wrapper { position: relative; @include flex(row); margin: 0; flex: 1; &__field { line-height: 26px; text-align: left; color: $uv-main-color; height: 24px; font-size: 15px; flex: 1; } } &__clear { width: 20px; height: 20px; border-radius: 100px; background-color: #c6c7cb; @include flex(row); align-items: center; justify-content: center; transform: scale(0.82); margin-left: 15px; } &__subfix-icon { margin-left: 4px; } &__prefix-icon { margin-right: 4px; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-input/components/uv-input/uv-input.vue
Vue
unknown
13,127
export default { props: { // 键盘的类型,number-数字键盘,card-身份证键盘,car-车牌号键盘 mode: { type: String, default: 'number' }, // 是否显示键盘的"."符号 dotDisabled: { type: Boolean, default: false }, // 是否显示顶部工具条 tooltip: { type: Boolean, default: true }, // 是否显示工具条中间的提示 showTips: { type: Boolean, default: true }, // 工具条中间的提示文字 tips: { type: String, default: '' }, // 是否显示工具条左边的"取消"按钮 showCancel: { type: Boolean, default: true }, // 是否显示工具条右边的"完成"按钮 showConfirm: { type: Boolean, default: true }, // 是否打乱键盘按键的顺序 random: { type: Boolean, default: false }, // 是否开启底部安全区适配,开启的话,会在iPhoneX机型底部添加一定的内边距 safeAreaInsetBottom: { type: Boolean, default: true }, // 是否允许通过点击遮罩关闭键盘 closeOnClickOverlay: { type: Boolean, default: true }, // 是否允许点击确认按钮关闭组件 closeOnClickConfirm: { type: Boolean, default: true }, // 是否显示遮罩,某些时候数字键盘时,用户希望看到自己的数值,所以可能不想要遮罩 overlay: { type: Boolean, default: true }, // z-index值 zIndex: { type: [String, Number], default: 10075 }, // 取消按钮的文字 cancelText: { type: String, default: '取消' }, // 确认按钮的文字 confirmText: { type: String, default: '确定' }, // 输入一个中文后,是否自动切换到英文 autoChange: { type: Boolean, default: false }, // 被禁用的键 disKeys: { type: Array, default: ()=>[] }, // 是否自定义abc customabc: { type: Boolean, default: false }, ...uni.$uv?.props?.keyboard } }
2301_77169380/AppruanjianApk
uni_modules/uv-keyboard/components/uv-keyboard/props.js
JavaScript
unknown
1,955
<template> <uv-popup ref="keyboardPopup" mode="bottom" :overlay="overlay" :closeOnClickOverlay="closeOnClickOverlay" :safeAreaInsetBottom="safeAreaInsetBottom" :zIndex="zIndex" :customStyle="{ backgroundColor: 'rgb(214, 218, 220)' }" @change="popupChange" > <view class="uv-keyboard"> <slot /> <view class="uv-keyboard__tooltip" v-if="tooltip" > <view hover-class="uv-hover-class" :hover-stay-time="100" > <text class="uv-keyboard__tooltip__item uv-keyboard__tooltip__cancel" v-if="showCancel" @tap="onCancel" >{{showCancel && cancelText}}</text> </view> <view> <text v-if="showTips" class="uv-keyboard__tooltip__item uv-keyboard__tooltip__tips" >{{tips ? tips : mode == 'number' ? '数字键盘' : mode == 'card' ? '身份证键盘' : '车牌号键盘'}}</text> </view> <view hover-class="uv-hover-class" :hover-stay-time="100" > <text v-if="showConfirm" @tap="onConfirm" class="uv-keyboard__tooltip__item uv-keyboard__tooltip__submit" hover-class="uv-hover-class" >{{showConfirm && confirmText}}</text> </view> </view> <template v-if="mode == 'number' || mode == 'card'"> <uv-keyboard-number :random="random" @backspace="backspace" @change="change" :mode="mode" :dotDisabled="dotDisabled" ></uv-keyboard-number> </template> <template v-else> <uv-keyboard-car ref="uvKeyboardCarRef" :random="random" :autoChange="autoChange" :disKeys="disKeys" :customabc="customabc" @backspace="backspace" @change="change" @changeCarInputMode="changeCarInputMode" > <slot name="abc"></slot> </uv-keyboard-car> </template> </view> </uv-popup> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * keyboard 键盘 * @description 此为uViw自定义的键盘面板,内含了数字键盘,车牌号键,身份证号键盘3中模式,都有可以打乱按键顺序的选项。 * @tutorial https://www.uvui.cn/components/keyboard.html * @property {String} mode 键盘类型,见官网基本使用的说明 (默认 'number' ) * @property {Boolean} dotDisabled 是否显示"."按键,只在mode=number时有效 (默认 false ) * @property {Boolean} tooltip 是否显示键盘顶部工具条 (默认 true ) * @property {Boolean} showTips 是否显示工具条中间的提示 (默认 true ) * @property {String} tips 工具条中间的提示文字,见上方基本使用的说明,如不需要,请传""空字符 * @property {Boolean} showCancel 是否显示工具条左边的"取消"按钮 (默认 true ) * @property {Boolean} showConfirm 是否显示工具条右边的"完成"按钮( 默认 true ) * @property {Boolean} random 是否打乱键盘按键的顺序 (默认 false ) * @property {Boolean} safeAreaInsetBottom 是否开启底部安全区适配 (默认 true ) * @property {Boolean} closeOnClickOverlay 是否允许点击遮罩收起键盘 (默认 true ) * @property {Boolean} show 控制键盘的弹出与收起(默认 false ) * @property {Boolean} overlay 是否显示遮罩 (默认 true ) * @property {String | Number} zIndex 弹出键盘的z-index值 (默认 1075 ) * @property {String} cancelText 取消按钮的文字 (默认 '取消' ) * @property {String} confirmText 确认按钮的文字 (默认 '确认' ) * @property {Object} customStyle 自定义样式,对象形式 * @event {Function} change 按键被点击(不包含退格键被点击) * @event {Function} cancel 键盘顶部工具条左边的"取消"按钮被点击 * @event {Function} confirm 键盘顶部工具条右边的"完成"按钮被点击 * @event {Function} backspace 键盘退格键被点击 * @example <uv-keyboard mode="number" v-model="show"></uv-keyboard> */ export default { name: "uv-keyboard", mixins: [mpMixin, mixin, props], emits: ['close','change','confirm','cancel','backspace','changeCarInputMode'], methods: { open() { this.$refs.keyboardPopup.open(); }, close() { this.$refs.keyboardPopup.close(); }, popupChange(e) { if(!e.show) this.$emit('close'); }, change(e) { this.$emit('change', e); }, // 输入完成 onConfirm() { this.$emit('confirm'); if(this.closeOnClickConfirm) this.close(); }, // 取消输入 onCancel() { this.$emit('cancel'); this.close(); }, // 退格键 backspace() { this.$emit('backspace'); }, // car模式切换中文|英文方法 changeCarInputMode(e) { this.$emit('changeCarInputMode',e); }, changeCarMode() { this.$refs.uvKeyboardCarRef && this.$refs.uvKeyboardCarRef.changeCarInputMode(); } } } </script> <style lang="scss" scoped> $show-hover: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-keyboard { &__tooltip { @include flex; justify-content: space-between; background-color: #FFFFFF; padding: 14px 12px; &__item { color: #333333; flex: 1; text-align: center; font-size: 15px; } &__submit { text-align: right; color: $uv-primary; } &__cancel { text-align: left; color: #888888; } &__tips { color: $uv-tips-color; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-keyboard/components/uv-keyboard/uv-keyboard.vue
Vue
unknown
5,723
export default { props: { // 是否打乱键盘按键的顺序 random: { type: Boolean, default: false }, // 输入一个中文后,是否自动切换到英文 autoChange: { type: Boolean, default: false }, // 被禁用的键 disKeys: { type: Array, default: ()=>[] }, // 是否自定义abc customabc: { type: Boolean, default: false } } }
2301_77169380/AppruanjianApk
uni_modules/uv-keyboard/components/uv-keyboard-car/props.js
JavaScript
unknown
390
<template> <view class="uv-keyboard" @touchmove.stop.prevent="noop" > <view v-for="(group, i) in abc ? engKeyBoardList : areaList" :key="i" class="uv-keyboard__button" :index="i" :class="[i + 1 === 4 && 'uv-keyboard__button--center']" > <view v-if="i === 3" class="uv-keyboard__button__inner-wrapper" > <view class="uv-keyboard__button__inner-wrapper__left" hover-class="uv-hover-class" :hover-stay-time="200" @tap="changeCarInputMode" > <slot> <template v-if="!customabc"> <text class="uv-keyboard__button__inner-wrapper__left__lang" :class="[!abc && 'uv-keyboard__button__inner-wrapper__left__lang--active']" >中</text> <text class="uv-keyboard__button__inner-wrapper__left__line">/</text> <text class="uv-keyboard__button__inner-wrapper__left__lang" :class="[abc && 'uv-keyboard__button__inner-wrapper__left__lang--active']" >英</text> </template> </slot> </view> </view> <view class="uv-keyboard__button__inner-wrapper" v-for="(item, j) in group" :key="j" > <view :class="['uv-keyboard__button__inner-wrapper__inner',{'uv-keyboard__button__inner-wrapper__inner--disabled': isDisabled(i,j)}]" :hover-stay-time="200" @tap="carInputClick(i, j)" :hover-class="isDisabled(i,j)?'none':'uv-hover-class'" > <text class="uv-keyboard__button__inner-wrapper__inner__text">{{ item }}</text> </view> <view class="uv-keyboard__button__inner-wrapper__disabled--mask" v-if="isDisabled(i,j)"></view> </view> <view v-if="i === 3" @touchstart="backspaceClick" @touchend="clearTimer" class="uv-keyboard__button__inner-wrapper" > <view class="uv-keyboard__button__inner-wrapper__right" hover-class="uv-hover-class" :hover-stay-time="200" > <uv-icon size="28" name="backspace" color="#303133" ></uv-icon> </view> </view> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * keyboard 键盘组件 * @description 此为uvui自定义的键盘面板,内含了数字键盘,车牌号键,身份证号键盘3种模式,都有可以打乱按键顺序的选项。 * @tutorial https://www.uvui.cn/components/keyboard.html * @property {Boolean} random 是否打乱键盘的顺序 * @event {Function} change 点击键盘触发 * @event {Function} backspace 点击退格键触发 * @example <uv-keyboard ref="uKeyboard" mode="car" v-model="show"></uv-keyboard> */ export default { name: "uv-keyboard", mixins: [mpMixin, mixin, props], emits: ['backspace','change','changeCarInputMode'], data() { return { // 车牌输入时,abc=true为输入车牌号码,bac=false为输入省份中文简称 abc: false }; }, computed: { areaList() { let data = [ '京', '沪', '粤', '津', '冀', '豫', '云', '辽', '黑', '湘', '皖', '鲁', '苏', '浙', '赣', '鄂', '桂', '甘', '晋', '陕', '蒙', '吉', '闽', '贵', '渝', '川', '青', '琼', '宁', '挂', '藏', '港', '澳', '新', '使', '学' ]; let tmp = []; // 打乱顺序 if (this.random) data = this.$uv.randomArray(data); // 切割成二维数组 tmp[0] = data.slice(0, 10); tmp[1] = data.slice(10, 20); tmp[2] = data.slice(20, 30); tmp[3] = data.slice(30, 36); return tmp; }, engKeyBoardList() { let data = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M' ]; let tmp = []; if (this.random) data = this.$uv.randomArray(data); tmp[0] = data.slice(0, 10); tmp[1] = data.slice(10, 20); tmp[2] = data.slice(20, 30); tmp[3] = data.slice(30, 36); return tmp; }, isDisabled(i,j) { return (i,j)=>{ let value = ''; if (this.abc) value = this.engKeyBoardList[i][j]; else value = this.areaList[i][j]; return this.disKeys.indexOf(value) > -1; } } }, methods: { // 点击键盘按钮 carInputClick(i, j) { if(this.isDisabled(i,j)) return; let value = ''; // 不同模式,获取不同数组的值 if (this.abc) value = this.engKeyBoardList[i][j]; else value = this.areaList[i][j]; // 如果允许自动切换,则将中文状态切换为英文 if (!this.abc && this.autoChange) this.$uv.sleep(200).then(() => this.abc = true) this.$emit('change', value); }, // 修改汽车牌键盘的输入模式,中文|英文 changeCarInputMode() { this.abc = !this.abc; this.$emit('changeCarInputMode',this.abc); }, // 点击退格键 backspaceClick() { this.$emit('backspace'); clearInterval(this.timer); //再次清空定时器,防止重复注册定时器 this.timer = null; this.timer = setInterval(() => { this.$emit('backspace'); }, 250); }, clearTimer() { clearInterval(this.timer); this.timer = null; }, } }; </script> <style lang="scss" scoped> $show-hover: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-car-keyboard-background-color: rgb(224, 228, 230) !default; $uv-car-keyboard-padding:6px 0 6px !default; $uv-car-keyboard-button-inner-width:64rpx !default; $uv-car-keyboard-button-inner-background-color:#FFFFFF !default; $uv-car-keyboard-button-height:80rpx !default; $uv-car-keyboard-button-inner-box-shadow:0 1px 0px #999992 !default; $uv-car-keyboard-button-border-radius:4px !default; $uv-car-keyboard-button-inner-margin:8rpx 5rpx !default; $uv-car-keyboard-button-text-font-size:16px !default; $uv-car-keyboard-button-text-color:$uv-main-color !default; $uv-car-keyboard-center-inner-margin: 0 4rpx !default; $uv-car-keyboard-special-button-width:134rpx !default; $uv-car-keyboard-lang-font-size:16px !default; $uv-car-keyboard-lang-color:$uv-main-color !default; $uv-car-keyboard-active-color:$uv-primary !default; $uv-car-keyboard-line-font-size:15px !default; $uv-car-keyboard-line-color:$uv-main-color !default; $uv-car-keyboard-line-margin:0 1px !default; $uv-car-keyboard-uv-hover-class-background-color:#BBBCC6 !default; .uv-keyboard { @include flex(column); justify-content: space-around; background-color: $uv-car-keyboard-background-color; align-items: stretch; padding: $uv-car-keyboard-padding; &__button { @include flex; justify-content: center; flex: 1; /* #ifndef APP-NVUE */ /* #endif */ &__inner-wrapper { position: relative; box-shadow: $uv-car-keyboard-button-inner-box-shadow; margin: $uv-car-keyboard-button-inner-margin; border-radius: $uv-car-keyboard-button-border-radius; &__disabled--mask { position: absolute; left: 0; top: 0; bottom: 0; right: 0; width: $uv-car-keyboard-button-inner-width; height: $uv-car-keyboard-button-height; } &__inner { @include flex; justify-content: center; align-items: center; width: $uv-car-keyboard-button-inner-width; background-color: $uv-car-keyboard-button-inner-background-color; height: $uv-car-keyboard-button-height; border-radius: $uv-car-keyboard-button-border-radius; &--disabled { opacity: 0.5; } &__text { font-size: $uv-car-keyboard-button-text-font-size; color: $uv-car-keyboard-button-text-color; } } &__left, &__right { border-radius: $uv-car-keyboard-button-border-radius; width: $uv-car-keyboard-special-button-width; height: $uv-car-keyboard-button-height; background-color: $uv-car-keyboard-uv-hover-class-background-color; @include flex; justify-content: center; align-items: center; box-shadow: $uv-car-keyboard-button-inner-box-shadow; } &__left { &__line { font-size: $uv-car-keyboard-line-font-size; color: $uv-car-keyboard-line-color; margin: $uv-car-keyboard-line-margin; } &__lang { font-size: $uv-car-keyboard-lang-font-size; color: $uv-car-keyboard-lang-color; &--active { color: $uv-car-keyboard-active-color; } } } } } } .uv-hover-class { background-color: $uv-car-keyboard-uv-hover-class-background-color; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-keyboard/components/uv-keyboard-car/uv-keyboard-car.vue
Vue
unknown
8,969
export default { props: { // 键盘的类型,number-数字键盘,card-身份证键盘 mode: { type: String, default: 'number' }, // 是否显示键盘的"."符号 dotDisabled: { type: Boolean, default: false }, // 是否打乱键盘按键的顺序 random: { type: Boolean, default: false } } }
2301_77169380/AppruanjianApk
uni_modules/uv-keyboard/components/uv-keyboard-number/props.js
JavaScript
unknown
335
<template> <view class="uv-keyboard" @touchmove.stop.prevent="noop" > <view class="uv-keyboard__button-wrapper" v-for="(item, index) in numList" :key="index" > <view class="uv-keyboard__button-wrapper__button" :style="[itemStyle(index)]" @tap="keyboardClick(item)" hover-class="uv-hover-class" :hover-stay-time="200" > <text class="uv-keyboard__button-wrapper__button__text">{{ item }}</text> </view> </view> <view class="uv-keyboard__button-wrapper" > <view class="uv-keyboard__button-wrapper__button uv-keyboard__button-wrapper__button--gray" hover-class="uv-hover-class" :hover-stay-time="200" @touchstart.stop="backspaceClick" @touchend="clearTimer" > <uv-icon name="backspace" color="#303133" size="28" ></uv-icon> </view> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * keyboard 键盘组件 * @description * @tutorial * @property {String} mode 键盘的类型,number-数字键盘,card-身份证键盘 * @property {Boolean} dotDisabled 是否显示键盘的"."符号 * @property {Boolean} random 是否打乱键盘按键的顺序 * @event {Function} change 点击键盘触发 * @event {Function} backspace 点击退格键触发 * @example */ export default { mixins: [mpMixin, mixin, props], emits: ['backspace','change'], data() { return { backspace: 'backspace', // 退格键内容 dot: '.', // 点 timer: null, // 长按多次删除的事件监听 cardX: 'X' // 身份证的X符号 }; }, computed: { // 键盘需要显示的内容 numList() { let tmp = []; if (this.dotDisabled && this.mode == 'number') { if (!this.random) { return [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; } else { return this.$uv.randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]); } } else if (!this.dotDisabled && this.mode == 'number') { if (!this.random) { return [1, 2, 3, 4, 5, 6, 7, 8, 9, this.dot, 0]; } else { return this.$uv.randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, this.dot, 0]); } } else if (this.mode == 'card') { if (!this.random) { return [1, 2, 3, 4, 5, 6, 7, 8, 9, this.cardX, 0]; } else { return this.$uv.randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, this.cardX, 0]); } } }, // 按键的样式,在非乱序&&数字键盘&&不显示点按钮时,index为9时,按键占位两个空间 itemStyle() { return index => { let style = {}; if (this.mode == 'number' && this.dotDisabled && index == 9) style.width = '464rpx'; return style; }; }, // 是否让按键显示灰色,只在非乱序&&数字键盘&&且允许点按键的时候 btnBgGray() { return index => { if (!this.random && index == 9 && (this.mode != 'number' || (this.mode == 'number' && !this .dotDisabled))) return true; else return false; }; }, }, created() { }, methods: { // 点击退格键 backspaceClick() { this.$emit('backspace'); clearInterval(this.timer); //再次清空定时器,防止重复注册定时器 this.timer = null; this.timer = setInterval(() => { this.$emit('backspace'); }, 250); }, clearTimer() { clearInterval(this.timer); this.timer = null; }, // 获取键盘显示的内容 keyboardClick(val) { // 允许键盘显示点模式和触发非点按键时,将内容转为数字类型 if (!this.dotDisabled && val != this.dot && val != this.cardX) val = Number(val); this.$emit('change', val); } } }; </script> <style lang="scss" scoped> $show-hover: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-number-keyboard-background-color:rgb(224, 228, 230) !default; $uv-number-keyboard-padding:8px 10rpx 8px 10rpx !default; $uv-number-keyboard-button-width:222rpx !default; $uv-number-keyboard-button-margin:4px 6rpx !default; $uv-number-keyboard-button-border-top-left-radius:4px !default; $uv-number-keyboard-button-border-top-right-radius:4px !default; $uv-number-keyboard-button-border-bottom-left-radius:4px !default; $uv-number-keyboard-button-border-bottom-right-radius:4px !default; $uv-number-keyboard-button-height: 90rpx!default; $uv-number-keyboard-button-background-color:#FFFFFF !default; $uv-number-keyboard-button-box-shadow:0 2px 0px #BBBCBE !default; $uv-number-keyboard-text-font-size:20px !default; $uv-number-keyboard-text-font-weight:500 !default; $uv-number-keyboard-text-color:$uv-main-color !default; $uv-number-keyboard-gray-background-color:rgb(200, 202, 210) !default; $uv-number-keyboard-uv-hover-class-background-color: #BBBCC6 !default; .uv-keyboard { @include flex; flex-direction: row; justify-content: space-around; background-color: $uv-number-keyboard-background-color; flex-wrap: wrap; padding: $uv-number-keyboard-padding; &__button-wrapper { box-shadow: $uv-number-keyboard-button-box-shadow; margin: $uv-number-keyboard-button-margin; border-top-left-radius: $uv-number-keyboard-button-border-top-left-radius; border-top-right-radius: $uv-number-keyboard-button-border-top-right-radius; border-bottom-left-radius: $uv-number-keyboard-button-border-bottom-left-radius; border-bottom-right-radius: $uv-number-keyboard-button-border-bottom-right-radius; &__button { width: $uv-number-keyboard-button-width; height: $uv-number-keyboard-button-height; background-color: $uv-number-keyboard-button-background-color; @include flex; justify-content: center; align-items: center; border-top-left-radius: $uv-number-keyboard-button-border-top-left-radius; border-top-right-radius: $uv-number-keyboard-button-border-top-right-radius; border-bottom-left-radius: $uv-number-keyboard-button-border-bottom-left-radius; border-bottom-right-radius: $uv-number-keyboard-button-border-bottom-right-radius; &__text { font-size: $uv-number-keyboard-text-font-size; font-weight: $uv-number-keyboard-text-font-weight; color: $uv-number-keyboard-text-color; } &--gray { background-color: $uv-number-keyboard-gray-background-color; } } } } .uv-hover-class { background-color: $uv-number-keyboard-uv-hover-class-background-color; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-keyboard/components/uv-keyboard-number/uv-keyboard-number.vue
Vue
unknown
6,600
export default { props: { color: { type: String, default: '#d6d7d9' }, // 长度,竖向时表现为高度,横向时表现为长度,可以为百分比,带px单位的值等 length: { type: [String, Number], default: '100%' }, // 线条方向,col-竖向,row-横向 direction: { type: String, default: 'row' }, // 是否显示细边框 hairline: { type: Boolean, default: true }, // 线条与上下左右元素的间距,字符串形式,如"30px"、"20px 30px" margin: { type: [String, Number], default: 0 }, // 是否虚线,true-虚线,false-实线 dashed: { type: Boolean, default: false }, ...uni.$uv?.props?.line } }
2301_77169380/AppruanjianApk
uni_modules/uv-line/components/uv-line/props.js
JavaScript
unknown
709
<template> <view class="uv-line" :style="[lineStyle]" > </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * line 线条 * @description 此组件一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单 * @tutorial https://www.uvui.cn/components/line.html * @property {String} color 线条的颜色 ( 默认 '#d6d7d9' ) * @property {String | Number} length 长度,竖向时表现为高度,横向时表现为长度,可以为百分比,带px单位的值等 ( 默认 '100%' ) * @property {String} direction 线条的方向,row-横向,col-竖向 (默认 'row' ) * @property {Boolean} hairline 是否显示细线条 (默认 true ) * @property {String | Number} margin 线条与上下左右元素的间距,字符串形式,如"30px" (默认 0 ) * @property {Boolean} dashed 是否虚线,true-虚线,false-实线 (默认 false ) * @property {Object} customStyle 定义需要用到的外部样式 * @example <uv-line color="red"></uv-line> */ export default { name: 'uv-line', mixins: [mpMixin, mixin, props], computed: { lineStyle() { const style = {} style.margin = this.margin // 如果是水平线条,边框高度为1px,再通过transform缩小一半,就是0.5px了 if (this.direction === 'row') { // 此处采用兼容分开写,兼容nvue的写法 style.borderBottomWidth = '1px' style.borderBottomStyle = this.dashed ? 'dashed' : 'solid' style.width = this.$uv.addUnit(this.length) if (this.hairline) style.transform = 'scaleY(0.5)' } else { // 如果是竖向线条,边框宽度为1px,再通过transform缩小一半,就是0.5px了 style.borderLeftWidth = '1px' style.borderLeftStyle = this.dashed ? 'dashed' : 'solid' style.height = this.$uv.addUnit(this.length) if (this.hairline) style.transform = 'scaleX(0.5)' } style.borderColor = this.color return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } } } </script> <style lang="scss" scoped> .uv-line { /* #ifndef APP-NVUE */ vertical-align: middle; /* #endif */ } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-line/components/uv-line/uv-line.vue
Vue
unknown
2,364
export default { props: { // 激活部分的颜色 activeColor: { type: String, default: '#19be6b' }, inactiveColor: { type: String, default: '#ececec' }, // 进度百分比,数值 percentage: { type: [String, Number], default: 0 }, // 是否在进度条内部显示百分比的值 showText: { type: Boolean, default: true }, // 进度条的高度,单位px height: { type: [String, Number], default: 12 }, ...uni.$uv?.props?.lineProgress } }
2301_77169380/AppruanjianApk
uni_modules/uv-line-progress/components/uv-line-progress/props.js
JavaScript
unknown
507
<template> <view class="uv-line-progress" :style="[$uv.addStyle(customStyle)]" > <view class="uv-line-progress__background" ref="uv-line-progress__background" :style="[{ backgroundColor: inactiveColor, height: $uv.addUnit($uv.getPx(height)) }]" > </view> <view class="uv-line-progress__line" :style="[progressStyle]" > <slot> <text v-if="showText && percentage >= 10" class="uv-line-progress__text">{{innserPercentage + '%'}}</text> </slot> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') // #endif /** * lineProgress 线型进度条 * @description 展示操作或任务的当前进度,比如上传文件,是一个线形的进度条。 * @tutorial https://www.uvui.cn/components/lineProgress.html * @property {String} activeColor 激活部分的颜色 ( 默认 '#19be6b' ) * @property {String} inactiveColor 背景色 ( 默认 '#ececec' ) * @property {String | Number} percentage 进度百分比,数值 ( 默认 0 ) * @property {Boolean} showText 是否在进度条内部显示百分比的值 ( 默认 true ) * @property {String | Number} height 进度条的高度,单位px ( 默认 12 ) * * @example <uv-line-progress :percent="70" :show-percent="true"></uv-line-progress> */ export default { name: "uv-line-progress", mixins: [mpMixin, mixin, props], data() { return { lineWidth: 0, } }, watch: { percentage(n) { this.resizeProgressWidth() } }, computed: { progressStyle() { let style = {} style.width = this.lineWidth style.backgroundColor = this.activeColor style.height = this.$uv.addUnit(this.$uv.getPx(this.height)) return style }, innserPercentage() { // 控制范围在0-100之间 return this.$uv.range(0, 100, this.percentage) } }, mounted() { this.init() }, methods: { init() { this.$uv.sleep(20).then(() => { this.resizeProgressWidth() }) }, getProgressWidth() { // #ifndef APP-NVUE return this.$uvGetRect('.uv-line-progress__background') // #endif // #ifdef APP-NVUE // 返回一个promise return new Promise(resolve => { dom.getComponentRect(this.$refs['uv-line-progress__background'], (res) => { resolve(res.size) }) }) // #endif }, resizeProgressWidth() { this.getProgressWidth().then(size => { const { width } = size // 通过设置的percentage值,计算其所占总长度的百分比 this.lineWidth = width * this.innserPercentage / 100 + 'px' }) } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-line-progress { align-items: stretch; position: relative; @include flex(row); flex: 1; overflow: hidden; border-radius: 100px; &__background { background-color: #ececec; border-radius: 100px; flex: 1; } &__line { position: absolute; top: 0; left: 0; bottom: 0; align-items: center; @include flex(row); color: #ffffff; border-radius: 100px; transition: width 0.5s ease; justify-content: flex-end; } &__text { font-size: 10px; align-items: center; text-align: right; color: #FFFFFF; margin-right: 5px; transform: scale(0.9); } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-line-progress/components/uv-line-progress/uv-line-progress.vue
Vue
unknown
3,553
export default { props: { // 文字颜色 color: { type: String, default: '' }, // 字体大小,单位px fontSize: { type: [String, Number], default: 14 }, // 是否显示下划线 underLine: { type: Boolean, default: false }, // 要跳转的链接 href: { type: String, default: '' }, // 小程序中复制到粘贴板的提示语 mpTips: { type: String, default: '链接已复制,请在浏览器打开' }, // 下划线颜色 lineColor: { type: String, default: '' }, // 超链接的问题,不使用slot形式传入,是因为nvue下无法修改颜色 text: { type: String, default: '' }, ...uni.$uv?.props?.link } }
2301_77169380/AppruanjianApk
uni_modules/uv-link/components/uv-link/props.js
JavaScript
unknown
712
<template> <text class="uv-link" @tap.stop="openLink" :style="[linkStyle, $uv.addStyle(customStyle)]" >{{text}}</text> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * link 超链接 * @description 该组件为超链接组件,在不同平台有不同表现形式:在APP平台会通过plus环境打开内置浏览器,在小程序中把链接复制到粘贴板,同时提示信息,在H5中通过window.open打开链接。 * @tutorial https://www.uvui.cn/components/link.html * @property {String} color 文字颜色 (默认 color['uv-primary'] ) * @property {String | Number} fontSize 字体大小,单位px (默认 15 ) * @property {Boolean} underLine 是否显示下划线 (默认 false ) * @property {String} href 跳转的链接,要带上http(s) * @property {String} mpTips 各个小程序平台把链接复制到粘贴板后的提示语(默认“链接已复制,请在浏览器打开”) * @property {String} lineColor 下划线颜色,默认同color参数颜色 * @property {String} text 超链接的问题,不使用slot形式传入,是因为nvue下无法修改颜色 * @property {Object} customStyle 定义需要用到的外部样式 * * @example <uv-link href="http://www.uvui.cn">蜀道难,难于上青天</uv-link> */ export default { name: "uv-link", emits:['click'], mixins: [mpMixin, mixin, props], computed: { linkStyle() { const style = { color: this.color, fontSize: this.$uv.addUnit(this.fontSize), // line-height设置为比字体大小多2px lineHeight: this.$uv.addUnit(this.$uv.getPx(this.fontSize) + 2), textDecoration: this.underLine ? 'underline' : 'none' } return style } }, methods: { openLink() { // #ifdef APP-PLUS plus.runtime.openURL(this.href) // #endif // #ifdef H5 window.open(this.href) // #endif // #ifdef MP uni.setClipboardData({ data: this.href, success: () => { uni.hideToast(); this.$nextTick(() => { this.$uv.toast(this.mpTips); }) } }); // #endif this.$emit('click') } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-link-line-height:1 !default; .uv-link { /* #ifndef APP-NVUE */ line-height: $uv-link-line-height; /* #endif */ @include flex; flex-wrap: wrap; flex: 1; color: $uv-primary; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-link/components/uv-link/uv-link.vue
Vue
unknown
2,681
<template> <!-- #ifndef APP-NVUE --> <view class="uv-list" :style="[$uv.addStyle(customStyle)]" > <view v-if="border" class="uv-list--border-top" :style="[{ 'background-color': borderColor }]" ></view> <slot /> <view v-if="border" class="uv-list--border-bottom" :style="[{ 'background-color': borderColor }]" ></view> </view> <!-- #endif --> <!-- #ifdef APP-NVUE --> <list :bounce="true" :scrollable="true" show-scrollbar :render-reverse="false" class="uv-list" :class="{ 'uv-list--border': border }" :style="[ { 'border-top-color': borderColor, 'border-bottom-color':borderColor }, $uv.addStyle(customStyle) ]" :enableBackToTop="false" :loadmoreoffset="15" @scroll="scroll" @loadmore="loadMore"> <slot /> </list> <!-- #endif --> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' /** * List 列表 * @description 列表组件 * @tutorial https://www.uvui.cn/components/list.html * @property {Boolean} border = [true|false] 是否显示边框 * @property {String} borderColor 边框颜色 * @property {String} direction 排版方向,默认row,列表里面使用其他组件 最好设置成column */ export default { name: 'uv-list', mixins: [mpMixin, mixin], 'mp-weixin': { options: { multipleSlots: false } }, props: { border: { type: Boolean, default: false }, borderColor: { type: String, default: '#dadbde' }, // 排版方向,默认row,列表里面使用其他组件 最好设置成column direction: { type: String, default: 'row' }, // 内边距 padding: { type: [String,Number], default: '20rpx 30rpx' } }, created() { this.firstChildAppend = false; }, computed: { parentData() { return [this.direction,this.padding]; } }, methods: { loadMore(e) { this.$emit('scrolltolower'); }, scroll(e) { this.$emit('scroll', e); } } }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-list { position: relative; @include flex(column); background-color: #fff; } .uv-list--border { position: relative; /* #ifdef APP-NVUE */ border-top-color: $uv-border-color; border-top-style: solid; border-top-width: 0.5px; border-bottom-color: $uv-border-color; border-bottom-style: solid; border-bottom-width: 0.5px; /* #endif */ z-index: -1; } /* #ifndef APP-NVUE */ .uv-list--border-top { position: absolute; top: 0; right: 0; left: 0; height: 1px; -webkit-transform: scaleY(0.5); transform: scaleY(0.5); background-color: $uv-border-color; z-index: 1; } .uv-list--border-bottom { position: absolute; bottom: 0; right: 0; left: 0; height: 1px; -webkit-transform: scaleY(0.5); transform: scaleY(0.5); background-color: $uv-border-color; } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-list/components/uv-list/uv-list.vue
Vue
unknown
3,082
<template> <!-- #ifdef APP-NVUE --> <cell :keep-scroll-position="keepScrollPosition"> <!-- #endif --> <view :class="{ 'uv-list-item--disabled': disabled }" :style="[$uv.addStyle(customStyle),{'background-color':customStyle.backgroundColor?customStyle.backgroundColor:'#fff'}]" :hover-class="(!clickable && !link) || disabled || showSwitch ? '' : 'uv-list-item--hover'" class="uv-list-item" @click="onClick"> <view v-if="!isFirstChild" class="border--left" :class="{ 'uv-list--border': border }"></view> <view class="uv-list-item__wrapper"> <slot> <view class="uv-list-item__container" :class="{ 'container--right': showArrow || link, 'flex--direction': directionData === 'column'}" :style="{paddingTop:padding.top,paddingLeft:padding.left,paddingRight:padding.right,paddingBottom:padding.bottom}"> <slot name="header"> <view class="uv-list-item__header"> <view v-if="thumb" class="uv-list-item__icon"> <image :src="thumb" class="uv-list-item__icon-img" :class="['uv-list--' + thumbSize]" /> </view> <view v-else-if="showExtraIcon" class="uv-list-item__icon"> <uv-icon :name="extraIcon.icon" :customPrefix="extraIcon.customPrefix" :color="extraIcon.color" :size="extraIcon.size" /> </view> </view> </slot> <slot name="body"> <view class="uv-list-item__content" :class="{ 'uv-list-item__content--center': thumb || showExtraIcon || showBadge || showSwitch }"> <text v-if="title" class="uv-list-item__content-title" :class="[ellipsis && `uv-line-${ellipsis}`]">{{ title }}</text> <text v-if="note" class="uv-list-item__content-note">{{ note }}</text> </view> </slot> <slot name="footer"> <view v-if="rightText || showBadge || showSwitch" class="uv-list-item__extra" :class="{ 'flex--justify': directionData === 'column' }"> <text v-if="rightText" class="uv-list-item__extra-text">{{ rightText }}</text> <uv-badge v-if="showBadge" :show="!!(badge.show || badge.isDot || badge.value)" :isDot="badge.isDot" :value="badge.value" :max="badge.max" :type="badge.type" :showZero="badge.showZero" :bgColor="badge.bgColor" :color="badge.color" :shape="badge.shape" :numberType="badge.numberType" :inverted="badge.inverted" customStyle="margin-left: 4px;" ></uv-badge> <uv-switch v-if="showSwitch" :value="switchChecked" :disabled="disabled" @change="onSwitchChange"></uv-switch> </view> </slot> </view> </slot> </view> <uv-icon v-if="showArrow || link" size="34rpx" class="uv-icon-wrapper" color="#bbb" name="arrow-right" /> </view> <!-- #ifdef APP-NVUE --> </cell> <!-- #endif --> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' /** * ListItem 列表子组件 * @description 列表子组件 * @tutorial https://ext.dcloud.net.cn/plugin?id=24 * @property {String} title 标题 * @property {String} note 描述 * @property {String} thumb 左侧缩略图,若thumb有值,则不会显示扩展图标 * @property {String} thumbSize = [lg|base|sm] 略缩图大小 * @value lg 大图 * @value base 一般 * @value sm 小图 * @property {String} rightText 右侧文字内容 * @property {Boolean} disabled = [true|false] 是否禁用 * @property {Boolean} clickable = [true|false] 是否开启点击反馈 * @property {String} link = [navigateTo|redirectTo|reLaunch|switchTab] 是否展示右侧箭头并开启点击反馈 * @value navigateTo 同 uni.navigateTo() * @value redirectTo 同 uni.redirectTo() * @value reLaunch 同 uni.reLaunch() * @value switchTab 同 uni.switchTab() * @property {String | PageURIString} to 跳转目标页面 * @property {Boolean} showBadge = [true|false] 是否显示数字角标 * @property {Object} badge 扩展数字角标的参数,格式为 :badge="{value: 122}" * @property {Boolean} showSwitch = [true|false] 是否显示Switch * @property {Boolean} switchChecked = [true|false] Switch是否被选中 * @property {Boolean} showExtraIcon = [true|false] 左侧是否显示扩展图标 * @property {Object} extraIcon 扩展图标参数,格式为 :extraIcon="{icon: 'photo',size: '30px'}" * @property {String} direction = [row|column] 排版方向 * @value row 水平排列 * @value column 垂直排列 * @event {Function} click 点击 uniListItem 触发事件 * @event {Function} switchChange 点击切换 Switch 时触发 */ export default { name: 'uv-list-item', mixins: [mpMixin, mixin], emits: ['click', 'switchChange'], props: { direction: { type: String, default: 'row' }, title: { type: String, default: '' }, note: { type: String, default: '' }, ellipsis: { type: [Number, String], default: 0 }, disabled: { type: [Boolean, String], default: false }, clickable: { type: Boolean, default: false }, showArrow: { type: [Boolean, String], default: false }, link: { type: [Boolean, String], default: false }, to: { type: String, default: '' }, showSwitch: { type: [Boolean, String], default: false }, switchChecked: { type: [Boolean, String], default: false }, showBadge: { type: [Boolean, String], default: false }, badge: { type: Object, default () { return {} } }, rightText: { type: String, default: '' }, thumb: { type: String, default: '' }, thumbSize: { type: String, default: 'base' }, showExtraIcon: { type: [Boolean, String], default: false }, extraIcon: { type: Object, default () { return { name: '', color: '#000000', size: 20, customPrefix: '' }; } }, border: { type: Boolean, default: false }, customStyle: { type: Object, default () { return { padding: '', backgroundColor: '#FFFFFF' } } }, keepScrollPosition: { type: Boolean, default: false } }, computed: { directionData(){ return this.direction ? this.direction : (this.parentData.direction ? this.parentData.direction : 'row'); } }, watch: { 'customStyle.padding': { handler(padding) { if(padding) this.setPadding(padding); }, immediate: true } }, data() { return { isFirstChild: false, padding: { top: "", right: "", bottom: "", left: "" }, parentData: { direction: 'row', padding: 0 } }; }, created() { this.updateParentData(); }, mounted() { this.init(); this.list = this.getForm() // 判断是否存在 uv-list 组件 if (this.list) { if (!this.list.firstChildAppend) { this.list.firstChildAppend = true; this.isFirstChild = true; } } }, methods: { init(){ if (!this.parent) { this.$uv.error('uv-list-item必须搭配uv-list组件使用'); } this.$nextTick(()=>{ if(!(this.padding.top || this.padding.right|| this.padding.bottom|| this.padding.left)){ this.setPadding(this.parentData.padding); } }) }, updateParentData() { this.getParentData('uv-list'); }, setPadding(padding){ if(typeof padding == 'number'){ padding += '' } let paddingArr = padding.split(' ') if (paddingArr.length === 1) { const allPadding = paddingArr[0] this.padding = { "top": allPadding, "right": allPadding, "bottom": allPadding, "left": allPadding } } else if (paddingArr.length === 2) { const [verticalPadding, horizontalPadding] = paddingArr; this.padding = { "top": verticalPadding, "right": horizontalPadding, "bottom": verticalPadding, "left": horizontalPadding } } else if (paddingArr.length === 4) { const [topPadding, rightPadding, bottomPadding, leftPadding] = paddingArr; this.padding = { "top": topPadding, "right": rightPadding, "bottom": bottomPadding, "left": leftPadding } } }, /** * 获取父元素实例 */ getForm(name = 'uniList') { let parent = this.$parent; let parentName = parent.$options.name; while (parentName !== name) { parent = parent.$parent; if (!parent) return false parentName = parent.$options.name; } return parent; }, onClick() { if (this.to !== '') { this.openPage(); return; } if (this.clickable || this.link) { this.$emit('click', { data: {} }); } }, onSwitchChange(e) { this.$emit('switchChange', e); }, openPage() { if (['navigateTo', 'redirectTo', 'reLaunch', 'switchTab'].indexOf(this.link) !== -1) { this.pageApi(this.link); } else { this.pageApi('navigateTo'); } }, pageApi(api) { let callback = { url: this.to, success: res => { this.$emit('click', { data: res }); }, fail: err => { this.$emit('click', { data: err }); } } switch (api) { case 'navigateTo': uni.navigateTo(callback) break case 'redirectTo': uni.redirectTo(callback) break case 'reLaunch': uni.reLaunch(callback) break case 'switchTab': uni.switchTab(callback) break default: uni.navigateTo(callback) } } } }; </script> <style lang="scss" scoped> $show-lines: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; $uv-font-size-sm:12px; $uv-font-size-base:14px; $uv-font-size-lg:16px; $uv-spacing-col-lg: 12px; $uv-spacing-row-lg: 15px; $uv-img-size-sm:20px; $uv-img-size-base:26px; $uv-img-size-lg:40px; $uv-border-color:#e5e5e5; $uv-bg-color-hover:#f1f1f1; $uv-text-color-grey:#999; $list-item-pd: $uv-spacing-col-lg $uv-spacing-row-lg; .uv-list-item { @include flex(row); font-size: $uv-font-size-lg; position: relative; justify-content: space-between; align-items: center; background-color: #fff; /* #ifdef H5 */ cursor: pointer; /* #endif */ } .uv-list-item--disabled { opacity: 0.3; } .uv-list-item--hover { background-color: $uv-bg-color-hover !important; } .uv-list-item__wrapper { @include flex(column); flex: 1; } .uv-list-item__container { position: relative; @include flex(row); padding: $list-item-pd; padding-left: $uv-spacing-row-lg; flex: 1; overflow: hidden; } .container--right { padding-right: 0; } .uv-list--border { position: absolute; top: 0; right: 0; left: 0; /* #ifdef APP-NVUE */ border-top-color: $uv-border-color; border-top-style: solid; border-top-width: 0.5px; /* #endif */ } /* #ifndef APP-NVUE */ .uv-list--border:after { position: absolute; top: 0; right: 0; left: 0; height: 1px; content: ''; -webkit-transform: scaleY(0.5); transform: scaleY(0.5); background-color: $uv-border-color; } /* #endif */ .uv-list-item__content { @include flex(column); padding-right: 8px; flex: 1; color: #3b4144; justify-content: space-between; overflow: hidden; } .uv-list-item__content--center { justify-content: center; } .uv-list-item__content-title { font-size: $uv-font-size-base; color: #3b4144; overflow: hidden; } .uv-list-item__content-note { margin-top: 6rpx; color: $uv-text-color-grey; font-size: $uv-font-size-sm; overflow: hidden; } .uv-list-item__extra { @include flex(row); justify-content: flex-end; align-items: center; } .uv-list-item__header { @include flex(row); align-items: center; } .uv-list-item__icon { margin-right: 18rpx; flex-direction: row; justify-content: center; align-items: center; } .uv-list-item__icon-img { /* #ifndef APP-NVUE */ display: block; /* #endif */ height: $uv-img-size-base; width: $uv-img-size-base; margin-right: 10px; } .uv-icon-wrapper { /* #ifndef APP-NVUE */ display: flex; /* #endif */ align-items: center; padding: 0 10px; } .flex--direction { flex-direction: column; /* #ifndef APP-NVUE */ align-items: initial; /* #endif */ } .flex--justify { /* #ifndef APP-NVUE */ justify-content: initial; /* #endif */ } .uv-list--lg { height: $uv-img-size-lg; width: $uv-img-size-lg; } .uv-list--base { height: $uv-img-size-base; width: $uv-img-size-base; } .uv-list--sm { height: $uv-img-size-sm; width: $uv-img-size-sm; } .uv-list-item__extra-text { color: $uv-text-color-grey; font-size: $uv-font-size-sm; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-list/components/uv-list-item/uv-list-item.vue
Vue
unknown
13,019
export default { props: { // 组件状态,loadmore-加载前的状态,loading-加载中的状态,nomore-没有更多的状态 status: { type: String, default: 'loadmore' }, // 组件背景色 bgColor: { type: String, default: 'transparent' }, // 是否显示加载中的图标 icon: { type: Boolean, default: true }, // 字体大小 fontSize: { type: [String, Number], default: 14 }, // 图标大小 iconSize: { type: [String, Number], default: 16 }, // 字体颜色 color: { type: String, default: '#606266' }, // 加载中状态的图标,spinner-花朵状图标,circle-圆圈状,semicircle-半圆 loadingIcon: { type: String, default: 'spinner' }, // 加载前的提示语 loadmoreText: { type: String, default: '加载更多' }, // 加载中提示语 loadingText: { type: String, default: '正在加载...' }, // 没有更多的提示语 nomoreText: { type: String, default: '没有更多了' }, // 在“没有更多”状态下,是否显示粗点 isDot: { type: Boolean, default: false }, // 加载中图标的颜色 iconColor: { type: String, default: '#b7b7b7' }, // 上边距 marginTop: { type: [String, Number], default: 10 }, // 下边距 marginBottom: { type: [String, Number], default: 10 }, // 高度,单位px height: { type: [String, Number], default: 'auto' }, // 是否显示左边分割线 line: { type: Boolean, default: false }, // 线条颜色 lineColor: { type: String, default: '#E6E8EB' }, // 是否虚线,true-虚线,false-实线 dashed: { type: Boolean, default: false }, ...uni.$uv?.props?.loadmore } }
2301_77169380/AppruanjianApk
uni_modules/uv-load-more/components/uv-load-more/props.js
JavaScript
unknown
1,768
<template> <view class="uv-loadmore" :style="[{ backgroundColor: bgColor, marginBottom: $uv.addUnit(marginBottom), marginTop: $uv.addUnit(marginTop), height: $uv.addUnit(height), }, $uv.addStyle(customStyle)]" > <uv-line length="140rpx" :color="lineColor" :hairline="false" :dashed="dashed" v-if="line" ></uv-line> <!-- 加载中和没有更多的状态才显示两边的横线 --> <view :class="status == 'loadmore' || status == 'nomore' ? 'uv-more' : ''" class="uv-loadmore__content" > <view class="uv-loadmore__content__icon-wrap" v-if="status === 'loading' && icon" > <uv-loading-icon :color="iconColor" :size="iconSize" :mode="loadingIcon" ></uv-loading-icon> </view> <!-- 如果没有更多的状态下,显示内容为dot(粗点),加载特定样式 --> <text class="uv-line-1" :style="[loadTextStyle]" :class="[(status == 'nomore' && isDot == true) ? 'uv-loadmore__content__dot-text' : 'uv-loadmore__content__text']" @tap="loadMore" >{{ showText }}</text> </view> <uv-line length="140rpx" :color="lineColor" :hairline="false" :dashed="dashed" v-if="line" ></uv-line> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * loadmore 加载更多 * @description 此组件一般用于标识页面底部加载数据时的状态。 * @tutorial https://www.uvui.cn/components/loadMore.html * @property {String} status 组件状态(默认 'loadmore' ) * @property {String} bgColor 组件背景颜色,在页面是非白色时会用到(默认 'transparent' ) * @property {Boolean} icon 加载中时是否显示图标(默认 true ) * @property {String | Number} fontSize 字体大小(默认 14 ) * @property {String | Number} iconSize 图标大小(默认 17 ) * @property {String} color 字体颜色(默认 '#606266' ) * @property {String} loadingIcon 加载图标(默认 'circle' ) * @property {String} loadmoreText 加载前的提示语(默认 '加载更多' ) * @property {String} loadingText 加载中提示语(默认 '正在加载...' ) * @property {String} nomoreText 没有更多的提示语(默认 '没有更多了' ) * @property {Boolean} isDot 到上一个相邻元素的距离 (默认 false ) * @property {String} iconColor 加载中图标的颜色 (默认 '#b7b7b7' ) * @property {String} lineColor 线条颜色(默认 #E6E8EB ) * @property {String | Number} marginTop 上边距 (默认 10 ) * @property {String | Number} marginBottom 下边距 (默认 10 ) * @property {String | Number} height 高度,单位px (默认 'auto' ) * @property {Boolean} line 是否显示左边分割线 (默认 false ) * @property {Boolean} dashed // 是否虚线,true-虚线,false-实线 (默认 false ) * @event {Function} loadmore status为loadmore时,点击组件会发出此事件 * @example <uv-loadmore :status="status" icon-type="iconType" load-text="loadText" /> */ export default { name: "uv-loadmore", mixins: [mpMixin, mixin,props], data() { return { // 粗点 dotText: "●" } }, computed: { // 加载的文字显示的样式 loadTextStyle() { return { color: this.color, fontSize: this.$uv.addUnit(this.fontSize), lineHeight: this.$uv.addUnit(this.fontSize), backgroundColor: this.bgColor, } }, // 显示的提示文字 showText() { let text = ''; if (this.status == 'loadmore') text = this.loadmoreText else if (this.status == 'loading') text = this.loadingText else if (this.status == 'nomore' && this.isDot) text = this.dotText; else text = this.nomoreText; return text; } }, methods: { loadMore() { // 只有在“加载更多”的状态下才发送点击事件,内容不满一屏时无法触发底部上拉事件,所以需要点击来触发 if (this.status == 'loadmore') this.$emit('loadmore'); } } } </script> <style lang="scss" scoped> $show-lines: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-loadmore { @include flex(row); align-items: center; justify-content: center; flex: 1; &__content { margin: 0 15px; @include flex(row); align-items: center; justify-content: center; &__icon-wrap { margin-right: 8px; } &__text { font-size: 14px; color: $uv-content-color; } &__dot-text { font-size: 15px; color: $uv-tips-color; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-load-more/components/uv-load-more/uv-load-more.vue
Vue
unknown
4,922
export default { props: { // 是否显示组件 show: { type: Boolean, default: true }, // 颜色 color: { type: String, default: '#909193' }, // 提示文字颜色 textColor: { type: String, default: '#909193' }, // 文字和图标是否垂直排列 vertical: { type: Boolean, default: false }, // 模式选择,circle-圆形,spinner-花朵形,semicircle-半圆形 mode: { type: String, default: 'spinner' }, // 图标大小,单位默认px size: { type: [String, Number], default: 24 }, // 文字大小 textSize: { type: [String, Number], default: 15 }, // 文字样式 textStyle: { type: Object, default () { return {} } }, // 文字内容 text: { type: [String, Number], default: '' }, // 动画模式 https://www.runoob.com/cssref/css3-pr-animation-timing-function.html timingFunction: { type: String, default: 'linear' }, // 动画执行周期时间 duration: { type: [String, Number], default: 1200 }, // mode=circle时的暗边颜色 inactiveColor: { type: String, default: '' }, ...uni.$uv?.props?.loadingIcon } }
2301_77169380/AppruanjianApk
uni_modules/uv-loading-icon/components/uv-loading-icon/props.js
JavaScript
unknown
1,183
<template> <view class="uv-loading-icon" :style="[$uv.addStyle(customStyle)]" :class="[vertical && 'uv-loading-icon--vertical']" v-if="show" > <view v-if="!webviewHide" class="uv-loading-icon__spinner" :class="[`uv-loading-icon__spinner--${mode}`]" ref="ani" :style="{ color: color, width: $uv.addUnit(size), height: $uv.addUnit(size), borderTopColor: color, borderBottomColor: otherBorderColor, borderLeftColor: otherBorderColor, borderRightColor: otherBorderColor, 'animation-duration': `${duration}ms`, 'animation-timing-function': mode === 'semicircle' || mode === 'circle' ? timingFunction : '' }" > <block v-if="mode === 'spinner'"> <!-- #ifndef APP-NVUE --> <view v-for="(item, index) in array12" :key="index" class="uv-loading-icon__dot" > </view> <!-- #endif --> <!-- #ifdef APP-NVUE --> <!-- 此组件内部图标部分无法设置宽高,即使通过width和height配置了也无效 --> <loading-indicator v-if="!webviewHide" class="uv-loading-indicator" :animating="true" :style="{ color: color, width: $uv.addUnit(size), height: $uv.addUnit(size) }" /> <!-- #endif --> </block> </view> <text v-if="text" class="uv-loading-icon__text" :style="[{ fontSize: $uv.addUnit(textSize), color: textColor, },$uv.addStyle(textStyle)]" >{{text}}</text> </view> </template> <script> import { colorGradient } from '@/uni_modules/uv-ui-tools/libs/function/colorGradient.js' import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; // #ifdef APP-NVUE const animation = weex.requireModule('animation'); // #endif /** * loading 加载动画 * @description 警此组件为一个小动画,目前用在uvui的loadmore加载更多和switch开关等组件的正在加载状态场景。 * @tutorial https://www.uvui.cn/components/loading.html * @property {Boolean} show 是否显示组件 (默认 true) * @property {String} color 动画活动区域的颜色,只对 mode = flower 模式有效(默认#909193) * @property {String} textColor 提示文本的颜色(默认#909193) * @property {Boolean} vertical 文字和图标是否垂直排列 (默认 false ) * @property {String} mode 模式选择,见官网说明(默认 'circle' ) * @property {String | Number} size 加载图标的大小,单位px (默认 24 ) * @property {String | Number} textSize 文字大小(默认 15 ) * @property {String | Number} text 文字内容 * @property {Object} textStyle 文字样式 * @property {String} timingFunction 动画模式 (默认 'ease-in-out' ) * @property {String | Number} duration 动画执行周期时间(默认 1200) * @property {String} inactiveColor mode=circle时的暗边颜色 * @property {Object} customStyle 定义需要用到的外部样式 * @example <uv-loading mode="circle"></uv-loading> */ export default { name: 'uv-loading-icon', mixins: [mpMixin, mixin, props], data() { return { // Array.form可以通过一个伪数组对象创建指定长度的数组 // https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array/from array12: Array.from({ length: 12 }), // 这里需要设置默认值为360,否则在安卓nvue上,会延迟一个duration周期后才执行 // 在iOS nvue上,则会一开始默认执行两个周期的动画 aniAngel: 360, // 动画旋转角度 webviewHide: false, // 监听webview的状态,如果隐藏了页面,则停止动画,以免性能消耗 loading: false, // 是否运行中,针对nvue使用 } }, computed: { // 当为circle类型时,给其另外三边设置一个更轻一些的颜色 // 之所以需要这么做的原因是,比如父组件传了color为红色,那么需要另外的三个边为浅红色 // 而不能是固定的某一个其他颜色(因为这个固定的颜色可能浅蓝,导致效果没有那么细腻良好) otherBorderColor() { const lightColor = colorGradient(this.color, '#ffffff', 100)[80] if (this.mode === 'circle') { return this.inactiveColor ? this.inactiveColor : lightColor } else { return 'transparent' } } }, watch: { show(n) { // nvue中,show为true,且为非loading状态,就重新执行动画模块 // #ifdef APP-NVUE if (n && !this.loading) { setTimeout(() => { this.startAnimate() }, 30) } // #endif } }, mounted() { this.init() }, methods: { init() { setTimeout(() => { // #ifdef APP-NVUE this.show && this.nvueAnimate() // #endif // #ifdef APP-PLUS this.show && this.addEventListenerToWebview() // #endif }, 20) }, // 监听webview的显示与隐藏 addEventListenerToWebview() { // webview的堆栈 const pages = getCurrentPages() // 当前页面 const page = pages[pages.length - 1] // 当前页面的webview实例 const currentWebview = page.$getAppWebview() // 监听webview的显示与隐藏,从而停止或者开始动画(为了性能) currentWebview.addEventListener('hide', () => { this.webviewHide = true }) currentWebview.addEventListener('show', () => { this.webviewHide = false }) }, // #ifdef APP-NVUE nvueAnimate() { // nvue下,非spinner类型时才需要旋转,因为nvue的spinner类型,使用了weex的 // loading-indicator组件,自带旋转功能 this.mode !== 'spinner' && this.startAnimate() }, // 执行nvue的animate模块动画 startAnimate() { this.loading = true const ani = this.$refs.ani if (!ani) return animation.transition(ani, { // 进行角度旋转 styles: { transform: `rotate(${this.aniAngel}deg)`, transformOrigin: 'center center' }, duration: this.duration, timingFunction: this.timingFunction, // delay: 10 }, () => { // 每次增加360deg,为了让其重新旋转一周 this.aniAngel += 360 // 动画结束后,继续循环执行动画,需要同时判断webviewHide变量 // nvue安卓,页面隐藏后依然会继续执行startAnimate方法 this.show && !this.webviewHide ? this.startAnimate() : this.loading = false }) } // #endif } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-loading-icon-color: #c8c9cc !default; $uv-loading-icon-text-margin-left:4px !default; $uv-loading-icon-text-color:$uv-content-color !default; $uv-loading-icon-text-font-size:14px !default; $uv-loading-icon-text-line-height:20px !default; $uv-loading-width:30px !default; $uv-loading-height:30px !default; $uv-loading-max-width:100% !default; $uv-loading-max-height:100% !default; $uv-loading-semicircle-border-width: 2px !default; $uv-loading-semicircle-border-color:transparent !default; $uv-loading-semicircle-border-top-right-radius: 100px !default; $uv-loading-semicircle-border-top-left-radius: 100px !default; $uv-loading-semicircle-border-bottom-left-radius: 100px !default; $uv-loading-semicircle-border-bottom-right-radiu: 100px !default; $uv-loading-semicircle-border-style: solid !default; $uv-loading-circle-border-top-right-radius: 100px !default; $uv-loading-circle-border-top-left-radius: 100px !default; $uv-loading-circle-border-bottom-left-radius: 100px !default; $uv-loading-circle-border-bottom-right-radiu: 100px !default; $uv-loading-circle-border-width:2px !default; $uv-loading-circle-border-top-color:#e5e5e5 !default; $uv-loading-circle-border-right-color:$uv-loading-circle-border-top-color !default; $uv-loading-circle-border-bottom-color:$uv-loading-circle-border-top-color !default; $uv-loading-circle-border-left-color:$uv-loading-circle-border-top-color !default; $uv-loading-circle-border-style:solid !default; $uv-loading-icon-host-font-size:0px !default; $uv-loading-icon-host-line-height:1 !default; $uv-loading-icon-vertical-margin:6px 0 0 !default; $uv-loading-icon-dot-top:0 !default; $uv-loading-icon-dot-left:0 !default; $uv-loading-icon-dot-width:100% !default; $uv-loading-icon-dot-height:100% !default; $uv-loading-icon-dot-before-width:2px !default; $uv-loading-icon-dot-before-height:25% !default; $uv-loading-icon-dot-before-margin:0 auto !default; $uv-loading-icon-dot-before-background-color:currentColor !default; $uv-loading-icon-dot-before-border-radius:40% !default; .uv-loading-icon { /* #ifndef APP-NVUE */ // display: inline-flex; /* #endif */ flex-direction: row; align-items: center; justify-content: center; color: $uv-loading-icon-color; &__text { margin-left: $uv-loading-icon-text-margin-left; color: $uv-loading-icon-text-color; font-size: $uv-loading-icon-text-font-size; line-height: $uv-loading-icon-text-line-height; } &__spinner { width: $uv-loading-width; height: $uv-loading-height; position: relative; /* #ifndef APP-NVUE */ box-sizing: border-box; max-width: $uv-loading-max-width; max-height: $uv-loading-max-height; animation: uv-rotate 1s linear infinite; /* #endif */ } &__spinner--semicircle { border-width: $uv-loading-semicircle-border-width; border-color: $uv-loading-semicircle-border-color; border-top-right-radius: $uv-loading-semicircle-border-top-right-radius; border-top-left-radius: $uv-loading-semicircle-border-top-left-radius; border-bottom-left-radius: $uv-loading-semicircle-border-bottom-left-radius; border-bottom-right-radius: $uv-loading-semicircle-border-bottom-right-radiu; border-style: $uv-loading-semicircle-border-style; } &__spinner--circle { border-top-right-radius: $uv-loading-circle-border-top-right-radius; border-top-left-radius: $uv-loading-circle-border-top-left-radius; border-bottom-left-radius: $uv-loading-circle-border-bottom-left-radius; border-bottom-right-radius: $uv-loading-circle-border-bottom-right-radiu; border-width: $uv-loading-circle-border-width; border-top-color: $uv-loading-circle-border-top-color; border-right-color: $uv-loading-circle-border-right-color; border-bottom-color: $uv-loading-circle-border-bottom-color; border-left-color: $uv-loading-circle-border-left-color; border-style: $uv-loading-circle-border-style; } &--vertical { flex-direction: column } } /* #ifndef APP-NVUE */ :host { font-size: $uv-loading-icon-host-font-size; line-height: $uv-loading-icon-host-line-height; } .uv-loading-icon { &__spinner--spinner { animation-timing-function: steps(12) } &__text:empty { display: none } &--vertical &__text { margin: $uv-loading-icon-vertical-margin; color: $uv-content-color; } &__dot { position: absolute; top: $uv-loading-icon-dot-top; left: $uv-loading-icon-dot-left; width: $uv-loading-icon-dot-width; height: $uv-loading-icon-dot-height; &:before { display: block; width: $uv-loading-icon-dot-before-width; height: $uv-loading-icon-dot-before-height; margin: $uv-loading-icon-dot-before-margin; background-color: $uv-loading-icon-dot-before-background-color; border-radius: $uv-loading-icon-dot-before-border-radius; content: " " } } } @for $i from 1 through 12 { .uv-loading-icon__dot:nth-of-type(#{$i}) { transform: rotate($i * 30deg); opacity: 1 - 0.0625 * ($i - 1); } } @keyframes uv-rotate { 0% { transform: rotate(0deg) } to { transform: rotate(1turn) } } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-loading-icon/components/uv-loading-icon/uv-loading-icon.vue
Vue
unknown
11,835
export default { props: { // 提示内容 loadingText: { type: [String, Number], default: '' }, // 文字上方用于替换loading动画的图片 image: { type: String, default: '' }, // 加载动画的模式,circle-圆形,spinner-花朵形,semicircle-半圆形 loadingMode: { type: String, default: 'circle' }, // 是否加载中 loading: { type: Boolean, default: false }, // 背景色 bgColor: { type: String, default: '#fff' }, // 文字颜色 color: { type: String, default: '#C8C8C8' }, // 文字大小 fontSize: { type: [String, Number], default: 16 }, // 图标大小 iconSize: { type: [String, Number], default: 26 }, // 加载中图标的颜色,只能rgb或者十六进制颜色值 loadingColor: { type: String, default: '#C8C8C8' }, // 过渡时间 duration: { type: [String, Number], default: 300 }, ...uni.$uv?.props?.loadingPage } }
2301_77169380/AppruanjianApk
uni_modules/uv-loading-page/components/uv-loading-page/props.js
JavaScript
unknown
978
<template> <view class="uv-loading-page uv-flex-column" v-if="showLoading" :style="[loadingPageStyle]"> <image v-if="image!=''" :src="image" class="uv-loading-page__img" mode="widthFit" :style="[{ width: $uv.addUnit(iconSize), height: $uv.addUnit(iconSize) }]"></image> <uv-loading-icon v-else :mode="loadingMode" :size="iconSize" :color="loadingColor"></uv-loading-icon> <slot> <text class="uv-loading-page__text" :style="[{ fontSize: $uv.addUnit(fontSize), color: color }]">{{ loadingText }}</text> </slot> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from "./props.js"; /** * loadingPage 加载动画 * @description 警此组件为一个小动画,目前用在uvui的loadmore加载更多和switch开关等组件的正在加载状态场景。 * @tutorial https://www.uvui.cn/components/loading.html * * @property {Boolean} loading 是否加载中 (默认 false ) * @property {String | Number} loadingText 提示内容 (默认 '正在加载' ) * @property {String} image 文字上方用于替换loading动画的图片 * @property {String} loadingMode 加载动画的模式,circle-圆形,spinner-花朵形,semicircle-半圆形 (默认 'circle' ) * @property {String} bgColor 背景色 (默认 '#ffffff' ) * @property {String} color 文字颜色 (默认 '#C8C8C8' ) * @property {String | Number} fontSize 文字大小 (默认 19 ) * @property {String | Number} iconSize 图标大小 (默认 28 ) * @property {String} loadingColor 加载中图标的颜色,只能rgb或者十六进制颜色值 (默认 '#C8C8C8' ) * @property {String | Number} duration 关闭加载时的过渡时间,单位ms (默认 300 ) * * @example <uv-loading mode="circle"></uv-loading> */ export default { name: "uv-loading-page", mixins: [mpMixin, mixin, props], data() { return { showLoading: false, opacity: 1 } }, watch: { loading: { immediate: true, handler(newVal) { if (newVal) { this.showLoading = true; this.opacity = 1; } else { this.opacity = 0; this.$nextTick(() => { this.$uv.sleep(this.duration).then(res => { this.showLoading = false; }) }) } } } }, computed: { loadingPageStyle() { const style = { 'position': 'fixed', 'top': '0', 'left': '0', 'right': '0', 'bottom': '0', 'zIndex': '999', 'background-color': this.bgColor, 'transition-duration': `${this.duration}ms`, 'opacity': this.opacity } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } } } </script> <style scoped lang="scss"> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; $uv-loading-icon-margin-bottom: 10px !default; .uv-loading-page { flex: 1; justify-content: center; align-items: center; padding-bottom: 150px; transition-property: opacity; &__text { margin-top: $uv-loading-icon-margin-bottom; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-loading-page/components/uv-loading-page/uv-loading-page.vue
Vue
unknown
3,161
export default { props: { // 标题 title: { type: [String], default: '' }, // 弹窗内容 content: { type: String, default: '' }, // 确认文案 confirmText: { type: String, default: '确认' }, // 取消文案 cancelText: { type: String, default: '取消' }, // 是否显示确认按钮 showConfirmButton: { type: Boolean, default: true }, // 是否显示取消按钮 showCancelButton: { type: Boolean, default: false }, // 确认按钮颜色 confirmColor: { type: String, default: '#2979ff' }, // 取消文字颜色 cancelColor: { type: String, default: '#606266' }, // 对调确认和取消的位置 buttonReverse: { type: Boolean, default: false }, // 是否开启缩放效果 zoom: { type: Boolean, default: true }, // 层级 zIndex: { type: [String, Number], default: 10075 }, // 是否异步关闭,只对确定按钮有效 asyncClose: { type: Boolean, default: false }, // 是否允许点击遮罩关闭modal closeOnClickOverlay: { type: Boolean, default: true }, // 给一个负的margin-top,往上偏移,避免和键盘重合的情况 negativeTop: { type: [String, Number], default: 0 }, // modal宽度,不支持百分比,可以数值,px,rpx单位 width: { type: [String, Number], default: '650rpx' }, // 文本对齐方式,默认left align: { type: String, default: 'left' }, // 文本自定义样式 textStyle: { type: [Object, String], default: '' }, ...uni.$uv?.props?.modal } }
2301_77169380/AppruanjianApk
uni_modules/uv-modal/components/uv-modal/props.js
JavaScript
unknown
1,618
<template> <uv-popup ref="modalPopup" mode="center" :zoom="zoom" :zIndex="zIndex" :customStyle="{ borderRadius: '6px', overflow: 'hidden', marginTop: `-${$uv.addUnit(negativeTop)}` }" :closeOnClickOverlay="closeOnClickOverlay" :safeAreaInsetBottom="false" :duration="400" @change="popupChange" > <view class="uv-modal" :style="{ width: $uv.addUnit(width), }" > <text class="uv-modal__title" v-if="title" >{{ title }}</text> <view class="uv-modal__content" :style="{ paddingTop: `${title ? 12 : 25}px` }" > <slot> <text class="uv-modal__content__text" :style="[ { textAlign: align }, nvueStyle, $uv.addStyle(textStyle) ]" >{{ content }}</text> </slot> </view> <slot name="confirmButton"> <uv-line></uv-line> <view v-if="showConfirmButton || showCancelButton" class="uv-modal__button-group" :style="{ flexDirection: buttonReverse ? 'row-reverse' : 'row' }" > <view class="uv-modal__button-group__wrapper uv-modal__button-group__wrapper--cancel" :hover-stay-time="150" hover-class="uv-modal__button-group__wrapper--hover" :class="[showCancelButton && !showConfirmButton && 'uv-modal__button-group__wrapper--only-cancel']" v-if="showCancelButton" @tap="cancelHandler" > <text class="uv-modal__button-group__wrapper__text" :style="{ color: cancelColor }" >{{ cancelText }}</text> </view> <uv-line direction="column" v-if="showConfirmButton && showCancelButton" ></uv-line> <view class="uv-modal__button-group__wrapper uv-modal__button-group__wrapper--confirm" :hover-stay-time="150" hover-class="uv-modal__button-group__wrapper--hover" :class="[!showCancelButton && showConfirmButton && 'uv-modal__button-group__wrapper--only-confirm']" v-if="showConfirmButton" @tap="confirmHandler" > <uv-loading-icon v-if="loading"></uv-loading-icon> <text v-else class="uv-modal__button-group__wrapper__text" :style="{ color: confirmColor }" >{{ confirmText }}</text> </view> </view> </slot> </view> </uv-popup> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * Modal 模态框 * @description 弹出模态框,常用于消息提示、消息确认、在当前页面内完成特定的交互操作。 * @tutorial https://www.uvui.cn/components/modul.html * @property {String} title 标题内容 * @property {String} content 模态框内容,如传入slot内容,则此参数无效 * @property {String} confirmText 确认按钮的文字 (默认 '确认' ) * @property {String} cancelText 取消按钮的文字 (默认 '取消' ) * @property {Boolean} showConfirmButton 是否显示确认按钮 (默认 true ) * @property {Boolean} showCancelButton 是否显示取消按钮 (默认 false ) * @property {String} confirmColor 确认按钮的颜色 (默认 '#2979ff' ) * @property {String} cancelColor 取消按钮的颜色 (默认 '#606266' ) * @property {Boolean} buttonReverse 对调确认和取消的位置 (默认 false ) * @property {Boolean} zoom 是否开启缩放模式 (默认 true ) * @property {Boolean} asyncClose 是否异步关闭,只对确定按钮有效,见上方说明 (默认 false ) * @property {Boolean} closeOnClickOverlay 是否允许点击遮罩关闭该组件 (默认 true ) * @property {String | Number} negativeTop 往上偏移的值,给一个负的margin-top,往上偏移,避免和键盘重合的情况,单位任意,数值则默认为px单位 (默认 0 ) * @property {String | Number} width modal宽度,不支持百分比,可以数值,px,rpx单位 (默认 '650rpx' ) * @property {String} align 文本对齐方式 (默认'left') * @property {String | Object} textStyle 文本扩展样式 * @event {Function} confirm 点击确认按钮时触发 * @event {Function} cancel 点击取消按钮时触发 * @event {Function} close 点击遮罩关闭出发,closeOnClickOverlay为true有效 * @example <uv-modal ref="modalPopup" title="title" content="content"></uv-modal> */ export default { name: 'uv-modal', mixins: [mpMixin, mixin, props], data() { return { loading: false } }, computed: { nvueStyle() { const style = {}; // 避免nvue中不能换行的问题 // #ifdef APP-NVUE style.width = this.$uv.addUnit(this.$uv.getPx(this.width) - 50,'px'); // #endif return style; } }, methods: { open() { this.$refs.modalPopup.open(); if (this.loading) this.loading = false; }, close() { this.$refs.modalPopup.close(); }, popupChange(e) { if(!e.show) this.$emit('close'); }, // 点击确定按钮 confirmHandler() { if(!this.loading) { this.$emit('confirm'); } // 如果配置了异步关闭,将按钮值为loading状态 if (this.asyncClose) { this.loading = true; } else { this.close(); } }, // 点击取消按钮 cancelHandler() { this.$emit('cancel'); this.close(); }, closeLoading() { this.$nextTick(()=>{ this.loading = false; }) } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-modal-border-radius: 6px; .uv-modal { width: 650rpx; border-radius: $uv-modal-border-radius; overflow: hidden; &__title { font-size: 16px; font-weight: bold; color: $uv-content-color; text-align: center; padding-top: 25px; } &__content { padding: 12px 25px 25px 25px; @include flex; justify-content: center; &__text { line-height: 48rpx; font-size: 15px; color: $uv-content-color; flex: 1; } } &__button-group { @include flex; height: 48px; &__wrapper { flex: 1; @include flex; justify-content: center; align-items: center; height: 48px; &--confirm, &--only-cancel { border-bottom-right-radius: $uv-modal-border-radius; } &--cancel, &--only-confirm { border-bottom-left-radius: $uv-modal-border-radius; } &--hover { background-color: $uv-bg-color; } &__text { color: $uv-content-color; font-size: 16px; text-align: center; } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-modal/components/uv-modal/uv-modal.vue
Vue
unknown
6,761
export default { props: { // 是否开启顶部安全区适配 safeAreaInsetTop: { type: Boolean, default: true }, // 固定在顶部时,是否生成一个等高元素,以防止塌陷 placeholder: { type: Boolean, default: false }, // 是否固定在顶部 fixed: { type: Boolean, default: true }, // 是否显示下边框 border: { type: Boolean, default: false }, // 左边的图标 leftIcon: { type: String, default: 'arrow-left' }, // 左边的提示文字 leftText: { type: String, default: '' }, // 左右的提示文字 rightText: { type: String, default: '' }, // 右边的图标 rightIcon: { type: String, default: '' }, // 标题 title: { type: [String, Number], default: '' }, // 背景颜色 bgColor: { type: String, default: '#ffffff' }, imgMode: { type: String, default: 'aspectFill' }, // 标题的宽度 titleWidth: { type: [String, Number], default: '400rpx' }, // 导航栏高度 height: { type: [String, Number], default: '44px' }, // 左侧返回图标的大小 leftIconSize: { type: [String, Number], default: 20 }, // 左侧返回图标的颜色 leftIconColor: { type: String, default: '#303133' }, // 点击左侧区域(返回图标),是否自动返回上一页 autoBack: { type: Boolean, default: false }, // 标题的样式,对象或字符串 titleStyle: { type: [String, Object], default: '' }, ...uni.$uv?.props?.navbar } }
2301_77169380/AppruanjianApk
uni_modules/uv-navbar/components/uv-navbar/props.js
JavaScript
unknown
1,564
<template> <view class="uv-navbar"> <view class="uv-navbar__placeholder" v-if="fixed && placeholder" :style="{ height: $uv.addUnit($uv.getPx(height) + $uv.sys().statusBarHeight,'px'), }" ></view> <view :class="[fixed && 'uv-navbar--fixed']"> <image class="uv-navbar--bgimg" :src="bgColor" :mode="imgMode" v-if="isImg" :style="[bgImgStyle]"></image> <uv-status-bar v-if="safeAreaInsetTop" :bgColor="getStatusbgColor" ></uv-status-bar> <view class="uv-navbar__content" :class="[border && 'uv-border-bottom']" :style="[{ height: $uv.addUnit(height) },getBgColor]" > <view class="uv-navbar__content__left" hover-class="uv-navbar__content__left--hover" hover-start-time="150" @tap="leftClick" > <slot name="left"> <uv-icon v-if="leftIcon" :name="leftIcon" :size="leftIconSize" :color="leftIconColor" ></uv-icon> <text v-if="leftText" :style="{ color: leftIconColor }" class="uv-navbar__content__left__text" >{{ leftText }}</text> </slot> </view> <slot name="center"> <text class="uv-line-1 uv-navbar__content__title" :style="[{ width: $uv.addUnit(titleWidth), flex: '0 1 auto' }, $uv.addStyle(titleStyle)]" >{{ title }}</text> </slot> <view class="uv-navbar__content__right" @tap="rightClick" > <slot name="right"> <uv-icon v-if="rightIcon" :name="rightIcon" size="20" ></uv-icon> <text v-if="rightText" class="uv-navbar__content__right__text" >{{ rightText }}</text> </slot> </view> </view> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * Navbar 自定义导航栏 * @description 此组件一般用于在特殊情况下,需要自定义导航栏的时候用到,一般建议使用uni-app带的导航栏。 * @tutorial https://www.uvui.cn/components/navbar.html * @property {Boolean} safeAreaInsetTop 是否开启顶部安全区适配 (默认 true ) * @property {Boolean} placeholder 固定在顶部时,是否生成一个等高元素,以防止塌陷 (默认 false ) * @property {Boolean} fixed 导航栏是否固定在顶部 (默认 false ) * @property {Boolean} border 导航栏底部是否显示下边框 (默认 false ) * @property {String} leftIcon 左边返回图标的名称,只能为uvui自带的图标 (默认 'arrow-left' ) * @property {String} leftText 左边的提示文字 * @property {String} rightText 右边的提示文字 * @property {String} rightIcon 右边返回图标的名称,只能为uvui自带的图标 * @property {String} title 导航栏标题,如设置为空字符,将会隐藏标题占位区域 * @property {String} bgColor 导航栏背景设置 (默认 '#ffffff' ) * @property {String | Number} titleWidth 导航栏标题的最大宽度,内容超出会以省略号隐藏 (默认 '400rpx' ) * @property {String | Number} height 导航栏高度(不包括状态栏高度在内,内部自动加上)(默认 '44px' ) * @property {String | Number} leftIconSize 左侧返回图标的大小(默认 20px ) * @property {String | Number} leftIconColor 左侧返回图标的颜色(默认 #303133 ) * @property {Boolean} autoBack 点击左侧区域(返回图标),是否自动返回上一页(默认 false ) * @property {Object | String} titleStyle 标题的样式,对象或字符串 * @event {Function} leftClick 点击左侧区域 * @event {Function} rightClick 点击右侧区域 * @example <uv-navbar title="剑未配妥,出门已是江湖" left-text="返回" right-text="帮助" @click-left="onClickBack" @click-right="onClickRight"></uv-navbar> */ export default { name: 'uv-navbar', mixins: [mpMixin, mixin, props], data() { return { } }, computed: { getBgColor(){ const style = {}; if(this.bgColor){ if (this.bgColor.indexOf("gradient") > -1) {// 渐变色 style.backgroundImage = this.bgColor; }else if(this.isImg){ style.background = 'transparent'; }else { style.background = this.bgColor; } } return style; }, getStatusbgColor() { if(this.bgColor){ if(this.isImg){ return 'transparent'; }else { return this.bgColor; } } }, // 判断传入的bgColor属性,是否图片路径,只要带有"/"均认为是图片形式 isImg() { const isBase64 = this.bgColor.indexOf('data:') > -1 && this.bgColor.indexOf('base64') > -1; return this.bgColor.indexOf('/') !== -1 || isBase64; }, bgImgStyle() { const style = {}; if(this.safeAreaInsetTop) { style.height = this.$uv.addUnit(this.$uv.sys().statusBarHeight + 44, 'px'); } else { style.height = '44px'; } return style; } }, methods: { // 点击左侧区域 leftClick() { // 如果配置了autoBack,自动返回上一页 this.$emit('leftClick') if(this.autoBack) { uni.navigateBack() } }, // 点击右侧区域 rightClick() { this.$emit('rightClick') } } } </script> <style lang="scss" scoped> $show-border: 1; $show-border-bottom: 1; $show-lines: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-navbar { position: relative; &--fixed { position: fixed; left: 0; right: 0; top: 0; z-index: 11; } &--bgimg { position: absolute; left: 0; right: 0; bottom: 0; top: 0; /* #ifndef APP-NVUE */ width: 100%; height: 100%; /* #endif */ /* #ifdef APP-NVUE */ width: 750rpx; /* #endif */ } &__content { @include flex(row); align-items: center; height: 44px; background-color: #9acafc; position: relative; justify-content: center; &__left, &__right { padding: 0 13px; position: absolute; top: 0; bottom: 0; @include flex(row); align-items: center; } &__left { left: 0; &--hover { opacity: 0.7; } &__text { font-size: 15px; margin-left: 3px; } } &__title { text-align: center; font-size: 16px; color: $uv-main-color; } &__right { right: 0; &__text { font-size: 15px; margin-left: 3px; } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-navbar/components/uv-navbar/uv-navbar.vue
Vue
unknown
6,727
<template> <uv-overlay :show="!isConnected" :zIndex="zIndex" @touchmove.stop.prevent="noop" :customStyle="{ backgroundColor: '#fff', display: 'flex', justifyContent: 'center', }" > <view class="uv-no-network" > <uv-icon :name="image" size="150" imgMode="widthFit" class="uv-no-network__error-icon" ></uv-icon> <text class="uv-no-network__tips">{{tips}}</text> <!-- 只有APP平台,才能跳转设置页,因为需要调用plus环境 --> <!-- #ifdef APP-PLUS --> <view class="uv-no-network__app"> <text class="uv-no-network__app__setting">请检查网络,或前往</text> <text class="uv-no-network__app__to-setting" @tap="openSettings" >设置</text> </view> <!-- #endif --> <view class="uv-no-network__retry"> <uv-button size="mini" text="重试" type="primary" plain @click="retry" ></uv-button> </view> </view> </uv-overlay> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * noNetwork 无网络提示 * @description 该组件无需任何配置,引入即可,内部自动处理所有功能和事件。 * @tutorial https://www.uvui.cn/components/noNetwork.html * @property {String} tips 没有网络时的提示语 (默认:'哎呀,网络信号丢失' ) * @property {String | Number} zIndex 组件的z-index值 * @property {String} image 无网络的图片提示,可用的src地址或base64图片 * @event {Function} retry 用户点击页面的"重试"按钮时触发 * @example <uv-no-network></uv-no-network> */ export default { name: "uv-no-network", mixins: [mpMixin, mixin, props], data() { return { isConnected: true, // 是否有网络连接 networkType: "none", // 网络类型 } }, mounted() { this.isIOS = (uni.getSystemInfoSync().platform === 'ios') uni.onNetworkStatusChange((res) => { this.isConnected = res.isConnected this.networkType = res.networkType this.emitEvent(this.networkType) }) uni.getNetworkType({ success: (res) => { this.networkType = res.networkType this.emitEvent(this.networkType) if (res.networkType == 'none') { this.isConnected = false } else { this.isConnected = true } } }) }, methods: { retry() { // 重新检查网络 uni.getNetworkType({ success: (res) => { this.networkType = res.networkType this.emitEvent(this.networkType) if (res.networkType == 'none') { this.$uv.toast('无网络连接') this.isConnected = false } else { this.$uv.toast('网络已连接') this.isConnected = true } } }) this.$emit('retry') }, // 发出事件给父组件 emitEvent(networkType) { this.$emit(networkType === 'none' ? 'disconnected' : 'connected') }, async openSettings() { if (this.networkType == "none") { this.openSystemSettings() return } }, openAppSettings() { this.gotoAppSetting() }, openSystemSettings() { // 以下方法来自5+范畴,如需深究,请自行查阅相关文档 // https://ask.dcloud.net.cn/docs/ if (this.isIOS) { this.gotoiOSSetting() } else { this.gotoAndroidSetting() } }, network() { var result = null var cellularData = plus.ios.newObject("CTCellularData") var state = cellularData.plusGetAttribute("restrictedState") if (state == 0) { result = null } else if (state == 2) { result = 1 } else if (state == 1) { result = 2 } plus.ios.deleteObject(cellularData) return result }, gotoAppSetting() { if (this.isIOS) { var UIApplication = plus.ios.import("UIApplication") var application2 = UIApplication.sharedApplication() var NSURL2 = plus.ios.import("NSURL") var setting2 = NSURL2.URLWithString("app-settings:") application2.openURL(setting2) plus.ios.deleteObject(setting2) plus.ios.deleteObject(NSURL2) plus.ios.deleteObject(application2) } else { var Intent = plus.android.importClass("android.content.Intent") var Settings = plus.android.importClass("android.provider.Settings") var Uri = plus.android.importClass("android.net.Uri") var mainActivity = plus.android.runtimeMainActivity() var intent = new Intent() intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) var uri = Uri.fromParts("package", mainActivity.getPackageName(), null) intent.setData(uri) mainActivity.startActivity(intent) } }, gotoiOSSetting() { var UIApplication = plus.ios.import("UIApplication") var application2 = UIApplication.sharedApplication() var NSURL2 = plus.ios.import("NSURL") var setting2 = NSURL2.URLWithString("App-prefs:root=General") application2.openURL(setting2) plus.ios.deleteObject(setting2) plus.ios.deleteObject(NSURL2) plus.ios.deleteObject(application2) }, gotoAndroidSetting() { var Intent = plus.android.importClass("android.content.Intent") var Settings = plus.android.importClass("android.provider.Settings") var mainActivity = plus.android.runtimeMainActivity() var intent = new Intent(Settings.ACTION_SETTINGS) mainActivity.startActivity(intent) } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-no-network { @include flex(column); justify-content: center; align-items: center; margin-top: -100px; &__tips { color: $uv-tips-color; font-size: 14px; margin-top: 15px; } &__app { @include flex(row); margin-top: 6px; &__setting { color: $uv-light-color; font-size: 13px; } &__to-setting { font-size: 13px; color: $uv-primary; margin-left: 3px; } } &__retry { @include flex(row); justify-content: center; margin-top: 15px; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-no-network/components/uv-no-network/uv-no-network.vue
Vue
unknown
6,178
export default { props: { // 显示的内容,字符串 text: { type: [Array], default: '' }, // 是否显示左侧的音量图标 icon: { type: [String, Boolean, null], default: 'volume' }, // 通告模式,link-显示右箭头,closable-显示右侧关闭图标 mode: { type: String, default: '' }, // 文字颜色,各图标也会使用文字颜色 color: { type: String, default: '#f9ae3d' }, // 背景颜色 bgColor: { type: String, default: '#fdf6ec' }, // 字体大小,单位px fontSize: { type: [String, Number], default: 14 }, // 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度 speed: { type: [String, Number], default: 80 }, // direction = row时,是否使用步进形式滚动 step: { type: Boolean, default: false }, // 滚动一个周期的时间长,单位ms duration: { type: [String, Number], default: 1500 }, // 是否禁止用手滑动切换,仅`direction="column"生效` // 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序 disableTouch: { type: Boolean, default: true }, // 是否禁止滚动,仅`direction="column"生效` disableScroll: { type: Boolean, default: false }, ...uni.$uv?.props?.columnNotice } }
2301_77169380/AppruanjianApk
uni_modules/uv-notice-bar/components/uv-column-notice/props.js
JavaScript
unknown
1,411
<template> <view class="uv-notice" @tap="clickHandler" > <slot name="icon"> <view class="uv-notice__left-icon" v-if="icon" > <uv-icon :name="icon" :color="color" size="19" ></uv-icon> </view> </slot> <swiper :disable-touch="disableTouch" :vertical="step ? false : true" circular :interval="duration" :autoplay="!disableScroll" class="uv-notice__swiper" :style="[swiperStyle]" @change="noticeChange" > <swiper-item v-for="(item, index) in text" :key="index" class="uv-notice__swiper__item" > <text class="uv-notice__swiper__item__text uv-line-1" :style="[textStyle]" >{{ item }}</text> </swiper-item> </swiper> <view class="uv-notice__right-icon" v-if="['link', 'closable'].includes(mode)" > <uv-icon v-if="mode === 'link'" name="arrow-right" :size="17" :color="color" ></uv-icon> <uv-icon v-if="mode === 'closable'" name="close" :size="16" :color="color" @click="close" ></uv-icon> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * ColumnNotice 滚动通知中的垂直滚动 内部组件 * @description 该组件用于滚动通告场景,是其中的垂直滚动方式 * @tutorial https://www.uvui.cn/components/noticeBar.html * @property {Array} text 显示的内容,字符串 * @property {String} icon 是否显示左侧的音量图标 ( 默认 'volume' ) * @property {String} mode 通告模式,link-显示右箭头,closable-显示右侧关闭图标 * @property {String} color 文字颜色,各图标也会使用文字颜色 ( 默认 '#f9ae3d' ) * @property {String} bgColor 背景颜色 ( 默认 '#fdf6ec' ) * @property {String | Number} fontSize 字体大小,单位px ( 默认 14 ) * @property {String | Number} speed 水平滚动时的滚动速度,即每秒滚动多少px(rpx),这有利于控制文字无论多少时,都能有一个恒定的速度 ( 默认 80 ) * @property {Boolean} step direction = row时,是否使用步进形式滚动 ( 默认 false ) * @property {String | Number} duration 滚动一个周期的时间长,单位ms ( 默认 1500 ) * @property {Boolean} disableTouch 是否禁止用手滑动切换 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序 ( 默认 true ) * @example */ export default { emits: ['click','close','change'], mixins: [mpMixin, mixin, props], watch: { text: { immediate: true, handler(newValue, oldValue) { if(!this.$uv.test.array(newValue)) { this.$uv.error('noticebar组件direction为column时,要求text参数为数组形式') } } } }, computed: { // 文字内容的样式 textStyle() { let style = {} style.color = this.color style.fontSize = this.$uv.addUnit(this.fontSize) return style }, // 垂直或者水平滚动 vertical() { if (this.mode == 'horizontal') return false else return true }, // NVUE中的swiper在css中样式不生效 swiperStyle(){ const style = {}; // #ifdef APP-NVUE style.flex = 1; style.height = '16px'; // #endif return style; } }, data() { return { index:0 } }, methods: { noticeChange(e){ this.index = e.detail.current this.$emit('change', this.index); }, // 点击通告栏 clickHandler() { this.$emit('click', this.index) }, // 点击关闭按钮 close() { this.$emit('close') } } }; </script> <style lang="scss" scoped> $show-lines: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-notice { @include flex; align-items: center; justify-content: space-between; &__left-icon { align-items: center; margin-right: 5px; } &__right-icon { margin-left: 5px; align-items: center; } &__swiper { height: 16px; @include flex; align-items: center; flex: 1; &__item { @include flex; align-items: center; overflow: hidden; &__text { font-size: 14px; color: $uv-warning; } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-notice-bar/components/uv-column-notice/uv-column-notice.vue
Vue
unknown
4,475
export default { props: { // 显示的内容,数组 text: { type: [Array, String], default: () => [] }, // 通告滚动模式,row-横向滚动,column-竖向滚动 direction: { type: String, default: 'row' }, // direction = row时,是否使用步进形式滚动 step: { type: Boolean, default: false }, // 是否显示左侧的音量图标 icon: { type: [String, Boolean, null], default: 'volume' }, // 通告模式,link-显示右箭头,closable-显示右侧关闭图标 mode: { type: String, default: '' }, // 文字颜色,各图标也会使用文字颜色 color: { type: String, default: '#f9ae3d' }, // 背景颜色 bgColor: { type: String, default: '#fdf6ec' }, // 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度 speed: { type: [String, Number], default: 80 }, // 字体大小 fontSize: { type: [String, Number], default: 14 }, // 滚动一个周期的时间长,单位ms duration: { type: [String, Number], default: 2000 }, // 跳转的页面路径 url: { type: String, default: '' }, // 页面跳转的类型 linkType: { type: String, default: 'navigateTo' }, // 是否禁止用手滑动切换 // 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序 disableTouch: { type: Boolean, default: true }, // 是否禁止滚动,仅`direction="column"生效` disableScroll: { type: Boolean, default: false }, ...uni.$uv?.props?.noticeBar } }
2301_77169380/AppruanjianApk
uni_modules/uv-notice-bar/components/uv-notice-bar/props.js
JavaScript
unknown
1,657
<template> <view class="uv-notice-bar" v-if="show" :style="[{ backgroundColor: bgColor }, $uv.addStyle(customStyle)]" > <template v-if="direction === 'column' || (direction === 'row' && step)"> <uv-column-notice :color="color" :bgColor="bgColor" :text="text" :mode="mode" :step="step" :icon="icon" :disable-touch="disableTouch" :disable-scroll="disableScroll" :fontSize="fontSize" :duration="duration" @close="close" @click="click" @change="change" ></uv-column-notice> </template> <template v-else> <uv-row-notice :color="color" :bgColor="bgColor" :text="text" :mode="mode" :fontSize="fontSize" :speed="speed" :url="url" :linkType="linkType" :icon="icon" @close="close" @click="click" ></uv-row-notice> </template> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * noticeBar 滚动通知 * @description 该组件用于滚动通告场景,有多种模式可供选择 * @tutorial https://www.uvui.cn/components/noticeBar.html * @property {Array | String} text 显示的内容,数组 * @property {String} direction 通告滚动模式,row-横向滚动,column-竖向滚动 ( 默认 'row' ) * @property {Boolean} step direction = row时,是否使用步进形式滚动 ( 默认 false ) * @property {String} icon 是否显示左侧的音量图标 ( 默认 'volume' ) * @property {String} mode 通告模式,link-显示右箭头,closable-显示右侧关闭图标 * @property {String} color 文字颜色,各图标也会使用文字颜色 ( 默认 '#f9ae3d' ) * @property {String} bgColor 背景颜色 ( 默认 '#fdf6ec' ) * @property {String | Number} speed 水平滚动时的滚动速度,即每秒滚动多少px(px),这有利于控制文字无论多少时,都能有一个恒定的速度 ( 默认 80 ) * @property {String | Number} fontSize 字体大小 ( 默认 14 ) * @property {String | Number} duration 滚动一个周期的时间长,单位ms ( 默认 2000 ) * @property {Boolean} disableTouch 是否禁止用手滑动切换 目前HX2.6.11,只支持App 2.5.5+、H5 2.5.5+、支付宝小程序、字节跳动小程序(默认34) ( 默认 true ) * @property {String} url 跳转的页面路径 * @property {String} linkType 页面跳转的类型 ( 默认 navigateTo ) * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function} click 点击通告文字触发 * @event {Function} close 点击右侧关闭图标触发 * @example <uv-notice-bar :more-icon="true" :list="list"></uv-notice-bar> */ export default { name: "uv-notice-bar", emits: ['click','close','change'], mixins: [mpMixin, mixin, props], data() { return { show: true } }, methods: { // 点击通告栏 click(index) { this.$emit('click', index) if (this.url && this.linkType) { // 此方法写在mixin中,另外跳转的url和linkType参数也在mixin的props中 this.openPage() } }, // 点击关闭按钮 close() { this.show = false this.$emit('close') }, // 竖向滚动时触发 change(index){ this.$emit('change',index) } } }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-notice-bar { overflow: hidden; padding: 9px 12px; flex: 1; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-notice-bar/components/uv-notice-bar/uv-notice-bar.vue
Vue
unknown
3,598
export default { props: { // 显示的内容,字符串 text: { type: String, default: '' }, // 是否显示左侧的音量图标 icon: { type: [String, Boolean, null], default: 'volume' }, // 通告模式,link-显示右箭头,closable-显示右侧关闭图标 mode: { type: String, default: '' }, // 文字颜色,各图标也会使用文字颜色 color: { type: String, default: '#f9ae3d' }, // 背景颜色 bgColor: { type: String, default: '#fdf6ec' }, // 字体大小,单位px fontSize: { type: [String, Number], default: 14 }, // 水平滚动时的滚动速度,即每秒滚动多少px(rpx),这有利于控制文字无论多少时,都能有一个恒定的速度 speed: { type: [String, Number], default: 80 }, ...uni.$uv?.props?.rowNotice } }
2301_77169380/AppruanjianApk
uni_modules/uv-notice-bar/components/uv-row-notice/props.js
JavaScript
unknown
849
<template> <view class="uv-notice" @tap="clickHandler" > <slot name="icon"> <view class="uv-notice__left-icon" v-if="icon" > <uv-icon :name="icon" :color="color" size="19" ></uv-icon> </view> </slot> <view class="uv-notice__content" ref="uv-notice__content" > <view ref="uv-notice__content__text" class="uv-notice__content__text" :style="[animationStyle]" > <text v-for="(item, index) in innerText" :key="index" :style="[textStyle]" >{{item}}</text> </view> </view> <view class="uv-notice__right-icon" v-if="['link', 'closable'].includes(mode)" > <uv-icon v-if="mode === 'link'" name="arrow-right" :size="17" :color="color" ></uv-icon> <uv-icon v-if="mode === 'closable'" @click="close" name="close" :size="16" :color="color" ></uv-icon> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; // #ifdef APP-NVUE const animation = uni.requireNativePlugin('animation') const dom = uni.requireNativePlugin('dom') // #endif /** * RowNotice 滚动通知中的水平滚动模式 * @description 水平滚动 * @tutorial https://www.uvui.cn/components/noticeBar.html * @property {String | Number} text 显示的内容,字符串 * @property {String} icon 是否显示左侧的音量图标 (默认 'volume' ) * @property {String} mode 通告模式,link-显示右箭头,closable-显示右侧关闭图标 * @property {String} color 文字颜色,各图标也会使用文字颜色 (默认 '#f9ae3d' ) * @property {String} bgColor 背景颜色 (默认 ''#fdf6ec' ) * @property {String | Number} fontSize 字体大小,单位px (默认 14 ) * @property {String | Number} speed 水平滚动时的滚动速度,即每秒滚动多少px(rpx),这有利于控制文字无论多少时,都能有一个恒定的速度 (默认 80 ) * * @event {Function} click 点击通告文字触发 * @event {Function} close 点击右侧关闭图标触发 * @example */ export default { name: 'uv-row-notice', emits: ['click','close'], mixins: [mpMixin, mixin, props], data() { return { animationDuration: '0', // 动画执行时间 animationPlayState: 'paused', // 动画的开始和结束执行 // nvue下,内容发生变化,导致滚动宽度也变化,需要标志为是否需要重新计算宽度 // 不能在内容变化时直接重新计算,因为nvue的animation模块上一次的滚动不是刚好结束,会有影响 nvueInit: true, show: true }; }, watch: { text: { immediate: true, handler(newValue, oldValue) { // #ifdef APP-NVUE this.nvueInit = true // #endif // #ifndef APP-NVUE this.vue() // #endif if(!this.$uv.test.string(newValue)) { this.$uv.error('noticebar组件direction为row时,要求text参数为字符串形式') } } }, fontSize() { // #ifdef APP-NVUE this.nvueInit = true // #endif // #ifndef APP-NVUE this.vue() // #endif }, speed() { // #ifdef APP-NVUE this.nvueInit = true // #endif // #ifndef APP-NVUE this.vue() // #endif } }, computed: { // 文字内容的样式 textStyle() { let style = {} style.color = this.color style.fontSize = this.$uv.addUnit(this.fontSize) return style }, animationStyle() { let style = {} style.animationDuration = this.animationDuration style.animationPlayState = this.animationPlayState return style }, // 内部对用户传入的数据进一步分割,放到多个text标签循环,否则如果用户传入的字符串很长(100个字符以上) // 放在一个text标签中进行滚动,在低端安卓机上,动画可能会出现抖动现象,需要分割到多个text中可解决此问题 innerText() { let result = [], // 每组text标签的字符长度 len = 20 const textArr = this.text? this.text.split(''):[] for (let i = 0; i < textArr.length; i += len) { // 对拆分的后的text进行slice分割,得到的为数组再进行join拼接为字符串 result.push(textArr.slice(i, i + len).join('')) } return result } }, mounted() { // #ifdef APP-PLUS // 在APP上(含nvue),监听当前webview是否处于隐藏状态(进入下一页时即为hide状态) // 如果webivew隐藏了,为了节省性能的损耗,应停止动画的执行,同时也是为了保持进入下一页返回后,滚动位置保持不变 var pages = getCurrentPages() var page = pages[pages.length - 1] var currentWebview = page.$getAppWebview() currentWebview.addEventListener('hide', () => { this.webviewHide = true }) currentWebview.addEventListener('show', () => { this.webviewHide = false }) // #endif this.init() }, methods: { init() { // #ifdef APP-NVUE this.nvue() // #endif // #ifndef APP-NVUE this.vue() // #endif if(!this.$uv.test.string(this.text)) { this.$uv.error('noticebar组件direction为row时,要求text参数为字符串形式') } }, // vue版处理 async vue() { // #ifndef APP-NVUE let boxWidth = 0, textWidth = 0 // 进行一定的延时 await this.$uv.sleep() // 查询盒子和文字的宽度 textWidth = (await this.$uvGetRect('.uv-notice__content__text')).width boxWidth = (await this.$uvGetRect('.uv-notice__content')).width // 根据t=s/v(时间=路程/速度),这里为何不需要加上#uv-notice-box的宽度,因为中设置了.uv-notice-content样式中设置了padding-left: 100% // 恰巧计算出来的结果中已经包含了#uv-notice-box的宽度 this.animationDuration = `${textWidth / this.$uv.getPx(this.speed)}s` // 这里必须这样开始动画,否则在APP上动画速度不会改变 this.animationPlayState = 'paused' setTimeout(() => { this.animationPlayState = 'running' }, 10) // #endif }, // nvue版处理 async nvue() { // #ifdef APP-NVUE this.nvueInit = false let boxWidth = 0, textWidth = 0 // 进行一定的延时 await this.$uv.sleep() // 查询盒子和文字的宽度 textWidth = (await this.getNvueRect('uv-notice__content__text')).width boxWidth = (await this.getNvueRect('uv-notice__content')).width // 将文字移动到盒子的右边沿,之所以需要这么做,是因为nvue不支持100%单位,否则可以通过css设置 animation.transition(this.$refs['uv-notice__content__text'], { styles: { transform: `translateX(${boxWidth}px)` }, }, () => { // 如果非禁止动画,则开始滚动 !this.stopAnimation && this.loopAnimation(textWidth, boxWidth) }); // #endif }, loopAnimation(textWidth, boxWidth) { // #ifdef APP-NVUE animation.transition(this.$refs['uv-notice__content__text'], { styles: { // 目标移动终点为-textWidth,也即当文字的最右边贴到盒子的左边框的位置 transform: `translateX(-${textWidth}px)` }, // 滚动时间的计算为,时间 = 路程(boxWidth + textWidth) / 速度,最后转为毫秒 duration: (boxWidth + textWidth) / this.$uv.getPx(this.speed) * 1000, delay: 10 }, () => { animation.transition(this.$refs['uv-notice__content__text'], { styles: { // 重新将文字移动到盒子的右边沿 transform: `translateX(${this.stopAnimation ? 0 : boxWidth}px)` }, }, () => { // 如果非禁止动画,则继续下一轮滚动 if (!this.stopAnimation) { // 判断是否需要初始化计算尺寸 if (this.nvueInit) { this.nvue() } else { this.loopAnimation(textWidth, boxWidth) } } }); }) // #endif }, getNvueRect(el) { // #ifdef APP-NVUE // 返回一个promise return new Promise(resolve => { dom.getComponentRect(this.$refs[el], (res) => { resolve(res.size) }) }) // #endif }, // 点击通告栏 clickHandler(index) { this.$emit('click') }, // 点击右侧按钮,需要判断点击的是关闭图标还是箭头图标 close() { this.$emit('close') } }, // #ifdef APP-NVUE // #ifdef VUE2 beforeDestroy() { this.stopAnimation = true }, // #endif // #ifdef VUE3 unmounted() { this.stopAnimation = true } // #endif // #endif }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-notice { @include flex; align-items: center; justify-content: space-between; &__left-icon { align-items: center; margin-right: 5px; } &__right-icon { margin-left: 5px; align-items: center; } &__content { text-align: right; flex: 1; @include flex; flex-wrap: nowrap; overflow: hidden; &__text { font-size: 14px; color: $uv-warning; /* #ifndef APP-NVUE */ // 这一句很重要,为了能让滚动左右连接起来 padding-left: 100%; word-break: keep-all; white-space: nowrap; animation: uv-loop-animation 10s linear infinite both; /* #endif */ @include flex(row); } } } /* #ifndef APP-NVUE */ @keyframes uv-loop-animation { 0% { transform: translate3d(0, 0, 0); } 100% { transform: translate3d(-100%, 0, 0); } } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-notice-bar/components/uv-row-notice/uv-row-notice.vue
Vue
unknown
9,714
export default { props: { // 到顶部的距离 top: { type: [String, Number], default: 0 }, // type主题,primary,success,warning,error type: { type: String, default: 'primary' }, // 字体颜色 color: { type: String, default: '#ffffff' }, // 背景颜色 bgColor: { type: String, default: '' }, // 展示的文字内容 message: { type: String, default: '' }, // 展示时长,为0时不消失,单位ms duration: { type: [String, Number], default: 3000 }, // 字体大小 fontSize: { type: [String, Number], default: 15 }, // 是否留出顶部安全距离(状态栏高度) safeAreaInsetTop: { type: Boolean, default: false }, ...uni.$uv?.props?.notify } }
2301_77169380/AppruanjianApk
uni_modules/uv-notify/components/uv-notify/props.js
JavaScript
unknown
774
<template> <uv-transition mode="slide-top" :customStyle="containerStyle" :show="open" > <view class="uv-notify" :class="[`uv-notify--${tmpConfig.type}`]" :style="[backgroundColor, $uv.addStyle(customStyle)]" > <uv-status-bar v-if="tmpConfig.safeAreaInsetTop"></uv-status-bar> <view class="uv-notify__warpper"> <slot name="icon"> <uv-icon v-if="['success', 'warning', 'error'].includes(tmpConfig.type)" :name="tmpConfig.icon" :color="tmpConfig.color" :size="1.3 * tmpConfig.fontSize" :customStyle="{marginRight: '4px'}" ></uv-icon> </slot> <text class="uv-notify__warpper__text" :style="{ fontSize: $uv.addUnit(tmpConfig.fontSize), color: tmpConfig.color }" >{{ tmpConfig.message }}</text> </view> </view> </uv-transition> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * notify 顶部提示 * @description 该组件一般用于页面顶部向下滑出一个提示,尔后自动收起的场景 * @tutorial * @property {String | Number} top 到顶部的距离 ( 默认 0 ) * @property {String} type 主题,primary,success,warning,error ( 默认 'primary' ) * @property {String} color 字体颜色 ( 默认 '#ffffff' ) * @property {String} bgColor 背景颜色 * @property {String} message 展示的文字内容 * @property {String | Number} duration 展示时长,为0时不消失,单位ms ( 默认 3000 ) * @property {String | Number} fontSize 字体大小 ( 默认 15 ) * @property {Boolean} safeAreaInsetTop 是否留出顶部安全距离(状态栏高度) ( 默认 false ) * @property {Object} customStyle 组件的样式,对象形式 * @event {Function} open 开启组件时调用的函数 * @event {Function} close 关闭组件式调用的函数 * @example <uv-notify message="Hi uvui"></uv-notify> */ export default { name: 'uv-notify', mixins: [mpMixin, mixin, props], data() { return { // 是否展示组件 open: false, timer: null, config: { // 到顶部的距离 top: this.top, // type主题,primary,success,warning,error type: this.type, // 字体颜色 color: this.color, // 背景颜色 bgColor: this.bgColor, // 展示的文字内容 message: this.message, // 展示时长,为0时不消失,单位ms duration: this.duration, // 字体大小 fontSize: this.fontSize, // 是否留出顶部安全距离(状态栏高度) safeAreaInsetTop: this.safeAreaInsetTop }, // 合并后的配置,避免多次调用组件后,可能会复用之前使用的配置参数 tmpConfig: {} } }, computed: { containerStyle() { let top = 0 if (this.tmpConfig.top === 0) { // #ifdef H5 // H5端,导航栏为普通元素,需要将组件移动到导航栏的下边沿 // H5的导航栏高度为44px top = 44 // #endif } const style = { top: this.$uv.addUnit(this.tmpConfig.top === 0 ? top : this.tmpConfig.top), // 因为组件底层为uv-transition组件,必须将其设置为fixed定位 // 让其出现在导航栏底部 position: 'fixed', left: 0, right: 0, zIndex: 10076 } return style }, // 组件背景颜色 backgroundColor() { const style = {} if (this.tmpConfig.bgColor) { style.backgroundColor = this.tmpConfig.bgColor } return style }, // 默认主题下的图标 icon() { let icon if (this.tmpConfig.type === 'success') { icon = 'checkmark-circle' } else if (this.tmpConfig.type === 'error') { icon = 'close-circle' } else if (this.tmpConfig.type === 'warning') { icon = 'error-circle' } return icon } }, created() { // 通过主题的形式调用toast,批量生成方法函数 ['primary', 'success', 'error', 'warning'].map(item => { this[item] = message => this.show({ type: item, message }) }) }, methods: { show(options) { // 不将结果合并到this.config变量,避免多次调用uv-toast,前后的配置造成混乱 this.tmpConfig = this.$uv.deepMerge(this.config, options) // 任何定时器初始化之前,都要执行清除操作,否则可能会造成混乱 this.clearTimer() this.open = true if (this.tmpConfig.duration > 0) { this.timer = setTimeout(() => { this.open = false // 倒计时结束,清除定时器,隐藏toast组件 this.clearTimer() // 判断是否存在callback方法,如果存在就执行 typeof(this.tmpConfig.complete) === 'function' && this.tmpConfig.complete() }, this.tmpConfig.duration) } }, // 关闭notify close() { this.clearTimer() }, clearTimer() { this.open = false // 清除定时器 clearTimeout(this.timer) this.timer = null } }, // #ifdef VUE2 beforeDestroy() { this.clearTimer() }, // #endif // #ifdef VUE3 unmounted() { this.clearTimer() } // #endif } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-notify-padding: 8px 10px !default; $uv-notify-text-font-size: 15px !default; $uv-notify-primary-bgColor: $uv-primary !default; $uv-notify-success-bgColor: $uv-success !default; $uv-notify-error-bgColor: $uv-error !default; $uv-notify-warning-bgColor: $uv-warning !default; .uv-notify { padding: $uv-notify-padding; &__warpper { @include flex; align-items: center; text-align: center; justify-content: center; &__text { font-size: $uv-notify-text-font-size; text-align: center; } } &--primary { background-color: $uv-notify-primary-bgColor; } &--success { background-color: $uv-notify-success-bgColor; } &--error { background-color: $uv-notify-error-bgColor; } &--warning { background-color: $uv-notify-warning-bgColor; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-notify/components/uv-notify/uv-notify.vue
Vue
unknown
6,221
export default { props: { value: { type: [String, Number], default: 0 }, modelValue: { type: [String, Number], default: 0 }, // 步进器标识符,在change回调返回 name: { type: [String, Number], default: '' }, // 最小值 min: { type: [String, Number], default: 1 }, // 最大值 max: { type: [String, Number], default: Number.MAX_SAFE_INTEGER }, // 加减的步长,可为小数 step: { type: [String, Number], default: 1 }, // 是否只允许输入整数 integer: { type: Boolean, default: false }, // 是否禁用,包括输入框,加减按钮 disabled: { type: Boolean, default: false }, // 是否禁用输入框 disabledInput: { type: Boolean, default: false }, // 是否开启异步变更,开启后需要手动控制输入值 asyncChange: { type: Boolean, default: false }, // 输入框宽度,单位为px inputWidth: { type: [String, Number], default: 35 }, // 是否显示减少按钮 showMinus: { type: Boolean, default: true }, // 是否显示增加按钮 showPlus: { type: Boolean, default: true }, // 显示的小数位数 decimalLength: { type: [String, Number, null], default: null }, // 是否开启长按加减手势 longPress: { type: Boolean, default: true }, // 输入框文字和加减按钮图标的颜色 color: { type: String, default: '#323233' }, // 按钮大小,宽高等于此值,单位px,输入框高度和此值保持一致 buttonSize: { type: [String, Number], default: 30 }, // 输入框和按钮的背景颜色 bgColor: { type: String, default: '#EBECEE' }, // 指定光标于键盘的距离,避免键盘遮挡输入框,单位px cursorSpacing: { type: [String, Number], default: 100 }, // 是否禁用增加按钮 disablePlus: { type: Boolean, default: false }, // 是否禁用减少按钮 disableMinus: { type: Boolean, default: false }, // 加减按钮图标的样式 iconStyle: { type: [Object, String], default: '' }, ...uni.$uv?.props?.numberBox } }
2301_77169380/AppruanjianApk
uni_modules/uv-number-box/components/uv-number-box/props.js
JavaScript
unknown
2,176
<template> <view class="uv-number-box"> <view class="uv-number-box__slot" @tap.stop="clickHandler('minus')" @touchstart="onTouchStart('minus')" @touchend.stop="clearTimeout" v-if="showMinus && $slots.minus" > <slot name="minus" /> </view> <view v-else-if="showMinus" class="uv-number-box__minus" @tap.stop="clickHandler('minus')" @touchstart="onTouchStart('minus')" @touchend.stop="clearTimeout" hover-class="uv-number-box__minus--hover" hover-stay-time="150" :class="{ 'uv-number-box__minus--disabled': isDisabled('minus') }" :style="[buttonStyle('minus')]" > <uv-icon name="minus" :color="isDisabled('minus') ? '#c8c9cc' : '#323233'" size="15" bold :customStyle="iconStyle" ></uv-icon> </view> <slot name="input"> <input :disabled="disabledInput || disabled" :cursor-spacing="getCursorSpacing" :class="{ 'uv-number-box__input--disabled': disabled || disabledInput }" v-model="currentValue" class="uv-number-box__input" @blur="onBlur" @focus="onFocus" @input="onInput" type="number" :style="[inputStyle]" /> </slot> <view class="uv-number-box__slot" @tap.stop="clickHandler('plus')" @touchstart="onTouchStart('plus')" @touchend.stop="clearTimeout" v-if="showPlus && $slots.plus" > <slot name="plus" /> </view> <view v-else-if="showPlus" class="uv-number-box__plus" @tap.stop="clickHandler('plus')" @touchstart="onTouchStart('plus')" @touchend.stop="clearTimeout" hover-class="uv-number-box__plus--hover" hover-stay-time="150" :class="{ 'uv-number-box__minus--disabled': isDisabled('plus') }" :style="[buttonStyle('plus')]" > <uv-icon name="plus" :color="isDisabled('plus') ? '#c8c9cc' : '#323233'" size="15" bold :customStyle="iconStyle" ></uv-icon> </view> </view> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * numberBox 步进器 * @description 该组件一般用于商城购物选择物品数量的场景。 * @tutorial https://www.uvui.cn/components/numberBox.html * @property {String | Number} value / v-model 用于双向绑定的值,初始化时设置设为默认min值(最小值) (默认 0 ) * @property {String | Number} name 步进器标识符,在change回调返回 * @property {String | Number} min 最小值 (默认 1 ) * @property {String | Number} max 最大值 (默认 Number.MAX_SAFE_INTEGER ) * @property {String | Number} step 加减的步长,可为小数 (默认 1 ) * @property {Boolean} integer 是否只允许输入整数 (默认 false ) * @property {Boolean} disabled 是否禁用,包括输入框,加减按钮 (默认 false ) * @property {Boolean} disabledInput 是否禁用输入框 (默认 false ) * @property {Boolean} asyncChange 是否开启异步变更,开启后需要手动控制输入值 (默认 false ) * @property {String | Number} inputWidth 输入框宽度,单位为px (默认 35 ) * @property {Boolean} showMinus 是否显示减少按钮 (默认 true ) * @property {Boolean} showPlus 是否显示增加按钮 (默认 true ) * @property {String | Number} decimalLength 显示的小数位数 * @property {Boolean} longPress 是否开启长按加减手势 (默认 true ) * @property {String} color 输入框文字和加减按钮图标的颜色 (默认 '#323233' ) * @property {String | Number} buttonSize 按钮大小,宽高等于此值,单位px,输入框高度和此值保持一致 (默认 30 ) * @property {String} bgColor 输入框和按钮的背景颜色 (默认 '#EBECEE' ) * @property {String | Number} cursorSpacing 指定光标于键盘的距离,避免键盘遮挡输入框,单位px (默认 100 ) * @property {Boolean} disablePlus 是否禁用增加按钮 (默认 false ) * @property {Boolean} disableMinus 是否禁用减少按钮 (默认 false ) * @property {Object | String} iconStyle 加减按钮图标的样式 * @event {Function} onFocus 输入框活动焦点 * @event {Function} onBlur 输入框失去焦点 * @event {Function} onInput 输入框值发生变化 * @event {Function} onChange * @example <uv-number-box v-model="value" @change="valChange"></uv-number-box> */ export default { name: 'uv-number-box', mixins: [mpMixin, mixin, props], data() { return { // 输入框实际操作的值 currentValue: '', // 定时器 longPressTimer: null } }, watch: { // 多个值之间,只要一个值发生变化,都要重新检查check()函数 watchChange(n) { this.check() }, value(newVal) { if (newVal !== this.currentValue) { this.currentValue = this.format(this.value) } }, modelValue(newVal) { if (newVal !== this.currentValue) { this.currentValue = this.format(this.modelValue) } } }, computed: { getCursorSpacing() { // 判断传入的单位,如果为px单位,需要转成px return this.$uv.getPx(this.cursorSpacing) }, // 按钮的样式 buttonStyle() { return (type) => { const style = { backgroundColor: this.bgColor, height: this.$uv.addUnit(this.buttonSize), color: this.color } if (this.isDisabled(type)) { style.backgroundColor = '#f7f8fa' } return style } }, // 输入框的样式 inputStyle() { const disabled = this.disabled || this.disabledInput const style = { color: this.color, backgroundColor: this.bgColor, height: this.$uv.addUnit(this.buttonSize), width: this.$uv.addUnit(this.inputWidth) } return style }, // 用于监听多个值发生变化 watchChange() { return [this.integer, this.decimalLength, this.min, this.max] }, isDisabled() { return (type) => { if (type === 'plus') { // 在点击增加按钮情况下,判断整体的disabled,是否单独禁用增加按钮,以及当前值是否大于最大的允许值 return ( this.disabled || this.disablePlus || this.currentValue >= this.max ) } // 点击减少按钮同理 return ( this.disabled || this.disableMinus || this.currentValue <= this.min ) } }, }, created() { this.init() }, methods: { init() { const value = this.value || this.modelValue; this.currentValue = this.format(value) }, // 格式化整理数据,限制范围 format(value) { value = this.filter(value) // 如果为空字符串,那么设置为0,同时将值转为Number类型 value = value === '' ? 0 : +value // 对比最大最小值,取在min和max之间的值 value = Math.max(Math.min(this.max, value), this.min) // 如果设定了最大的小数位数,使用toFixed去进行格式化 if (this.decimalLength !== null) { value = value.toFixed(this.decimalLength) } return value }, // 过滤非法的字符 filter(value) { // 只允许0-9之间的数字,"."为小数点,"-"为负数时候使用 value = String(value).replace(/[^0-9.-]/g, '') // 如果只允许输入整数,则过滤掉小数点后的部分 if (this.integer && value.indexOf('.') !== -1) { value = value.split('.')[0] } return value; }, check() { // 格式化了之后,如果前后的值不相等,那么设置为格式化后的值 const val = this.format(this.currentValue); if (val !== this.currentValue) { this.currentValue = val } }, // 输入框活动焦点 onFocus(event) { this.$emit('focus', { ...event.detail, name: this.name, }) }, // 输入框失去焦点 onBlur(event) { // 对输入值进行格式化 const value = this.format(event.detail.value) // 发出blur事件 this.$emit( 'blur', { ...event.detail, name: this.name, } ) }, // 输入框值发生变化 onInput(e) { const { value = '' } = e.detail || {} // 为空返回 if (value === '') return let formatted = this.filter(value) // 最大允许的小数长度 if (this.decimalLength !== null && formatted.indexOf('.') !== -1) { const pair = formatted.split('.'); formatted = `${pair[0]}.${pair[1].slice(0, this.decimalLength)}` } formatted = this.format(formatted) this.emitChange(formatted); }, // 发出change事件 emitChange(value) { // 如果开启了异步变更值,则不修改内部的值,需要用户手动在外部通过v-model变更 if (!this.asyncChange) { this.$nextTick(() => { this.$emit('input', value) this.$emit('update:modelValue', value) this.currentValue = value this.$forceUpdate() }) } this.$emit('change', { value, name: this.name, }); }, onChange() { const { type } = this if (this.isDisabled(type)) { return this.$emit('overlimit', type) } const diff = type === 'minus' ? -this.step : +this.step const value = this.format(this.add(+this.currentValue, diff)) this.emitChange(value) this.$emit(type) }, // 对值扩大后进行四舍五入,再除以扩大因子,避免出现浮点数操作的精度问题 add(num1, num2) { const cardinal = Math.pow(10, 10); return Math.round((num1 + num2) * cardinal) / cardinal }, // 点击加减按钮 clickHandler(type) { this.type = type this.onChange() }, longPressStep() { // 每隔一段时间,重新调用longPressStep方法,实现长按加减 this.clearTimeout() this.longPressTimer = setTimeout(() => { this.onChange() this.longPressStep() }, 250); }, onTouchStart(type) { if (!this.longPress) return this.clearTimeout() this.type = type // 一定时间后,默认达到长按状态 this.longPressTimer = setTimeout(() => { this.onChange() this.longPressStep() }, 600) }, // 触摸结束,清除定时器,停止长按加减 onTouchEnd() { if (!this.longPress) return this.clearTimeout() }, // 清除定时器 clearTimeout() { clearTimeout(this.longPressTimer) this.longPressTimer = null } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; $uv-numberBox-hover-bgColor: #E6E6E6 !default; $uv-numberBox-disabled-color: #c8c9cc !default; $uv-numberBox-disabled-bgColor: #f7f8fa !default; $uv-numberBox-plus-radius: 4px !default; $uv-numberBox-minus-radius: 4px !default; $uv-numberBox-input-text-align: center !default; $uv-numberBox-input-font-size: 15px !default; $uv-numberBox-input-padding: 0 !default; $uv-numberBox-input-margin: 0 2px !default; $uv-numberBox-input-disabled-color: #c8c9cc !default; $uv-numberBox-input-disabled-bgColor: #f2f3f5 !default; .uv-number-box { @include flex(row); align-items: center; &__slot { /* #ifndef APP-NVUE */ touch-action: none; /* #endif */ } &__plus, &__minus { width: 35px; @include flex; justify-content: center; align-items: center; /* #ifndef APP-NVUE */ touch-action: none; /* #endif */ &--hover { background-color: $uv-numberBox-hover-bgColor !important; } &--disabled { color: $uv-numberBox-disabled-color; background-color: $uv-numberBox-disabled-bgColor; } } &__plus { border-top-right-radius: $uv-numberBox-plus-radius; border-bottom-right-radius: $uv-numberBox-plus-radius; } &__minus { border-top-left-radius: $uv-numberBox-minus-radius; border-bottom-left-radius: $uv-numberBox-minus-radius; } &__input { position: relative; text-align: $uv-numberBox-input-text-align; font-size: $uv-numberBox-input-font-size; padding: $uv-numberBox-input-padding; margin: $uv-numberBox-input-margin; @include flex; align-items: center; justify-content: center; &--disabled { color: $uv-numberBox-input-disabled-color; background-color: $uv-numberBox-input-disabled-bgColor; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-number-box/components/uv-number-box/uv-number-box.vue
Vue
unknown
12,423
export default { props: { // 是否显示遮罩 show: { type: Boolean, default: false }, // 层级z-index zIndex: { type: [String, Number], default: 10070 }, // 遮罩的过渡时间,单位为ms duration: { type: [String, Number], default: 300 }, // 不透明度值,当做rgba的第四个参数 opacity: { type: [String, Number], default: 0.5 }, ...uni.$uv?.props?.overlay } }
2301_77169380/AppruanjianApk
uni_modules/uv-overlay/components/uv-overlay/props.js
JavaScript
unknown
432
<template> <uv-transition :show="show" mode="fade" custom-class="uv-overlay" :duration="duration" :custom-style="overlayStyle" @click="clickHandler" @touchmove.stop.prevent="clear" > <slot /> </uv-transition> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; /** * overlay 遮罩 * @description 创建一个遮罩层,用于强调特定的页面元素,并阻止用户对遮罩下层的内容进行操作,一般用于弹窗场景 * @tutorial https://www.uvui.cn/components/overlay.html * @property {Boolean} show 是否显示遮罩(默认 false ) * @property {String | Number} zIndex zIndex 层级(默认 10070 ) * @property {String | Number} duration 动画时长,单位毫秒(默认 300 ) * @property {String | Number} opacity 不透明度值,当做rgba的第四个参数 (默认 0.5 ) * @property {Object} customStyle 定义需要用到的外部样式 * @event {Function} click 点击遮罩发送事件 * @example <uv-overlay :show="show" @click="show = false"></uv-overlay> */ export default { name: "uv-overlay", emits: ['click'], mixins: [mpMixin, mixin, props], watch: { show(newVal){ // #ifdef H5 if(newVal){ document.querySelector('body').style.overflow = 'hidden'; }else{ document.querySelector('body').style.overflow = ''; } // #endif } }, computed: { overlayStyle() { const style = { position: 'fixed', top: 0, left: 0, right: 0, zIndex: this.zIndex, bottom: 0, 'background-color': `rgba(0, 0, 0, ${this.opacity})` } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } }, methods: { clickHandler() { this.$emit('click') }, clear() {} } } </script> <style lang="scss" scoped> /* #ifndef APP-NVUE */ $uv-overlay-top:0 !default; $uv-overlay-left:0 !default; $uv-overlay-width:100% !default; $uv-overlay-height:100% !default; $uv-overlay-background-color:rgba(0, 0, 0, .7) !default; .uv-overlay { position: fixed; top:$uv-overlay-top; left:$uv-overlay-left; width: $uv-overlay-width; height:$uv-overlay-height; background-color:$uv-overlay-background-color; } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-overlay/components/uv-overlay/uv-overlay.vue
Vue
unknown
2,360
<template> <view :id="attrs.id" :class="'_block _'+name+' '+attrs.class" :style="attrs.style"> <block v-for="(n, i) in childs" v-bind:key="i"> <!-- 图片 --> <!-- 占位图 --> <image v-if="n.name==='img'&&!n.t&&((opts[1]&&!ctrl[i])||ctrl[i]<0)" class="_img" :style="n.attrs.style" :src="ctrl[i]<0?opts[2]:opts[1]" mode="widthFix" /> <!-- 显示图片 --> <!-- #ifdef H5 || (APP-PLUS && VUE2) --> <img v-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" /> <!-- #endif --> <!-- #ifndef H5 || (APP-PLUS && VUE2) --> <!-- 表格中的图片,使用 rich-text 防止大小不正确 --> <rich-text v-if="n.name==='img'&&n.t" :style="'display:'+n.t" :nodes="[{attrs:{style:n.attrs.style,src:n.attrs.src},name:'img'}]" :data-i="i" @tap.stop="imgTap" /> <!-- #endif --> <!-- #ifndef H5 || APP-PLUS --> <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;height:1px;'+n.attrs.style" :src="n.attrs.src" :mode="!n.h?'widthFix':(!n.w?'heightFix':'')" :lazy-load="opts[0]" :webp="n.webp" :show-menu-by-longpress="opts[3]&&!n.attrs.ignore" :image-menu-prevent="!opts[3]||n.attrs.ignore" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" /> <!-- #endif --> <!-- #ifdef APP-PLUS && VUE3 --> <image v-else-if="n.name==='img'" :id="n.attrs.id" :class="'_img '+n.attrs.class" :style="(ctrl[i]===-1?'display:none;':'')+'width:'+(ctrl[i]||1)+'px;'+n.attrs.style" :src="n.attrs.src||(ctrl.load?n.attrs['data-src']:'')" :mode="!n.h?'widthFix':(!n.w?'heightFix':'')" :data-i="i" @load="imgLoad" @error="mediaError" @tap.stop="imgTap" @longpress="imgLongTap" /> <!-- #endif --> <!-- 文本 --> <!-- #ifdef MP-WEIXIN --> <text v-else-if="n.text" :user-select="opts[4]=='force'&&isiOS" decode>{{n.text}}</text> <!-- #endif --> <!-- #ifndef MP-WEIXIN || MP-BAIDU || MP-ALIPAY || MP-TOUTIAO --> <text v-else-if="n.text" decode>{{n.text}}</text> <!-- #endif --> <text v-else-if="n.name==='br'">\n</text> <!-- 链接 --> <view v-else-if="n.name==='a'" :id="n.attrs.id" :class="(n.attrs.href?'_a ':'')+n.attrs.class" hover-class="_hover" :style="'display:inline;'+n.attrs.style" :data-i="i" @tap.stop="linkTap"> <node name="span" :childs="n.children" :opts="opts" style="display:inherit" /> </view> <!-- 视频 --> <!-- #ifdef APP-PLUS --> <view v-else-if="n.html" :id="n.attrs.id" :class="'_video '+n.attrs.class" :style="n.attrs.style" v-html="n.html" @vplay.stop="play" /> <!-- #endif --> <!-- #ifndef APP-PLUS --> <video v-else-if="n.name==='video'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :autoplay="n.attrs.autoplay" :controls="n.attrs.controls" :loop="n.attrs.loop" :muted="n.attrs.muted" :object-fit="n.attrs['object-fit']" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @error="mediaError" /> <!-- #endif --> <!-- #ifdef H5 || APP-PLUS --> <iframe v-else-if="n.name==='iframe'" :style="n.attrs.style" :allowfullscreen="n.attrs.allowfullscreen" :frameborder="n.attrs.frameborder" :src="n.attrs.src" /> <embed v-else-if="n.name==='embed'" :style="n.attrs.style" :src="n.attrs.src" /> <!-- #endif --> <!-- #ifndef MP-TOUTIAO || ((H5 || APP-PLUS) && VUE3) --> <!-- 音频 --> <audio v-else-if="n.name==='audio'" :id="n.attrs.id" :class="n.attrs.class" :style="n.attrs.style" :author="n.attrs.author" :controls="n.attrs.controls" :loop="n.attrs.loop" :name="n.attrs.name" :poster="n.attrs.poster" :src="n.src[ctrl[i]||0]" :data-i="i" @play="play" @error="mediaError" /> <!-- #endif --> <view v-else-if="(n.name==='table'&&n.c)||n.name==='li'" :id="n.attrs.id" :class="'_'+n.name+' '+n.attrs.class" :style="n.attrs.style"> <node v-if="n.name==='li'" :childs="n.children" :opts="opts" /> <view v-else v-for="(tbody, x) in n.children" v-bind:key="x" :class="'_'+tbody.name+' '+tbody.attrs.class" :style="tbody.attrs.style"> <node v-if="tbody.name==='td'||tbody.name==='th'" :childs="tbody.children" :opts="opts" /> <block v-else v-for="(tr, y) in tbody.children" v-bind:key="y"> <view v-if="tr.name==='td'||tr.name==='th'" :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style"> <node :childs="tr.children" :opts="opts" /> </view> <view v-else :class="'_'+tr.name+' '+tr.attrs.class" :style="tr.attrs.style"> <view v-for="(td, z) in tr.children" v-bind:key="z" :class="'_'+td.name+' '+td.attrs.class" :style="td.attrs.style"> <node :childs="td.children" :opts="opts" /> </view> </view> </block> </view> </view> <!-- 富文本 --> <!-- #ifdef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) --> <rich-text v-else-if="!n.c&&!handler.isInline(n.name, n.attrs.style)" :id="n.attrs.id" :style="n.f" :user-select="opts[4]" :nodes="[n]" /> <!-- #endif --> <!-- #ifndef H5 || ((MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE2) --> <rich-text v-else-if="!n.c" :id="n.attrs.id" :style="'display:inline;'+n.f" :preview="false" :selectable="opts[4]" :user-select="opts[4]" :nodes="[n]" /> <!-- #endif --> <!-- 继续递归 --> <view v-else-if="n.c===2" :id="n.attrs.id" :class="'_block _'+n.name+' '+n.attrs.class" :style="n.f+';'+n.attrs.style"> <node v-for="(n2, j) in n.children" v-bind:key="j" :style="n2.f" :name="n2.name" :attrs="n2.attrs" :childs="n2.children" :opts="opts" /> </view> <node v-else :style="n.f" :name="n.name" :attrs="n.attrs" :childs="n.children" :opts="opts" /> </block> </view> </template> <script module="handler" lang="wxs"> // 行内标签列表 var inlineTags = { abbr: true, b: true, big: true, code: true, del: true, em: true, i: true, ins: true, label: true, q: true, small: true, span: true, strong: true, sub: true, sup: true } /** * @description 判断是否为行内标签 */ module.exports = { isInline: function (tagName, style) { return inlineTags[tagName] || (style || '').indexOf('display:inline') !== -1 } } </script> <script> import node from './node' export default { name: 'node', options: { // #ifdef MP-WEIXIN virtualHost: true, // #endif // #ifdef MP-TOUTIAO addGlobalClass: false // #endif }, data () { return { ctrl: {}, // #ifdef MP-WEIXIN isiOS: uni.getSystemInfoSync().system.includes('iOS') // #endif } }, props: { name: String, attrs: { type: Object, default () { return {} } }, childs: Array, opts: Array }, components: { // #ifndef (H5 || APP-PLUS) && VUE3 node // #endif }, mounted () { this.$nextTick(() => { for (this.root = this.$parent; this.root.$options.name !== 'uv-parse'; this.root = this.root.$parent); }) // #ifdef H5 || APP-PLUS if (this.opts[0]) { let i for (i = this.childs.length; i--;) { if (this.childs[i].name === 'img') break } if (i !== -1) { this.observer = uni.createIntersectionObserver(this).relativeToViewport({ top: 500, bottom: 500 }) this.observer.observe('._img', res => { if (res.intersectionRatio) { this.$set(this.ctrl, 'load', 1) this.observer.disconnect() } }) } } // #endif }, beforeDestroy () { // #ifdef H5 || APP-PLUS if (this.observer) { this.observer.disconnect() } // #endif }, methods:{ // #ifdef MP-WEIXIN toJSON () { return this }, // #endif /** * @description 播放视频事件 * @param {Event} e */ play (e) { this.root.$emit('play') // #ifndef APP-PLUS if (this.root.pauseVideo) { let flag = false const id = e.target.id for (let i = this.root._videos.length; i--;) { if (this.root._videos[i].id === id) { flag = true } else { this.root._videos[i].pause() // 自动暂停其他视频 } } // 将自己加入列表 if (!flag) { const ctx = uni.createVideoContext(id // #ifndef MP-BAIDU , this // #endif ) ctx.id = id if (this.root.playbackRate) { ctx.playbackRate(this.root.playbackRate) } this.root._videos.push(ctx) } } // #endif }, /** * @description 图片点击事件 * @param {Event} e */ imgTap (e) { const node = this.childs[e.currentTarget.dataset.i] if (node.a) { this.linkTap(node.a) return } if (node.attrs.ignore) return // #ifdef H5 || APP-PLUS node.attrs.src = node.attrs.src || node.attrs['data-src'] // #endif this.root.$emit('imgtap', node.attrs) // 自动预览图片 if (this.root.previewImg) { uni.previewImage({ // #ifdef MP-WEIXIN showmenu: this.root.showImgMenu, // #endif // #ifdef MP-ALIPAY enablesavephoto: this.root.showImgMenu, enableShowPhotoDownload: this.root.showImgMenu, // #endif current: parseInt(node.attrs.i), urls: this.root.imgList }) } }, /** * @description 图片长按 */ imgLongTap (e) { // #ifdef APP-PLUS const attrs = this.childs[e.currentTarget.dataset.i].attrs if (this.opts[3] && !attrs.ignore) { uni.showActionSheet({ itemList: ['保存图片'], success: () => { const save = path => { uni.saveImageToPhotosAlbum({ filePath: path, success () { uni.showToast({ title: '保存成功' }) } }) } if (this.root.imgList[attrs.i].startsWith('http')) { uni.downloadFile({ url: this.root.imgList[attrs.i], success: res => save(res.tempFilePath) }) } else { save(this.root.imgList[attrs.i]) } } }) } // #endif }, /** * @description 图片加载完成事件 * @param {Event} e */ imgLoad (e) { const i = e.currentTarget.dataset.i /* #ifndef H5 || (APP-PLUS && VUE2) */ if (!this.childs[i].w) { // 设置原宽度 this.$set(this.ctrl, i, e.detail.width) } else /* #endif */ if ((this.opts[1] && !this.ctrl[i]) || this.ctrl[i] === -1) { // 加载完毕,取消加载中占位图 this.$set(this.ctrl, i, 1) } this.checkReady() }, /** * @description 检查是否所有图片加载完毕 */ checkReady () { if (this.root && !this.root.lazyLoad) { this.root._unloadimgs -= 1 if (!this.root._unloadimgs) { setTimeout(() => { this.root.getRect().then(rect => { this.root.$emit('ready', rect) }).catch(() => { this.root.$emit('ready', {}) }) }, 350) } } }, /** * @description 链接点击事件 * @param {Event} e */ linkTap (e) { const node = e.currentTarget ? this.childs[e.currentTarget.dataset.i] : {} const attrs = node.attrs || e const href = attrs.href this.root.$emit('linktap', Object.assign({ innerText: this.root.getText(node.children || []) // 链接内的文本内容 }, attrs)) if (href) { if (href[0] === '#') { // 跳转锚点 this.root.navigateTo(href.substring(1)).catch(() => { }) } else if (href.split('?')[0].includes('://')) { // 复制外部链接 if (this.root.copyLink) { // #ifdef H5 window.open(href) // #endif // #ifdef MP uni.setClipboardData({ data: href, success: () => uni.showToast({ title: '链接已复制' }) }) // #endif // #ifdef APP-PLUS plus.runtime.openWeb(href) // #endif } } else { // 跳转页面 uni.navigateTo({ url: href, fail () { uni.switchTab({ url: href, fail () { } }) } }) } } }, /** * @description 错误事件 * @param {Event} e */ mediaError (e) { const i = e.currentTarget.dataset.i const node = this.childs[i] // 加载其他源 if (node.name === 'video' || node.name === 'audio') { let index = (this.ctrl[i] || 0) + 1 if (index > node.src.length) { index = 0 } if (index < node.src.length) { this.$set(this.ctrl, i, index) return } } else if (node.name === 'img') { // #ifdef H5 && VUE3 if (this.opts[0] && !this.ctrl.load) return // #endif // 显示错误占位图 if (this.opts[2]) { this.$set(this.ctrl, i, -1) } this.checkReady() } if (this.root) { this.root.$emit('error', { source: node.name, attrs: node.attrs, // #ifndef H5 && VUE3 errMsg: e.detail.errMsg // #endif }) } } } } </script> <style> /* a 标签默认效果 */ ._a { padding: 1.5px 0 1.5px 0; color: #366092; word-break: break-all; } /* a 标签点击态效果 */ ._hover { text-decoration: underline; opacity: 0.7; } /* 图片默认效果 */ ._img { max-width: 100%; -webkit-touch-callout: none; } /* 内部样式 */ ._block { display: block; } ._b, ._strong { font-weight: bold; } ._code { font-family: monospace; } ._del { text-decoration: line-through; } ._em, ._i { font-style: italic; } ._h1 { font-size: 2em; } ._h2 { font-size: 1.5em; } ._h3 { font-size: 1.17em; } ._h5 { font-size: 0.83em; } ._h6 { font-size: 0.67em; } ._h1, ._h2, ._h3, ._h4, ._h5, ._h6 { display: block; font-weight: bold; } ._image { height: 1px; } ._ins { text-decoration: underline; } ._li { display: list-item; } ._ol { list-style-type: decimal; } ._ol, ._ul { display: block; padding-left: 40px; margin: 1em 0; } ._q::before { content: '"'; } ._q::after { content: '"'; } ._sub { font-size: smaller; vertical-align: sub; } ._sup { font-size: smaller; vertical-align: super; } ._thead, ._tbody, ._tfoot { display: table-row-group; } ._tr { display: table-row; } ._td, ._th { display: table-cell; vertical-align: middle; } ._th { font-weight: bold; text-align: center; } ._ul { list-style-type: disc; } ._ul ._ul { margin: 0; list-style-type: circle; } ._ul ._ul ._ul { list-style-type: square; } ._abbr, ._b, ._code, ._del, ._em, ._i, ._ins, ._label, ._q, ._span, ._strong, ._sub, ._sup { display: inline; } /* #ifdef APP-PLUS */ ._video { width: 300px; height: 225px; } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-parse/components/uv-parse/node/node.vue
Vue
unknown
15,826
/** * @fileoverview html 解析器 */ // 配置 const config = { // 信任的标签(保持标签名不变) trustTags: makeMap('a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,ruby,rt,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video'), // 块级标签(转为 div,其他的非信任标签转为 span) blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section'), // #ifdef (MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE3 // 行内标签 inlineTags: makeMap('abbr,b,big,code,del,em,i,ins,label,q,small,span,strong,sub,sup'), // #endif // 要移除的标签 ignoreTags: makeMap('area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr'), // 自闭合的标签 voidTags: makeMap('area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'), // html 实体 entities: { lt: '<', gt: '>', quot: '"', apos: "'", ensp: '\u2002', emsp: '\u2003', nbsp: '\xA0', semi: ';', ndash: '–', mdash: '—', middot: '·', lsquo: '‘', rsquo: '’', ldquo: '“', rdquo: '”', bull: '•', hellip: '…', larr: '←', uarr: '↑', rarr: '→', darr: '↓' }, // 默认的标签样式 tagStyle: { // #ifndef APP-PLUS-NVUE address: 'font-style:italic', big: 'display:inline;font-size:1.2em', caption: 'display:table-caption;text-align:center', center: 'text-align:center', cite: 'font-style:italic', dd: 'margin-left:40px', mark: 'background-color:yellow', pre: 'font-family:monospace;white-space:pre', s: 'text-decoration:line-through', small: 'display:inline;font-size:0.8em', strike: 'text-decoration:line-through', u: 'text-decoration:underline' // #endif }, // svg 大小写对照表 svgDict: { animatetransform: 'animateTransform', lineargradient: 'linearGradient', viewbox: 'viewBox', attributename: 'attributeName', repeatcount: 'repeatCount', repeatdur: 'repeatDur' } } const tagSelector={} const { windowWidth, // #ifdef MP-WEIXIN system // #endif } = uni.getSystemInfoSync() const blankChar = makeMap(' ,\r,\n,\t,\f') let idIndex = 0 // #ifdef H5 || APP-PLUS config.ignoreTags.iframe = undefined config.trustTags.iframe = true config.ignoreTags.embed = undefined config.trustTags.embed = true // #endif // #ifdef APP-PLUS-NVUE config.ignoreTags.source = undefined config.ignoreTags.style = undefined // #endif /** * @description 创建 map * @param {String} str 逗号分隔 */ function makeMap (str) { const map = Object.create(null) const list = str.split(',') for (let i = list.length; i--;) { map[list[i]] = true } return map } /** * @description 解码 html 实体 * @param {String} str 要解码的字符串 * @param {Boolean} amp 要不要解码 &amp; * @returns {String} 解码后的字符串 */ function decodeEntity (str, amp) { let i = str.indexOf('&') while (i !== -1) { const j = str.indexOf(';', i + 3) let code if (j === -1) break if (str[i + 1] === '#') { // &#123; 形式的实体 code = parseInt((str[i + 2] === 'x' ? '0' : '') + str.substring(i + 2, j)) if (!isNaN(code)) { str = str.substr(0, i) + String.fromCharCode(code) + str.substr(j + 1) } } else { // &nbsp; 形式的实体 code = str.substring(i + 1, j) if (config.entities[code] || (code === 'amp' && amp)) { str = str.substr(0, i) + (config.entities[code] || '&') + str.substr(j + 1) } } i = str.indexOf('&', i + 1) } return str } /** * @description 合并多个块级标签,加快长内容渲染 * @param {Array} nodes 要合并的标签数组 */ function mergeNodes (nodes) { let i = nodes.length - 1 for (let j = i; j >= -1; j--) { if (j === -1 || nodes[j].c || !nodes[j].name || (nodes[j].name !== 'div' && nodes[j].name !== 'p' && nodes[j].name[0] !== 'h') || (nodes[j].attrs.style || '').includes('inline')) { if (i - j >= 5) { nodes.splice(j + 1, i - j, { name: 'div', attrs: {}, children: nodes.slice(j + 1, i + 1) }) } i = j - 1 } } } /** * @description html 解析器 * @param {Object} vm 组件实例 */ function Parser (vm) { this.options = vm || {} this.tagStyle = Object.assign({}, config.tagStyle, this.options.tagStyle) this.imgList = vm.imgList || [] this.imgList._unloadimgs = 0 this.plugins = vm.plugins || [] this.attrs = Object.create(null) this.stack = [] this.nodes = [] this.pre = (this.options.containerStyle || '').includes('white-space') && this.options.containerStyle.includes('pre') ? 2 : 0 } /** * @description 执行解析 * @param {String} content 要解析的文本 */ Parser.prototype.parse = function (content) { // 插件处理 for (let i = this.plugins.length; i--;) { if (this.plugins[i].onUpdate) { content = this.plugins[i].onUpdate(content, config) || content } } new Lexer(this).parse(content) // 出栈未闭合的标签 while (this.stack.length) { this.popNode() } if (this.nodes.length > 50) { mergeNodes(this.nodes) } return this.nodes } /** * @description 将标签暴露出来(不被 rich-text 包含) */ Parser.prototype.expose = function () { // #ifndef APP-PLUS-NVUE for (let i = this.stack.length; i--;) { const item = this.stack[i] if (item.c || item.name === 'a' || item.name === 'video' || item.name === 'audio') return item.c = 1 } // #endif } /** * @description 处理插件 * @param {Object} node 要处理的标签 * @returns {Boolean} 是否要移除此标签 */ Parser.prototype.hook = function (node) { for (let i = this.plugins.length; i--;) { if (this.plugins[i].onParse && this.plugins[i].onParse(node, this) === false) { return false } } return true } /** * @description 将链接拼接上主域名 * @param {String} url 需要拼接的链接 * @returns {String} 拼接后的链接 */ Parser.prototype.getUrl = function (url) { const domain = this.options.domain if (url[0] === '/') { if (url[1] === '/') { // // 开头的补充协议名 url = (domain ? domain.split('://')[0] : 'http') + ':' + url } else if (domain) { // 否则补充整个域名 url = domain + url } /* #ifdef APP-PLUS */ else { url = plus.io.convertLocalFileSystemURL(url) } /* #endif */ } else if (!url.includes('data:') && !url.includes('://')) { if (domain) { url = domain + '/' + url } /* #ifdef APP-PLUS */ else { url = plus.io.convertLocalFileSystemURL(url) } /* #endif */ } return url } /** * @description 解析样式表 * @param {Object} node 标签 * @returns {Object} */ Parser.prototype.parseStyle = function (node) { const attrs = node.attrs const list = (this.tagStyle[node.name] || '').split(';').concat((attrs.style || '').split(';')) const styleObj = {} let tmp = '' if (attrs.id && !this.xml) { // 暴露锚点 if (this.options.useAnchor) { this.expose() } else if (node.name !== 'img' && node.name !== 'a' && node.name !== 'video' && node.name !== 'audio') { attrs.id = undefined } } // 转换 width 和 height 属性 if (attrs.width) { styleObj.width = parseFloat(attrs.width) + (attrs.width.includes('%') ? '%' : 'px') attrs.width = undefined } if (attrs.height) { styleObj.height = parseFloat(attrs.height) + (attrs.height.includes('%') ? '%' : 'px') attrs.height = undefined } for (let i = 0, len = list.length; i < len; i++) { const info = list[i].split(':') if (info.length < 2) continue const key = info.shift().trim().toLowerCase() let value = info.join(':').trim() if ((value[0] === '-' && value.lastIndexOf('-') > 0) || value.includes('safe')) { // 兼容性的 css 不压缩 tmp += `;${key}:${value}` } else if (!styleObj[key] || value.includes('import') || !styleObj[key].includes('import')) { // 重复的样式进行覆盖 if (value.includes('url')) { // 填充链接 let j = value.indexOf('(') + 1 if (j) { while (value[j] === '"' || value[j] === "'" || blankChar[value[j]]) { j++ } value = value.substr(0, j) + this.getUrl(value.substr(j)) } } else if (value.includes('rpx')) { // 转换 rpx(rich-text 内部不支持 rpx) value = value.replace(/[0-9.]+\s*rpx/g, $ => parseFloat($) * windowWidth / 750 + 'px') } styleObj[key] = value } } node.attrs.style = tmp return styleObj } /** * @description 解析到标签名 * @param {String} name 标签名 * @private */ Parser.prototype.onTagName = function (name) { this.tagName = this.xml ? name : name.toLowerCase() if (this.tagName === 'svg') { this.xml = (this.xml || 0) + 1 // svg 标签内大小写敏感 config.ignoreTags.style = undefined // svg 标签内 style 可用 } } /** * @description 解析到属性名 * @param {String} name 属性名 * @private */ Parser.prototype.onAttrName = function (name) { name = this.xml ? name : name.toLowerCase() if (name.substr(0, 5) === 'data-') { if (name === 'data-src' && !this.attrs.src) { // data-src 自动转为 src this.attrName = 'src' } else if (this.tagName === 'img' || this.tagName === 'a') { // a 和 img 标签保留 data- 的属性,可以在 imgtap 和 linktap 事件中使用 this.attrName = name } else { // 剩余的移除以减小大小 this.attrName = undefined } } else { this.attrName = name this.attrs[name] = 'T' // boolean 型属性缺省设置 } } /** * @description 解析到属性值 * @param {String} val 属性值 * @private */ Parser.prototype.onAttrVal = function (val) { const name = this.attrName || '' if (name === 'style' || name === 'href') { // 部分属性进行实体解码 this.attrs[name] = decodeEntity(val, true) } else if (name.includes('src')) { // 拼接主域名 this.attrs[name] = this.getUrl(decodeEntity(val, true)) } else if (name) { this.attrs[name] = val } } /** * @description 解析到标签开始 * @param {Boolean} selfClose 是否有自闭合标识 /> * @private */ Parser.prototype.onOpenTag = function (selfClose) { // 拼装 node const node = Object.create(null) node.name = this.tagName node.attrs = this.attrs // 避免因为自动 diff 使得 type 被设置为 null 导致部分内容不显示 if (this.options.nodes.length) { node.type = 'node' } this.attrs = Object.create(null) const attrs = node.attrs const parent = this.stack[this.stack.length - 1] const siblings = parent ? parent.children : this.nodes const close = this.xml ? selfClose : config.voidTags[node.name] // 替换标签名选择器 if (tagSelector[node.name]) { attrs.class = tagSelector[node.name] + (attrs.class ? ' ' + attrs.class : '') } // 转换 embed 标签 if (node.name === 'embed') { // #ifndef H5 || APP-PLUS const src = attrs.src || '' // 按照后缀名和 type 将 embed 转为 video 或 audio if (src.includes('.mp4') || src.includes('.3gp') || src.includes('.m3u8') || (attrs.type || '').includes('video')) { node.name = 'video' } else if (src.includes('.mp3') || src.includes('.wav') || src.includes('.aac') || src.includes('.m4a') || (attrs.type || '').includes('audio')) { node.name = 'audio' } if (attrs.autostart) { attrs.autoplay = 'T' } attrs.controls = 'T' // #endif // #ifdef H5 || APP-PLUS this.expose() // #endif } // #ifndef APP-PLUS-NVUE // 处理音视频 if (node.name === 'video' || node.name === 'audio') { // 设置 id 以便获取 context if (node.name === 'video' && !attrs.id) { attrs.id = 'v' + idIndex++ } // 没有设置 controls 也没有设置 autoplay 的自动设置 controls if (!attrs.controls && !attrs.autoplay) { attrs.controls = 'T' } // 用数组存储所有可用的 source node.src = [] if (attrs.src) { node.src.push(attrs.src) attrs.src = undefined } this.expose() } // #endif // 处理自闭合标签 if (close) { if (!this.hook(node) || config.ignoreTags[node.name]) { // 通过 base 标签设置主域名 if (node.name === 'base' && !this.options.domain) { this.options.domain = attrs.href } /* #ifndef APP-PLUS-NVUE */ else if (node.name === 'source' && parent && (parent.name === 'video' || parent.name === 'audio') && attrs.src) { // 设置 source 标签(仅父节点为 video 或 audio 时有效) parent.src.push(attrs.src) } /* #endif */ return } // 解析 style const styleObj = this.parseStyle(node) // 处理图片 if (node.name === 'img') { if (attrs.src) { // 标记 webp if (attrs.src.includes('webp')) { node.webp = 'T' } // data url 图片如果没有设置 original-src 默认为不可预览的小图片 if (attrs.src.includes('data:') && !attrs['original-src']) { attrs.ignore = 'T' } if (!attrs.ignore || node.webp || attrs.src.includes('cloud://')) { for (let i = this.stack.length; i--;) { const item = this.stack[i] if (item.name === 'a') { node.a = item.attrs } if (item.name === 'table' && !node.webp && !attrs.src.includes('cloud://')) { if (!styleObj.display || styleObj.display.includes('inline')) { node.t = 'inline-block' } else { node.t = styleObj.display } styleObj.display = undefined } // #ifndef H5 || APP-PLUS const style = item.attrs.style || '' if (style.includes('flex:') && !style.includes('flex:0') && !style.includes('flex: 0') && (!styleObj.width || parseInt(styleObj.width) > 100)) { styleObj.width = '100% !important' styleObj.height = '' for (let j = i + 1; j < this.stack.length; j++) { this.stack[j].attrs.style = (this.stack[j].attrs.style || '').replace('inline-', '') } } else if (style.includes('flex') && styleObj.width === '100%') { for (let j = i + 1; j < this.stack.length; j++) { const style = this.stack[j].attrs.style || '' if (!style.includes(';width') && !style.includes(' width') && style.indexOf('width') !== 0) { styleObj.width = '' break } } } else if (style.includes('inline-block')) { if (styleObj.width && styleObj.width[styleObj.width.length - 1] === '%') { item.attrs.style += ';max-width:' + styleObj.width styleObj.width = '' } else { item.attrs.style += ';max-width:100%' } } // #endif item.c = 1 } attrs.i = this.imgList.length.toString() let src = attrs['original-src'] || attrs.src // #ifndef H5 || MP-ALIPAY || APP-PLUS || MP-360 if (this.imgList.includes(src)) { // 如果有重复的链接则对域名进行随机大小写变换避免预览时错位 let i = src.indexOf('://') if (i !== -1) { i += 3 let newSrc = src.substr(0, i) for (; i < src.length; i++) { if (src[i] === '/') break newSrc += Math.random() > 0.5 ? src[i].toUpperCase() : src[i] } newSrc += src.substr(i) src = newSrc } } // #endif this.imgList.push(src) if (!node.t) { this.imgList._unloadimgs += 1 } // #ifdef H5 || APP-PLUS if (this.options.lazyLoad) { attrs['data-src'] = attrs.src attrs.src = undefined } // #endif } } if (styleObj.display === 'inline') { styleObj.display = '' } // #ifndef APP-PLUS-NVUE if (attrs.ignore) { styleObj['max-width'] = styleObj['max-width'] || '100%' attrs.style += ';-webkit-touch-callout:none' } // #endif // 设置的宽度超出屏幕,为避免变形,高度转为自动 if (parseInt(styleObj.width) > windowWidth) { styleObj.height = undefined } // 记录是否设置了宽高 if (!isNaN(parseInt(styleObj.width))) { node.w = 'T' } if (!isNaN(parseInt(styleObj.height)) && (!styleObj.height.includes('%') || (parent && (parent.attrs.style || '').includes('height')))) { node.h = 'T' } } else if (node.name === 'svg') { siblings.push(node) this.stack.push(node) this.popNode() return } for (const key in styleObj) { if (styleObj[key]) { attrs.style += `;${key}:${styleObj[key].replace(' !important', '')}` } } attrs.style = attrs.style.substr(1) || undefined // #ifdef (MP-WEIXIN || MP-QQ) && VUE3 if (!attrs.style) { delete attrs.style } // #endif } else { if ((node.name === 'pre' || ((attrs.style || '').includes('white-space') && attrs.style.includes('pre'))) && this.pre !== 2) { this.pre = node.pre = 1 } node.children = [] this.stack.push(node) } // 加入节点树 siblings.push(node) } /** * @description 解析到标签结束 * @param {String} name 标签名 * @private */ Parser.prototype.onCloseTag = function (name) { // 依次出栈到匹配为止 name = this.xml ? name : name.toLowerCase() let i for (i = this.stack.length; i--;) { if (this.stack[i].name === name) break } if (i !== -1) { while (this.stack.length > i) { this.popNode() } } else if (name === 'p' || name === 'br') { const siblings = this.stack.length ? this.stack[this.stack.length - 1].children : this.nodes siblings.push({ name, attrs: { class: tagSelector[name] || '', style: this.tagStyle[name] || '' } }) } } /** * @description 处理标签出栈 * @private */ Parser.prototype.popNode = function () { const node = this.stack.pop() let attrs = node.attrs const children = node.children const parent = this.stack[this.stack.length - 1] const siblings = parent ? parent.children : this.nodes if (!this.hook(node) || config.ignoreTags[node.name]) { // 获取标题 if (node.name === 'title' && children.length && children[0].type === 'text' && this.options.setTitle) { uni.setNavigationBarTitle({ title: children[0].text }) } siblings.pop() return } if (node.pre && this.pre !== 2) { // 是否合并空白符标识 this.pre = node.pre = undefined for (let i = this.stack.length; i--;) { if (this.stack[i].pre) { this.pre = 1 } } } const styleObj = {} // 转换 svg if (node.name === 'svg') { if (this.xml > 1) { // 多层 svg 嵌套 this.xml-- return } // #ifdef APP-PLUS-NVUE (function traversal (node) { if (node.name) { // 调整 svg 的大小写 node.name = config.svgDict[node.name] || node.name for (const item in node.attrs) { if (config.svgDict[item]) { node.attrs[config.svgDict[item]] = node.attrs[item] node.attrs[item] = undefined } } for (let i = 0; i < (node.children || []).length; i++) { traversal(node.children[i]) } } })(node) // #endif // #ifndef APP-PLUS-NVUE let src = '' const style = attrs.style attrs.style = '' attrs.xmlns = 'http://www.w3.org/2000/svg'; (function traversal (node) { if (node.type === 'text') { src += node.text return } const name = config.svgDict[node.name] || node.name src += '<' + name for (const item in node.attrs) { const val = node.attrs[item] if (val) { src += ` ${config.svgDict[item] || item}="${val}"` } } if (!node.children) { src += '/>' } else { src += '>' for (let i = 0; i < node.children.length; i++) { traversal(node.children[i]) } src += '</' + name + '>' } })(node) node.name = 'img' node.attrs = { src: 'data:image/svg+xml;utf8,' + src.replace(/#/g, '%23'), style, ignore: 'T' } node.children = undefined // #endif this.xml = false config.ignoreTags.style = true return } // #ifndef APP-PLUS-NVUE // 转换 align 属性 if (attrs.align) { if (node.name === 'table') { if (attrs.align === 'center') { styleObj['margin-inline-start'] = styleObj['margin-inline-end'] = 'auto' } else { styleObj.float = attrs.align } } else { styleObj['text-align'] = attrs.align } attrs.align = undefined } // 转换 dir 属性 if (attrs.dir) { styleObj.direction = attrs.dir attrs.dir = undefined } // 转换 font 标签的属性 if (node.name === 'font') { if (attrs.color) { styleObj.color = attrs.color attrs.color = undefined } if (attrs.face) { styleObj['font-family'] = attrs.face attrs.face = undefined } if (attrs.size) { let size = parseInt(attrs.size) if (!isNaN(size)) { if (size < 1) { size = 1 } else if (size > 7) { size = 7 } styleObj['font-size'] = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', 'xxx-large'][size - 1] } attrs.size = undefined } } // #endif // 一些编辑器的自带 class if ((attrs.class || '').includes('align-center')) { styleObj['text-align'] = 'center' } Object.assign(styleObj, this.parseStyle(node)) if (node.name !== 'table' && parseInt(styleObj.width) > windowWidth) { styleObj['max-width'] = '100%' styleObj['box-sizing'] = 'border-box' } // #ifndef APP-PLUS-NVUE if (config.blockTags[node.name]) { node.name = 'div' } else if (!config.trustTags[node.name] && !this.xml) { // 未知标签转为 span,避免无法显示 node.name = 'span' } if (node.name === 'a' || node.name === 'ad' // #ifdef H5 || APP-PLUS || node.name === 'iframe' // eslint-disable-line // #endif ) { this.expose() } else if (node.name === 'video') { if ((styleObj.height || '').includes('auto')) { styleObj.height = undefined } /* #ifdef APP-PLUS */ let str = '<video style="width:100%;height:100%"' for (const item in attrs) { if (attrs[item]) { str += ' ' + item + '="' + attrs[item] + '"' } } if (this.options.pauseVideo) { str += ' onplay="this.dispatchEvent(new CustomEvent(\'vplay\',{bubbles:!0}));for(var e=document.getElementsByTagName(\'video\'),t=0;t<e.length;t++)e[t]!=this&&e[t].pause()"' } str += '>' for (let i = 0; i < node.src.length; i++) { str += '<source src="' + node.src[i] + '">' } str += '</video>' node.html = str /* #endif */ } else if ((node.name === 'ul' || node.name === 'ol') && node.c) { // 列表处理 const types = { a: 'lower-alpha', A: 'upper-alpha', i: 'lower-roman', I: 'upper-roman' } if (types[attrs.type]) { attrs.style += ';list-style-type:' + types[attrs.type] attrs.type = undefined } for (let i = children.length; i--;) { if (children[i].name === 'li') { children[i].c = 1 } } } else if (node.name === 'table') { // 表格处理 // cellpadding、cellspacing、border 这几个常用表格属性需要通过转换实现 let padding = parseFloat(attrs.cellpadding) let spacing = parseFloat(attrs.cellspacing) const border = parseFloat(attrs.border) const bordercolor = styleObj['border-color'] const borderstyle = styleObj['border-style'] if (node.c) { // padding 和 spacing 默认 2 if (isNaN(padding)) { padding = 2 } if (isNaN(spacing)) { spacing = 2 } } if (border) { attrs.style += `;border:${border}px ${borderstyle || 'solid'} ${bordercolor || 'gray'}` } if (node.flag && node.c) { // 有 colspan 或 rowspan 且含有链接的表格通过 grid 布局实现 styleObj.display = 'grid' if (spacing) { styleObj['grid-gap'] = spacing + 'px' styleObj.padding = spacing + 'px' } else if (border) { // 无间隔的情况下避免边框重叠 attrs.style += ';border-left:0;border-top:0' } const width = [] // 表格的列宽 const trList = [] // tr 列表 const cells = [] // 保存新的单元格 const map = {}; // 被合并单元格占用的格子 (function traversal (nodes) { for (let i = 0; i < nodes.length; i++) { if (nodes[i].name === 'tr') { trList.push(nodes[i]) } else { traversal(nodes[i].children || []) } } })(children) for (let row = 1; row <= trList.length; row++) { let col = 1 for (let j = 0; j < trList[row - 1].children.length; j++) { const td = trList[row - 1].children[j] if (td.name === 'td' || td.name === 'th') { // 这个格子被上面的单元格占用,则列号++ while (map[row + '.' + col]) { col++ } let style = td.attrs.style || '' let start = style.indexOf('width') ? style.indexOf(';width') : 0 // 提取出 td 的宽度 if (start !== -1) { let end = style.indexOf(';', start + 6) if (end === -1) { end = style.length } if (!td.attrs.colspan) { width[col] = style.substring(start ? start + 7 : 6, end) } style = style.substr(0, start) + style.substr(end) } // 设置竖直对齐 style += ';display:flex' start = style.indexOf('vertical-align') if (start !== -1) { const val = style.substr(start + 15, 10) if (val.includes('middle')) { style += ';align-items:center' } else if (val.includes('bottom')) { style += ';align-items:flex-end' } } else { style += ';align-items:center' } // 设置水平对齐 start = style.indexOf('text-align') if (start !== -1) { const val = style.substr(start + 11, 10) if (val.includes('center')) { style += ';justify-content: center' } else if (val.includes('right')) { style += ';justify-content: right' } } style = (border ? `;border:${border}px ${borderstyle || 'solid'} ${bordercolor || 'gray'}` + (spacing ? '' : ';border-right:0;border-bottom:0') : '') + (padding ? `;padding:${padding}px` : '') + ';' + style // 处理列合并 if (td.attrs.colspan) { style += `;grid-column-start:${col};grid-column-end:${col + parseInt(td.attrs.colspan)}` if (!td.attrs.rowspan) { style += `;grid-row-start:${row};grid-row-end:${row + 1}` } col += parseInt(td.attrs.colspan) - 1 } // 处理行合并 if (td.attrs.rowspan) { style += `;grid-row-start:${row};grid-row-end:${row + parseInt(td.attrs.rowspan)}` if (!td.attrs.colspan) { style += `;grid-column-start:${col};grid-column-end:${col + 1}` } // 记录下方单元格被占用 for (let rowspan = 1; rowspan < td.attrs.rowspan; rowspan++) { for (let colspan = 0; colspan < (td.attrs.colspan || 1); colspan++) { map[(row + rowspan) + '.' + (col - colspan)] = 1 } } } if (style) { td.attrs.style = style } cells.push(td) col++ } } if (row === 1) { let temp = '' for (let i = 1; i < col; i++) { temp += (width[i] ? width[i] : 'auto') + ' ' } styleObj['grid-template-columns'] = temp } } node.children = cells } else { // 没有使用合并单元格的表格通过 table 布局实现 if (node.c) { styleObj.display = 'table' } if (!isNaN(spacing)) { styleObj['border-spacing'] = spacing + 'px' } if (border || padding) { // 遍历 (function traversal (nodes) { for (let i = 0; i < nodes.length; i++) { const td = nodes[i] if (td.name === 'th' || td.name === 'td') { if (border) { td.attrs.style = `border:${border}px ${borderstyle || 'solid'} ${bordercolor || 'gray'};${td.attrs.style || ''}` } if (padding) { td.attrs.style = `padding:${padding}px;${td.attrs.style || ''}` } } else if (td.children) { traversal(td.children) } } })(children) } } // 给表格添加一个单独的横向滚动层 if (this.options.scrollTable && !(attrs.style || '').includes('inline')) { const table = Object.assign({}, node) node.name = 'div' node.attrs = { style: 'overflow:auto' } node.children = [table] attrs = table.attrs } } else if ((node.name === 'td' || node.name === 'th') && (attrs.colspan || attrs.rowspan)) { for (let i = this.stack.length; i--;) { if (this.stack[i].name === 'table') { this.stack[i].flag = 1 // 指示含有合并单元格 break } } } else if (node.name === 'ruby') { // 转换 ruby node.name = 'span' for (let i = 0; i < children.length - 1; i++) { if (children[i].type === 'text' && children[i + 1].name === 'rt') { children[i] = { name: 'div', attrs: { style: 'display:inline-block;text-align:center' }, children: [{ name: 'div', attrs: { style: 'font-size:50%;' + (children[i + 1].attrs.style || '') }, children: children[i + 1].children }, children[i]] } children.splice(i + 1, 1) } } } else if (node.c) { (function traversal (node) { node.c = 2 for (let i = node.children.length; i--;) { const child = node.children[i] // #ifdef (MP-WEIXIN || MP-QQ || APP-PLUS || MP-360) && VUE3 if (child.name && (config.inlineTags[child.name] || ((child.attrs.style || '').includes('inline') && child.children)) && !child.c) { traversal(child) } // #endif if (!child.c || child.name === 'table') { node.c = 1 } } })(node) } if ((styleObj.display || '').includes('flex') && !node.c) { for (let i = children.length; i--;) { const item = children[i] if (item.f) { item.attrs.style = (item.attrs.style || '') + item.f item.f = undefined } } } // flex 布局时部分样式需要提取到 rich-text 外层 const flex = parent && ((parent.attrs.style || '').includes('flex') || (parent.attrs.style || '').includes('grid')) // #ifdef MP-WEIXIN // 检查基础库版本 virtualHost 是否可用 && !(node.c && wx.getNFCAdapter) // eslint-disable-line // #endif // #ifndef MP-WEIXIN || MP-QQ || MP-BAIDU || MP-TOUTIAO && !node.c // eslint-disable-line // #endif if (flex) { node.f = ';max-width:100%' } if (children.length >= 50 && node.c && !(styleObj.display || '').includes('flex')) { mergeNodes(children) } // #endif for (const key in styleObj) { if (styleObj[key]) { const val = `;${key}:${styleObj[key].replace(' !important', '')}` /* #ifndef APP-PLUS-NVUE */ if (flex && ((key.includes('flex') && key !== 'flex-direction') || key === 'align-self' || key.includes('grid') || styleObj[key][0] === '-' || (key.includes('width') && val.includes('%')))) { node.f += val if (key === 'width') { attrs.style += ';width:100%' } } else /* #endif */ { attrs.style += val } } } attrs.style = attrs.style.substr(1) || undefined // #ifdef (MP-WEIXIN || MP-QQ) && VUE3 for (const key in attrs) { if (!attrs[key]) { delete attrs[key] } } // #endif } /** * @description 解析到文本 * @param {String} text 文本内容 */ Parser.prototype.onText = function (text) { if (!this.pre) { // 合并空白符 let trim = '' let flag for (let i = 0, len = text.length; i < len; i++) { if (!blankChar[text[i]]) { trim += text[i] } else { if (trim[trim.length - 1] !== ' ') { trim += ' ' } if (text[i] === '\n' && !flag) { flag = true } } } // 去除含有换行符的空串 if (trim === ' ') { if (flag) return // #ifdef VUE3 else { const parent = this.stack[this.stack.length - 1] if (parent && parent.name[0] === 't') return } // #endif } text = trim } const node = Object.create(null) node.type = 'text' // #ifdef (MP-BAIDU || MP-ALIPAY || MP-TOUTIAO) && VUE3 node.attrs = {} // #endif node.text = decodeEntity(text) if (this.hook(node)) { // #ifdef MP-WEIXIN if (this.options.selectable === 'force' && system.includes('iOS') && !uni.canIUse('rich-text.user-select')) { this.expose() } // #endif const siblings = this.stack.length ? this.stack[this.stack.length - 1].children : this.nodes siblings.push(node) } } /** * @description html 词法分析器 * @param {Object} handler 高层处理器 */ function Lexer (handler) { this.handler = handler } /** * @description 执行解析 * @param {String} content 要解析的文本 */ Lexer.prototype.parse = function (content) { this.content = content || '' this.i = 0 // 标记解析位置 this.start = 0 // 标记一个单词的开始位置 this.state = this.text // 当前状态 for (let len = this.content.length; this.i !== -1 && this.i < len;) { this.state() } } /** * @description 检查标签是否闭合 * @param {String} method 如果闭合要进行的操作 * @returns {Boolean} 是否闭合 * @private */ Lexer.prototype.checkClose = function (method) { const selfClose = this.content[this.i] === '/' if (this.content[this.i] === '>' || (selfClose && this.content[this.i + 1] === '>')) { if (method) { this.handler[method](this.content.substring(this.start, this.i)) } this.i += selfClose ? 2 : 1 this.start = this.i this.handler.onOpenTag(selfClose) if (this.handler.tagName === 'script') { this.i = this.content.indexOf('</', this.i) if (this.i !== -1) { this.i += 2 this.start = this.i } this.state = this.endTag } else { this.state = this.text } return true } return false } /** * @description 文本状态 * @private */ Lexer.prototype.text = function () { this.i = this.content.indexOf('<', this.i) // 查找最近的标签 if (this.i === -1) { // 没有标签了 if (this.start < this.content.length) { this.handler.onText(this.content.substring(this.start, this.content.length)) } return } const c = this.content[this.i + 1] if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { // 标签开头 if (this.start !== this.i) { this.handler.onText(this.content.substring(this.start, this.i)) } this.start = ++this.i this.state = this.tagName } else if (c === '/' || c === '!' || c === '?') { if (this.start !== this.i) { this.handler.onText(this.content.substring(this.start, this.i)) } const next = this.content[this.i + 2] if (c === '/' && ((next >= 'a' && next <= 'z') || (next >= 'A' && next <= 'Z'))) { // 标签结尾 this.i += 2 this.start = this.i this.state = this.endTag return } // 处理注释 let end = '-->' if (c !== '!' || this.content[this.i + 2] !== '-' || this.content[this.i + 3] !== '-') { end = '>' } this.i = this.content.indexOf(end, this.i) if (this.i !== -1) { this.i += end.length this.start = this.i } } else { this.i++ } } /** * @description 标签名状态 * @private */ Lexer.prototype.tagName = function () { if (blankChar[this.content[this.i]]) { // 解析到标签名 this.handler.onTagName(this.content.substring(this.start, this.i)) while (blankChar[this.content[++this.i]]); if (this.i < this.content.length && !this.checkClose()) { this.start = this.i this.state = this.attrName } } else if (!this.checkClose('onTagName')) { this.i++ } } /** * @description 属性名状态 * @private */ Lexer.prototype.attrName = function () { let c = this.content[this.i] if (blankChar[c] || c === '=') { // 解析到属性名 this.handler.onAttrName(this.content.substring(this.start, this.i)) let needVal = c === '=' const len = this.content.length while (++this.i < len) { c = this.content[this.i] if (!blankChar[c]) { if (this.checkClose()) return if (needVal) { // 等号后遇到第一个非空字符 this.start = this.i this.state = this.attrVal return } if (this.content[this.i] === '=') { needVal = true } else { this.start = this.i this.state = this.attrName return } } } } else if (!this.checkClose('onAttrName')) { this.i++ } } /** * @description 属性值状态 * @private */ Lexer.prototype.attrVal = function () { const c = this.content[this.i] const len = this.content.length if (c === '"' || c === "'") { // 有冒号的属性 this.start = ++this.i this.i = this.content.indexOf(c, this.i) if (this.i === -1) return this.handler.onAttrVal(this.content.substring(this.start, this.i)) } else { // 没有冒号的属性 for (; this.i < len; this.i++) { if (blankChar[this.content[this.i]]) { this.handler.onAttrVal(this.content.substring(this.start, this.i)) break } else if (this.checkClose('onAttrVal')) return } } while (blankChar[this.content[++this.i]]); if (this.i < len && !this.checkClose()) { this.start = this.i this.state = this.attrName } } /** * @description 结束标签状态 * @returns {String} 结束的标签名 * @private */ Lexer.prototype.endTag = function () { const c = this.content[this.i] if (blankChar[c] || c === '>' || c === '/') { this.handler.onCloseTag(this.content.substring(this.start, this.i)) if (c !== '>') { this.i = this.content.indexOf('>', this.i) if (this.i === -1) return } this.start = ++this.i this.state = this.text } else { this.i++ } } export default Parser
2301_77169380/AppruanjianApk
uni_modules/uv-parse/components/uv-parse/parser.js
JavaScript
unknown
40,032
<template> <view id="_root" :class="(selectable?'_select ':'')+'_root'" :style="containerStyle"> <slot v-if="!nodes[0]" /> <!-- #ifndef APP-PLUS-NVUE --> <node v-else :childs="nodes" :opts="[lazyLoad,loadingImg,errorImg,showImgMenu,selectable]" name="span" /> <!-- #endif --> <!-- #ifdef APP-PLUS-NVUE --> <web-view ref="web" src="/uni_modules/uv-parse/static/app-plus/uv-parse/local.html" :style="'margin-top:-2px;height:' + height + 'px'" @onPostMessage="_onMessage" /> <!-- #endif --> </view> </template> <script> /** * uv-parse v1.0.3 * @description 富文本组件 * @tutorial https://www.uvui.cn/components/parse.html * @property {String} container-style 容器的样式 * @property {String} content 用于渲染的 html 字符串 * @property {Boolean} copy-link 是否允许外部链接被点击时自动复制 * @property {String} domain 主域名,用于拼接链接 * @property {String} error-img 图片出错时的占位图链接 * @property {Boolean} lazy-load 是否开启图片懒加载 * @property {string} loading-img 图片加载过程中的占位图链接 * @property {Boolean} pause-video 是否在播放一个视频时自动暂停其他视频 * @property {Boolean} preview-img 是否允许图片被点击时自动预览 * @property {Boolean} scroll-table 是否给每个表格添加一个滚动层使其能单独横向滚动 * @property {Boolean | String} selectable 是否开启长按复制 * @property {Boolean} set-title 是否将 title 标签的内容设置到页面标题 * @property {Boolean} show-img-menu 是否允许图片被长按时显示菜单 * @property {Object} tag-style 标签的默认样式 * @property {Boolean | Number} use-anchor 是否使用锚点链接 * @event {Function} load dom 结构加载完毕时触发 * @event {Function} ready 所有图片加载完毕时触发 * @event {Function} imgtap 图片被点击时触发 * @event {Function} linktap 链接被点击时触发 * @event {Function} play 音视频播放时触发 * @event {Function} error 媒体加载出错时触发 */ // #ifndef APP-PLUS-NVUE import node from './node/node' // #endif import Parser from './parser' const plugins=[] // #ifdef APP-PLUS-NVUE const dom = weex.requireModule('dom') // #endif export default { name: 'uv-parse', data () { return { nodes: [], // #ifdef APP-PLUS-NVUE height: 3 // #endif } }, props: { containerStyle: { type: String, default: '' }, content: { type: String, default: '' }, copyLink: { type: [Boolean, String], default: true }, domain: String, errorImg: { type: String, default: '' }, lazyLoad: { type: [Boolean, String], default: false }, loadingImg: { type: String, default: '' }, pauseVideo: { type: [Boolean, String], default: true }, previewImg: { type: [Boolean, String], default: true }, scrollTable: [Boolean, String], selectable: [Boolean, String], setTitle: { type: [Boolean, String], default: true }, showImgMenu: { type: [Boolean, String], default: true }, tagStyle: Object, useAnchor: [Boolean, Number] }, // #ifdef VUE3 emits: ['load', 'ready', 'imgtap', 'linktap', 'play', 'error'], // #endif // #ifndef APP-PLUS-NVUE components: { node }, // #endif watch: { content (content) { this.setContent(content) } }, created () { this.plugins = [] for (let i = plugins.length; i--;) { this.plugins.push(new plugins[i](this)) } }, mounted () { if (this.content && !this.nodes.length) { this.setContent(this.content) } }, beforeDestroy () { this._hook('onDetached') }, methods: { /** * @description 将锚点跳转的范围限定在一个 scroll-view 内 * @param {Object} page scroll-view 所在页面的示例 * @param {String} selector scroll-view 的选择器 * @param {String} scrollTop scroll-view scroll-top 属性绑定的变量名 */ in (page, selector, scrollTop) { // #ifndef APP-PLUS-NVUE if (page && selector && scrollTop) { this._in = { page, selector, scrollTop } } // #endif }, /** * @description 锚点跳转 * @param {String} id 要跳转的锚点 id * @param {Number} offset 跳转位置的偏移量 * @returns {Promise} */ navigateTo (id, offset) { return new Promise((resolve, reject) => { if (!this.useAnchor) { reject(Error('Anchor is disabled')) return } offset = offset || parseInt(this.useAnchor) || 0 // #ifdef APP-PLUS-NVUE if (!id) { dom.scrollToElement(this.$refs.web, { offset }) resolve() } else { this._navigateTo = { resolve, reject, offset } this.$refs.web.evalJs('uni.postMessage({data:{action:"getOffset",offset:(document.getElementById(' + id + ')||{}).offsetTop}})') } // #endif // #ifndef APP-PLUS-NVUE let deep = ' ' // #ifdef MP-WEIXIN || MP-QQ || MP-TOUTIAO deep = '>>>' // #endif const selector = uni.createSelectorQuery() // #ifndef MP-ALIPAY .in(this._in ? this._in.page : this) // #endif .select((this._in ? this._in.selector : '._root') + (id ? `${deep}#${id}` : '')).boundingClientRect() if (this._in) { selector.select(this._in.selector).scrollOffset() .select(this._in.selector).boundingClientRect() } else { // 获取 scroll-view 的位置和滚动距离 selector.selectViewport().scrollOffset() // 获取窗口的滚动距离 } selector.exec(res => { if (!res[0]) { reject(Error('Label not found')) return } const scrollTop = res[1].scrollTop + res[0].top - (res[2] ? res[2].top : 0) + offset if (this._in) { // scroll-view 跳转 this._in.page[this._in.scrollTop] = scrollTop } else { // 页面跳转 uni.pageScrollTo({ scrollTop, duration: 300 }) } resolve() }) // #endif }) }, /** * @description 获取文本内容 * @return {String} */ getText (nodes) { let text = ''; (function traversal (nodes) { for (let i = 0; i < nodes.length; i++) { const node = nodes[i] if (node.type === 'text') { text += node.text.replace(/&amp;/g, '&') } else if (node.name === 'br') { text += '\n' } else { // 块级标签前后加换行 const isBlock = node.name === 'p' || node.name === 'div' || node.name === 'tr' || node.name === 'li' || (node.name[0] === 'h' && node.name[1] > '0' && node.name[1] < '7') if (isBlock && text && text[text.length - 1] !== '\n') { text += '\n' } // 递归获取子节点的文本 if (node.children) { traversal(node.children) } if (isBlock && text[text.length - 1] !== '\n') { text += '\n' } else if (node.name === 'td' || node.name === 'th') { text += '\t' } } } })(nodes || this.nodes) return text }, /** * @description 获取内容大小和位置 * @return {Promise} */ getRect () { return new Promise((resolve, reject) => { uni.createSelectorQuery() // #ifndef MP-ALIPAY .in(this) // #endif .select('#_root').boundingClientRect().exec(res => res[0] ? resolve(res[0]) : reject(Error('Root label not found'))) }) }, /** * @description 暂停播放媒体 */ pauseMedia () { for (let i = (this._videos || []).length; i--;) { this._videos[i].pause() } // #ifdef APP-PLUS const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].pause()' // #ifndef APP-PLUS-NVUE let page = this.$parent while (!page.$scope) page = page.$parent page.$scope.$getAppWebview().evalJS(command) // #endif // #ifdef APP-PLUS-NVUE this.$refs.web.evalJs(command) // #endif // #endif }, /** * @description 设置媒体播放速率 * @param {Number} rate 播放速率 */ setPlaybackRate (rate) { this.playbackRate = rate for (let i = (this._videos || []).length; i--;) { this._videos[i].playbackRate(rate) } // #ifdef APP-PLUS const command = 'for(var e=document.getElementsByTagName("video"),i=e.length;i--;)e[i].playbackRate=' + rate // #ifndef APP-PLUS-NVUE let page = this.$parent while (!page.$scope) page = page.$parent page.$scope.$getAppWebview().evalJS(command) // #endif // #ifdef APP-PLUS-NVUE this.$refs.web.evalJs(command) // #endif // #endif }, /** * @description 设置内容 * @param {String} content html 内容 * @param {Boolean} append 是否在尾部追加 */ setContent (content, append) { if (!append || !this.imgList) { this.imgList = [] } const nodes = new Parser(this).parse(content) // #ifdef APP-PLUS-NVUE if (this._ready) { this._set(nodes, append) } // #endif this.$set(this, 'nodes', append ? (this.nodes || []).concat(nodes) : nodes) // #ifndef APP-PLUS-NVUE this._videos = [] this.$nextTick(() => { this._hook('onLoad') this.$emit('load') }) if (this.lazyLoad || this.imgList._unloadimgs < this.imgList.length / 2) { // 设置懒加载,每 350ms 获取高度,不变则认为加载完毕 let height = 0 const callback = rect => { if (!rect || !rect.height) rect = {} // 350ms 总高度无变化就触发 ready 事件 if (rect.height === height) { this.$emit('ready', rect) } else { height = rect.height setTimeout(() => { this.getRect().then(callback).catch(callback) }, 350) } } this.getRect().then(callback).catch(callback) } else { // 未设置懒加载,等待所有图片加载完毕 if (!this.imgList._unloadimgs) { this.getRect().then(rect => { this.$emit('ready', rect) }).catch(() => { this.$emit('ready', {}) }) } } // #endif }, /** * @description 调用插件钩子函数 */ _hook (name) { for (let i = plugins.length; i--;) { if (this.plugins[i][name]) { this.plugins[i][name]() } } }, // #ifdef APP-PLUS-NVUE /** * @description 设置内容 */ _set (nodes, append) { this.$refs.web.evalJs('setContent(' + JSON.stringify(nodes).replace(/%22/g, '') + ',' + JSON.stringify([this.containerStyle.replace(/(?:margin|padding)[^;]+/g, ''), this.errorImg, this.loadingImg, this.pauseVideo, this.scrollTable, this.selectable]) + ',' + append + ')') }, /** * @description 接收到 web-view 消息 */ _onMessage (e) { const message = e.detail.data[0] switch (message.action) { // web-view 初始化完毕 case 'onJSBridgeReady': this._ready = true if (this.nodes) { this._set(this.nodes) } break // 内容 dom 加载完毕 case 'onLoad': this.height = message.height this._hook('onLoad') this.$emit('load') break // 所有图片加载完毕 case 'onReady': this.getRect().then(res => { this.$emit('ready', res) }).catch(() => { this.$emit('ready', {}) }) break // 总高度发生变化 case 'onHeightChange': this.height = message.height break // 图片点击 case 'onImgTap': this.$emit('imgtap', message.attrs) if (this.previewImg) { uni.previewImage({ current: parseInt(message.attrs.i), urls: this.imgList }) } break // 链接点击 case 'onLinkTap': { const href = message.attrs.href this.$emit('linktap', message.attrs) if (href) { // 锚点跳转 if (href[0] === '#') { if (this.useAnchor) { dom.scrollToElement(this.$refs.web, { offset: message.offset }) } } else if (href.includes('://')) { // 打开外链 if (this.copyLink) { plus.runtime.openWeb(href) } } else { uni.navigateTo({ url: href, fail () { uni.switchTab({ url: href }) } }) } } break } case 'onPlay': this.$emit('play') break // 获取到锚点的偏移量 case 'getOffset': if (typeof message.offset === 'number') { dom.scrollToElement(this.$refs.web, { offset: message.offset + this._navigateTo.offset }) this._navigateTo.resolve() } else { this._navigateTo.reject(Error('Label not found')) } break // 点击 case 'onClick': this.$emit('tap') this.$emit('click') break // 出错 case 'onError': this.$emit('error', { source: message.source, attrs: message.attrs }) } } // #endif } } </script> <style> /* #ifndef APP-PLUS-NVUE */ /* 根节点样式 */ ._root { padding: 1px 0; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; } /* 长按复制 */ ._select { user-select: text; } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-parse/components/uv-parse/uv-parse.vue
Vue
unknown
14,559
'use strict' // 等待初始化完毕 document.addEventListener('UniAppJSBridgeReady', () => { document.body.onclick = function () { return uni.postMessage({ data: { action: 'onClick' } }) } uni.postMessage({ data: { action: 'onJSBridgeReady' } }) }) let options let medias = [] /** * @description 获取标签的所有属性 * @param {Element} ele */ function getAttrs(ele) { const attrs = Object.create(null) for (let i = ele.attributes.length; i--;) { attrs[ele.attributes[i].name] = ele.attributes[i].value } return attrs } /** * @description 图片加载出错 */ function onImgError() { if (options[1]) { this.src = options[1] this.onerror = null } // 取消监听点击 this.onclick = null this.ontouchstart = null uni.postMessage({ data: { action: 'onError', source: 'img', attrs: getAttrs(this) } }) } /** * @description 创建 dom 结构 * @param {object[]} nodes 节点数组 * @param {Element} parent 父节点 * @param {string} namespace 命名空间 */ function createDom(nodes, parent, namespace) { const _loop = function _loop(i) { const node = nodes[i] let ele = void 0 if (!node.type || node.type == 'node') { let { name } = node // svg 需要设置 namespace if (name == 'svg') namespace = 'http://www.w3.org/2000/svg' if (name == 'html' || name == 'body') name = 'div' // 创建标签 if (!namespace) ele = document.createElement(name); else ele = document.createElementNS(namespace, name) // 设置属性 for (const item in node.attrs) { ele.setAttribute(item, node.attrs[item]) } // 递归创建子节点 if (node.children) createDom(node.children, ele, namespace) // 处理图片 if (name == 'img') { if (!ele.src && ele.getAttribute('data-src')) ele.src = ele.getAttribute('data-src') if (!node.attrs.ignore) { // 监听图片点击事件 ele.onclick = function (e) { e.stopPropagation() uni.postMessage({ data: { action: 'onImgTap', attrs: getAttrs(this) } }) } } if (options[2]) { image = new Image() image.src = ele.src ele.src = options[2] image.onload = function () { ele.src = this.src } image.onerror = function () { ele.onerror() } } ele.onerror = onImgError } // 处理链接 else if (name == 'a') { ele.addEventListener('click', function (e) { e.stopPropagation() e.preventDefault() // 阻止默认跳转 const href = this.getAttribute('href') let offset if (href && href[0] == '#') offset = (document.getElementById(href.substr(1)) || {}).offsetTop uni.postMessage({ data: { action: 'onLinkTap', attrs: getAttrs(this), offset } }) }, true) } // 处理音视频 else if (name == 'video' || name == 'audio') { medias.push(ele) if (!node.attrs.autoplay) { if (!node.attrs.controls) ele.setAttribute('controls', 'true') // 空白图占位 if (!node.attrs.poster) ele.setAttribute('poster', "data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg'/>") } if (options[3]) { ele.onplay = function () { for (let _i = 0; _i < medias.length; _i++) { if (medias[_i] != this) medias[_i].pause() } } } ele.onerror = function () { uni.postMessage({ data: { action: 'onError', source: name, attrs: getAttrs(this) } }) } } // 处理表格 else if (name == 'table' && options[4] && !ele.style.cssText.includes('inline')) { const div = document.createElement('div') div.style.overflow = 'auto' div.appendChild(ele) ele = div } else if (name == 'svg') namespace = void 0 } else ele = document.createTextNode(node.text.replace(/&amp;/g, '&')) parent.appendChild(ele) } for (let i = 0; i < nodes.length; i++) { var image _loop(i) } } // 设置 html 内容 window.setContent = function (nodes, opts, append) { const ele = document.getElementById('content') // 背景颜色 if (opts[0]) document.body.bgColor = opts[0] // 长按复制 if (!opts[5]) ele.style.userSelect = 'none' if (!append) { ele.innerHTML = '' // 不追加则先清空 medias = [] } options = opts const fragment = document.createDocumentFragment() createDom(nodes, fragment) ele.appendChild(fragment) // 触发事件 let height = ele.scrollHeight uni.postMessage({ data: { action: 'onLoad', height } }) clearInterval(window.timer) let ready = false window.timer = setInterval(() => { if (ele.scrollHeight != height) { height = ele.scrollHeight uni.postMessage({ data: { action: 'onHeightChange', height } }) } else if (!ready) { ready = true uni.postMessage({ data: { action: 'onReady' } }) } }, 350) } // 回收计时器 window.onunload = function () { clearInterval(window.timer) }
2301_77169380/AppruanjianApk
uni_modules/uv-parse/static/app-plus/uv-parse/js/handler.js
JavaScript
unknown
6,590
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"><style>body,html{width:100%;height:100%;overflow:hidden}body{margin:0}video{width:300px;height:225px}img{max-width:100%;-webkit-touch-callout:none}@keyframes show{0%{opacity:0}100%{opacity:1}}</style></head><body><div id="content"></div><script type="text/javascript" src="./js/uni.webview.min.js"></script><script type="text/javascript" src="./js/handler.js"></script></body>
2301_77169380/AppruanjianApk
uni_modules/uv-parse/static/app-plus/uv-parse/local.html
HTML
unknown
520
/** * hsb 转 rgb * @param {Object} hsb 颜色模式 H(hues)表示色相,S(saturation)表示饱和度,B(brightness)表示亮度 */ export function hsbToRgb(hsb) { let rgb = {}; let h = hsb.h; let s = hsb.s * 255 / 100; let v = hsb.b * 255 / 100; if (s == 0) { rgb.r = rgb.g = rgb.b = v; } else { let t1 = v; let t2 = ((255 - s) * v) / 255; let t3 = ((t1 - t2) * (h % 60)) / 60; if (h == 360) h = 0; if (h < 60) { rgb.r = t1; rgb.b = t2; rgb.g = t2 + t3; } else if (h < 120) { rgb.g = t1; rgb.b = t2; rgb.r = t1 - t3; } else if (h < 180) { rgb.g = t1; rgb.r = t2; rgb.b = t2 + t3; } else if (h < 240) { rgb.b = t1; rgb.r = t2; rgb.g = t1 - t3; } else if (h < 300) { rgb.b = t1; rgb.g = t2; rgb.r = t2 + t3; } else if (h < 360) { rgb.r = t1; rgb.g = t2; rgb.b = t1 - t3; } else { rgb.r = 0; rgb.g = 0; rgb.b = 0; } } return { r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b) }; } /** * rgb转hsb * @param {Object} rgb 颜色rgb值 */ export function rgbToHsb(rgb) { let hsb = { h: 0, s: 0, b: 0 }; let h = 0, s = 0, v = 0; let r = rgb.r, g = rgb.g, b = rgb.b; let min = Math.min(rgb.r, rgb.g, rgb.b); let max = Math.max(rgb.r, rgb.g, rgb.b); v = max / 255; if (max === 0) { s = 0; } else { s = 1 - (min / max); } if (max === min) { h = 0; //事实上,max===min的时候,h无论为多少都无所谓 } else if (max === r && g >= b) { h = 60 * ((g - b) / (max - min)) + 0; } else if (max === r && g < b) { h = 60 * ((g - b) / (max - min)) + 360 } else if (max === g) { h = 60 * ((b - r) / (max - min)) + 120 } else if (max === b) { h = 60 * ((r - g) / (max - min)) + 240 } hsb.h = parseInt(h); hsb.s = parseInt(s * 100); hsb.b = parseInt(v * 100); return hsb; } /** * rgb 转 二进制 hex * @param {Object} rgb */ export function rgbToHex(rgb) { let hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)]; hex.map(function(str, i) { if (str.length == 1) { hex[i] = '0' + str; } }); return hex.join(''); } //预制颜色 export const colorList = [{ r: 60, g: 156, b: 255, a: 1 }, { r: 245, g: 108, b: 108, a: 1 }, { r: 249, g: 174, b: 61, a: 1 }, { r: 90, g: 199, b: 37, a: 1 }, { r: 144, g: 147, b: 153, a: 1 }, { r: 48, g: 49, b: 51, a: 1 }, { r: 233, g: 30, b: 99, a: 1 }, { r: 156, g: 39, b: 176, a: 1 }, { r: 103, g: 58, b: 183, a: 1 }, { r: 63, g: 81, b: 181, a: 1 }, { r: 0, g: 188, b: 212, a: 1 }, { r: 0, g: 150, b: 136, a: 1 }, { r: 139, g: 195, b: 74, a: 1 }, { r: 205, g: 220, b: 57, a: 1 }, { r: 255, g: 235, b: 59, a: 1 }, { r: 255, g: 193, b: 7, a: 1 }, { r: 255, g: 152, b: 0, a: 1 }, { r: 255, g: 87, b: 34, a: 1 }, { r: 121, g: 85, b: 72, a: 1 }, { r: 158, g: 158, b: 158, a: 1 }, { r: 0, g: 0, b: 0, a: 0.5 }, { r: 0, g: 0, b: 0, a: 0 }]
2301_77169380/AppruanjianApk
uni_modules/uv-pick-color/components/uv-pick-color/colors.js
JavaScript
unknown
2,953
export default { props: { // 颜色选择器初始颜色 color: { type: Object, default: () => { return { r: 0, g: 0, b: 0, a: 0 } } }, // 预制颜色 prefabColor: { type: Array, default: () => [] }, // 是否允许点击遮罩关闭 closeOnClickOverlay: { type: Boolean, default: true }, // 顶部标题 title: { type: String, default: '' }, // 取消按钮的文字 cancelText: { type: String, default: '取消' }, // 确认按钮的文字 confirmText: { type: String, default: '确定' }, // 取消按钮的颜色 cancelColor: { type: String, default: '#909193' }, // 确认按钮的颜色 confirmColor: { type: String, default: '#3c9cff' }, ...uni.$uv?.props?.pickColor } }
2301_77169380/AppruanjianApk
uni_modules/uv-pick-color/components/uv-pick-color/props.js
JavaScript
unknown
785
<template> <!-- #ifndef APP-NVUE --> <uv-popup ref="pickerColorPopup" mode="bottom" :close-on-click-overlay="closeOnClickOverlay" @change="popupChange"> <view class="uv-pick-color"> <uv-toolbar :show="showToolbar" :cancelColor="cancelColor" :confirmColor="confirmColor" :cancelText="cancelText" :confirmText="confirmText" :title="title" :show-border="true" @cancel="cancelHandler" @confirm="confirmHandler"></uv-toolbar> <view class="uv-pick-color__box" :style="{ background:`rgb(${bgcolor.r},${bgcolor.g},${bgcolor.b})` }" > <!-- #ifdef H5 --> <view class="uv-pick-color__box__bg drag-box" @tap.stop.prevent="touchstart($event, 0)" @touchstart.stop.prevent="touchstart($event, 0)" @touchmove.stop.prevent="touchmove($event, 0)" @touchend.stop.prevent="touchend($event, 0)" > <!-- #endif --> <!-- #ifndef H5 --> <view class="uv-pick-color__box__bg drag-box" @touchstart.stop.prevent="touchstart($event, 0)" @touchmove.stop.prevent="touchmove($event, 0)" @touchend.stop.prevent="touchend($event, 0)" > <!-- #endif --> <view class="uv-pick-color__box__bg-mask"></view> <view class="uv-pick-color__box__bg-pointer" :style="[pointerStyle]" > </view> </view> </view> <view class="uv-pick-color__control"> <view class="uv-pick-color__control__alpha"> <view class="uv-pick-color__control__alpha--color" :style="{ background:`rgba(${rgba.r},${rgba.g},${rgba.b},${rgba.a})` }" ></view> </view> <view class="uv-pick-color__control__item"> <!-- #ifdef H5 --> <view class="uv-pick-color__control__item__drag drag-box" @tap.stop="touchstart($event, 1)" @touchstart.stop="touchstart($event, 1)" @touchmove.stop="touchmove($event, 1)" @touchend.stop="touchend($event, 1)" > <!-- #endif --> <!-- #ifndef H5 --> <view class="uv-pick-color__control__item__drag drag-box" @touchstart.stop="touchstart($event, 1)" @touchmove.stop="touchmove($event, 1)" @touchend.stop="touchend($event, 1)" > <!-- #endif --> <view class="uv-pick-color__control__item__drag--hue"></view> <view class="uv-pick-color__control__item__drag--circle" :style="{ left: $uv.getPx(site[1].left - 10,true) }" ></view> </view> <!-- #ifdef H5 --> <view class="uv-pick-color__control__item__drag drag-box" @tap.stop="touchstart($event, 2)" @touchstart.stop="touchstart($event, 2)" @touchmove.stop="touchmove($event, 2)" @touchend.stop="touchend($event, 2)" > <!-- #endif --> <!-- #ifndef H5 --> <view class="uv-pick-color__control__item__drag drag-box" @touchstart.stop="touchstart($event, 2)" @touchmove.stop="touchmove($event, 2)" @touchend.stop="touchend($event, 2)" > <!-- #endif --> <view class="uv-pick-color__control__item__drag--alpha"></view> <view class="uv-pick-color__control__item__drag--circle" :style="{ left: $uv.getPx(site[2].left - 10,true) }" ></view> </view> </view> </view> <view class="uv-pick-color__result"> <view class="uv-pick-color__result__select" hover-class="uv-hover-class" @click.stop="select" > <text class="text">切换</text> <text class="text">模式</text> </view> <view class="uv-pick-color__result__item" v-if="mode"> <view class="uv-pick-color__result__item--value uv-border"> <text>{{hex}}</text> </view> <view class="uv-pick-color__result__item--hex"> <text>HEX</text> </view> </view> <template v-else> <view class="uv-pick-color__result__item"> <view class="uv-pick-color__result__item--value uv-border"> <text>{{rgba.r}}</text> </view> <view class="uv-pick-color__result__item--rgba"> <text>R</text> </view> </view> <view class="uv-pick-color__result__gap"></view> <view class="uv-pick-color__result__item"> <view class="uv-pick-color__result__item--value uv-border"> <text>{{rgba.g}}</text> </view> <view class="uv-pick-color__result__item--rgba"> <text>G</text> </view> </view> <view class="uv-pick-color__result__gap"></view> <view class="uv-pick-color__result__item"> <view class="uv-pick-color__result__item--value uv-border"> <text>{{rgba.b}}</text> </view> <view class="uv-pick-color__result__item--rgba"> <text>B</text> </view> </view> <view class="uv-pick-color__result__gap"></view> <view class="uv-pick-color__result__item"> <view class="uv-pick-color__result__item--value uv-border"> <text>{{rgba.a}}</text> </view> <view class="uv-pick-color__result__item--rgba"> <text>A</text> </view> </view> </template> </view> <view class="uv-pick-color__prefab"> <view class="uv-pick-color__prefab__item" v-for="(item,index) in colorList" :key="index" > <view class="uv-pick-color__prefab__item--color" :style="{ background:`rgba(${item.r},${item.g},${item.b},${item.a})` }" @click.stop="setColorBySelect(item)" ></view> </view> </view> </view> </uv-popup> <!-- #endif --> <!-- #ifdef APP-NVUE --> <view> <text>nvue暂不支持uv-pick-color组件</text> </view> <!-- #endif --> </template> <script> import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js'; import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js'; import { rgbToHsb, hsbToRgb, rgbToHex, colorList } from './colors.js'; import props from './props.js'; export default { name: 'uv-pick-color', emits: ['confirm', 'cancel', 'close', 'change'], mixins: [mpMixin, mixin, props], computed: { pointerStyle() { const style = {}; style.top = this.$uv.addUnit(this.site[0].top - 8); style.left = this.$uv.addUnit(this.site[0].left - 8); return style; } }, data() { return { showToolbar: false, // rgba 颜色 rgba: { r: 0, g: 0, b: 0, a: 1 }, // hsb 颜色 hsb: { h: 0, s: 0, b: 0 }, site: [{ top: 0, left: 0 }, { left: 0 }, { left: 0 }], index: 0, bgcolor: { r: 255, g: 0, b: 0, a: 1 }, hex: '#000000', mode: true, colorList: colorList }; }, watch: { prefabColor(newVal) { this.colorList = newVal; } }, created() { // #ifdef APP-NVUE return this.$uv.error('nvue暂不支持uv-pick-color组件'); // #endif this.rgba = this.color; if (this.prefabColor.length) this.colorList = this.prefabColor; }, methods: { open() { this.$refs.pickerColorPopup.open(); this.showToolbar = true; this.$nextTick(async () => { await this.$uv.sleep(350); this.getSelectorQuery(); }) }, close() { this.$refs.pickerColorPopup.close(); }, popupChange(e) { if(!e.show) this.$emit('close'); }, // 点击工具栏的取消按钮 cancelHandler() { this.$emit('cancel'); this.close(); }, // 点击工具栏的确定按钮 confirmHandler() { this.$emit('confirm', { rgba: this.rgba, hex: this.hex }) this.close(); }, // 初始化 init() { // hsb 颜色 this.hsb = rgbToHsb(this.rgba); this.setValue(this.rgba); }, async getSelectorQuery() { const data = await this.$uvGetRect('.drag-box',true); this.position = data; this.setColorBySelect(this.rgba); }, // 选择模式 select() { this.mode = !this.mode; }, touchstart(e, index) { const { clientX, clientY } = e.touches[0]; this.pageX = clientX; this.pageY = clientY; this.setPosition(clientX, clientY, index); }, touchmove(e, index) { const { clientX, clientY } = e.touches[0]; this.moveX = clientX; this.moveY = clientY; this.setPosition(clientX, clientY, index); }, touchend(e, index) {}, /** * 设置位置 */ setPosition(x, y, index) { this.index = index; const { top, left, width, height } = this.position[index]; // 设置最大最小值 this.site[index].left = Math.max(0, Math.min(parseInt(x - left), width)); if (index === 0) { this.site[index].top = Math.max(0, Math.min(parseInt(y - top), height)); // 设置颜色 this.hsb.s = parseInt((100 * this.site[index].left) / width); this.hsb.b = parseInt(100 - (100 * this.site[index].top) / height); this.setColor(); this.setValue(this.rgba); } else { this.setControl(index, this.site[index].left); } }, /** * 设置 rgb 颜色 */ setColor() { const rgb = hsbToRgb(this.hsb); this.rgba.r = rgb.r; this.rgba.g = rgb.g; this.rgba.b = rgb.b; }, /** * 设置二进制颜色 * @param {Object} rgb */ setValue(rgb) { this.hex = `#${(rgbToHex(rgb))}`; }, setControl(index, x) { const { top, left, width, height } = this.position[index]; if (index === 1) { this.hsb.h = parseInt((360 * x) / width); this.bgcolor = hsbToRgb({ h: this.hsb.h, s: 100, b: 100 }); this.setColor() } else { this.rgba.a = +(x / width).toFixed(1); } this.setValue(this.rgba); }, setColorBySelect(getrgb) { const { r, g, b, a } = getrgb; let rgb = {}; rgb = { r: r ? parseInt(r) : 0, g: g ? parseInt(g) : 0, b: b ? parseInt(b) : 0, a: a ? a : 0 }; this.rgba = rgb; this.hsb = rgbToHsb(rgb); this.changeViewByHsb(); }, changeViewByHsb() { const [a, b, c] = this.position; this.site[0].left = parseInt(this.hsb.s * a.width / 100); this.site[0].top = parseInt((100 - this.hsb.b) * a.height / 100); this.setColor(this.hsb.h); this.setValue(this.rgba); this.bgcolor = hsbToRgb({ h: this.hsb.h, s: 100, b: 100 }); this.site[1].left = this.hsb.h / 360 * b.width; this.site[2].left = this.rgba.a * c.width; } } }; </script> <style scoped lang="scss"> $show-border: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; $height: 400rpx; /* #ifndef APP-NVUE */ .uv-pick-color { &__box { position: relative; height: $height; background: rgb(255, 0, 0); margin: 20rpx; &__bg { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0)); &-mask { position: absolute; top: 0; left: 0; right: 0; bottom: 0; height: $height; background: linear-gradient(to top, #000, rgba(0, 0, 0, 0)); } &-pointer { position: absolute; top: -8px; left: -8px; z-index: 2; width: 16px; height: 16px; border: 1px #fff solid; border-radius: 8px; } } } &__control { @include flex; padding: 10rpx 20rpx; &__alpha { width: 100rpx; height: 100rpx; border-radius: 50rpx; background-color: #fff; background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee),linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee); background-size: 36rpx 36rpx; background-position: 0 0, 18rpx 18rpx; border: 1px #eee solid; overflow: hidden; &--color { width: 100%; height: 100%; } } &__item { flex: 1; @include flex(column); justify-content: space-between; height: 100rpx; padding: 6rpx 0 6rpx 30rpx; } &__item__drag { position: relative; height: 16px; background-color: #fff; background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee), linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee); background-size: 32rpx 32rpx; background-position: 0 0, 16rpx 16rpx; &--hue { width: 100%; height: 100%; background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%); } &--alpha { width: 100%; height: 100%; background: linear-gradient(to right, rgba(0, 0, 0, 0) 0%, rgb(0, 0, 0)); } &--circle { position: absolute; top: -2px; width: 20px; height: 20px; box-sizing: border-box; border-radius: 10px; background: #fff; box-shadow: 0 0 2px 1px rgba(0, 0, 0, 0.1); } } } &__result { @include flex; padding: 20rpx; text-align: center; &__select { @include flex(column); justify-content: center; width: 100rpx; height: 100rpx; margin-right: 10px; border-radius: 10rpx; box-shadow: 1px 1px 2px 1px rgba(0, 0, 0, 0.1); font-size: 14px; color: #999; } &__item { flex: 1; height: 100rpx; &--value { height: 50rpx; line-height: 50rpx; border-radius: 4rpx; font-size: 28rpx; color: #999; } &--hex, &--rgba { height: 50rpx; line-height: 50rpx; font-size: 30rpx; } } &__gap { width: 10px; height: 10px; } } &__prefab { @include flex; margin: 0 -8rpx; padding: 0 20rpx 20rpx; flex-wrap: wrap; &__item { width: 50rpx; height: 50rpx; margin: 8rpx; border-radius: 6rpx; background-color: #fff; background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee), linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee); background-size: 36rpx 36rpx; background-position: 0 0, 18rpx 18rpx; border: 1px #eee solid; &--color { width: 100%; height: 100%; border-radius: 6rpx; } } } } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-pick-color/components/uv-pick-color/uv-pick-color.vue
Vue
unknown
14,089
export default { props: { // 是否展示顶部的操作栏 showToolbar: { type: Boolean, default: true }, // 顶部标题 title: { type: String, default: '' }, // 弹窗圆角 round: { type: [String, Number], default: 0 }, // 对象数组,设置每一列的数据 columns: { type: Array, default: () => [] }, // 是否显示加载中状态 loading: { type: Boolean, default: false }, // 各列中,单个选项的高度 itemHeight: { type: [String, Number], default: 44 }, // 取消按钮的文字 cancelText: { type: String, default: '取消' }, // 确认按钮的文字 confirmText: { type: String, default: '确定' }, // 取消按钮的颜色 cancelColor: { type: String, default: '#909193' }, // 确认按钮的颜色 confirmColor: { type: String, default: '#3c9cff' }, // 文字颜色 color: { type: String, default: '' }, // 选中文字的颜色 activeColor: { type: String, default: '' }, // 每列中可见选项的数量 visibleItemCount: { type: [String, Number], default: 5 }, // 选项对象中,需要展示的属性键名 keyName: { type: String, default: 'text' }, // 是否允许点击遮罩关闭选择器 closeOnClickOverlay: { type: Boolean, default: true }, // 是否允许点击确认关闭选择器 closeOnClickConfirm: { type: Boolean, default: true }, // 各列的默认索引 defaultIndex: { type: Array, default: () => [], }, // 是否在手指松开时立即触发 change 事件。若不开启则会在滚动动画结束后触发 change 事件,只在微信2.21.1及以上有效 immediateChange: { type: Boolean, default: true }, ...uni.$uv?.props?.picker } }
2301_77169380/AppruanjianApk
uni_modules/uv-picker/components/uv-picker/props.js
JavaScript
unknown
1,814
<template> <uv-popup ref="pickerPopup" mode="bottom" :round="round" :close-on-click-overlay="closeOnClickOverlay" @change="popupChange" > <view class="uv-picker"> <uv-toolbar v-if="showToolbar" :cancelColor="cancelColor" :confirmColor="confirmColor" :cancelText="cancelText" :confirmText="confirmText" :title="title" @cancel="cancel" @confirm="confirm" ></uv-toolbar> <!-- #ifdef MP-TOUTIAO --> <picker-view class="uv-picker__view" :indicatorStyle="`height: ${$uv.addUnit(itemHeight)}`" :value="innerIndex" :immediateChange="immediateChange" :style="{ height: `${$uv.addUnit(visibleItemCount * itemHeight)}` }" @pickend="changeHandler" > <!-- #endif --> <!-- #ifndef MP-TOUTIAO --> <picker-view class="uv-picker__view" :indicatorStyle="`height: ${$uv.addUnit(itemHeight)}`" :value="innerIndex" :immediateChange="immediateChange" :style="{ height: `${$uv.addUnit(visibleItemCount * itemHeight)}` }" @change="changeHandler" > <!-- #endif --> <!-- @pickend在这里为了解决抖音等滚到底不触发change兼容性问题 --> <picker-view-column v-for="(item, index) in innerColumns" :key="index" class="uv-picker__view__column" > <text v-if="$uv.test.array(item)" class="uv-picker__view__column__item uv-line-1" v-for="(item1, index1) in item" :key="index1" :style="[{ height: $uv.addUnit(itemHeight), lineHeight: $uv.addUnit(itemHeight), fontWeight: index1 === innerIndex[index] ? 'bold' : 'normal' },textStyle(index,index1)]" >{{ getItemText(item1) }}</text> </picker-view-column> </picker-view> <view v-if="loading" class="uv-picker--loading" > <uv-loading-icon mode="circle"></uv-loading-icon> </view> </view> </uv-popup> </template> <script> /** * uv-picker * @description 选择器 * @property {Boolean} showToolbar 是否显示顶部的操作栏(默认 true ) * @property {String} title 顶部标题 * @property {Array} columns 对象数组,设置每一列的数据 * @property {Boolean} loading 是否显示加载中状态(默认 false ) * @property {String | Number} itemHeight 各列中,单个选项的高度(默认 44 ) * @property {String} cancelText 取消按钮的文字(默认 '取消' ) * @property {String} confirmText 确认按钮的文字(默认 '确定' ) * @property {String} cancelColor 取消按钮的颜色(默认 '#909193' ) * @property {String} confirmColor 确认按钮的颜色(默认 '#3c9cff' ) * @property {String} color 文字颜色(默认 '' ) * @property {String} activeColor 选中文字的颜色(默认 '' ) * @property {String | Number} visibleItemCount 每列中可见选项的数量(默认 5 ) * @property {String} keyName 选项对象中,需要展示的属性键名(默认 'text' ) * @property {Boolean} closeOnClickOverlay 是否允许点击遮罩关闭选择器(默认 false ) * @property {Array} defaultIndex 各列的默认索引 * @property {Boolean} immediateChange 是否在手指松开时立即触发change事件(默认 false ) * @event {Function} close 关闭选择器时触发 * @event {Function} cancel 点击取消按钮触发 * @event {Function} change 当选择值变化时触发 * @event {Function} confirm 点击确定按钮,返回当前选择的值 */ import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' import props from './props.js'; export default { name: 'uv-picker', emits: ['confirm','cancel','close','change'], mixins: [mpMixin, mixin, props], computed: { // 为了解决支付宝不生效 textStyle(){ return (index,index1) => { const style = {}; // #ifndef APP-NVUE style.display = 'block'; // #endif if(this.color) { style.color = this.color; } if(this.activeColor && index1 === this.innerIndex[index]) { style.color = this.activeColor; } return style; } } }, data() { return { // 上一次选择的列索引 lastIndex: [], // 索引值 ,对应picker-view的value innerIndex: [], // 各列的值 innerColumns: [], // 上一次的变化列索引 columnIndex: 0, } }, watch: { // 监听默认索引的变化,重新设置对应的值 defaultIndex: { immediate: true, handler(n) { this.setIndexs(n, true) } }, // 监听columns参数的变化 columns: { deep: true, immediate: true, handler(n) { this.setColumns(n) } }, }, methods: { open() { this.$refs.pickerPopup.open(); }, close() { this.$refs.pickerPopup.close(); }, popupChange(e) { if(!e.show) this.$emit('close'); }, // 获取item需要显示的文字,判别为对象还是文本 getItemText(item) { if (this.$uv.test.object(item)) { return item[this.keyName] } else { return item } }, // 点击工具栏的取消按钮 cancel() { this.$emit('cancel'); this.close(); }, // 点击工具栏的确定按钮 confirm() { // 在这里使用deepClone拷贝后,vue3会自动转换成原始对象,这样处理是因为cli项目可能出现不返回值的情况 this.$emit('confirm', this.$uv.deepClone({ indexs: this.innerIndex, value: this.innerColumns.map((item, index) => item[this.innerIndex[index]]), values: this.innerColumns })); if(this.closeOnClickConfirm) { this.close(); } }, // 选择器某一列的数据发生变化时触发 changeHandler(e) { const { value } = e.detail let index = 0, columnIndex = 0 // 通过对比前后两次的列索引,得出当前变化的是哪一列 for (let i = 0; i < value.length; i++) { let item = value[i] if (item !== (this.lastIndex[i] || 0)) { // 把undefined转为合法假值0 // 设置columnIndex为当前变化列的索引 columnIndex = i // index则为变化列中的变化项的索引 index = item break // 终止循环,即使少一次循环,也是性能的提升 } } this.columnIndex = columnIndex const values = this.innerColumns // 将当前的各项变化索引,设置为"上一次"的索引变化值 this.setLastIndex(value) this.setIndexs(value) this.$emit('change', { value: this.innerColumns.map((item, index) => item[value[index]]), index, indexs: value, // values为当前变化列的数组内容 values, columnIndex }) }, // 设置index索引,此方法可被外部调用设置 setIndexs(index, setLastIndex) { this.innerIndex = this.$uv.deepClone(index) if (setLastIndex) { this.setLastIndex(index) } }, // 记录上一次的各列索引位置 setLastIndex(index) { // 当能进入此方法,意味着当前设置的各列默认索引,即为“上一次”的选中值,需要记录,是因为changeHandler中 // 需要拿前后的变化值进行对比,得出当前发生改变的是哪一列 this.lastIndex = this.$uv.deepClone(index) }, // 设置对应列选项的所有值 setColumnValues(columnIndex, values) { // 替换innerColumns数组中columnIndex索引的值为values,使用的是数组的splice方法 this.innerColumns.splice(columnIndex, 1, values) // 拷贝一份原有的innerIndex做临时变量,将大于当前变化列的所有的列的默认索引设置为0 let tmpIndex = this.$uv.deepClone(this.innerIndex) for (let i = 0; i < this.innerColumns.length; i++) { if (i > this.columnIndex) { tmpIndex[i] = 0 } } // 一次性赋值,不能单个修改,否则无效 this.setIndexs(tmpIndex) }, // 获取对应列的所有选项 getColumnValues(columnIndex) { // 进行同步阻塞,因为外部得到change事件之后,可能需要执行setColumnValues更新列的值 // 索引如果在外部change的回调中调用getColumnValues的话,可能无法得到变更后的列值,这里进行一定延时,保证值的准确性 (async () => { await this.$uv.sleep() })() return this.innerColumns[columnIndex] }, // 设置整体各列的columns的值 setColumns(columns) { this.innerColumns = this.$uv.deepClone(columns) // 如果在设置各列数据时,没有被设置默认的各列索引defaultIndex,那么用0去填充它,数组长度为列的数量 if (this.innerIndex.length === 0) { this.innerIndex = new Array(columns.length).fill(0) } }, // 获取各列选中值对应的索引 getIndexs() { return this.innerIndex }, // 获取各列选中的值 getValues() { // 进行同步阻塞,因为外部得到change事件之后,可能需要执行setColumnValues更新列的值 // 索引如果在外部change的回调中调用getValues的话,可能无法得到变更后的列值,这里进行一定延时,保证值的准确性 (async () => { await this.$uv.sleep() })() return this.innerColumns.map((item, index) => item[this.innerIndex[index]]) } }, } </script> <style lang="scss" scoped> $show-lines: 1; @import '@/uni_modules/uv-ui-tools/libs/css/variable.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @import '@/uni_modules/uv-ui-tools/libs/css/color.scss'; .uv-picker { position: relative; &__view { &__column { @include flex; flex: 1; justify-content: center; &__item { @include flex; justify-content: center; align-items: center; font-size: 16px; text-align: center; /* #ifndef APP-NVUE */ display: block; /* #endif */ color: $uv-main-color; &--disabled { /* #ifndef APP-NVUE */ cursor: not-allowed; /* #endif */ opacity: 0.35; } } } } &--loading { position: absolute; top: 0; right: 0; left: 0; bottom: 0; @include flex; justify-content: center; align-items: center; background-color: rgba(255, 255, 255, 0.87); z-index: 1000; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-picker/components/uv-picker/uv-picker.vue
Vue
unknown
10,172
// #ifdef H5 export default { name: 'Keypress', props: { disable: { type: Boolean, default: false } }, mounted () { const keyNames = { esc: ['Esc', 'Escape'], tab: 'Tab', enter: 'Enter', space: [' ', 'Spacebar'], up: ['Up', 'ArrowUp'], left: ['Left', 'ArrowLeft'], right: ['Right', 'ArrowRight'], down: ['Down', 'ArrowDown'], delete: ['Backspace', 'Delete', 'Del'] } const listener = ($event) => { if (this.disable) { return } const keyName = Object.keys(keyNames).find(key => { const keyName = $event.key const value = keyNames[key] return value === keyName || (Array.isArray(value) && value.includes(keyName)) }) if (keyName) { // 避免和其他按键事件冲突 setTimeout(() => { this.$emit(keyName, {}) }, 0) } } document.addEventListener('keyup', listener) // this.$once('hook:beforeDestroy', () => { // document.removeEventListener('keyup', listener) // }) }, render: () => {} } // #endif
2301_77169380/AppruanjianApk
uni_modules/uv-popup/components/uv-popup/keypress.js
JavaScript
unknown
1,119
<template> <view v-if="showPopup" class="uv-popup" :class="[popupClass, isDesktop ? 'fixforpc-z-index' : '']" :style="[{zIndex: zIndex}]" > <view @touchstart="touchstart"> <!-- 遮罩层 --> <uv-overlay key="1" v-if="maskShow && overlay" :show="showTrans" :duration="duration" :custom-style="overlayStyle" :opacity="overlayOpacity" :zIndex="zIndex" @click="onTap" ></uv-overlay> <uv-transition key="2" :mode="ani" name="content" :custom-style="transitionStyle" :duration="duration" :show="showTrans" @click="onTap" > <view class="uv-popup__content" :style="[contentStyle]" :class="[popupClass]" @click="clear" > <uv-status-bar v-if="safeAreaInsetTop"></uv-status-bar> <slot /> <uv-safe-bottom v-if="safeAreaInsetBottom"></uv-safe-bottom> <view v-if="closeable" @tap.stop="close" class="uv-popup__content__close" :class="['uv-popup__content__close--' + closeIconPos]" hover-class="uv-popup__content__close--hover" hover-stay-time="150" > <uv-icon name="close" color="#909399" size="18" bold ></uv-icon> </view> </view> </uv-transition> </view> <!-- #ifdef H5 --> <keypress v-if="maskShow" @esc="onTap" /> <!-- #endif --> </view> </template> <script> // #ifdef H5 import keypress from './keypress.js' // #endif import mpMixin from '@/uni_modules/uv-ui-tools/libs/mixin/mpMixin.js' import mixin from '@/uni_modules/uv-ui-tools/libs/mixin/mixin.js' /** * PopUp 弹出层 * @description 弹出层组件,为了解决遮罩弹层的问题 * @tutorial https://www.uvui.cn/components/popup.html * @property {String} mode = [top|center|bottom|left|right] 弹出方式 * @value top 顶部弹出 * @value center 中间弹出 * @value bottom 底部弹出 * @value left 左侧弹出 * @value right 右侧弹出 * @property {Number} duration 动画时长,默认300 * @property {Boolean} overlay 是否显示遮罩,默认true * @property {Boolean} overlayOpacity 遮罩透明度,默认0.5 * @property {Object} overlayStyle 遮罩自定义样式 * @property {Boolean} closeOnClickOverlay = [true|false] 蒙版点击是否关闭弹窗,默认true * @property {Number | String} zIndex 弹出层的层级 * @property {Boolean} safeAreaInsetTop 是否留出顶部安全区(状态栏高度),默认false * @property {Boolean} safeAreaInsetBottom 是否为留出底部安全区适配,默认true * @property {Boolean} closeable 是否显示关闭图标,默认false * @property {Boolean} closeIconPos 自定义关闭图标位置,`top-left`-左上角,`top-right`-右上角,`bottom-left`-左下角,`bottom-right`-右下角,默认top-right * @property {String} bgColor 主窗口背景色 * @property {String} maskBackgroundColor 蒙版颜色 * @property {Boolean} customStyle 自定义样式 * @event {Function} change 打开关闭弹窗触发,e={show: false} * @event {Function} maskClick 点击遮罩触发 */ export default { name: 'uv-popup', components: { // #ifdef H5 keypress // #endif }, mixins: [mpMixin, mixin], emits: ['change', 'maskClick'], props: { // 弹出层类型,可选值,top: 顶部弹出层;bottom:底部弹出层;center:全屏弹出层 // message: 消息提示 ; dialog : 对话框 mode: { type: String, default: 'center' }, // 动画时长,单位ms duration: { type: [String, Number], default: 300 }, // 层级 zIndex: { type: [String, Number], // #ifdef H5 default: 997 // #endif // #ifndef H5 default: 10075 // #endif }, bgColor: { type: String, default: '#ffffff' }, safeArea: { type: Boolean, default: true }, // 是否显示遮罩 overlay: { type: Boolean, default: true }, // 点击遮罩是否关闭弹窗 closeOnClickOverlay: { type: Boolean, default: true }, // 遮罩的透明度,0-1之间 overlayOpacity: { type: [Number, String], default: 0.4 }, // 自定义遮罩的样式 overlayStyle: { type: [Object, String], default: '' }, // 是否为iPhoneX留出底部安全距离 safeAreaInsetBottom: { type: Boolean, default: true }, // 是否留出顶部安全距离(状态栏高度) safeAreaInsetTop: { type: Boolean, default: false }, // 是否显示关闭图标 closeable: { type: Boolean, default: false }, // 自定义关闭图标位置,top-left为左上角,top-right为右上角,bottom-left为左下角,bottom-right为右下角 closeIconPos: { type: String, default: 'top-right' }, // mode=center,也即中部弹出时,是否使用缩放模式 zoom: { type: Boolean, default: true }, round: { type: [Number, String], default: 0 }, ...uni.$uv?.props?.popup }, watch: { /** * 监听type类型 */ type: { handler: function(type) { if (!this.config[type]) return this[this.config[type]](true) }, immediate: true }, isDesktop: { handler: function(newVal) { if (!this.config[newVal]) return this[this.config[this.mode]](true) }, immediate: true }, // H5 下禁止底部滚动 showPopup(show) { // #ifdef H5 // fix by mehaotian 处理 h5 滚动穿透的问题 document.getElementsByTagName('body')[0].style.overflow = show ? 'hidden' : 'visible' // #endif } }, data() { return { ani: [], showPopup: false, showTrans: false, popupWidth: 0, popupHeight: 0, config: { top: 'top', bottom: 'bottom', center: 'center', left: 'left', right: 'right', message: 'top', dialog: 'center', share: 'bottom' }, transitionStyle: { position: 'fixed', left: 0, right: 0 }, maskShow: true, mkclick: true, popupClass: this.isDesktop ? 'fixforpc-top' : 'top', direction: '' } }, computed: { isDesktop() { return this.popupWidth >= 500 && this.popupHeight >= 500 }, bg() { if (this.bgColor === '' || this.bgColor === 'none' || this.$uv.getPx(this.round)>0) { return 'transparent' } return this.bgColor }, contentStyle() { const style = {}; if (this.bgColor) { style.backgroundColor = this.bg } if(this.round) { const value = this.$uv.addUnit(this.round) const mode = this.direction?this.direction:this.mode style.backgroundColor = this.bgColor if(mode === 'top') { style.borderBottomLeftRadius = value style.borderBottomRightRadius = value } else if(mode === 'bottom') { style.borderTopLeftRadius = value style.borderTopRightRadius = value } else if(mode === 'center') { style.borderRadius = value } } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } }, // #ifndef VUE3 // TODO vue2 destroyed() { this.setH5Visible() }, // #endif // #ifdef VUE3 // TODO vue3 unmounted() { this.setH5Visible() }, // #endif created() { // TODO 处理 message 组件生命周期异常的问题 this.messageChild = null // TODO 解决头条冒泡的问题 this.clearPropagation = false }, methods: { setH5Visible() { // #ifdef H5 // fix by mehaotian 处理 h5 滚动穿透的问题 document.getElementsByTagName('body')[0].style.overflow = 'visible' // #endif }, /** * 公用方法,不显示遮罩层 */ closeMask() { this.maskShow = false }, // TODO nvue 取消冒泡 clear(e) { // #ifndef APP-NVUE e.stopPropagation() // #endif this.clearPropagation = true }, open(direction) { // fix by mehaotian 处理快速打开关闭的情况 if (this.showPopup) { return } let innerType = ['top', 'center', 'bottom', 'left', 'right', 'message', 'dialog', 'share'] if (!(direction && innerType.indexOf(direction) !== -1)) { direction = this.mode }else { this.direction = direction; } if (!this.config[direction]) { return this.$uv.error(`缺少类型:${direction}`); } this[this.config[direction]]() this.$emit('change', { show: true, type: direction }) }, close(type) { this.showTrans = false this.$emit('change', { show: false, type: this.mode }) clearTimeout(this.timer) // // 自定义关闭事件 this.timer = setTimeout(() => { this.showPopup = false }, 300) }, // TODO 处理冒泡事件,头条的冒泡事件有问题 ,先这样兼容 touchstart() { this.clearPropagation = false }, onTap() { if (this.clearPropagation) { // fix by mehaotian 兼容 nvue this.clearPropagation = false return } this.$emit('maskClick') if (!this.closeOnClickOverlay) return this.close() }, /** * 顶部弹出样式处理 */ top(type) { this.popupClass = this.isDesktop ? 'fixforpc-top' : 'top' this.ani = ['slide-top'] this.transitionStyle = { position: 'fixed', zIndex: this.zIndex, left: 0, right: 0, backgroundColor: this.bg } // TODO 兼容 type 属性 ,后续会废弃 if (type) return this.showPopup = true this.showTrans = true this.$nextTick(() => { if (this.messageChild && this.mode === 'message') { this.messageChild.timerClose() } }) }, /** * 底部弹出样式处理 */ bottom(type) { this.popupClass = 'bottom' this.ani = ['slide-bottom'] this.transitionStyle = { position: 'fixed', zIndex: this.zIndex, left: 0, right: 0, bottom: 0, backgroundColor: this.bg } // TODO 兼容 type 属性 ,后续会废弃 if (type) return this.showPopup = true this.showTrans = true }, /** * 中间弹出样式处理 */ center(type) { this.popupClass = 'center' this.ani = this.zoom?['zoom-in', 'fade']:['fade']; this.transitionStyle = { position: 'fixed', zIndex: this.zIndex, /* #ifndef APP-NVUE */ display: 'flex', flexDirection: 'column', /* #endif */ bottom: 0, left: 0, right: 0, top: 0, justifyContent: 'center', alignItems: 'center' } // TODO 兼容 type 属性 ,后续会废弃 if (type) return this.showPopup = true this.showTrans = true }, left(type) { this.popupClass = 'left' this.ani = ['slide-left'] this.transitionStyle = { position: 'fixed', zIndex: this.zIndex, left: 0, bottom: 0, top: 0, backgroundColor: this.bg, /* #ifndef APP-NVUE */ display: 'flex', flexDirection: 'column' /* #endif */ } // TODO 兼容 type 属性 ,后续会废弃 if (type) return this.showPopup = true this.showTrans = true }, right(type) { this.popupClass = 'right' this.ani = ['slide-right'] this.transitionStyle = { position: 'fixed', zIndex: this.zIndex, bottom: 0, right: 0, top: 0, backgroundColor: this.bg, /* #ifndef APP-NVUE */ display: 'flex', flexDirection: 'column' /* #endif */ } // TODO 兼容 type 属性 ,后续会废弃 if (type) return this.showPopup = true this.showTrans = true } } } </script> <style lang="scss" scoped> .uv-popup { position: fixed; /* #ifndef APP-NVUE */ z-index: 99; /* #endif */ &.top, &.left, &.right { /* #ifdef H5 */ top: var(--window-top); /* #endif */ /* #ifndef H5 */ top: 0; /* #endif */ } .uv-popup__content { /* #ifndef APP-NVUE */ display: block; overflow: hidden; /* #endif */ position: relative; &.left, &.right { /* #ifdef H5 */ padding-top: var(--window-top); /* #endif */ /* #ifndef H5 */ padding-top: 0; /* #endif */ flex: 1; } &__close { position: absolute; &--hover { opacity: 0.4; } } &__close--top-left { top: 15px; left: 15px; } &__close--top-right { top: 15px; right: 15px; } &__close--bottom-left { bottom: 15px; left: 15px; } &__close--bottom-right { right: 15px; bottom: 15px; } } } .fixforpc-z-index { /* #ifndef APP-NVUE */ z-index: 999; /* #endif */ } .fixforpc-top { top: 0; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-popup/components/uv-popup/uv-popup.vue
Vue
unknown
12,598
export const cacheImageList = [];
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/cache.js
JavaScript
unknown
33
const isWeex = typeof WXEnvironment !== 'undefined'; const isWeexIOS = isWeex && /ios/i.test(WXEnvironment.platform); const isWeexAndroid = isWeex && !isWeexIOS; import GLmethod from '../context-webgl/GLmethod'; const GCanvasModule = (typeof weex !== 'undefined' && weex.requireModule) ? (weex.requireModule('gcanvas')) : (typeof __weex_require__ !== 'undefined') ? (__weex_require__('@weex-module/gcanvas')) : {}; let isDebugging = false; let isComboDisabled = false; const logCommand = (function () { const methodQuery = []; Object.keys(GLmethod).forEach(key => { methodQuery[GLmethod[key]] = key; }) const queryMethod = (id) => { return methodQuery[parseInt(id)] || 'NotFoundMethod'; } const logCommand = (id, cmds) => { const mId = cmds.split(',')[0]; const mName = queryMethod(mId); console.log(`=== callNative - componentId:${id}; method: ${mName}; cmds: ${cmds}`); } return logCommand; })(); function joinArray(arr, sep) { let res = ''; for (let i = 0; i < arr.length; i++) { if (i !== 0) { res += sep; } res += arr[i]; } return res; } const commandsCache = {} const GBridge = { callEnable: (ref, configArray) => { commandsCache[ref] = []; return GCanvasModule.enable({ componentId: ref, config: configArray }); }, callEnableDebug: () => { isDebugging = true; }, callEnableDisableCombo: () => { isComboDisabled = true; }, callSetContextType: function (componentId, context_type) { GCanvasModule.setContextType(context_type, componentId); }, callReset: function(id){ GCanvasModule.resetComponent && canvasModule.resetComponent(componentId); }, render: isWeexIOS ? function (componentId) { return GCanvasModule.extendCallNative({ contextId: componentId, type: 0x60000001 }); } : function (componentId) { return callGCanvasLinkNative(componentId, 0x60000001, 'render'); }, render2d: isWeexIOS ? function (componentId, commands, callback) { if (isDebugging) { console.log('>>> >>> render2d ==='); console.log('>>> commands: ' + commands); } GCanvasModule.render([commands, callback?true:false], componentId, callback); } : function (componentId, commands,callback) { if (isDebugging) { console.log('>>> >>> render2d ==='); console.log('>>> commands: ' + commands); } callGCanvasLinkNative(componentId, 0x20000001, commands); if(callback){ callback(); } }, callExtendCallNative: isWeexIOS ? function (componentId, cmdArgs) { throw 'should not be here anymore ' + cmdArgs; } : function (componentId, cmdArgs) { throw 'should not be here anymore ' + cmdArgs; }, flushNative: isWeexIOS ? function (componentId) { const cmdArgs = joinArray(commandsCache[componentId], ';'); commandsCache[componentId] = []; if (isDebugging) { console.log('>>> >>> flush native ==='); console.log('>>> commands: ' + cmdArgs); } const result = GCanvasModule.extendCallNative({ "contextId": componentId, "type": 0x60000000, "args": cmdArgs }); const res = result && result.result; if (isDebugging) { console.log('>>> result: ' + res); } return res; } : function (componentId) { const cmdArgs = joinArray(commandsCache[componentId], ';'); commandsCache[componentId] = []; if (isDebugging) { console.log('>>> >>> flush native ==='); console.log('>>> commands: ' + cmdArgs); } const result = callGCanvasLinkNative(componentId, 0x60000000, cmdArgs); if (isDebugging) { console.log('>>> result: ' + result); } return result; }, callNative: function (componentId, cmdArgs, cache) { if (isDebugging) { logCommand(componentId, cmdArgs); } commandsCache[componentId].push(cmdArgs); if (!cache || isComboDisabled) { return GBridge.flushNative(componentId); } else { return undefined; } }, texImage2D(componentId, ...args) { if (isWeexIOS) { if (args.length === 6) { const [target, level, internalformat, format, type, image] = args; GBridge.callNative( componentId, GLmethod.texImage2D + ',' + 6 + ',' + target + ',' + level + ',' + internalformat + ',' + format + ',' + type + ',' + image.src ) } else if (args.length === 9) { const [target, level, internalformat, width, height, border, format, type, image] = args; GBridge.callNative( componentId, GLmethod.texImage2D + ',' + 9 + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' + + format + ',' + type + ',' + (image ? image.src : 0) ) } } else if (isWeexAndroid) { if (args.length === 6) { const [target, level, internalformat, format, type, image] = args; GCanvasModule.texImage2D(componentId, target, level, internalformat, format, type, image.src); } else if (args.length === 9) { const [target, level, internalformat, width, height, border, format, type, image] = args; GCanvasModule.texImage2D(componentId, target, level, internalformat, width, height, border, format, type, (image ? image.src : 0)); } } }, texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image) { if (isWeexIOS) { if (arguments.length === 8) { GBridge.callNative( componentId, GLmethod.texSubImage2D + ',' + 6 + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset, + ',' + format + ',' + type + ',' + image.src ) } } else if (isWeexAndroid) { GCanvasModule.texSubImage2D(componentId, target, level, xoffset, yoffset, format, type, image.src); } }, bindImageTexture(componentId, src, imageId) { GCanvasModule.bindImageTexture([src, imageId], componentId); }, perloadImage([url, id], callback) { GCanvasModule.preLoadImage([url, id], function (image) { image.url = url; image.id = id; callback(image); }); }, measureText(text, fontStyle, componentId) { return GCanvasModule.measureText([text, fontStyle], componentId); }, getImageData (componentId, x, y, w, h, callback) { GCanvasModule.getImageData([x, y,w,h],componentId,callback); }, putImageData (componentId, data, x, y, w, h, callback) { GCanvasModule.putImageData([x, y,w,h,data],componentId,callback); }, toTempFilePath(componentId, x, y, width, height, destWidth, destHeight, fileType, quality, callback){ GCanvasModule.toTempFilePath([x, y, width,height, destWidth, destHeight, fileType, quality], componentId, callback); } } export default GBridge;
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/bridge/bridge-weex.js
JavaScript
unknown
7,461
class FillStyleLinearGradient { constructor(x0, y0, x1, y1) { this._start_pos = { _x: x0, _y: y0 }; this._end_pos = { _x: x1, _y: y1 }; this._stop_count = 0; this._stops = [0, 0, 0, 0, 0]; } addColorStop = function (pos, color) { if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) { this._stops[this._stop_count] = { _pos: pos, _color: color }; this._stop_count++; } } } export default FillStyleLinearGradient;
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-2d/FillStyleLinearGradient.js
JavaScript
unknown
504
class FillStylePattern { constructor(img, pattern) { this._style = pattern; this._img = img; } } export default FillStylePattern;
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-2d/FillStylePattern.js
JavaScript
unknown
154
class FillStyleRadialGradient { constructor(x0, y0, r0, x1, y1, r1) { this._start_pos = { _x: x0, _y: y0, _r: r0 }; this._end_pos = { _x: x1, _y: y1, _r: r1 }; this._stop_count = 0; this._stops = [0, 0, 0, 0, 0]; } addColorStop(pos, color) { if (this._stop_count < 5 && 0.0 <= pos && pos <= 1.0) { this._stops[this._stop_count] = { _pos: pos, _color: color }; this._stop_count++; } } } export default FillStyleRadialGradient;
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-2d/FillStyleRadialGradient.js
JavaScript
unknown
515
import FillStylePattern from './FillStylePattern'; import FillStyleLinearGradient from './FillStyleLinearGradient'; import FillStyleRadialGradient from './FillStyleRadialGradient'; import GImage from '../env/image.js'; import { ArrayBufferToBase64, Base64ToUint8ClampedArray } from '../env/tool.js'; export default class CanvasRenderingContext2D { _drawCommands = ''; _globalAlpha = 1.0; _fillStyle = 'rgb(0,0,0)'; _strokeStyle = 'rgb(0,0,0)'; _lineWidth = 1; _lineCap = 'butt'; _lineJoin = 'miter'; _miterLimit = 10; _globalCompositeOperation = 'source-over'; _textAlign = 'start'; _textBaseline = 'alphabetic'; _font = '10px sans-serif'; _savedGlobalAlpha = []; timer = null; componentId = null; _notCommitDrawImageCache = []; _needRedrawImageCache = []; _redrawCommands = ''; _autoSaveContext = true; // _imageMap = new GHashMap(); // _textureMap = new GHashMap(); constructor() { this.className = 'CanvasRenderingContext2D'; //this.save() } setFillStyle(value) { this.fillStyle = value; } set fillStyle(value) { this._fillStyle = value; if (typeof(value) == 'string') { this._drawCommands = this._drawCommands.concat("F" + value + ";"); } else if (value instanceof FillStylePattern) { const image = value._img; if (!image.complete) { image.onload = () => { var index = this._needRedrawImageCache.indexOf(image); if (index > -1) { this._needRedrawImageCache.splice(index, 1); CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id); this._redrawflush(true); } } this._notCommitDrawImageCache.push(image); } else { CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id); } //CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id); this._drawCommands = this._drawCommands.concat("G" + image._id + "," + value._style + ";"); } else if (value instanceof FillStyleLinearGradient) { var command = "D" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," + value._stop_count; for (var i = 0; i < value._stop_count; ++i) { command += ("," + value._stops[i]._pos + "," + value._stops[i]._color); } this._drawCommands = this._drawCommands.concat(command + ";"); } else if (value instanceof FillStyleRadialGradient) { var command = "H" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._start_pos._r .toFixed(2) + "," + value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," + value._end_pos._r.toFixed(2) + "," + value._stop_count; for (var i = 0; i < value._stop_count; ++i) { command += ("," + value._stops[i]._pos + "," + value._stops[i]._color); } this._drawCommands = this._drawCommands.concat(command + ";"); } } get fillStyle() { return this._fillStyle; } get globalAlpha() { return this._globalAlpha; } setGlobalAlpha(value) { this.globalAlpha = value; } set globalAlpha(value) { this._globalAlpha = value; this._drawCommands = this._drawCommands.concat("a" + value.toFixed(2) + ";"); } get strokeStyle() { return this._strokeStyle; } setStrokeStyle(value) { this.strokeStyle = value; } set strokeStyle(value) { this._strokeStyle = value; if (typeof(value) == 'string') { this._drawCommands = this._drawCommands.concat("S" + value + ";"); } else if (value instanceof FillStylePattern) { CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id); this._drawCommands = this._drawCommands.concat("G" + image._id + "," + value._style + ";"); } else if (value instanceof FillStyleLinearGradient) { var command = "D" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._end_pos._x.toFixed(2) + "," + value._end_pos._y.toFixed(2) + "," + value._stop_count; for (var i = 0; i < value._stop_count; ++i) { command += ("," + value._stops[i]._pos + "," + value._stops[i]._color); } this._drawCommands = this._drawCommands.concat(command + ";"); } else if (value instanceof FillStyleRadialGradient) { var command = "H" + value._start_pos._x.toFixed(2) + "," + value._start_pos._y.toFixed(2) + "," + value._start_pos._r .toFixed(2) + "," + value._end_pos._x.toFixed(2) + "," + value._end_pos._y + ",".toFixed(2) + value._end_pos._r.toFixed(2) + "," + value._stop_count; for (var i = 0; i < value._stop_count; ++i) { command += ("," + value._stops[i]._pos + "," + value._stops[i]._color); } this._drawCommands = this._drawCommands.concat(command + ";"); } } get lineWidth() { return this._lineWidth; } setLineWidth(value) { this.lineWidth = value; } set lineWidth(value) { this._lineWidth = value; this._drawCommands = this._drawCommands.concat("W" + value + ";"); } get lineCap() { return this._lineCap; } setLineCap(value) { this.lineCap = value; } set lineCap(value) { this._lineCap = value; this._drawCommands = this._drawCommands.concat("C" + value + ";"); } get lineJoin() { return this._lineJoin; } setLineJoin(value) { this.lineJoin = value } set lineJoin(value) { this._lineJoin = value; this._drawCommands = this._drawCommands.concat("J" + value + ";"); } get miterLimit() { return this._miterLimit; } setMiterLimit(value) { this.miterLimit = value } set miterLimit(value) { this._miterLimit = value; this._drawCommands = this._drawCommands.concat("M" + value + ";"); } get globalCompositeOperation() { return this._globalCompositeOperation; } set globalCompositeOperation(value) { this._globalCompositeOperation = value; let mode = 0; switch (value) { case "source-over": mode = 0; break; case "source-atop": mode = 5; break; case "source-in": mode = 0; break; case "source-out": mode = 2; break; case "destination-over": mode = 4; break; case "destination-atop": mode = 4; break; case "destination-in": mode = 4; break; case "destination-out": mode = 3; break; case "lighter": mode = 1; break; case "copy": mode = 2; break; case "xor": mode = 6; break; default: mode = 0; } this._drawCommands = this._drawCommands.concat("B" + mode + ";"); } get textAlign() { return this._textAlign; } setTextAlign(value) { this.textAlign = value } set textAlign(value) { this._textAlign = value; let Align = 0; switch (value) { case "start": Align = 0; break; case "end": Align = 1; break; case "left": Align = 2; break; case "center": Align = 3; break; case "right": Align = 4; break; default: Align = 0; } this._drawCommands = this._drawCommands.concat("A" + Align + ";"); } get textBaseline() { return this._textBaseline; } setTextBaseline(value) { this.textBaseline = value } set textBaseline(value) { this._textBaseline = value; let baseline = 0; switch (value) { case "alphabetic": baseline = 0; break; case "middle": baseline = 1; break; case "top": baseline = 2; break; case "hanging": baseline = 3; break; case "bottom": baseline = 4; break; case "ideographic": baseline = 5; break; default: baseline = 0; break; } this._drawCommands = this._drawCommands.concat("E" + baseline + ";"); } get font() { return this._font; } setFontSize(size) { var str = this._font; var strs = str.trim().split(/\s+/); for (var i = 0; i < strs.length; i++) { var values = ["normal", "italic", "oblique", "normal", "small-caps", "normal", "bold", "bolder", "lighter", "100", "200", "300", "400", "500", "600", "700", "800", "900", "normal", "ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded" ]; if (-1 == values.indexOf(strs[i].trim())) { if (typeof size === 'string') { strs[i] = size; } else if (typeof size === 'number') { strs[i] = String(size) + 'px'; } break; } } this.font = strs.join(" "); } set font(value) { this._font = value; this._drawCommands = this._drawCommands.concat("j" + value + ";"); } setTransform(a, b, c, d, tx, ty) { this._drawCommands = this._drawCommands.concat("t" + (a === 1 ? "1" : a.toFixed(2)) + "," + (b === 0 ? "0" : b.toFixed(2)) + "," + (c === 0 ? "0" : c.toFixed(2)) + "," + (d === 1 ? "1" : d.toFixed(2)) + "," + tx.toFixed(2) + "," + ty.toFixed(2) + ";"); } transform(a, b, c, d, tx, ty) { this._drawCommands = this._drawCommands.concat("f" + (a === 1 ? "1" : a.toFixed(2)) + "," + (b === 0 ? "0" : b.toFixed(2)) + "," + (c === 0 ? "0" : c.toFixed(2)) + "," + (d === 1 ? "1" : d.toFixed(2)) + "," + tx + "," + ty + ";"); } resetTransform() { this._drawCommands = this._drawCommands.concat("m;"); } scale(a, d) { this._drawCommands = this._drawCommands.concat("k" + a.toFixed(2) + "," + d.toFixed(2) + ";"); } rotate(angle) { this._drawCommands = this._drawCommands .concat("r" + angle.toFixed(6) + ";"); } translate(tx, ty) { this._drawCommands = this._drawCommands.concat("l" + tx.toFixed(2) + "," + ty.toFixed(2) + ";"); } save() { this._savedGlobalAlpha.push(this._globalAlpha); this._drawCommands = this._drawCommands.concat("v;"); } restore() { this._drawCommands = this._drawCommands.concat("e;"); this._globalAlpha = this._savedGlobalAlpha.pop(); } createPattern(img, pattern) { if (typeof img === 'string') { var imgObj = new GImage(); imgObj.src = img; img = imgObj; } return new FillStylePattern(img, pattern); } createLinearGradient(x0, y0, x1, y1) { return new FillStyleLinearGradient(x0, y0, x1, y1); } createRadialGradient = function(x0, y0, r0, x1, y1, r1) { return new FillStyleRadialGradient(x0, y0, r0, x1, y1, r1); }; createCircularGradient = function(x0, y0, r0) { return new FillStyleRadialGradient(x0, y0, 0, x0, y0, r0); }; strokeRect(x, y, w, h) { this._drawCommands = this._drawCommands.concat("s" + x + "," + y + "," + w + "," + h + ";"); } clearRect(x, y, w, h) { this._drawCommands = this._drawCommands.concat("c" + x + "," + y + "," + w + "," + h + ";"); } clip() { this._drawCommands = this._drawCommands.concat("p;"); } resetClip() { this._drawCommands = this._drawCommands.concat("q;"); } closePath() { this._drawCommands = this._drawCommands.concat("o;"); } moveTo(x, y) { this._drawCommands = this._drawCommands.concat("g" + x.toFixed(2) + "," + y.toFixed(2) + ";"); } lineTo(x, y) { this._drawCommands = this._drawCommands.concat("i" + x.toFixed(2) + "," + y.toFixed(2) + ";"); } quadraticCurveTo = function(cpx, cpy, x, y) { this._drawCommands = this._drawCommands.concat("u" + cpx + "," + cpy + "," + x + "," + y + ";"); } bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y, ) { this._drawCommands = this._drawCommands.concat( "z" + cp1x.toFixed(2) + "," + cp1y.toFixed(2) + "," + cp2x.toFixed(2) + "," + cp2y.toFixed(2) + "," + x.toFixed(2) + "," + y.toFixed(2) + ";"); } arcTo(x1, y1, x2, y2, radius) { this._drawCommands = this._drawCommands.concat("h" + x1 + "," + y1 + "," + x2 + "," + y2 + "," + radius + ";"); } beginPath() { this._drawCommands = this._drawCommands.concat("b;"); } fillRect(x, y, w, h) { this._drawCommands = this._drawCommands.concat("n" + x + "," + y + "," + w + "," + h + ";"); } rect(x, y, w, h) { this._drawCommands = this._drawCommands.concat("w" + x + "," + y + "," + w + "," + h + ";"); } fill() { this._drawCommands = this._drawCommands.concat("L;"); } stroke(path) { this._drawCommands = this._drawCommands.concat("x;"); } arc(x, y, radius, startAngle, endAngle, anticlockwise) { let ianticlockwise = 0; if (anticlockwise) { ianticlockwise = 1; } this._drawCommands = this._drawCommands.concat( "y" + x.toFixed(2) + "," + y.toFixed(2) + "," + radius.toFixed(2) + "," + startAngle + "," + endAngle + "," + ianticlockwise + ";" ); } fillText(text, x, y) { let tmptext = text.replace(/!/g, "!!"); tmptext = tmptext.replace(/,/g, "!,"); tmptext = tmptext.replace(/;/g, "!;"); this._drawCommands = this._drawCommands.concat("T" + tmptext + "," + x + "," + y + ",0.0;"); } strokeText = function(text, x, y) { let tmptext = text.replace(/!/g, "!!"); tmptext = tmptext.replace(/,/g, "!,"); tmptext = tmptext.replace(/;/g, "!;"); this._drawCommands = this._drawCommands.concat("U" + tmptext + "," + x + "," + y + ",0.0;"); } measureText(text) { return CanvasRenderingContext2D.GBridge.measureText(text, this.font, this.componentId); } isPointInPath = function(x, y) { throw new Error('GCanvas not supported yet'); } drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) { if (typeof image === 'string') { var imgObj = new GImage(); imgObj.src = image; image = imgObj; } if (image instanceof GImage) { if (!image.complete) { imgObj.onload = () => { var index = this._needRedrawImageCache.indexOf(image); if (index > -1) { this._needRedrawImageCache.splice(index, 1); CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id); this._redrawflush(true); } } this._notCommitDrawImageCache.push(image); } else { CanvasRenderingContext2D.GBridge.bindImageTexture(this.componentId, image.src, image._id); } var srcArgs = [image, sx, sy, sw, sh, dx, dy, dw, dh]; var args = []; for (var arg in srcArgs) { if (typeof(srcArgs[arg]) != 'undefined') { args.push(srcArgs[arg]); } } this.__drawImage.apply(this, args); //this.__drawImage(image,sx, sy, sw, sh, dx, dy, dw, dh); } } __drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) { const numArgs = arguments.length; function drawImageCommands() { if (numArgs === 3) { const x = parseFloat(sx) || 0.0; const y = parseFloat(sy) || 0.0; return ("d" + image._id + ",0,0," + image.width + "," + image.height + "," + x + "," + y + "," + image.width + "," + image.height + ";"); } else if (numArgs === 5) { const x = parseFloat(sx) || 0.0; const y = parseFloat(sy) || 0.0; const width = parseInt(sw) || image.width; const height = parseInt(sh) || image.height; return ("d" + image._id + ",0,0," + image.width + "," + image.height + "," + x + "," + y + "," + width + "," + height + ";"); } else if (numArgs === 9) { sx = parseFloat(sx) || 0.0; sy = parseFloat(sy) || 0.0; sw = parseInt(sw) || image.width; sh = parseInt(sh) || image.height; dx = parseFloat(dx) || 0.0; dy = parseFloat(dy) || 0.0; dw = parseInt(dw) || image.width; dh = parseInt(dh) || image.height; return ("d" + image._id + "," + sx + "," + sy + "," + sw + "," + sh + "," + dx + "," + dy + "," + dw + "," + dh + ";"); } } this._drawCommands += drawImageCommands(); } _flush(reserve, callback) { const commands = this._drawCommands; this._drawCommands = ''; CanvasRenderingContext2D.GBridge.render2d(this.componentId, commands, callback); this._needRender = false; } _redrawflush(reserve, callback) { const commands = this._redrawCommands; CanvasRenderingContext2D.GBridge.render2d(this.componentId, commands, callback); if (this._needRedrawImageCache.length == 0) { this._redrawCommands = ''; } } draw(reserve, callback) { if (!reserve) { this._globalAlpha = this._savedGlobalAlpha.pop(); this._savedGlobalAlpha.push(this._globalAlpha); this._redrawCommands = this._drawCommands; this._needRedrawImageCache = this._notCommitDrawImageCache; if (this._autoSaveContext) { this._drawCommands = ("v;" + this._drawCommands); this._autoSaveContext = false; } else { this._drawCommands = ("e;X;v;" + this._drawCommands); } } else { this._needRedrawImageCache = this._needRedrawImageCache.concat(this._notCommitDrawImageCache); this._redrawCommands += this._drawCommands; if (this._autoSaveContext) { this._drawCommands = ("v;" + this._drawCommands); this._autoSaveContext = false; } } this._notCommitDrawImageCache = []; if (this._flush) { this._flush(reserve, callback); } } getImageData(x, y, w, h, callback) { CanvasRenderingContext2D.GBridge.getImageData(this.componentId, x, y, w, h, function(res) { res.data = Base64ToUint8ClampedArray(res.data); if (typeof(callback) == 'function') { callback(res); } }); } putImageData(data, x, y, w, h, callback) { if (data instanceof Uint8ClampedArray) { data = ArrayBufferToBase64(data); CanvasRenderingContext2D.GBridge.putImageData(this.componentId, data, x, y, w, h, function(res) { if (typeof(callback) == 'function') { callback(res); } }); } } toTempFilePath(x, y, width, height, destWidth, destHeight, fileType, quality, callback) { CanvasRenderingContext2D.GBridge.toTempFilePath(this.componentId, x, y, width, height, destWidth, destHeight, fileType, quality, function(res) { if (typeof(callback) == 'function') { callback(res); } }); } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-2d/RenderingContext.js
JavaScript
unknown
17,416
export default class WebGLActiveInfo { className = 'WebGLActiveInfo'; constructor({ type, name, size }) { this.type = type; this.name = name; this.size = size; } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/ActiveInfo.js
JavaScript
unknown
212
import {getTransferedObjectUUID} from './classUtils'; const name = 'WebGLBuffer'; function uuid(id) { return getTransferedObjectUUID(name, id); } export default class WebGLBuffer { className = name; constructor(id) { this.id = id; } static uuid = uuid; uuid() { return uuid(this.id); } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/Buffer.js
JavaScript
unknown
337