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
import {getTransferedObjectUUID} from './classUtils'; const name = 'WebGLFrameBuffer'; function uuid(id) { return getTransferedObjectUUID(name, id); } export default class WebGLFramebuffer { 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/Framebuffer.js
JavaScript
unknown
347
export default { "DEPTH_BUFFER_BIT": 256, "STENCIL_BUFFER_BIT": 1024, "COLOR_BUFFER_BIT": 16384, "POINTS": 0, "LINES": 1, "LINE_LOOP": 2, "LINE_STRIP": 3, "TRIANGLES": 4, "TRIANGLE_STRIP": 5, "TRIANGLE_FAN": 6, "ZERO": 0, "ONE": 1, "SRC_COLOR": 768, "ONE_MINUS_SRC_COLOR": 769, "SRC_ALPHA": 770, "ONE_MINUS_SRC_ALPHA": 771, "DST_ALPHA": 772, "ONE_MINUS_DST_ALPHA": 773, "DST_COLOR": 774, "ONE_MINUS_DST_COLOR": 775, "SRC_ALPHA_SATURATE": 776, "FUNC_ADD": 32774, "BLEND_EQUATION": 32777, "BLEND_EQUATION_RGB": 32777, "BLEND_EQUATION_ALPHA": 34877, "FUNC_SUBTRACT": 32778, "FUNC_REVERSE_SUBTRACT": 32779, "BLEND_DST_RGB": 32968, "BLEND_SRC_RGB": 32969, "BLEND_DST_ALPHA": 32970, "BLEND_SRC_ALPHA": 32971, "CONSTANT_COLOR": 32769, "ONE_MINUS_CONSTANT_COLOR": 32770, "CONSTANT_ALPHA": 32771, "ONE_MINUS_CONSTANT_ALPHA": 32772, "BLEND_COLOR": 32773, "ARRAY_BUFFER": 34962, "ELEMENT_ARRAY_BUFFER": 34963, "ARRAY_BUFFER_BINDING": 34964, "ELEMENT_ARRAY_BUFFER_BINDING": 34965, "STREAM_DRAW": 35040, "STATIC_DRAW": 35044, "DYNAMIC_DRAW": 35048, "BUFFER_SIZE": 34660, "BUFFER_USAGE": 34661, "CURRENT_VERTEX_ATTRIB": 34342, "FRONT": 1028, "BACK": 1029, "FRONT_AND_BACK": 1032, "TEXTURE_2D": 3553, "CULL_FACE": 2884, "BLEND": 3042, "DITHER": 3024, "STENCIL_TEST": 2960, "DEPTH_TEST": 2929, "SCISSOR_TEST": 3089, "POLYGON_OFFSET_FILL": 32823, "SAMPLE_ALPHA_TO_COVERAGE": 32926, "SAMPLE_COVERAGE": 32928, "NO_ERROR": 0, "INVALID_ENUM": 1280, "INVALID_VALUE": 1281, "INVALID_OPERATION": 1282, "OUT_OF_MEMORY": 1285, "CW": 2304, "CCW": 2305, "LINE_WIDTH": 2849, "ALIASED_POINT_SIZE_RANGE": 33901, "ALIASED_LINE_WIDTH_RANGE": 33902, "CULL_FACE_MODE": 2885, "FRONT_FACE": 2886, "DEPTH_RANGE": 2928, "DEPTH_WRITEMASK": 2930, "DEPTH_CLEAR_VALUE": 2931, "DEPTH_FUNC": 2932, "STENCIL_CLEAR_VALUE": 2961, "STENCIL_FUNC": 2962, "STENCIL_FAIL": 2964, "STENCIL_PASS_DEPTH_FAIL": 2965, "STENCIL_PASS_DEPTH_PASS": 2966, "STENCIL_REF": 2967, "STENCIL_VALUE_MASK": 2963, "STENCIL_WRITEMASK": 2968, "STENCIL_BACK_FUNC": 34816, "STENCIL_BACK_FAIL": 34817, "STENCIL_BACK_PASS_DEPTH_FAIL": 34818, "STENCIL_BACK_PASS_DEPTH_PASS": 34819, "STENCIL_BACK_REF": 36003, "STENCIL_BACK_VALUE_MASK": 36004, "STENCIL_BACK_WRITEMASK": 36005, "VIEWPORT": 2978, "SCISSOR_BOX": 3088, "COLOR_CLEAR_VALUE": 3106, "COLOR_WRITEMASK": 3107, "UNPACK_ALIGNMENT": 3317, "PACK_ALIGNMENT": 3333, "MAX_TEXTURE_SIZE": 3379, "MAX_VIEWPORT_DIMS": 3386, "SUBPIXEL_BITS": 3408, "RED_BITS": 3410, "GREEN_BITS": 3411, "BLUE_BITS": 3412, "ALPHA_BITS": 3413, "DEPTH_BITS": 3414, "STENCIL_BITS": 3415, "POLYGON_OFFSET_UNITS": 10752, "POLYGON_OFFSET_FACTOR": 32824, "TEXTURE_BINDING_2D": 32873, "SAMPLE_BUFFERS": 32936, "SAMPLES": 32937, "SAMPLE_COVERAGE_VALUE": 32938, "SAMPLE_COVERAGE_INVERT": 32939, "COMPRESSED_TEXTURE_FORMATS": 34467, "DONT_CARE": 4352, "FASTEST": 4353, "NICEST": 4354, "GENERATE_MIPMAP_HINT": 33170, "BYTE": 5120, "UNSIGNED_BYTE": 5121, "SHORT": 5122, "UNSIGNED_SHORT": 5123, "INT": 5124, "UNSIGNED_INT": 5125, "FLOAT": 5126, "DEPTH_COMPONENT": 6402, "ALPHA": 6406, "RGB": 6407, "RGBA": 6408, "LUMINANCE": 6409, "LUMINANCE_ALPHA": 6410, "UNSIGNED_SHORT_4_4_4_4": 32819, "UNSIGNED_SHORT_5_5_5_1": 32820, "UNSIGNED_SHORT_5_6_5": 33635, "FRAGMENT_SHADER": 35632, "VERTEX_SHADER": 35633, "MAX_VERTEX_ATTRIBS": 34921, "MAX_VERTEX_UNIFORM_VECTORS": 36347, "MAX_VARYING_VECTORS": 36348, "MAX_COMBINED_TEXTURE_IMAGE_UNITS": 35661, "MAX_VERTEX_TEXTURE_IMAGE_UNITS": 35660, "MAX_TEXTURE_IMAGE_UNITS": 34930, "MAX_FRAGMENT_UNIFORM_VECTORS": 36349, "SHADER_TYPE": 35663, "DELETE_STATUS": 35712, "LINK_STATUS": 35714, "VALIDATE_STATUS": 35715, "ATTACHED_SHADERS": 35717, "ACTIVE_UNIFORMS": 35718, "ACTIVE_ATTRIBUTES": 35721, "SHADING_LANGUAGE_VERSION": 35724, "CURRENT_PROGRAM": 35725, "NEVER": 512, "LESS": 513, "EQUAL": 514, "LEQUAL": 515, "GREATER": 516, "NOTEQUAL": 517, "GEQUAL": 518, "ALWAYS": 519, "KEEP": 7680, "REPLACE": 7681, "INCR": 7682, "DECR": 7683, "INVERT": 5386, "INCR_WRAP": 34055, "DECR_WRAP": 34056, "VENDOR": 7936, "RENDERER": 7937, "VERSION": 7938, "NEAREST": 9728, "LINEAR": 9729, "NEAREST_MIPMAP_NEAREST": 9984, "LINEAR_MIPMAP_NEAREST": 9985, "NEAREST_MIPMAP_LINEAR": 9986, "LINEAR_MIPMAP_LINEAR": 9987, "TEXTURE_MAG_FILTER": 10240, "TEXTURE_MIN_FILTER": 10241, "TEXTURE_WRAP_S": 10242, "TEXTURE_WRAP_T": 10243, "TEXTURE": 5890, "TEXTURE_CUBE_MAP": 34067, "TEXTURE_BINDING_CUBE_MAP": 34068, "TEXTURE_CUBE_MAP_POSITIVE_X": 34069, "TEXTURE_CUBE_MAP_NEGATIVE_X": 34070, "TEXTURE_CUBE_MAP_POSITIVE_Y": 34071, "TEXTURE_CUBE_MAP_NEGATIVE_Y": 34072, "TEXTURE_CUBE_MAP_POSITIVE_Z": 34073, "TEXTURE_CUBE_MAP_NEGATIVE_Z": 34074, "MAX_CUBE_MAP_TEXTURE_SIZE": 34076, "TEXTURE0": 33984, "TEXTURE1": 33985, "TEXTURE2": 33986, "TEXTURE3": 33987, "TEXTURE4": 33988, "TEXTURE5": 33989, "TEXTURE6": 33990, "TEXTURE7": 33991, "TEXTURE8": 33992, "TEXTURE9": 33993, "TEXTURE10": 33994, "TEXTURE11": 33995, "TEXTURE12": 33996, "TEXTURE13": 33997, "TEXTURE14": 33998, "TEXTURE15": 33999, "TEXTURE16": 34000, "TEXTURE17": 34001, "TEXTURE18": 34002, "TEXTURE19": 34003, "TEXTURE20": 34004, "TEXTURE21": 34005, "TEXTURE22": 34006, "TEXTURE23": 34007, "TEXTURE24": 34008, "TEXTURE25": 34009, "TEXTURE26": 34010, "TEXTURE27": 34011, "TEXTURE28": 34012, "TEXTURE29": 34013, "TEXTURE30": 34014, "TEXTURE31": 34015, "ACTIVE_TEXTURE": 34016, "REPEAT": 10497, "CLAMP_TO_EDGE": 33071, "MIRRORED_REPEAT": 33648, "FLOAT_VEC2": 35664, "FLOAT_VEC3": 35665, "FLOAT_VEC4": 35666, "INT_VEC2": 35667, "INT_VEC3": 35668, "INT_VEC4": 35669, "BOOL": 35670, "BOOL_VEC2": 35671, "BOOL_VEC3": 35672, "BOOL_VEC4": 35673, "FLOAT_MAT2": 35674, "FLOAT_MAT3": 35675, "FLOAT_MAT4": 35676, "SAMPLER_2D": 35678, "SAMPLER_CUBE": 35680, "VERTEX_ATTRIB_ARRAY_ENABLED": 34338, "VERTEX_ATTRIB_ARRAY_SIZE": 34339, "VERTEX_ATTRIB_ARRAY_STRIDE": 34340, "VERTEX_ATTRIB_ARRAY_TYPE": 34341, "VERTEX_ATTRIB_ARRAY_NORMALIZED": 34922, "VERTEX_ATTRIB_ARRAY_POINTER": 34373, "VERTEX_ATTRIB_ARRAY_BUFFER_BINDING": 34975, "IMPLEMENTATION_COLOR_READ_TYPE": 35738, "IMPLEMENTATION_COLOR_READ_FORMAT": 35739, "COMPILE_STATUS": 35713, "LOW_FLOAT": 36336, "MEDIUM_FLOAT": 36337, "HIGH_FLOAT": 36338, "LOW_INT": 36339, "MEDIUM_INT": 36340, "HIGH_INT": 36341, "FRAMEBUFFER": 36160, "RENDERBUFFER": 36161, "RGBA4": 32854, "RGB5_A1": 32855, "RGB565": 36194, "DEPTH_COMPONENT16": 33189, "STENCIL_INDEX8": 36168, "DEPTH_STENCIL": 34041, "RENDERBUFFER_WIDTH": 36162, "RENDERBUFFER_HEIGHT": 36163, "RENDERBUFFER_INTERNAL_FORMAT": 36164, "RENDERBUFFER_RED_SIZE": 36176, "RENDERBUFFER_GREEN_SIZE": 36177, "RENDERBUFFER_BLUE_SIZE": 36178, "RENDERBUFFER_ALPHA_SIZE": 36179, "RENDERBUFFER_DEPTH_SIZE": 36180, "RENDERBUFFER_STENCIL_SIZE": 36181, "FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE": 36048, "FRAMEBUFFER_ATTACHMENT_OBJECT_NAME": 36049, "FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL": 36050, "FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE": 36051, "COLOR_ATTACHMENT0": 36064, "DEPTH_ATTACHMENT": 36096, "STENCIL_ATTACHMENT": 36128, "DEPTH_STENCIL_ATTACHMENT": 33306, "NONE": 0, "FRAMEBUFFER_COMPLETE": 36053, "FRAMEBUFFER_INCOMPLETE_ATTACHMENT": 36054, "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT": 36055, "FRAMEBUFFER_INCOMPLETE_DIMENSIONS": 36057, "FRAMEBUFFER_UNSUPPORTED": 36061, "FRAMEBUFFER_BINDING": 36006, "RENDERBUFFER_BINDING": 36007, "MAX_RENDERBUFFER_SIZE": 34024, "INVALID_FRAMEBUFFER_OPERATION": 1286, "UNPACK_FLIP_Y_WEBGL": 37440, "UNPACK_PREMULTIPLY_ALPHA_WEBGL": 37441, "CONTEXT_LOST_WEBGL": 37442, "UNPACK_COLORSPACE_CONVERSION_WEBGL": 37443, "BROWSER_DEFAULT_WEBGL": 37444 };
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/GLenum.js
JavaScript
unknown
8,637
let i = 1; const GLmethod = {}; GLmethod.activeTexture = i++; //1 GLmethod.attachShader = i++; GLmethod.bindAttribLocation = i++; GLmethod.bindBuffer = i++; GLmethod.bindFramebuffer = i++; GLmethod.bindRenderbuffer = i++; GLmethod.bindTexture = i++; GLmethod.blendColor = i++; GLmethod.blendEquation = i++; GLmethod.blendEquationSeparate = i++; //10 GLmethod.blendFunc = i++; GLmethod.blendFuncSeparate = i++; GLmethod.bufferData = i++; GLmethod.bufferSubData = i++; GLmethod.checkFramebufferStatus = i++; GLmethod.clear = i++; GLmethod.clearColor = i++; GLmethod.clearDepth = i++; GLmethod.clearStencil = i++; GLmethod.colorMask = i++; //20 GLmethod.compileShader = i++; GLmethod.compressedTexImage2D = i++; GLmethod.compressedTexSubImage2D = i++; GLmethod.copyTexImage2D = i++; GLmethod.copyTexSubImage2D = i++; GLmethod.createBuffer = i++; GLmethod.createFramebuffer = i++; GLmethod.createProgram = i++; GLmethod.createRenderbuffer = i++; GLmethod.createShader = i++; //30 GLmethod.createTexture = i++; GLmethod.cullFace = i++; GLmethod.deleteBuffer = i++; GLmethod.deleteFramebuffer = i++; GLmethod.deleteProgram = i++; GLmethod.deleteRenderbuffer = i++; GLmethod.deleteShader = i++; GLmethod.deleteTexture = i++; GLmethod.depthFunc = i++; GLmethod.depthMask = i++; //40 GLmethod.depthRange = i++; GLmethod.detachShader = i++; GLmethod.disable = i++; GLmethod.disableVertexAttribArray = i++; GLmethod.drawArrays = i++; GLmethod.drawArraysInstancedANGLE = i++; GLmethod.drawElements = i++; GLmethod.drawElementsInstancedANGLE = i++; GLmethod.enable = i++; GLmethod.enableVertexAttribArray = i++; //50 GLmethod.flush = i++; GLmethod.framebufferRenderbuffer = i++; GLmethod.framebufferTexture2D = i++; GLmethod.frontFace = i++; GLmethod.generateMipmap = i++; GLmethod.getActiveAttrib = i++; GLmethod.getActiveUniform = i++; GLmethod.getAttachedShaders = i++; GLmethod.getAttribLocation = i++; GLmethod.getBufferParameter = i++; //60 GLmethod.getContextAttributes = i++; GLmethod.getError = i++; GLmethod.getExtension = i++; GLmethod.getFramebufferAttachmentParameter = i++; GLmethod.getParameter = i++; GLmethod.getProgramInfoLog = i++; GLmethod.getProgramParameter = i++; GLmethod.getRenderbufferParameter = i++; GLmethod.getShaderInfoLog = i++; GLmethod.getShaderParameter = i++; //70 GLmethod.getShaderPrecisionFormat = i++; GLmethod.getShaderSource = i++; GLmethod.getSupportedExtensions = i++; GLmethod.getTexParameter = i++; GLmethod.getUniform = i++; GLmethod.getUniformLocation = i++; GLmethod.getVertexAttrib = i++; GLmethod.getVertexAttribOffset = i++; GLmethod.isBuffer = i++; GLmethod.isContextLost = i++; //80 GLmethod.isEnabled = i++; GLmethod.isFramebuffer = i++; GLmethod.isProgram = i++; GLmethod.isRenderbuffer = i++; GLmethod.isShader = i++; GLmethod.isTexture = i++; GLmethod.lineWidth = i++; GLmethod.linkProgram = i++; GLmethod.pixelStorei = i++; GLmethod.polygonOffset = i++; //90 GLmethod.readPixels = i++; GLmethod.renderbufferStorage = i++; GLmethod.sampleCoverage = i++; GLmethod.scissor = i++; GLmethod.shaderSource = i++; GLmethod.stencilFunc = i++; GLmethod.stencilFuncSeparate = i++; GLmethod.stencilMask = i++; GLmethod.stencilMaskSeparate = i++; GLmethod.stencilOp = i++; //100 GLmethod.stencilOpSeparate = i++; GLmethod.texImage2D = i++; GLmethod.texParameterf = i++; GLmethod.texParameteri = i++; GLmethod.texSubImage2D = i++; GLmethod.uniform1f = i++; GLmethod.uniform1fv = i++; GLmethod.uniform1i = i++; GLmethod.uniform1iv = i++; GLmethod.uniform2f = i++; //110 GLmethod.uniform2fv = i++; GLmethod.uniform2i = i++; GLmethod.uniform2iv = i++; GLmethod.uniform3f = i++; GLmethod.uniform3fv = i++; GLmethod.uniform3i = i++; GLmethod.uniform3iv = i++; GLmethod.uniform4f = i++; GLmethod.uniform4fv = i++; GLmethod.uniform4i = i++; //120 GLmethod.uniform4iv = i++; GLmethod.uniformMatrix2fv = i++; GLmethod.uniformMatrix3fv = i++; GLmethod.uniformMatrix4fv = i++; GLmethod.useProgram = i++; GLmethod.validateProgram = i++; GLmethod.vertexAttrib1f = i++; //new GLmethod.vertexAttrib2f = i++; //new GLmethod.vertexAttrib3f = i++; //new GLmethod.vertexAttrib4f = i++; //new //130 GLmethod.vertexAttrib1fv = i++; //new GLmethod.vertexAttrib2fv = i++; //new GLmethod.vertexAttrib3fv = i++; //new GLmethod.vertexAttrib4fv = i++; //new GLmethod.vertexAttribPointer = i++; GLmethod.viewport = i++; export default GLmethod;
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/GLmethod.js
JavaScript
unknown
4,497
const GLtype = {}; [ "GLbitfield", "GLboolean", "GLbyte", "GLclampf", "GLenum", "GLfloat", "GLint", "GLintptr", "GLsizei", "GLsizeiptr", "GLshort", "GLubyte", "GLuint", "GLushort" ].sort().map((typeName, i) => GLtype[typeName] = 1 >> (i + 1)); export default GLtype;
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/GLtype.js
JavaScript
unknown
332
import {getTransferedObjectUUID} from './classUtils'; const name = 'WebGLProgram'; function uuid(id) { return getTransferedObjectUUID(name, id); } export default class WebGLProgram { 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/Program.js
JavaScript
unknown
339
import {getTransferedObjectUUID} from './classUtils'; const name = 'WebGLRenderBuffer'; function uuid(id) { return getTransferedObjectUUID(name, id); } export default class WebGLRenderbuffer { 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/Renderbuffer.js
JavaScript
unknown
349
import GLenum from './GLenum'; import ActiveInfo from './ActiveInfo'; import Buffer from './Buffer'; import Framebuffer from './Framebuffer'; import Renderbuffer from './Renderbuffer'; import Texture from './Texture'; import Program from './Program'; import Shader from './Shader'; import ShaderPrecisionFormat from './ShaderPrecisionFormat'; import UniformLocation from './UniformLocation'; import GLmethod from './GLmethod'; const processArray = (array, checkArrayType = false) => { function joinArray(arr, sep) { let res = ''; for (let i = 0; i < arr.length; i++) { if (i !== 0) { res += sep; } res += arr[i]; } return res; } let type = 'Float32Array'; if (checkArrayType) { if (array instanceof Uint8Array) { type = 'Uint8Array' } else if (array instanceof Uint16Array) { type = 'Uint16Array'; } else if (array instanceof Uint32Array) { type = 'Uint32Array'; } else if (array instanceof Float32Array) { type = 'Float32Array'; } else { throw new Error('Check array type failed. Array type is ' + typeof array); } } const ArrayTypes = { Uint8Array: 1, Uint16Array: 2, Uint32Array: 4, Float32Array: 14 }; return ArrayTypes[type] + ',' + btoa(joinArray(array, ',')) } export default class WebGLRenderingContext { // static GBridge = null; className = 'WebGLRenderingContext'; constructor(canvas, type, attrs) { this._canvas = canvas; this._type = type; this._version = 'WebGL 1.0'; this._attrs = attrs; this._map = new Map(); Object.keys(GLenum) .forEach(name => Object.defineProperty(this, name, { value: GLenum[name] })); } get canvas() { return this._canvas; } activeTexture = function (textureUnit) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.activeTexture + ',' + textureUnit, true ); } attachShader = function (progarm, shader) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.attachShader + ',' + progarm.id + ',' + shader.id, true ); } bindAttribLocation = function (program, index, name) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.bindAttribLocation + ',' + program.id + ',' + index + ',' + name, true ) } bindBuffer = function (target, buffer) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.bindBuffer + ',' + target + ',' + (buffer ? buffer.id : 0), true ); } bindFramebuffer = function (target, framebuffer) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.bindFramebuffer + ',' + target + ',' + (framebuffer ? framebuffer.id : 0), true ) } bindRenderbuffer = function (target, renderBuffer) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.bindRenderbuffer + ',' + target + ',' + (renderBuffer ? renderBuffer.id : 0), true ) } bindTexture = function (target, texture) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.bindTexture + ',' + target + ',' + (texture ? texture.id : 0), true ) } blendColor = function (r, g, b, a) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.blendColor + ',' + target + ',' + r + ',' + g + ',' + b + ',' + a, true ) } blendEquation = function (mode) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.blendEquation + ',' + mode, true ) } blendEquationSeparate = function (modeRGB, modeAlpha) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.blendEquationSeparate + ',' + modeRGB + ',' + modeAlpha, true ) } blendFunc = function (sfactor, dfactor) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.blendFunc + ',' + sfactor + ',' + dfactor, true ); } blendFuncSeparate = function (srcRGB, dstRGB, srcAlpha, dstAlpha) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.blendFuncSeparate + ',' + srcRGB + ',' + dstRGB + ',' + srcAlpha + ',' + dstAlpha, true ); } bufferData = function (target, data, usage) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.bufferData + ',' + target + ',' + processArray(data, true) + ',' + usage, true ) } bufferSubData = function (target, offset, data) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.bufferSubData + ',' + target + ',' + offset + ',' + processArray(data, true), true ) } checkFramebufferStatus = function (target) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.checkFramebufferStatus + ',' + target ); return Number(result); } clear = function (mask) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.clear + ',' + mask ); this._canvas._needRender = true; } clearColor = function (r, g, b, a) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.clearColor + ',' + r + ',' + g + ',' + b, true ) } clearDepth = function (depth) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.clearDepth + ',' + depth, true ) } clearStencil = function (s) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.clearStencil + ',' + s ); } colorMask = function (r, g, b, a) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.colorMask + ',' + r + ',' + g + ',' + b + ',' + a ) } compileShader = function (shader) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.compileShader + ',' + shader.id, true ) } compressedTexImage2D = function (target, level, internalformat, width, height, border, pixels) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.compressedTexImage2D + ',' + target + ',' + level + ',' + internalformat + ',' + width + ',' + height + ',' + border + ',' + processArray(pixels), true ) } compressedTexSubImage2D = function (target, level, xoffset, yoffset, width, height, format, pixels) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.compressedTexSubImage2D + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset + ',' + width + ',' + height + ',' + format + ',' + processArray(pixels), true ) } copyTexImage2D = function (target, level, internalformat, x, y, width, height, border) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.copyTexImage2D + ',' + target + ',' + level + ',' + internalformat + ',' + x + ',' + y + ',' + width + ',' + height + ',' + border, true ); } copyTexSubImage2D = function (target, level, xoffset, yoffset, x, y, width, height) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.copyTexSubImage2D + ',' + target + ',' + level + ',' + xoffset + ',' + yoffset + ',' + x + ',' + y + ',' + width + ',' + height ); } createBuffer = function () { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.createBuffer + '' ); const buffer = new Buffer(result); this._map.set(buffer.uuid(), buffer); return buffer; } createFramebuffer = function () { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.createFramebuffer + '' ); const framebuffer = new Framebuffer(result); this._map.set(framebuffer.uuid(), framebuffer); return framebuffer; } createProgram = function () { const id = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.createProgram + '' ); const program = new Program(id); this._map.set(program.uuid(), program); return program; } createRenderbuffer = function () { const id = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.createRenderbuffer + '' ) const renderBuffer = new Renderbuffer(id); this._map.set(renderBuffer.uuid(), renderBuffer); return renderBuffer; } createShader = function (type) { const id = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.createShader + ',' + type ) const shader = new Shader(id, type); this._map.set(shader.uuid(), shader); return shader; } createTexture = function () { const id = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.createTexture + '' ); const texture = new Texture(id); this._map.set(texture.uuid(), texture); return texture; } cullFace = function (mode) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.cullFace + ',' + mode, true ) } deleteBuffer = function (buffer) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.deleteBuffer + ',' + buffer.id, true ) } deleteFramebuffer = function (framebuffer) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.deleteFramebuffer + ',' + framebuffer.id, true ) } deleteProgram = function (program) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.deleteProgram + ',' + program.id, true ) } deleteRenderbuffer = function (renderbuffer) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.deleteRenderbuffer + ',' + renderbuffer.id, true ) } deleteShader = function (shader) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.deleteShader + ',' + shader.id, true ) } deleteTexture = function (texture) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.deleteTexture + ',' + texture.id, true ) } depthFunc = function (func) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.depthFunc + ',' + func ) } depthMask = function (flag) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.depthMask + ',' + Number(flag), true ) } depthRange = function (zNear, zFar) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.depthRange + ',' + zNear + ',' + zFar, true ) } detachShader = function (program, shader) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.detachShader + ',' + program.id + ',' + shader.id, true ) } disable = function (cap) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.disable + ',' + cap, true ) } disableVertexAttribArray = function (index) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.disableVertexAttribArray + ',' + index, true ); } drawArrays = function (mode, first, count) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.drawArrays + ',' + mode + ',' + first + ',' + count ) this._canvas._needRender = true; } drawElements = function (mode, count, type, offset) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.drawElements + ',' + mode + ',' + count + ',' + type + ',' + offset + ';' ); this._canvas._needRender = true; } enable = function (cap) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.enable + ',' + cap, true ); } enableVertexAttribArray = function (index) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.enableVertexAttribArray + ',' + index, true ) } flush = function () { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.flush + '' ) } framebufferRenderbuffer = function (target, attachment, textarget, texture, level) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.framebufferRenderbuffer + ',' + target + ',' + attachment + ',' + textarget + ',' + (texture ? texture.id : 0) + ',' + level, true ) } framebufferTexture2D = function (target, attachment, textarget, texture, level) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.framebufferTexture2D + ',' + target + ',' + attachment + ',' + textarget + ',' + (texture ? texture.id : 0) + ',' + level, true ) } frontFace = function (mode) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.frontFace + ',' + mode, true ) } generateMipmap = function (target) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.generateMipmap + ',' + target, true ) } getActiveAttrib = function (progarm, index) { const resultString = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getActiveAttrib + ',' + progarm.id + ',' + index ) const [type, size, name] = resultString.split(','); return new ActiveInfo({ type: Number(type), size: Number(size), name }); } getActiveUniform = function (progarm, index) { const resultString = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getActiveUniform + ',' + progarm.id + ',' + index ); const [type, size, name] = resultString.split(','); return new ActiveInfo({ type: Number(type), size: Number(size), name }) } getAttachedShaders = function (progarm) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getAttachedShaders + ',' + progarm.id ); const [type, ...ids] = result; return ids.map(id => this._map.get(Shader.uuid(id))); } getAttribLocation = function (progarm, name) { return WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getAttribLocation + ',' + progarm.id + ',' + name ) } getBufferParameter = function (target, pname) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getBufferParameter + ',' + target + ',' + pname ); const [type, res] = getBufferParameter; return res; } getError = function () { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getError + '' ) return result; } getExtension = function (name) { return null; } getFramebufferAttachmentParameter = function (target, attachment, pname) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getFramebufferAttachmentParameter + ',' + target + ',' + attachment + ',' + pname ) switch (pname) { case GLenum.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: return this._map.get(Renderbuffer.uuid(result)) || this._map.get(Texture.uuid(result)) || null; default: return result; } } getParameter = function (pname) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getParameter + ',' + pname ) switch (pname) { case GLenum.VERSION: return this._version; case GLenum.ARRAY_BUFFER_BINDING: // buffer case GLenum.ELEMENT_ARRAY_BUFFER_BINDING: // buffer return this._map.get(Buffer.uuid(result)) || null; case GLenum.CURRENT_PROGRAM: // program return this._map.get(Program.uuid(result)) || null; case GLenum.FRAMEBUFFER_BINDING: // framebuffer return this._map.get(Framebuffer.uuid(result)) || null; case GLenum.RENDERBUFFER_BINDING: // renderbuffer return this._map.get(Renderbuffer.uuid(result)) || null; case GLenum.TEXTURE_BINDING_2D: // texture case GLenum.TEXTURE_BINDING_CUBE_MAP: // texture return this._map.get(Texture.uuid(result)) || null; case GLenum.ALIASED_LINE_WIDTH_RANGE: // Float32Array case GLenum.ALIASED_POINT_SIZE_RANGE: // Float32Array case GLenum.BLEND_COLOR: // Float32Array case GLenum.COLOR_CLEAR_VALUE: // Float32Array case GLenum.DEPTH_RANGE: // Float32Array case GLenum.MAX_VIEWPORT_DIMS: // Int32Array case GLenum.SCISSOR_BOX: // Int32Array case GLenum.VIEWPORT: // Int32Array case GLenum.COMPRESSED_TEXTURE_FORMATS: // Uint32Array default: const [type, ...res] = result.split(','); if (res.length === 1) { return Number(res[0]); } else { return res.map(Number); } } } getProgramInfoLog = function (progarm) { return WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getProgramInfoLog + ',' + progarm.id ) } getProgramParameter = function (program, pname) { const res = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getProgramParameter + ',' + program.id + ',' + pname ); const [type, result] = res.split(',').map(i => parseInt(i)); if (type === 1) { return Boolean(result); } else if (type === 2) { return result; } else { throw new Error('Unrecongized program paramater ' + res + ', type: ' + typeof res); } } getRenderbufferParameter = function (target, pname) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getRenderbufferParameter + ',' + target + ',' + pname ) return result; } getShaderInfoLog = function (shader) { return WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getShaderInfoLog + ',' + shader.id ); } getShaderParameter = function (shader, pname) { return WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getShaderParameter + ',' + shader.id + ',' + pname ) } getShaderPrecisionFormat = function (shaderType, precisionType) { const [rangeMin, rangeMax, precision] = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getShaderPrecisionFormat + ',' + shaderType + ',' + precisionType ); const shaderPrecisionFormat = new ShaderPrecisionFormat({ rangeMin: Number(rangeMin), rangeMax: Number(rangeMax), precision: Number(precision) }); return shaderPrecisionFormat; } getShaderSource = function (shader) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getShaderSource + ',' + shader.id ); return result; } getSupportedExtensions = function () { return Object.keys({}); } getTexParameter = function (target, pname) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getTexParameter + ',' + target + ',' + pname ) return result; } getUniformLocation = function (program, name) { const id = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getUniformLocation + ',' + program.id + ',' + name ); if (id === -1) { return null; } else { return new UniformLocation(Number(id)); } } getVertexAttrib = function (index, pname) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getVertexAttrib + ',' + index + ',' + pname ); switch (pname) { case GLenum.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: return this._map.get(Buffer.uuid(result)) || null; case GLenum.CURRENT_VERTEX_ATTRIB: // Float32Array default: return result; } } getVertexAttribOffset = function (index, pname) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.getVertexAttribOffset + ',' + index + ',' + pname ) return Number(result); } isBuffer = function (buffer) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.isBuffer + ',' + buffer.id ) return Boolean(result); } isContextLost = function () { return false; } isEnabled = function (cap) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.isEnabled + ',' + cap ) return Boolean(result); } isFramebuffer = function (framebuffer) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.isFramebuffer + ',' + framebuffer.id ) return Boolean(result); } isProgram = function (program) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.isProgram + ',' + program.id ) return Boolean(result); } isRenderbuffer = function (renderBuffer) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.isRenderbuffer + ',' + renderbuffer.id ) return Boolean(result); } isShader = function (shader) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.isShader + ',' + shader.id ) return Boolean(result); } isTexture = function (texture) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.isTexture + ',' + texture.id ); return Boolean(result); } lineWidth = function (width) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.lineWidth + ',' + width, true ) } linkProgram = function (program) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.linkProgram + ',' + program.id, true ); } pixelStorei = function (pname, param) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.pixelStorei + ',' + pname + ',' + Number(param) ) } polygonOffset = function (factor, units) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.polygonOffset + ',' + factor + ',' + units ) } readPixels = function (x, y, width, height, format, type, pixels) { const result = WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.readPixels + ',' + x + ',' + y + ',' + width + ',' + height + ',' + format + ',' + type ) return result; } renderbufferStorage = function (target, internalFormat, width, height) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.renderbufferStorage + ',' + target + ',' + internalFormat + ',' + width + ',' + height, true ) } sampleCoverage = function (value, invert) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.sampleCoverage + ',' + value + ',' + Number(invert), true ) } scissor = function (x, y, width, height) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.scissor + ',' + x + ',' + y + ',' + width + ',' + height, true ) } shaderSource = function (shader, source) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.shaderSource + ',' + shader.id + ',' + source ) } stencilFunc = function (func, ref, mask) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.stencilFunc + ',' + func + ',' + ref + ',' + mask, true ) } stencilFuncSeparate = function (face, func, ref, mask) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.stencilFuncSeparate + ',' + face + ',' + func + ',' + ref + ',' + mask, true ) } stencilMask = function (mask) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.stencilMask + ',' + mask, true ) } stencilMaskSeparate = function (face, mask) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.stencilMaskSeparate + ',' + face + ',' + mask, true ) } stencilOp = function (fail, zfail, zpass) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.stencilOp + ',' + fail + ',' + zfail + ',' + zpass ) } stencilOpSeparate = function (face, fail, zfail, zpass) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.stencilOp + ',' + face + ',' + fail + ',' + zfail + ',' + zpass, true ) } texImage2D = function (...args) { WebGLRenderingContext.GBridge.texImage2D(this._canvas.id, ...args); } texParameterf = function (target, pname, param) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.texParameterf + ',' + target + ',' + pname + ',' + param, true ) } texParameteri = function (target, pname, param) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.texParameteri + ',' + target + ',' + pname + ',' + param ) } texSubImage2D = function (...args) { WebGLRenderingContext.GBridge.texSubImage2D(this._canvas.id, ...args); } uniform1f = function (location, v0) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform1f + ',' + location.id + ',' + v0 ) } uniform1fv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform1fv + ',' + location.id + ',' + processArray(value), true ) } uniform1i = function (location, v0) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform1i + ',' + location.id + ',' + v0, // true ) } uniform1iv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform1iv + ',' + location.id + ',' + processArray(value), true ) } uniform2f = function (location, v0, v1) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform2f + ',' + location.id + ',' + v0 + ',' + v1, true ) } uniform2fv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform2fv + ',' + location.id + ',' + processArray(value), true ) } uniform2i = function (location, v0, v1) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform2i + ',' + location.id + ',' + v0 + ',' + v1, true ) } uniform2iv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform2iv + ',' + location.id + ',' + processArray(value), true ) } uniform3f = function (location, v0, v1, v2) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform3f + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2, true ) } uniform3fv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform3fv + ',' + location.id + ',' + processArray(value), true ) } uniform3i = function (location, v0, v1, v2) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform3i + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2, true ) } uniform3iv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform3iv + ',' + location.id + ',' + processArray(value), true ) } uniform4f = function (location, v0, v1, v2, v3) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform4f + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2 + ',' + v3, true ) } uniform4fv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform4fv + ',' + location.id + ',' + processArray(value), true ) } uniform4i = function (location, v0, v1, v2, v3) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform4i + ',' + location.id + ',' + v0 + ',' + v1 + ',' + v2 + ',' + v3, true ) } uniform4iv = function (location, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniform4iv + ',' + location.id + ',' + processArray(value, true), true ) } uniformMatrix2fv = function (location, transpose, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniformMatrix2fv + ',' + location.id + ',' + Number(transpose) + ',' + processArray(value), true ) } uniformMatrix3fv = function (location, transpose, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniformMatrix3fv + ',' + location.id + ',' + Number(transpose) + ',' + processArray(value), true ) } uniformMatrix4fv = function (location, transpose, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.uniformMatrix4fv + ',' + location.id + ',' + Number(transpose) + ',' + processArray(value), true ); } useProgram = function (progarm) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.useProgram + ',' + progarm.id + '', true ) } validateProgram = function (program) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.validateProgram + ',' + program.id, true ) } vertexAttrib1f = function (index, v0) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib1f + ',' + index + ',' + v0, true ) } vertexAttrib2f = function (index, v0, v1) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib2f + ',' + index + ',' + v0 + ',' + v1, true ) } vertexAttrib3f = function (index, v0, v1, v2) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib3f + ',' + index + ',' + v0 + ',' + v1 + ',' + v2, true ) } vertexAttrib4f = function (index, v0, v1, v2, v3) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib4f + ',' + index + ',' + v0 + ',' + v1 + ',' + v2 + ',' + v3, true ) } vertexAttrib1fv = function (index, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib1fv + ',' + index + ',' + processArray(value), true ) } vertexAttrib2fv = function (index, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib2fv + ',' + index + ',' + processArray(value), true ) } vertexAttrib3fv = function (index, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib3fv + ',' + index + ',' + processArray(value), true ) } vertexAttrib4fv = function (index, value) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttrib4fv + ',' + index + ',' + processArray(value), true ) } vertexAttribPointer = function (index, size, type, normalized, stride, offset) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.vertexAttribPointer + ',' + index + ',' + size + ',' + type + ',' + Number(normalized) + ',' + stride + ',' + offset, true ) } viewport = function (x, y, width, height) { WebGLRenderingContext.GBridge.callNative( this._canvas.id, GLmethod.viewport + ',' + x + ',' + y + ',' + width + ',' + height, true ) } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/RenderingContext.js
JavaScript
unknown
36,749
import {getTransferedObjectUUID} from './classUtils'; const name = 'WebGLShader'; function uuid(id) { return getTransferedObjectUUID(name, id); } export default class WebGLShader { className = name; constructor(id, type) { this.id = id; this.type = type; } static uuid = uuid; uuid() { return uuid(this.id); } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/Shader.js
JavaScript
unknown
369
export default class WebGLShaderPrecisionFormat { className = 'WebGLShaderPrecisionFormat'; constructor({ rangeMin, rangeMax, precision }) { this.rangeMin = rangeMin; this.rangeMax = rangeMax; this.precision = precision; } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/ShaderPrecisionFormat.js
JavaScript
unknown
273
import {getTransferedObjectUUID} from './classUtils'; const name = 'WebGLTexture'; function uuid(id) { return getTransferedObjectUUID(name, id); } export default class WebGLTexture { className = name; constructor(id, type) { this.id = id; this.type = type; } static uuid = uuid; uuid() { return uuid(this.id); } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/Texture.js
JavaScript
unknown
371
import {getTransferedObjectUUID} from './classUtils'; const name = 'WebGLUniformLocation'; function uuid(id) { return getTransferedObjectUUID(name, id); } export default class WebGLUniformLocation { className = name; constructor(id, type) { this.id = id; this.type = type; } static uuid = uuid; uuid() { return uuid(this.id); } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/UniformLocation.js
JavaScript
unknown
387
export function getTransferedObjectUUID(name, id) { return `${name.toLowerCase()}-${id}`; }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/context-webgl/classUtils.js
JavaScript
unknown
95
import GCanvas from './env/canvas'; import GImage from './env/image'; import GWebGLRenderingContext from './context-webgl/RenderingContext'; import GContext2D from './context-2d/RenderingContext'; import GBridgeWeex from './bridge/bridge-weex'; export let Image = GImage; export let WeexBridge = GBridgeWeex; export function enable(el, { bridge, debug, disableAutoSwap, disableComboCommands } = {}) { const GBridge = GImage.GBridge = GCanvas.GBridge = GWebGLRenderingContext.GBridge = GContext2D.GBridge = bridge; GBridge.callEnable(el.ref, [ 0, // renderMode: 0--RENDERMODE_WHEN_DIRTY, 1--RENDERMODE_CONTINUOUSLY -1, // hybridLayerType: 0--LAYER_TYPE_NONE 1--LAYER_TYPE_SOFTWARE 2--LAYER_TYPE_HARDWARE false, // supportScroll false, // newCanvasMode 1, // compatible 'white',// clearColor false // sameLevel: newCanvasMode = true && true => GCanvasView and Webview is same level ]); if (debug === true) { GBridge.callEnableDebug(); } if (disableComboCommands) { GBridge.callEnableDisableCombo(); } var canvas = new GCanvas(el.ref, { disableAutoSwap }); canvas.width = el.style.width; canvas.height = el.style.height; return canvas; };
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/gcanvas/index.js
JavaScript
unknown
1,280
export default { props: { //二维码内容 value: { type: [String, Number] }, //选项 options: { type: Object, default: () => { return {}; } }, //二维码大小 size: { type: [String, Number], default: 200 }, //导出的文件类型 fileType: { type: String, default: 'png' }, //是否初始化组件后就开始生成 start: { type: Boolean, default: true }, //是否数据发生改变自动重绘 auto: { type: Boolean, default: true }, //隐藏组件 hide: { type: Boolean, default: false }, /** * canvas 类型,微信小程序默认使用2d,非2d微信官方已放弃维护,问题比较多 * 注意:微信小程序type2d手机上正常,PC上微信内打开小程序toDataURL报错,看后期微信官方团队会不会做兼容,不兼容的话只能在自行判断在PC使用非2d,或者直接提示用户请在手机上操作,微信团队的海报中心小程序就是这么做的 */ type: { type: String, default: () => { // #ifdef MP-WEIXIN return '2d'; // #endif // #ifndef MP-WEIXIN return 'normal'; // #endif } }, //队列绘制,主要针对NVue端 queue: { type: Boolean, default: false }, //是否队列加载图片,可减少canvas发起的网络资源请求,节省服务器资源 isQueueLoadImage: { type: Boolean, default: false }, //loading态 loading: { type: Boolean, default: undefined }, //H5保存即自动下载(在支持的环境下),默认false为仅弹层提示用户需要长按图片保存,不会自动下载 h5SaveIsDownload: { type: Boolean, default: false }, //H5下载名称 h5DownloadName: { type: String, default: 'uvQRCode' }, // H5保存二维码时候是否显示提示 h5SaveTip: { type: Boolean, default: true } } }
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/props.js
JavaScript
unknown
1,896
function Queue() { let waitingQueue = this.waitingQueue = []; let isRunning = this.isRunning = false; // 记录是否有未完成的任务 function execute(task, resolve, reject) { task() .then((data) => { resolve(data); }) .catch((e) => { reject(e); }) .finally(() => { // 等待任务队列中如果有任务,则触发它;否则设置isRunning = false,表示无任务状态 if (waitingQueue.length) { const next = waitingQueue.shift(); execute(next.task, next.resolve, next.reject); } else { isRunning = false; } }); } this.exec = function(task) { return new Promise((resolve, reject) => { if (isRunning) { waitingQueue.push({ task, resolve, reject }); } else { isRunning = true; execute(task, resolve, reject); } }); } } /* 队列实例,某些平台一起使用多个组件时需要通过队列逐一绘制,否则部分绘制方法异常,nvue端的iOS gcanvas尤其明显,在不通过队列绘制时会出现图片丢失的情况 */ export const queueDraw = new Queue(); export const queueLoadImage = new Queue();
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/queue.js
JavaScript
unknown
1,248
<template> <view class="uqrcode" :class="{ 'uqrcode-hide': hide }" :style="{ width: `${templateOptions.width}px`, height: `${templateOptions.height}px` }"> <view class="uqrcode-canvas-wrapper"> <!-- 画布 --> <!-- #ifndef APP-NVUE --> <canvas class="uqrcode-canvas" :id="canvasId" :canvas-id="canvasId" :type="canvasType" :style="{ width: `${templateOptions.canvasWidth}px`, height: `${templateOptions.canvasHeight}px`, transform: templateOptions.canvasTransform }" v-if="templateOptions.canvasDisplay" @click="onClick"></canvas> <!-- #endif --> <!-- nvue用gcanvas --> <!-- #ifdef APP-NVUE --> <gcanvas class="uqrcode-canvas" ref="gcanvas" :style="{ width: `${templateOptions.canvasWidth}px`, height: `${templateOptions.canvasHeight}px` }" v-if="templateOptions.canvasDisplay" @click="onClick"></gcanvas> <!-- #endif --> </view> <!-- 加载效果 --> <view class="uqrcode-makeing" v-if="loading === undefined || !loading ? makeing : loading"> <slot name="loading"> <image class="uqrcode-makeing-image" :style="{ width: `${templateOptions.size / 4}px`, height: `${templateOptions.size / 4}px` }" src="data:image/gif;base64,R0lGODlhAAEAAfIEAOHh4SSsWuDg4N3d3f///wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDYuMC1jMDAyIDc5LjE2NDQ4OCwgMjAyMC8wNy8xMC0yMjowNjo1MyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIyLjAgKFdpbmRvd3MpIiB4bXBNTTpJbnN0YW5jZUlEPSJ4bXAuaWlkOjAyODhGMzM4RDEwMTExRUM4MDhCRkVBQkE2QUZDQzkwIiB4bXBNTTpEb2N1bWVudElEPSJ4bXAuZGlkOjAyODhGMzM5RDEwMTExRUM4MDhCRkVBQkE2QUZDQzkwIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6MDI4OEYzMzZEMTAxMTFFQzgwOEJGRUFCQTZBRkNDOTAiIHN0UmVmOmRvY3VtZW50SUQ9InhtcC5kaWQ6MDI4OEYzMzdEMTAxMTFFQzgwOEJGRUFCQTZBRkNDOTAiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4B//79/Pv6+fj39vX08/Lx8O/u7ezr6uno5+bl5OPi4eDf3t3c29rZ2NfW1dTT0tHQz87NzMvKycjHxsXEw8LBwL++vby7urm4t7a1tLOysbCvrq2sq6qpqKempaSjoqGgn56dnJuamZiXlpWUk5KRkI+OjYyLiomIh4aFhIOCgYB/fn18e3p5eHd2dXRzcnFwb25tbGtqaWhnZmVkY2JhYF9eXVxbWllYV1ZVVFNSUVBPTk1MS0pJSEdGRURDQkFAPz49PDs6OTg3NjU0MzIxMC8uLSwrKikoJyYlJCMiISAfHh0cGxoZGBcWFRQTEhEQDw4NDAsKCQgHBgUEAwIBAAAh+QQFFAAEACwAAAAAAAEAAQAD/0i63P4wykmrvTjrzbv/YCiOZGmeaKqubOu+cCzPdG3feK7vfO//wKBwSCwaj8ikcslsOp/QqHRKrVqv2Kx2y+16v+CweEwum8/otHrNbrvf8Lh8Tq/b7/i8fs/v+/+AgYKDhIWGh4iJiouMjY6PkJGSk5SVlpeYmZqbnJ2en6ChoqOkpaanigCqq6ytrieusbISAbW2t7i5uru8vb66bLLCrLDDw7S/ycrLzLXBxsLF0LHIzdbXzc/Trybb1BHY4eK92t6r0uaq1ePs4+Xp6PDg7fTh7+bx+PP1/Mz33vkA7utH0Ne/bQERDizIMNfBaQkhLmxIMcBDaBExTqzI8P+isYwfN3Ik6PFYt3TnRI7kVzLaSZQA1q0s2HLWS5QyZ/ar+a0ETHUqdbLjyc3nz5xC6RFtBdIkhKQ01/yMeVPeU6g7pR6tqu8q1npLiXEV6PVru7ApjcJEquyEPa1rxyosm83EWzVTm7qk688uNrRA1eIMatDvNcBUBVt9cJdEYzR55Urku8ztX7iDFXdlfLnE4zORNZPlfNiwNcR6bVJua7ou3q2i55I+3brv67ixJ8927bhzmtAkgDv4HIJ4GeEikDMw/oH5GOUgoCtw3oF6GOkesFvfsP0L9g7afY/o7uU7h/ClPYsHDTt4++Hri8c//j55/eXzm+d/fj96/+n/+1UX4HX/ZVcgeRggyIV5G6BHmycMauAgb5xEmMGEtnViIQYYVvbJhhd0yBqEBYJ34ICUgGiBiMmAomIFLP7iYonnnZiehjQ2aOODOE7l449MERbVai1iBuSRO67EVpG3IenkYvDptKSMRj5pZUhENjRlYU1e6aVqu420JTlVfmlmYGFyNCYviJ2ZWZoVrblLm25uFuVMcgJTZp1X5gmWkGzuyeeTfioF6JyCDopkoWcdqmeXilrJ6FCOOpRopD9O6k6luNCJ6V5wUqSpRZd+mqSYnN7iqalFhaplqrasyqpYWXYEqzOlzmpnA0mNKquuiblqa61kQgrsqWreSqqx/8e+eaeSyqIi7bTUVmvttdhmq+223Hbr7bejCCDuuOSWa+656Kar7rrnSjDAu/DGK++89NZr77340vsru/z2224E+QYs8MAEw7uvvwj3627BDDfM8MEJR5zuwg5XbHG9EEusMbkUX+zxxRlvvHHHH5f8cK4ip+wvySa3HHDIKifMsss0Y4xyzDijO3PNPBt8c85Aj7tzzzzDHPS6QxNNs9FHTwyw0lAPwHTT/0IQNdRTU11u0ld/nLXWQj/dddE/g50y12Nb/LXZaKft8Npgt+32ycyafbTccxMMt9Z45y3w3lT37Xe+qEnGruDxzihxalU/ULHiETNuLuI+k7i44f9Ii013j5Fjri7l70Ius+dOW/32hxpLvrXmBYuOsOocs6436pfndrjsA7u+Muk64/437Z3bnrnpDeuuMO+NO/A48KML/7nvLzP/OvKTQ0+49Ls7X7rjp1sevHu1c1889sdr3zvxm1eYOvWro986+fzCHrb7s3vfPPjfK9895/ePMLL1+DKe3c6Hv/fZb4DPM5++4IfA9hWwfvxrIAH9tz/1STCBD8wdAy8oNfYlboMXlF/oQChBEXbwgByMnQLnJcAUmrCFHDTh4FhYNrZ5cIY2q5sLb4hDGuowhjzs4Qd/GMIgCnGERCyhEY8IOAxS8IgVZE8Kk2cfKI4viQ2UIRPAaxi3JQqxiXcDoBXtVbgVOlB/YzTgb9ZnRhWKL40axCIVQ/A/+sExgFwU1wvFeMchrjF8T8xfA/oYxz8Kko5sfCMh71XGDJZPkYvMoSH7V8VDLiCS15Nj9do4P0hiUl6NDCQlGfBJRoLrlKhMpSpXycpWuvKVsIylLGdJy1ra8pa4zKUud8nLXvryl8AMpjCHScxiGvOYyEymMpfJzGY685nQjKY0p0nNalrzmtjMpja3yc1uevOb4AynOMdJhwQAACH5BAUUAAQALDIAMgCcAJwAAAP/KLrcTjDKSWt0OFsIuv9gKI5kaZ6Ztq1s6iorKs90/apsTt1pbP/AIA+mK16Gj41wyWwan8ikpUmtRp/GaMNn7Xq3WJ2Wwf2arWHxmDg9u6np3JpdeduX8da8fO8j83xXSn6EQ4CDa4GFi2CHO3uIjJJkjo+JkZOTlZZjipmFmxNzAp6ffqESo6Wmd6hHl22sjK4ckLGyoLSqmLh9tAS7t72+urZ1QL+LycacNcuEz528M9HErsHHP9WtxbDZNtt24YbTMuNu5zerJulm7S7rJe9e8zjfzt2n+VrxJPVo+wQJo/GvSsFG9wgGFLeQ3EBqDdFFVFcOxUEnE1/0G3GR/0lHOs0UXss10ltIiCX1peRX8cRHIS83iniJLVRNUcgyfonZkp1Oej/tnTT3K87NSkdfgSuaJukhp8ByMsUCNQ/UIFPDVDXKDKe2rFC6IhWrFB/YIlubkq319awak5uuSnWrB+5Yu2VF0pUpBZXctnt7jhqMl63KhMMIU3z4hm9ixY4xMn6sGENkj4IpVyaVuctlzdImn/kMWiDixp1L/z08VPVm0lhTuw59WqLo2YNhz22NO7dsOL9789ANmLfwwlGhBT8Obzke58wtQ499O/qf6bu9WvddHWj37RqxF9cOHrky8ZvTs/wOkH2IwPDjy59Pv779+/jz69/Pv7////8ABijggAQWaOCBCCao4FQDNOjggxBGKOGEFFZooYQrBKDhhhx26OGHIIYo4ogfXmjiiSim6GCGJLbo4oswaqjijDTSyGKMOOYYY4089ljhjToGKWSJPhZpJJBDJimkkUz2iKSSUO7Y5JQqPhnllSRSqeWJVmLpJZFbhjlhl1+WKaOYaEJIpplfpulmg2uyieWbbsYpZ5R0pmnnnUrmieaefA7pp5iABhrkoGEWamiOiG6p6KJSNjrlo5C+KCmVlFba4qWTbqCpl5w2memnIvLIkwVB6mdqUBh6qqOqNZ5aQar5rbpSiqMGAKuNrEaY664zykoBrfjZ6lesruYIbJX/vaqZLI7L4trsg7/WiuytKFZb7LXH8orqq9Z6222wz8YYbbbTrlgujOdymS6c677YronCTkDsfcbaxO2w4G4rrr7/2tsvvvvGVbAE99qXr8EBIzywwgc7srDDyoZLLrbufluxv6EOUFTC9XWsLi0g0ycyvCQ/HPLJH6tsMsu/lDzfyR7H7PLMMKe8McEit7wzxD3b/PPKQesMrcWh+kxqnzm7sjSeTaPyNJQ0Kz31oVGHcnWSVQu9tY5dG/01jmE7PTbYWW9yNtpFm712pDQ3HMHbZEf8lN0E0A03sxjTG6/eIU4sMd6AW4q3VYQXvunhXMkNgeKLOw6I4I9DPiLlGZMnbnngjKsl+ealdq6V5qB7iDnin5f+YQIAIfkEBRQABAAsMgAyAJwAnAAAA/84utxOMMpJa3Q4Wyi6/2AojmRpnpm2rWzqKisqz3T9qmxO3Wls/8AgD6YrXoaPjXDJbBqfyKSlSa1Gn8Zow2fterdYnZbB/ZqtYfGYOD27qencml1525fx1rx87yPzfFdKfoRDgINrgYWLYIc7e4iMkmSOj4mRk5OVlmOKmYWbE3MDnp9+oRKjpaZ3qEeXbayMrhyQsbKgtKqYuH20BLu3vb66tnVAv4vJxpw1y4TPnbwz0cSuwcc/1a3FsNk223bhhtMy427nN6sm6WbtLusl717zON/O3af5WvEk9Wj7BAmj8a9KwUb3CAYUt5DcQGoN0UVUVw7FQScTX/QbcZH/SUc6zRReyzXSW0iIJfWl5FfxxEchLzeKeIktVE1RyDJ+idmSnU56P+2dNPcrzs1KR1+BK5om6SGnwHIyxQI1D9QgU8NUNcoMp7asULoiFasUH9giW5uSrfX1rBqTm65KdasH7li7ZUXSlSkFldy2e3uOGoyXrcqEwwhTfPiGb2LFjjEyfqwYQ2SPgilXJpW5y2XN0iaf+QxaIOLGnUv/PTxU9WbSWFO7Dn1aoujZg2HPbY07t2w4v3vz0A2Yt/DCUaEFPw5vOR7nzC1Dj307+p/pu71a910daPftGrEX1w4euTLxm9Oz/A6QfYjA8OPLn0+/vv37+PPr38+/v////wAGKOCABBZo4IEIJqjgVAE06OCDEEYo4YQUVmihhMQBoOGGHHbo4YcghsjhhSSWaOKJDmYo4oostqghijDGGKOKLtZo44sy5qgjhTTe6OOKOwYpZAA9/mikh0MmKWORRzYJgJJQnsikk0ZGaeWFU1Lp45VcTpilljZ2KeaDX4Lp4pholmkmi2iOqeaaIrYp5ptwgihnl3TWieSdV+ap54h8WunnnzgGCuWghBoaJaJ/KnooeoTW6KiSjOo5aZKV1pnjL5tCp1+nroBaG4ufLkmLqMaJWOqMp5rqXoerwsipq6OuGCuKs7L6Koe3StmqrrWqmh+qmxCbipG9mpirrP+eDktrKMbmVWOyJS6La7P4RXuItsn5SC2J1vq664bfYvkrs+NqWK6F4SqL7X3c5sHtketW2G6179oXbxzzIusssNA+S56N9fJ47rXpAlCwlweLG2yIC7fJU7aXkhnUhxGnebGHGbu5Maz/Vkzkx7yGXPHE8IrcIMr6qjzySgSbfCnL9bn8sl/+UqwyTZHeaDPPPUvqMtBBt/gzyUVvOTTSSYe5NMxNr3k01FGDOTXOVWv6NNZZS721TV3DaXO/YZu5bxpkl63l2WGkrbaTbGPh9ttHxv3E3HT/aLcReOfts8CV9O230AAXC7i0gxOOLiqCJ87m4dtC3q3jThceuOQElP+YAAAh+QQFFAAEACwyADIAnACcAAAD/xi63E4wyklrdDhbOLr/YCiOZGmKWcpsbEuoMHvOdG17sOruVJ7Kt6Aw6NPwjq/iYzNsOkvKJXIXbQCfWGx1NaVuFdesWPgFd13lQHjMpqXP6PK6TSe94ay7pc6HyvEbehV9hCGCgBOHE4WMHYqIEI8RjYySiJYElIWYeJiahJxwnp98oWejpHSmXaipbKtTra5isEiys1p/kIm6g7hjtUe3v03BPMM0uxTFvcpJX3M1zhLM0NORzYtD1xxDxl7We9vc1Vvcz+ZM49flVefIM+ftUe/Z1OvT80r14b5C8t7sQYJ3AiAZgZcQZsLnTF8RfunE/SMXsJ8zgiYMElHYSf9hE403vsWxqG0iu4oRp2EsAdKGyBYrSbSs8TKPR4bKHPqA6E6dyXwoe16LOWKmG46ibv5sGJQeN6IijM6oGUhpkHMdSe6CGgJrUq0Drd7wegppWbDdlpIFl/KiWBtrY5ll9VZaXGFz5aJdqPZu1b1Z25a86petUJV1kxUeKXhr4niLYaaZTFmKP03RjlbePDkzIc8nOIt+3Ae0idGonUrE7HNj6tc6WlMy7Qe2bcvLSNG2c7v3gt1tgKPw7Vv4GOMgiBeX3Qj5B+W9nWOR7gi6bepOsFu/zpyR9u2vsX/srhn8aPE47x00f578Z/eh2bdfPRv+afmi0fed1BQ/VzH/3/lXmX6E0eeSgAPaV0eACP6XBXaRRSjhhBRWaOGFGGao4YYcdujhhyCGKOKIJJZo4okopqjiimQB4OKLMMYo44w01mjjjTMSKMCOPPbo449ABinkkDgWaeSROOpI5JJMNonkk1BGqaSTVFYZ5ZVY3jillVx2meWXSG7p5Zhkgmmmi2KWqeaZbBqZ5ppwtilnjG/GaeecbNZ55554Yqknn4D2eeSfgRYqaI2EGqrooS8muiijkDr6KKSCSjoppXNaeimmeSq46aec2qgpqKH66SmpqJYKwKipqjroqa3yKVWSsP64oaknSVmrj7deOauWu/bYq665QgmhhrgCRexl/1UOayxFy+bGpbNP/ipqsDxSGya0zxropLavFlsttjuC6ya343rbpLlFWosouQKwS6u426rLpLzA0hsus1Tie62+59q7pL/vAtwuvATT6K7CCCPrK7r18vutw9Hm9LDARCacI8T7SmulxjIuvDHGQ4JMJ8cBS7wuxa6GjPK9LLcMo8i2xiwzmi8PbPPNNPO6s8w9C/tzy0FnO7SrRZd7tKpJx7t0qU2bzGjUT4fadKxYn2xw1lwfvHXXYDP8ddhkN5pz2WhfjTbQZ68dttpuM9123De7PDbddZvJatZUk4x3xbsk6/Hfa/atMuGCWww4f4gXPrfYhzferbKTDy554hmBXxz55R0rXvlgnGvO1OJphS665+luTncCADs="> </image> </slot> </view> <!-- 错误处理 --> <view class="uqrcode-error" v-if="isError" @click="onClick"> <slot name="error" :error="error"> <text class="uqrcode-error-message">{{ error.errMsg }}</text> </slot> </view> <!-- H5保存提示 --> <!-- #ifdef H5 --> <view class="uqrcode-h5-save" v-if="isH5Save"> <slot name="h5save" :tempFilePath="tempFilePath"> <image class="uqrcode-h5-save-image" :src="tempFilePath"></image> <text class="uqrcode-h5-save-text">{{ h5SaveIsDownload ? '若保存失败,' : '' }}请长按二维码进行保存</text> </slot> <view class="uqrcode-h5-save-close" @click.stop="isH5Save = false"> <view class="uqrcode-h5-save-close-before"></view> <view class="uqrcode-h5-save-close-after"></view> </view> </view> <!-- #endif --> </view> </template> <script> import props from './props.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' // #ifdef VUE3 import { toRaw } from 'vue'; // #endif /* 引入uvQRCode核心js */ import UQRCode from './qrcode'; /* 引入nvue所需模块 */ // #ifdef APP-NVUE import { enable, WeexBridge } from './gcanvas'; const modal = weex.requireModule('modal'); // #endif /* 引入队列 */ import { queueDraw, queueLoadImage } from './queue'; /* 引入缓存图片 */ import { cacheImageList } from './cache'; let instance = null; /** * qrcode 二维码 * @description 二维码生成插件,可扩展性高,它支持自定义渲染二维码,可通过uQRCode API得到二维码绘制关键信息后,使用canvas、svg或js操作dom的方式绘制二维码图案。还可自定义二维码样式,如随机颜色、圆点、方块、块与块之间的间距等。 * @tutorial https://www.uvui.cn/components/qrcode.html * @property {String} value 二维码内容 (start为true时必填 ) * @property {Object} options 二维码配置选项 (data|size|margin...) * @property {String} fileType 导出的文件类型 (jpg | png) * @property {String} start 是否初始化组件后就开始生成 (默认 true) * @property {String} auto 是否数据发生改变自动重绘 (默认 false) * @property {String} hide 隐藏组件。如果只需要导出二维码作为图片使用,可设置为true,不能在组件或组件父级元素设置v-if="false"、v-show="false"、style="display:none;"等实现隐藏效果,这样会导致导出二维码空白 (默认 false) * @property {String} type canvas组件类型。微信小程序默认2d (默认 undefined) * @property {String} queue 队列绘制 (默认 false) * @property {String} isQueueLoadImage 是否队列加载图片,选择true将通过队列缓存所需要加载的图片。优点是加载重复资源可减少资源请求次数,节省网络资源,缺点是会转化为同步请求,资源不重复且多的情况下,等待时间会更久。总之,请求重复资源较多则选择true,请求不重复资源较多则选择false (默认 false) * @property {String} loading loading态 (默认 false) * @property {String} h5SaveIsDownload H5保存即自动下载(在支持的环境下),默认false为仅弹层提示用户需要长按图片保存,不会自动下载 (默认 false) * @property {String} h5DownloadName H5下载名称 * @property {String} h5SaveTip H5保存二维码时候是否显示提示 * @example <uv-qrcode ref="uvqrcode" size="400rpx" canvas-id="qrcode" value="https://www.uvui.cn"></uv-qrcode> */ export default { name: 'uv-qrcode', mixins: [mpMixin,mixin,props], emits: ['click','change','complete'], data() { return { canvasId: "", canvas: undefined, canvasType: undefined, canvasContext: undefined, makeDelegate: undefined, drawDelegate: undefined, toTempFilePathDelegate: undefined, makeExecuted: false, makeing: false, drawing: false, isError: false, error: undefined, isH5Save: false, tempFilePath: '', templateOptions: { size: 0, width: 0, // 组件宽度 height: 0, canvasWidth: 0, // canvas宽度 canvasHeight: 0, canvasTransform: '', canvasDisplay: false }, uqrcodeOptions: { data: '' }, plugins: [], makeingPattern: [ [ [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true] ], [ [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, false, false, false], [true, true, true, true, true, true, false, true, true, true], [true, true, true, true, true, true, false, true, true, true], [true, true, true, true, true, true, false, true, true, true] ], [ [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true], [true, true, true, true, true, true, true, false, false, false], [true, true, true, true, true, true, true, false, false, false], [true, true, true, true, true, true, true, false, false, false], [true, true, true, false, false, false, false, true, true, true], [true, true, true, false, false, false, false, true, true, true] ], [ [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, false, false, false, false, false, false, false], [true, true, true, false, false, false, false, false, false, false], [true, true, true, false, false, false, false, false, false, false], [true, true, true, false, false, false, false, false, false, false], [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true] ] ] }; }, watch: { type: { handler(val) { const types = ['2d']; if (types.includes(val)) { this.canvasType = val; } else { this.canvasType = undefined; } }, immediate: true }, value: { handler() { if (this.auto) { this.remake(); } } }, size: { handler() { if (this.auto) { this.remake(); } } }, options: { handler() { if (this.auto) { this.remake(); } }, deep: true }, makeing: { handler(val) { if (!val) { if (typeof this.toTempFilePathDelegate === 'function') { this.toTempFilePathDelegate(); } } } } }, created() { this.canvasId = this.$uv.guid(); }, mounted() { this.templateOptions.size = this.$uv.getPx(this.size); this.templateOptions.width = this.templateOptions.size; this.templateOptions.height = this.templateOptions.size; this.templateOptions.canvasWidth = this.templateOptions.size; this.templateOptions.canvasHeight = this.templateOptions.size; if (this.canvasType == '2d') { // #ifndef MP-WEIXIN this.templateOptions.canvasTransform = `scale(${this.templateOptions.size / this.templateOptions.canvasWidth}, ${this.templateOptions.size / this.templateOptions.canvasHeight})`; // #endif } else { this.templateOptions.canvasTransform = `scale(${this.templateOptions.size / this.templateOptions.canvasWidth}, ${this.templateOptions.size / this.templateOptions.canvasHeight})`; } if (this.start) { this.$nextTick(()=>{ this.make(); }) } }, methods: { /** * 获取模板选项 */ getTemplateOptions() { var size = this.$uv.getPx(this.size); return deepReplace(this.templateOptions, { size, width: size, height: size }); }, /** * 获取插件选项 */ getUqrcodeOptions() { return deepReplace(this.options, { data: String(this.value), size: Number(this.templateOptions.size) }); }, /** * 重置画布 */ resetCanvas(callback) { this.templateOptions.canvasDisplay = false; this.$nextTick(() => { this.templateOptions.canvasDisplay = true; this.$nextTick(() => { callback && callback(); }); }); }, /** * 绘制二维码 */ async draw(callback = {}, isDrawDelegate = false) { if (typeof callback.success != 'function') { callback.success = () => {}; } if (typeof callback.fail != 'function') { callback.fail = () => {}; } if (typeof callback.complete != 'function') { callback.complete = () => {}; } if (this.drawing) { if (!isDrawDelegate) { this.drawDelegate = () => { this.draw(callback, true); }; return; } } else { this.drawing = true; } if (!this.canvasId) { console.error('[uQRCode]: canvasId must be set!'); this.isError = true; this.drawing = false; callback.fail({ errMsg: '[uQRCode]: canvasId must be set!' }); callback.complete({ errMsg: '[uQRCode]: canvasId must be set!' }); return; } if (!this.value) { console.error('[uQRCode]: value must be set!'); this.isError = true; this.drawing = false; callback.fail({ errMsg: '[uQRCode]: value must be set!' }); callback.complete({ errMsg: '[uQRCode]: value must be set!' }); return; } /* 组件数据 */ this.templateOptions = this.getTemplateOptions(); /* uQRCode选项 */ this.uqrcodeOptions = this.getUqrcodeOptions(); /* 纠错等级兼容字母写法 */ if (typeof this.uqrcodeOptions.errorCorrectLevel === 'string') { this.uqrcodeOptions.errorCorrectLevel = UQRCode.errorCorrectLevel[this.uqrcodeOptions.errorCorrectLevel]; } /* nvue不支持动态修改gcanvas尺寸,除nvue外,默认使用useDynamicSize */ // #ifndef APP-NVUE if (typeof this.options.useDynamicSize === 'undefined') { this.uqrcodeOptions.useDynamicSize = true; } // #endif // #ifdef APP-NVUE if (typeof this.options.useDynamicSize === 'undefined') { this.uqrcodeOptions.useDynamicSize = false; } // if (typeof this.options.drawReserve === 'undefined') { // this.uqrcodeOptions.drawReserve = true; // } // #endif /* 获取uQRCode实例 */ const qr = instance = new UQRCode(); /* 注册扩展 */ this.plugins.forEach(p => qr.register(p.plugin)); /* 设置uQRCode选项 */ qr.setOptions(this.uqrcodeOptions); /* 调用制作二维码方法 */ qr.make(); /* 获取canvas上下文 */ let canvasContext = null; // #ifndef APP-NVUE if (this.canvasType === '2d') { // #ifdef MP-WEIXIN /* 微信小程序获取canvas2d上下文方式 */ const canvas = (this.canvas = await new Promise(resolve => { uni .createSelectorQuery() .in(this) // 在组件内使用需要 .select(`#${this.canvasId}`) .fields({ node: true, size: true }) .exec(res => { resolve(res[0].node); }); })); canvasContext = this.canvasContext = canvas.getContext('2d'); /* 2d的组件设置宽高与实际canvas绘制宽高不是一个,打个比方,组件size=200,canvas.width设置为100,那么绘制出来就是100=200,组件size=400,canvas.width设置为800,绘制大小还是800=400,所以无需理会下方返回的dynamicSize是多少,按dpr重新赋值给canvas即可 */ this.templateOptions.canvasWidth = qr.size; this.templateOptions.canvasHeight = qr.size; this.templateOptions.canvasTransform = ''; /* 使用dynamicSize+scale,可以解决小块间出现白线问题,dpr可以解决模糊问题 */ const dpr = uni.getSystemInfoSync().pixelRatio; canvas.width = qr.dynamicSize * dpr; canvas.height = qr.dynamicSize * dpr; canvasContext.scale(dpr, dpr); /* 微信小程序获取图像方式 */ qr.loadImage = this.getLoadImage(function(src) { /* 小程序下获取网络图片信息需先配置download域名白名单才能生效 */ return new Promise((resolve, reject) => { const img = canvas.createImage(); img.src = src; img.onload = () => { resolve(img); }; img.onerror = err => { reject(err); }; }); }); // #endif // #ifndef MP-WEIXIN /* 非微信小程序不支持2d,切换回uniapp获取canvas上下文方式 */ canvasContext = this.canvasContext = uni.createCanvasContext(this.canvasId, this); /* 使用dynamicSize,可以解决小块间出现白线问题,再通过scale缩放至size,使其达到所设尺寸 */ this.templateOptions.canvasWidth = qr.dynamicSize; this.templateOptions.canvasHeight = qr.dynamicSize; this.templateOptions.canvasTransform = `scale(${this.templateOptions.size / this.templateOptions.canvasWidth}, ${this.templateOptions.size / this.templateOptions.canvasHeight})`; /* uniapp获取图像方式 */ qr.loadImage = this.getLoadImage(function(src) { return new Promise((resolve, reject) => { if (src.startsWith('http')) { uni.getImageInfo({ src, success: res => { resolve(res.path); }, fail: err => { reject(err); } }); } else { if (src.startsWith('.')) { console.error('[uQRCode]: 本地图片路径仅支持绝对路径!'); throw new Error('[uQRCode]: local image path only supports absolute path!'); } else { resolve(src); } } }); }); // #endif } else { /* uniapp获取canvas上下文方式 */ canvasContext = this.canvasContext = uni.createCanvasContext(this.canvasId, this); /* 使用dynamicSize,可以解决小块间出现白线问题,再通过scale缩放至size,使其达到所设尺寸 */ this.templateOptions.canvasWidth = qr.dynamicSize; this.templateOptions.canvasHeight = qr.dynamicSize; this.templateOptions.canvasTransform = `scale(${this.templateOptions.size / this.templateOptions.canvasWidth}, ${this.templateOptions.size / this.templateOptions.canvasHeight})`; /* uniapp获取图像方式 */ qr.loadImage = this.getLoadImage(function(src) { return new Promise((resolve, reject) => { /* getImageInfo在微信小程序的bug:本地路径返回路径会把开头的/或../移除,导致路径错误,解决方法:限制只能使用绝对路径 */ if (src.startsWith('http')) { uni.getImageInfo({ src, success: res => { resolve(res.path); }, fail: err => { reject(err); } }); } else { if (src.startsWith('.')) { console.error('[uQRCode]: 本地图片路径仅支持绝对路径!'); throw new Error('[uQRCode]: local image path only supports absolute path!'); } else { resolve(src); } } }); }); } // #endif // #ifdef APP-NVUE /* NVue获取canvas上下文方式 */ const gcanvas = this.$refs['gcanvas']; const canvas = enable(gcanvas, { bridge: WeexBridge }); canvasContext = this.canvasContext = canvas.getContext('2d'); /* NVue获取图像方式 */ qr.loadImage = this.getLoadImage(function(src) { return new Promise((resolve, reject) => { /* getImageInfo在nvue的bug:获取同一个路径的图片信息,同一时间第一次获取成功,后续失败,猜测是写入本地时产生文件写入冲突,所以没有返回,特别是对于网络资源 --- 已实现队列绘制,已解决此问题 */ if (src.startsWith('.')) { console.error('[uQRCode]: 本地图片路径仅支持绝对路径!'); throw new Error('[uQRCode]: local image path only supports absolute path!'); } else { uni.getImageInfo({ src, success: res => { resolve(res.path); }, fail: err => { reject(err); } }); } }); }); // #endif /* 设置uQRCode实例的canvas上下文 */ qr.canvasContext = canvasContext; /* 延时等待页面重新绘制完毕 */ setTimeout(() => { /* 从插件获取具体要调用哪一个扩展函数 */ var plugin = this.plugins.find(p => p.name == qr.style); var drawCanvasName = plugin ? plugin.drawCanvas : 'drawCanvas'; /* 虽然qr[drawCanvasName]是直接返回Promise的,但由于js内部this指向问题,故不能直接exec(qr[drawCanvasName])此方式执行,需要改成exec(() => qr[drawCanvasName]())才能正确获取this */ var drawCanvas; if (this.queue) { drawCanvas = () => queueDraw.exec(() => qr[drawCanvasName]()); // drawCanvas = () => queueDraw.exec(() => new Promise((resolve, reject) => { // setTimeout(() => { // qr[drawCanvasName]().then(resolve).catch(reject); // }, 1000); // })); } else { drawCanvas = () => qr[drawCanvasName](); } /* 调用绘制方法将二维码图案绘制到canvas上 */ drawCanvas() .then(() => { if (this.drawDelegate) { /* 高频重绘纠正 */ let delegate = this.drawDelegate; this.drawDelegate = undefined; delegate(); } else { this.drawing = false; callback.success(); } }) .catch(err => { console.log(err); if (this.drawDelegate) { /* 高频重绘纠正 */ let delegate = this.drawDelegate; this.drawDelegate = undefined; delegate(); } else { this.drawing = false; this.isError = true; callback.fail(err); } }) .finally(() => { callback.complete(); }); }, 300); }, /** * 生成二维码 */ make(callback = {}) { this.makeExecuted = true; this.makeing = true; this.isError = false; if (typeof callback.success != 'function') { callback.success = () => {}; } if (typeof callback.fail != 'function') { callback.fail = () => {}; } if (typeof callback.complete != 'function') { callback.complete = () => {}; } this.resetCanvas(() => { clearTimeout(this.makeDelegate); this.makeDelegate = setTimeout(() => { this.draw({ success: () => { setTimeout(() => { callback.success(); this.complete(true); }, 300); }, fail: err => { callback.fail(err); this.error = err; this.complete(false, err.errMsg); }, complete: () => { callback.complete(); this.makeing = false; } }); }, 300); }); }, /** * 重新生成 */ remake(callback) { this.$emit('change'); this.make(callback); }, /** * 生成完成 */ complete(success = true, errMsg = '') { if (success) { this.$emit('complete', { success }); } else { this.$emit('complete', { success, errMsg }); } }, /** * 导出临时路径 */ toTempFilePath(callback = {}) { if (typeof callback.success != 'function') { callback.success = () => {}; } if (typeof callback.fail != 'function') { callback.fail = () => {}; } if (typeof callback.complete != 'function') { callback.complete = () => {}; } if (!this.makeExecuted) { console.error('[uQRCode]: make() 方法从未调用!请先成功调用 make() 后再进行操作。'); var err = { errMsg: '[uQRCode]: make() method has never been executed! please execute make() successfully before operating.' }; callback.fail(err); callback.complete(err); return; } if (this.isError) { callback.fail(this.error); callback.complete(this.error); return; } if (this.makeing) { /* 如果还在生成状态,那当前操作将托管到委托,监听生成完成后再通过委托复调当前方法 */ this.toTempFilePathDelegate = () => { this.toTempFilePath(callback); }; return; } else { this.toTempFilePathDelegate = null; } // #ifndef APP-NVUE if (this.canvasType === '2d') { // #ifdef MP-WEIXIN try { let dataURL = null; // #ifdef VUE3 dataURL = toRaw(this.canvas) .toDataURL(); // #endif // #ifndef VUE3 dataURL = this.canvas.toDataURL(); // #endif callback.success({ tempFilePath: dataURL }); callback.complete({ tempFilePath: dataURL }); } catch (e) { callback.fail(e); callback.complete(e); } // #endif } else { uni.canvasToTempFilePath({ canvasId: this.canvasId, fileType: this.fileType, width: Number(this.templateOptions.canvasWidth), height: Number(this.templateOptions.canvasHeight), destWidth: Number(this.templateOptions.size), destHeight: Number(this.templateOptions.size), success: res => { callback.success(res); }, fail: err => { callback.fail(err); }, complete: () => { callback.complete(); } }, this ); } // #endif // #ifdef APP-NVUE const dpr = uni.getSystemInfoSync().pixelRatio; this.canvasContext.toTempFilePath( 0, 0, this.templateOptions.canvasWidth * dpr, this.templateOptions.canvasHeight * dpr, this.templateOptions.size * dpr, this.templateOptions.size * dpr, '', 1, res => { callback.success(res); callback.complete(res); } ); // #endif }, /** * 保存 */ save(callback = {}) { if (typeof callback.success != 'function') { callback.success = () => {}; } if (typeof callback.fail != 'function') { callback.fail = () => {}; } if (typeof callback.complete != 'function') { callback.complete = () => {}; } this.toTempFilePath({ success: res => { // #ifndef H5 if (this.canvasType === '2d') { // #ifdef MP-WEIXIN /* 需要将 data:image/png;base64, 这段去除 writeFile 才能正常打开文件,否则是损坏文件,无法打开 */ const reg = new RegExp('^data:image/png;base64,', 'g'); const dataURL = res.tempFilePath.replace(reg, ''); const fs = wx.getFileSystemManager(); const tempFilePath = `${wx.env.USER_DATA_PATH}/${new Date().getTime()}${ Math.random() .toString() .split('.')[1] }.png`; fs.writeFile({ filePath: tempFilePath, // 要写入的文件路径 (本地路径) data: dataURL, // base64图片 encoding: 'base64', success: res1 => { uni.saveImageToPhotosAlbum({ filePath: tempFilePath, success: res2 => { callback.success(res2); }, fail: err2 => { callback.fail(err2); }, complete: () => { callback.complete(); } }); }, fail: err => { callback.fail(err); }, complete: () => { callback.complete(); } }); // #endif } else { uni.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: res1 => { callback.success(res1); }, fail: err1 => { callback.fail(err1); }, complete: () => { callback.complete(); } }); } // #endif // #ifdef H5 /* 可以在电脑浏览器下载,移动端iOS不行,安卓微信浏览器不行,安卓外部浏览器可以 */ this.isH5Save = this.h5SaveTip; this.tempFilePath = res.tempFilePath; if (this.h5SaveIsDownload) { const aEle = document.createElement('a'); aEle.download = this.h5DownloadName; // 设置下载的文件名,默认是'下载' aEle.href = res.tempFilePath; document.body.appendChild(aEle); aEle.click(); aEle.remove(); // 下载之后把创建的元素删除 } callback.success({ errMsg: 'ok' }); callback.complete({ errMsg: 'ok' }); // #endif }, fail: err => { callback.fail(err); callback.complete(err); } }); }, /** * 注册click事件 */ onClick(e) { this.$emit('click', e); }, /** * 获取实例 */ getInstance() { return instance; }, /** * 注册扩展,组件仅支持注册type为style的drawCanvas扩展 * @param {Object} plugin */ registerStyle(plugin) { if (plugin.Type != 'style') { console.warn('[uQRCode]: registerStyle 仅支持注册 style 类型的扩展!'); return { errMsg: 'registerStyle 仅支持注册 style 类型的扩展!' }; } if (typeof plugin === 'function') { this.plugins.push({ plugin, name: plugin.Name, drawCanvas: plugin.DrawCanvas }); } }, getLoadImage(loadImage) { var that = this; if (typeof loadImage == 'function') { return function(src) { /* 判断是否是队列加载图片的 */ if (that.isQueueLoadImage) { /* 解决iOS APP||NVUE同时绘制多个二维码导致图片丢失需使用队列 */ return queueLoadImage.exec(() => { return new Promise((resolve, reject) => { setTimeout(() => { const cache = cacheImageList.find(x => x.src == src); if (cache) { resolve(cache.img); } else { loadImage(src) .then(img => { cacheImageList.push({ src, img }); resolve(img); }) .catch(err => { reject(err); }); } }, 10); }); }); } else { return loadImage(src); } }; } else { return function(src) { return Promise.resolve(src); }; } } } }; /** * 对象属性深度替换 * @param {Object} o 原始对象/默认对象/被替换的对象 * @param {Object} r 从这个对象里取值替换到o对象里 * @return {Object} 替换后的新对象 */ function deepReplace(o = {}, r = {}, c = false) { let obj; if (c) { // 从源替换 obj = o; } else { // 不替换源,copy一份备份来替换 obj = { ...o }; } for (let k in r) { var vr = r[k]; if (vr != undefined) { if (vr.constructor == Object) { obj[k] = this.deepReplace(obj[k], vr); } else if (vr.constructor == String && !vr) { obj[k] = obj[k]; } else { obj[k] = vr; } } } return obj; } </script> <style scoped> .uqrcode { position: relative; } .uqrcode-hide { position: fixed; left: 7500rpx; } .uqrcode-canvas { transform-origin: top left; } .uqrcode-makeing { position: absolute; top: 0; right: 0; bottom: 0; left: 0; z-index: 10; /* #ifndef APP-NVUE */ display: flex; /* #endif */ justify-content: center; align-items: center; } .uqrcode-makeing-image { /* #ifndef APP-NVUE */ display: block; max-width: 120px; max-height: 120px; /* #endif */ } .uqrcode-error { position: absolute; top: 0; right: 0; bottom: 0; left: 0; /* #ifndef APP-NVUE */ display: flex; /* #endif */ justify-content: center; align-items: center; } .uqrcode-error-message { font-size: 12px; color: #939291; } /* #ifdef H5 */ .uqrcode-h5-save { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 100; background-color: rgba(0, 0, 0, 0.68); display: flex; flex-direction: column; justify-content: center; align-items: center; } .uqrcode-h5-save-image { width: 512rpx; height: 512rpx; padding: 32rpx; } .uqrcode-h5-save-text { margin-top: 20rpx; font-size: 32rpx; font-weight: 700; color: #ffffff; } .uqrcode-h5-save-close { position: relative; margin-top: 72rpx; width: 60rpx; height: 60rpx; border: 2rpx solid #ffffff; border-radius: 60rpx; padding: 10rpx; } .uqrcode-h5-save-close-before { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(45deg); width: 40rpx; height: 4rpx; background: #ffffff; } .uqrcode-h5-save-close-after { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) rotate(-45deg); width: 40rpx; height: 4rpx; background: #ffffff; } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-qrcode/components/uv-qrcode/uv-qrcode.vue
Vue
unknown
39,149
export default { props: { // radio的名称 name: { type: [String, Number, Boolean], default: '' }, // 形状,square为方形,circle为圆型 shape: { type: String, default: '' }, // 是否禁用 disabled: { type: [String, Boolean], default: '' }, // 是否禁止点击提示语选中单选框 labelDisabled: { type: [String, Boolean], default: '' }, // 选中状态下的颜色,如设置此值,将会覆盖parent的activeColor值 activeColor: { type: String, default: '' }, // 未选中的颜色 inactiveColor: { type: String, default: '' }, // 图标的大小,单位px iconSize: { type: [String, Number], default: '' }, // label的字体大小,px单位 labelSize: { type: [String, Number], default: '' }, // label提示文字,因为nvue下,直接slot进来的文字,由于特殊的结构,无法修改样式 label: { type: [String, Number, Boolean], default: '' }, // 整体的大小 size: { type: [String, Number], default: '' }, // 图标颜色 iconColor: { type: String, default: '' }, // label的颜色 labelColor: { type: String, default: '' }, ...uni.$uv?.props?.radio } }
2301_77169380/AppruanjianApk
uni_modules/uv-radio/components/uv-radio/props.js
JavaScript
unknown
1,247
<template> <view class="uv-radio" @tap.stop="wrapperClickHandler" :style="[radioStyle]" :class="[`uv-radio-label--${parentData.iconPlacement}`, parentData.borderBottom && parentData.placement === 'column' && 'uv-border-bottom']" > <view class="uv-radio__icon-wrap" @tap.stop="iconClickHandler" :class="iconClasses" :style="[iconWrapStyle]" > <slot name="icon"> <uv-icon class="uv-radio__icon-wrap__icon" name="checkbox-mark" :size="elIconSize" :color="elIconColor" /> </slot> </view> <view class="uv-radio__label-wrap" @tap.stop="labelClickHandler"> <slot> <text :style="{ color: elDisabled ? elInactiveColor : elLabelColor, fontSize: elLabelSize, lineHeight: elLabelSize }" >{{label}}</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'; /** * radio 单选框 * @description 单选框用于有一个选择,用户只能选择其中一个的场景。搭配uv-radio-group使用 * @tutorial https://www.uvui.cn/components/radio.html * @property {String | Number} name radio的名称 * @property {String} shape 形状,square为方形,circle为圆型 * @property {Boolean} disabled 是否禁用 * @property {String | Boolean} labelDisabled 是否禁止点击提示语选中单选框 * @property {String} activeColor 选中时的颜色,如设置parent的active-color将失效 * @property {String} inactiveColor 未选中的颜色 * @property {String | Number} iconSize 图标大小,单位px * @property {String | Number} labelSize label字体大小,单位px * @property {String | Number} label label提示文字,因为nvue下,直接slot进来的文字,由于特殊的结构,无法修改样式 * @property {String | Number} size 整体的大小 * @property {String} iconColor 图标颜色 * @property {String} labelColor label的颜色 * @property {Object} customStyle 组件的样式,对象形式 * * @event {Function} change 某个radio状态发生变化时触发(选中状态) * @example <uv-radio :labelDisabled="false">门掩黄昏,无计留春住</uv-radio> */ export default { name: "uv-radio", mixins: [mpMixin, mixin, props], data() { return { checked: false, // 当你看到这段代码的时候, // 父组件的默认值,因为头条小程序不支持在computed中使用this.parent.shape的形式 // 故只能使用如此方法 parentData: { iconSize: 12, labelSize: 14, labelColor: '#303133', labelDisabled: null, disabled: null, shape: null, activeColor: null, inactiveColor: null, size: 18, value: null, modelValue: null, iconColor: null, placement: 'row', borderBottom: false, iconPlacement: 'left' } } }, computed: { // 是否禁用,如果父组件uv-raios-group禁用的话,将会忽略子组件的配置 elDisabled() { return this.disabled !== '' ? this.disabled : this.parentData.disabled !== null ? this.parentData.disabled : false; }, // 是否禁用label点击 elLabelDisabled() { return this.labelDisabled !== '' ? this.labelDisabled : this.parentData.labelDisabled !== null ? this.parentData.labelDisabled : false; }, // 组件尺寸,对应size的值,默认值为21px elSize() { return this.size ? this.size : (this.parentData.size ? this.parentData.size : 21); }, // 组件的勾选图标的尺寸,默认12px elIconSize() { return this.iconSize ? this.iconSize : (this.parentData.iconSize ? this.parentData.iconSize : 12); }, // 组件选中激活时的颜色 elActiveColor() { return this.activeColor ? this.activeColor : (this.parentData.activeColor ? this.parentData.activeColor : '#2979ff'); }, // 组件选未中激活时的颜色 elInactiveColor() { return this.inactiveColor ? this.inactiveColor : (this.parentData.inactiveColor ? this.parentData.inactiveColor : '#c8c9cc'); }, // label的颜色 elLabelColor() { return this.labelColor ? this.labelColor : (this.parentData.labelColor ? this.parentData.labelColor : '#606266') }, // 组件的形状 elShape() { return this.shape ? this.shape : (this.parentData.shape ? this.parentData.shape : 'circle'); }, // label大小 elLabelSize() { return this.$uv.addUnit(this.labelSize ? this.labelSize : (this.parentData.labelSize ? this.parentData.labelSize : '15')) }, elIconColor() { const iconColor = this.iconColor ? this.iconColor : (this.parentData.iconColor ? this.parentData.iconColor : '#ffffff'); // 图标的颜色 if (this.elDisabled) { // disabled状态下,已勾选的radio图标改为elInactiveColor return this.checked ? this.elInactiveColor : 'transparent' } else { return this.checked ? iconColor : 'transparent' } }, iconClasses() { let classes = [] // 组件的形状 classes.push('uv-radio__icon-wrap--' + this.elShape) if (this.elDisabled) { classes.push('uv-radio__icon-wrap--disabled') } if (this.checked && this.elDisabled) { classes.push('uv-radio__icon-wrap--disabled--checked') } // 支付宝,头条小程序无法动态绑定一个数组类名,否则解析出来的结果会带有",",而导致失效 // #ifdef MP-ALIPAY || MP-TOUTIAO classes = classes.join(' ') // #endif return classes }, iconWrapStyle() { // radio的整体样式 const style = {} style.backgroundColor = this.checked && !this.elDisabled ? this.elActiveColor : '#ffffff' style.borderColor = this.checked && !this.elDisabled ? this.elActiveColor : this.elInactiveColor style.width = this.$uv.addUnit(this.elSize) style.height = this.$uv.addUnit(this.elSize) // 如果是图标在右边的话,移除它的右边距 if (this.parentData.iconPlacement === 'right') { style.marginRight = 0 } return style }, radioStyle() { const style = {} if (this.parentData.borderBottom && this.parentData.placement === 'row') { this.$uv.error('检测到您将borderBottom设置为true,需要同时将uv-radio-group的placement设置为column才有效') } // 当父组件设置了显示下边框并且排列形式为纵向时,给内容和边框之间加上一定间隔 if (this.parentData.borderBottom && this.parentData.placement === 'column') { // ios像素密度高,需要多一点的距离 style.paddingBottom = this.$uv.os() === 'ios' ? '12px' : '8px' } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } }, created() { this.init() }, methods: { init() { // 支付宝小程序不支持provide/inject,所以使用这个方法获取整个父组件,在created定义,避免循环引用 this.updateParentData() if (!this.parent) { this.$uv.error('uv-radio必须搭配uv-radio-group组件使用') } // 设置初始化时,是否默认选中的状态 this.$nextTick(()=>{ let parentValue = null; // #ifdef VUE2 parentValue = this.parentData.value; // #endif // #ifdef VUE3 parentValue = this.parentData.modelValue; // #endif this.checked = this.name === parentValue }) }, updateParentData() { this.getParentData('uv-radio-group') }, // 点击图标 iconClickHandler(e) { this.preventEvent(e) // 如果整体被禁用,不允许被点击 if (!this.elDisabled) { this.setRadioCheckedStatus() } }, // 横向两端排列时,点击组件即可触发选中事件 wrapperClickHandler(e) { this.parentData.iconPlacement === 'right' && this.iconClickHandler(e) }, // 点击label labelClickHandler(e) { this.preventEvent(e) // 如果按钮整体被禁用或者label被禁用,则不允许点击文字修改状态 if (!this.elLabelDisabled && !this.elDisabled) { this.setRadioCheckedStatus() } }, emitEvent() { // uv-radio的checked不为true时(意味着未选中),才发出事件,避免多次点击触发事件 if (!this.checked) { this.$emit('change', this.name) // 尝试调用uv-form的验证方法,进行一定延迟,否则微信小程序更新可能会不及时 this.$nextTick(() => { this.$uv.formValidate(this, 'change') }) } }, // 改变组件选中状态 // 这里的改变的依据是,更改本组件的checked值为true,同时通过父组件遍历所有uv-radio实例 // 将本组件外的其他uv-radio的checked都设置为false(都被取消选中状态),因而只剩下一个为选中状态 setRadioCheckedStatus() { this.emitEvent() // 将本组件标记为选中状态 this.checked = true typeof this.parent.unCheckedOther === 'function' && this.parent.unCheckedOther(this) } } } </script> <style lang="scss" scoped> $show-border: 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-radio-label-wrap-padding-right: 6px !default; $uv-radio-wrap-font-size: 20px !default; $uv-radio-wrap-border-width: 1px !default; $uv-radio-wrap-border-color: #c8c9cc !default; $uv-radio-line-height: 0 !default; $uv-radio-circle-border-radius: 100% !default; $uv-radio-square-border-radius: 3px !default; $uv-radio-checked-color: #fff !default; $uv-radio-checked-background-color: red !default; $uv-radio-checked-border-color: #2979ff !default; $uv-radio-disabled-background-color: #ebedf0 !default; $uv-radio-disabled--checked-color: #c8c9cc !default; $uv-radio-label-margin-left: 5px !default; $uv-radio-label-margin-right: 12px !default; $uv-radio-label-color: $uv-content-color !default; $uv-radio-label-font-size: 15px !default; $uv-radio-label-disabled-color: #c8c9cc !default; .uv-radio { /* #ifndef APP-NVUE */ @include flex(row); /* #endif */ overflow: hidden; flex-direction: row; align-items: center; &-label--left { flex-direction: row } &-label--right { flex-direction: row-reverse; justify-content: space-between } &__icon-wrap { /* #ifndef APP-NVUE */ box-sizing: border-box; // nvue下,border-color过渡有问题 transition-property: border-color, background-color, color; transition-duration: 0.2s; /* #endif */ color: $uv-content-color; @include flex; align-items: center; justify-content: center; color: transparent; text-align: center; font-size: $uv-radio-wrap-font-size; border-width: $uv-radio-wrap-border-width; border-color: $uv-radio-wrap-border-color; border-style: solid; /* #ifdef MP-TOUTIAO */ // 头条小程序兼容性问题,需要设置行高为0,否则图标偏下 &__icon { line-height: $uv-radio-line-height; } /* #endif */ &--circle { border-radius: $uv-radio-circle-border-radius; } &--square { border-radius: $uv-radio-square-border-radius; } &--checked { color: $uv-radio-checked-color; background-color: $uv-radio-checked-background-color; border-color: $uv-radio-checked-border-color; } &--disabled { background-color: $uv-radio-disabled-background-color !important; } &--disabled--checked { color: $uv-radio-disabled--checked-color !important; } } &__label { /* #ifndef APP-NVUE */ word-wrap: break-word; /* #endif */ margin-left: $uv-radio-label-margin-left; margin-right: $uv-radio-label-margin-right; color: $uv-radio-label-color; font-size: $uv-radio-label-font-size; &--disabled { color: $uv-radio-label-disabled-color; } } &__label-wrap { flex: 1; padding-left: $uv-radio-label-wrap-padding-right; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-radio/components/uv-radio/uv-radio.vue
Vue
unknown
12,064
export default { props: { // 绑定的值 value: { type: [String, Number, Boolean], default: '' }, modelValue: { type: [String, Number, Boolean], default: '' }, // 是否禁用全部radio disabled: { type: Boolean, default: false }, // 形状,circle-圆形,square-方形 shape: { type: String, default: 'circle' }, // 选中状态下的颜色,如设置此值,将会覆盖parent的activeColor值 activeColor: { type: String, default: '#2979ff' }, // 未选中的颜色 inactiveColor: { type: String, default: '#c8c9cc' }, // 标识符 name: { type: String, default: '' }, // 整个组件的尺寸,默认px size: { type: [String, Number], default: 18 }, // 布局方式,row-横向,column-纵向 placement: { type: String, default: 'row' }, // label的文本 label: { type: [String], default: '' }, // label的颜色 (默认 '#303133' ) labelColor: { type: [String], default: '#303133' }, // label的字体大小,px单位 labelSize: { type: [String, Number], default: 14 }, // 是否禁止点击文本操作checkbox(默认 false ) labelDisabled: { type: Boolean, default: false }, // 图标颜色 iconColor: { type: String, default: '#fff' }, // 图标的大小,单位px iconSize: { type: [String, Number], default: 12 }, // 竖向配列时,是否显示下划线 borderBottom: { type: Boolean, default: false }, // 图标与文字的对齐方式 iconPlacement: { type: String, default: 'left' }, ...uni.$uv?.props?.radioGroup } }
2301_77169380/AppruanjianApk
uni_modules/uv-radio/components/uv-radio-group/props.js
JavaScript
unknown
1,656
<template> <view class="uv-radio-group" :class="bemClass" :style="[$uv.addStyle(this.customStyle)]" > <slot></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'; /** * radioRroup 单选框父组件 * @description 单选框用于有一个选择,用户只能选择其中一个的场景。搭配uv-radio使用 * @tutorial https://www.uvui.cn/components/radio.html * @property {String | Number | Boolean} value 绑定的值 * @property {Boolean} disabled 是否禁用所有radio(默认 false ) * @property {String} shape 外观形状,shape-方形,circle-圆形(默认 circle ) * @property {String} activeColor 选中时的颜色,应用到所有子Radio组件(默认 '#2979ff' ) * @property {String} inactiveColor 未选中的颜色 (默认 '#c8c9cc' ) * @property {String} name 标识符 * @property {String | Number} size 组件整体的大小,单位px(默认 18 ) * @property {String} placement 布局方式,row-横向,column-纵向 (默认 'row' ) * @property {String} label 文本 * @property {String} labelColor label的颜色 (默认 '#303133' ) * @property {String | Number} labelSize label的字体大小,px单位 (默认 14 ) * @property {Boolean} labelDisabled 是否禁止点击文本操作checkbox(默认 false ) * @property {String} iconColor 图标颜色 (默认 '#ffffff' ) * @property {String | Number} iconSize 图标的大小,单位px (默认 12 ) * @property {Boolean} borderBottom placement为row时,是否显示下边框 (默认 false ) * @property {String} iconPlacement 图标与文字的对齐方式 (默认 'left' ) * @property {Object} customStyle 组件的样式,对象形式 * @event {Function} change 任一个radio状态发生变化时触发 * @example <uv-radio-group v-model="value"></uv-radio-group> */ export default { name: 'uv-radio-group', mixins: [mpMixin, mixin, props], computed: { // 这里computed的变量,都是子组件uv-radio需要用到的,由于头条小程序的兼容性差异,子组件无法实时监听父组件参数的变化 // 所以需要手动通知子组件,这里返回一个parentData变量,供watch监听,在其中去通知每一个子组件重新从父组件(uv-radio-group) // 拉取父组件新的变化后的参数 parentData() { const value = this.value || this.modelValue; return [value, this.disabled, this.inactiveColor, this.activeColor, this.size, this.labelDisabled, this.shape, this.iconSize, this.borderBottom, this.placement] }, bemClass() { // this.bem为一个computed变量,在mixin中 return this.bem('radio-group', ['placement']) }, }, watch: { // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件 parentData() { if (this.children.length) { this.children.map(child => { // 判断子组件(uv-radio)如果有init方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值) typeof(child.init) === 'function' && child.init() }) } }, }, data() { return { } }, created() { this.children = [] }, methods: { // 将其他的radio设置为未选中的状态 unCheckedOther(childInstance) { this.children.map(child => { // 所有子radio中,被操作组件实例的checked的值无需修改 if (childInstance !== child) { child.checked = false } }) const { name } = childInstance // 通过emit事件,设置父组件通过v-model双向绑定的值 // #ifdef VUE2 this.$emit('input', name) // #endif // #ifdef VUE3 this.$emit('update:modelValue',name) // #endif // 发出事件 this.$emit('change', name) }, } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-radio-group { flex: 1; &--row { @include flex; flex-wrap: wrap; } &--column { @include flex(column); } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-radio/components/uv-radio-group/uv-radio-group.vue
Vue
unknown
4,292
export default { props: { value: { type: [String, Number], default: 0 }, modelValue: { type: [String, Number], default: 0 }, // 要显示的星星数量 count: { type: [String, Number], default: 5 }, // 是否不可选中 disabled: { type: Boolean, default: false }, // 是否只读 readonly: { type: Boolean, default: false }, // 星星的大小,单位px size: { type: [String, Number], default: 18 }, // 未选中时的颜色 inactiveColor: { type: String, default: '#b2b2b2' }, // 选中的颜色 activeColor: { type: String, default: '#FA3534' }, // 星星之间的间距,单位px gutter: { type: [String, Number], default: 4 }, // 最少能选择的星星个数 minCount: { type: [String, Number], default: 1 }, // 是否允许半星 allowHalf: { type: Boolean, default: false }, // 选中时的图标(星星) activeIcon: { type: String, default: 'star-fill' }, // 未选中时的图标(星星) inactiveIcon: { type: String, default: 'star' }, // 是否可以通过滑动手势选择评分 touchable: { type: Boolean, default: false }, ...uni.$uv?.props?.rate } }
2301_77169380/AppruanjianApk
uni_modules/uv-rate/components/uv-rate/props.js
JavaScript
unknown
1,240
<template> <view class="uv-rate" :id="elId" ref="uv-rate" :style="[$uv.addStyle(customStyle)]" > <view class="uv-rate__content" @touchmove.stop="touchMove" @touchend.stop="touchEnd"> <view class="uv-rate__content__item" v-for="(item, index) in Number(count)" :key="index" :class="[elClass]"> <view class="uv-rate__content__item__icon-wrap" ref="uv-rate__content__item__icon-wrap" @tap.stop="clickHandler($event, index + 1)"> <uv-icon :name="Math.floor(activeIndex) > index? activeIcon : inactiveIcon" :color="disabled ? '#c8c9cc' : Math.floor(activeIndex) > index ? activeColor : inactiveColor" :custom-style="{ 'padding-left': $uv.addUnit(gutter / 2), 'padding-right': $uv.addUnit(gutter / 2) }" :size="size" ></uv-icon> </view> <view v-if="allowHalf" @tap.stop="clickHandler($event, index + 1)" class="uv-rate__content__item__icon-wrap uv-rate__content__item__icon-wrap--half" :style="[{ width: $uv.addUnit(rateWidth / 2)}]" ref="uv-rate__content__item__icon-wrap"> <uv-icon :name=" Math.ceil(activeIndex) > index ? activeIcon : inactiveIcon " :color=" disabled ? '#c8c9cc' : Math.ceil(activeIndex) > index ? activeColor : inactiveColor " :custom-style="{ 'padding-left': $uv.addUnit(gutter / 2), 'padding-right': $uv.addUnit(gutter / 2) }" :size="size"> </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'; // #ifdef APP-NVUE const dom = weex.requireModule("dom"); // #endif /** * rate 评分 * @description 该组件一般用于满意度调查,星型评分的场景 * @tutorial https://www.uvui.cn/components/rate.html * @property {String | Number} value 用于v-model双向绑定选中的星星数量 (默认 1 ) * @property {String | Number} count 最多可选的星星数量 (默认 5 ) * @property {Boolean} disabled 是否禁止用户操作 (默认 false ) * @property {Boolean} readonly 是否只读 (默认 false ) * @property {String | Number} size 星星的大小,单位px (默认 18 ) * @property {String} inactiveColor 未选中星星的颜色 (默认 '#b2b2b2' ) * @property {String} activeColor 选中的星星颜色 (默认 '#FA3534' ) * @property {String | Number} gutter 星星之间的距离 (默认 4 ) * @property {String | Number} minCount 最少选中星星的个数 (默认 1 ) * @property {Boolean} allowHalf 是否允许半星选择 (默认 false ) * @property {String} activeIcon 选中时的图标名,只能为uvui的内置图标 (默认 'star-fill' ) * @property {String} inactiveIcon 未选中时的图标名,只能为uvui的内置图标 (默认 'star' ) * @property {Boolean} touchable 是否可以通过滑动手势选择评分 (默认 'false' ) * @property {Object} customStyle 组件的样式,对象形式 * @event {Function} change 选中的星星发生变化时触发 * @example <uv-rate :count="count" :value="2"></uv-rate> */ export default { name: "uv-rate", mixins: [mpMixin, mixin, props], data() { return { // 生成一个唯一id,否则一个页面多个评分组件,会造成冲突 elId: '', elClass: '', rateBoxLeft: 0, // 评分盒子左边到屏幕左边的距离,用于滑动选择时计算距离 activeIndex: 0, rateWidth: 0, // 每个星星的宽度 // 标识是否正在滑动,由于iOS事件上touch比click先触发,导致快速滑动结束后,接着触发click,导致事件混乱而出错 moving: false } }, watch: { value(newVal){ this.activeIndex = newVal; }, modelValue(newVal){ this.activeIndex = newVal; } }, created() { this.activeIndex = Number(this.value || this.modelValue); this.elId = this.$uv.guid(); this.elClass = this.$uv.guid(); }, mounted() { this.init(); }, methods: { init() { this.$uv.sleep(200).then(() => { this.getRateItemRect(); this.getRateIconWrapRect(); }) }, // 获取评分组件盒子的布局信息 async getRateItemRect() { await this.$uv.sleep(); // uvui封装的获取节点的方法,详见文档 // #ifndef APP-NVUE this.$uvGetRect("#" + this.elId).then((res) => { this.rateBoxLeft = res.left; }); // #endif // #ifdef APP-NVUE dom.getComponentRect(this.$refs["uv-rate"], (res) => { this.rateBoxLeft = res.size.left; }); // #endif }, // 获取单个星星的尺寸 getRateIconWrapRect() { // uvui封装的获取节点的方法,详见文档 // #ifndef APP-NVUE this.$uvGetRect("." + this.elClass).then((res) => { this.rateWidth = res.width; }); // #endif // #ifdef APP-NVUE dom.getComponentRect(this.$refs["uv-rate__content__item__icon-wrap"][0], (res) => { this.rateWidth = res.size.width; }); // #endif }, // 手指滑动 touchMove(e) { // 如果禁止通过手动滑动选择,返回 if (!this.touchable) { return; } this.preventEvent(e); const x = e.changedTouches && e.changedTouches[0].pageX || e.detail && e.detail.pageX; this.getActiveIndex(x); }, // 停止滑动 touchEnd(e) { // 如果禁止通过手动滑动选择,返回 if (!this.touchable) { return; } this.preventEvent(e); const x = e.changedTouches && e.changedTouches[0].pageX || e.detail && e.detail.pageX; this.getActiveIndex(x); }, // 通过点击,直接选中 clickHandler(e, index) { // ios上,moving状态取消事件触发 if (this.$uv.os() === "ios" && this.moving) { return; } this.preventEvent(e); let x = 0; // 点击时,在nvue上,无法获得点击的坐标,所以无法实现点击半星选择 // #ifndef APP-NVUE x = e.changedTouches && e.changedTouches[0].pageX || e.detail && e.detail.pageX; // #endif // #ifdef APP-NVUE // nvue下,无法通过点击获得坐标信息,这里通过元素的位置尺寸值模拟坐标 x = index * this.rateWidth + this.rateBoxLeft; // #endif this.getActiveIndex(x, true); }, // 发出事件 changeEvent() { this.$emit("change", this.activeIndex); this.$emit("input", this.activeIndex); this.$emit("update:modelValue", this.activeIndex); }, // 获取当前激活的评分图标 getActiveIndex(x, isClick = false) { if (this.disabled || this.readonly) { return; } // 判断当前操作的点的x坐标值,是否在允许的边界范围内 const allRateWidth = this.rateWidth * this.count + this.rateBoxLeft; // 如果小于第一个图标的左边界,设置为最小值,如果大于所有图标的宽度,则设置为最大值 x = this.$uv.range(this.rateBoxLeft, allRateWidth, x) - this.rateBoxLeft // 滑动点相对于评分盒子左边的距离 const distance = x; // 滑动的距离,相当于多少颗星星 let index; // 判断是否允许半星 if (this.allowHalf) { index = Math.floor(distance / this.rateWidth); // 取余,判断小数的区间范围 const decimal = distance % this.rateWidth; if (decimal <= this.rateWidth / 2 && decimal > 0) { index += 0.5; } else if (decimal > this.rateWidth / 2) { index++; } } else { index = Math.floor(distance / this.rateWidth); // 取余,判断小数的区间范围 const decimal = distance % this.rateWidth; // 非半星时,只有超过了图标的一半距离,才认为是选择了这颗星 if (isClick) { if (decimal > 0) index++; } else { if (decimal > this.rateWidth / 2) index++; } } this.activeIndex = Math.min(index, this.count); // 对最少颗星星的限制 if (this.activeIndex < this.minCount) { this.activeIndex = this.minCount; } this.changeEvent(); // 设置延时为了让click事件在touchmove之前触发 setTimeout(() => { this.moving = true; }, 10); // 一定时间后,取消标识为移动中状态,是为了让click事件无效 setTimeout(() => { this.moving = false; }, 10); } } } </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-rate-margin: 0 !default; $uv-rate-padding: 0 !default; $uv-rate-item-icon-wrap-half-top: 0 !default; $uv-rate-item-icon-wrap-half-left: 0 !default; .uv-rate { @include flex; align-items: center; margin: $uv-rate-margin; padding: $uv-rate-padding; /* #ifndef APP-NVUE */ touch-action: none; /* #endif */ &__content { @include flex; &__item { position: relative; &__icon-wrap { &--half { position: absolute; overflow: hidden; top: $uv-rate-item-icon-wrap-half-top; left: $uv-rate-item-icon-wrap-half-left; } } } } } .uv-icon { /* #ifndef APP-NVUE */ box-sizing: border-box; /* #endif */ } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-rate/components/uv-rate/uv-rate.vue
Vue
unknown
9,319
export default { props: { // 默认的显示占位高度 showHeight: { type: [String, Number], default: 400 }, // 展开后是否显示"收起"按钮 toggle: { type: Boolean, default: false }, // 关闭时的提示文字 closeText: { type: String, default: '展开阅读全文' }, // 展开时的提示文字 openText: { type: String, default: '收起' }, // 提示的文字颜色 color: { type: String, default: '#2979ff' }, // 提示文字的大小 fontSize: { type: [String, Number], default: 14 }, // 是否显示阴影 // 此参数不能写在props/readMore.js中进行默认配置,因为使用了条件编译,在外部js中 // uni无法准确识别当前是否处于nvue还是非nvue下 shadowStyle: { type: Object, default: () => ({ // #ifndef APP-NVUE backgroundImage: 'linear-gradient(-180deg, rgba(255, 255, 255, 0) 0%, #fff 80%)', // #endif // #ifdef APP-NVUE // nvue上不支持设置复杂的backgroundImage属性 backgroundImage: 'linear-gradient(to top, #fff, rgba(255, 255, 255, 0.5))', // #endif paddingTop: '100px', marginTop: '-100px' }) }, // 段落首行缩进的字符个数 textIndent: { type: String, default: '2em' }, // open和close事件时,将此参数返回在回调参数中 name: { type: [String, Number], default: '' }, ...uni.$uv?.props?.readMore } }
2301_77169380/AppruanjianApk
uni_modules/uv-read-more/components/uv-read-more/props.js
JavaScript
unknown
1,444
<template> <view class="uv-read-more"> <view class="uv-read-more__content" :style="{ height: isLongContent && status === 'close' ? $uv.addUnit(showHeight) : $uv.addUnit(contentHeight,'px'), textIndent: textIndent }" > <view class="uv-read-more__content__inner" ref="uv-read-more__content__inner" :class="[elId]" > <slot></slot> </view> </view> <view class="uv-read-more__toggle" :style="[innerShadowStyle]" v-if="isLongContent" > <slot name="toggle"> <view class="uv-read-more__toggle__text" @tap="toggleReadMore" > <uv-text :text="status === 'close' ? closeText : openText" :color="color" :size="fontSize" :lineHeight="fontSize" margin="0 5px 0 0" ></uv-text> <view class="uv-read-more__toggle__icon"> <uv-icon :color="color" :size="fontSize + 2" :name="status === 'close' ? 'arrow-down' : 'arrow-up'" ></uv-icon> </view> </view> </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' // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') // #endif import props from './props.js'; /** * readMore 阅读更多 * @description 该组件一般用于内容较长,预先收起一部分,点击展开全部内容的场景。 * @tutorial https://www.uvui.cn/components/readMore.html * @property {String | Number} showHeight 内容超出此高度才会显示展开全文按钮,单位px(默认 400 ) * @property {Boolean} toggle 展开后是否显示收起按钮(默认 false ) * @property {String} closeText 关闭时的提示文字(默认 '展开阅读全文' ) * @property {String} openText 展开时的提示文字(默认 '收起' ) * @property {String} color 提示文字的颜色(默认 '#2979ff' ) * @property {String | Number} fontSize 提示文字的大小,单位px (默认 14 ) * @property {Object} shadowStyle 显示阴影的样式 * @property {String} textIndent 段落首行缩进的字符个数 (默认 '2em' ) * @property {String | Number} name 用于在 open 和 close 事件中当作回调参数返回 * @event {Function} open 内容被展开时触发 * @event {Function} close 内容被收起时触发 * @example <uv-read-more><rich-text :nodes="content"></rich-text></uv-read-more> */ export default { name: 'uv-read-more', mixins: [mpMixin, mixin, props], data() { return { isLongContent: false, // 是否需要隐藏一部分内容 status: 'close', // 当前隐藏与显示的状态,close-收起状态,open-展开状态 elId: '', // 生成唯一class contentHeight: 100, // 内容高度 } }, computed: { // 展开后无需阴影,收起时才需要阴影样式 innerShadowStyle() { if (this.status === 'open') return {} else return this.shadowStyle } }, created() { this.elId = this.$uv.guid(); }, mounted() { this.init() }, methods: { async init() { this.getContentHeight().then(height => { this.contentHeight = height // 判断高度,如果真实内容高度大于占位高度,则显示收起与展开的控制按钮 if (height > this.$uv.getPx(this.showHeight)) { this.isLongContent = true this.status = 'close' } }) }, // 获取内容的高度 async getContentHeight() { // 延时一定时间再获取节点 await this.$uv.sleep(30) return new Promise(resolve => { // #ifndef APP-NVUE this.$uvGetRect('.' + this.elId).then(res => { resolve(res.height) }) // #endif // #ifdef APP-NVUE const ref = this.$refs['uv-read-more__content__inner'] dom.getComponentRect(ref, (res) => { resolve(res.size.height) }) // #endif }) }, // 展开或者收起 toggleReadMore() { this.status = this.status === 'close' ? 'open' : 'close' // 如果toggle为false,隐藏"收起"部分的内容 if (this.toggle == false) this.isLongContent = false // 发出打开或者收齐的事件 this.$emit(this.status, this.name) } } } </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-read-more { &__content { overflow: hidden; color: $uv-content-color; font-size: 15px; text-align: left; } &__toggle { @include flex; justify-content: center; &__text { @include flex; align-items: center; justify-content: center; margin-top: 5px; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-read-more/components/uv-read-more/uv-read-more.vue
Vue
unknown
4,772
export default { props: { // 占父容器宽度的多少等分,总分为12份 span: { type: [String, Number], default: 12 }, // 指定栅格左侧的间隔数(总12栏) offset: { type: [String, Number], default: 0 }, // 水平排列方式,可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`) justify: { type: String, default: 'start' }, // 垂直对齐方式,可选值为top、center、bottom、stretch align: { type: String, default: 'stretch' }, // 文字对齐方式 textAlign: { type: String, default: 'left' }, ...uni.$uv?.props?.col } }
2301_77169380/AppruanjianApk
uni_modules/uv-row/components/uv-col/props.js
JavaScript
unknown
692
<template> <view class="uv-col" ref="uv-col" :class="[ 'uv-col-' + span ]" :style="[colStyle]" @tap="clickHandler" > <slot></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'; /** * CodeInput 栅格系统的列 * @description 该组件一般用于Layout 布局 通过基础的 12 分栏,迅速简便地创建布局 * @tutorial https://www.uvui.cn/components/Layout.html * @property {String | Number} span 栅格占据的列数,总12等份 (默认 12 ) * @property {String | Number} offset 分栏左边偏移,计算方式与span相同 (默认 0 ) * @property {String} justify 水平排列方式,可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`) (默认 'start' ) * @property {String} align 垂直对齐方式,可选值为top、center、bottom、stretch (默认 'stretch' ) * @property {String} textAlign 文字水平对齐方式 (默认 'left' ) * @property {Object} customStyle 定义需要用到的外部样式 * @event {Function} click col被点击,会阻止事件冒泡到row * @example <uv-col span="3" offset="3" > <view class="demo-layout bg-purple"></view> </uv-col> */ export default { name: 'uv-col', emits: ['click'], mixins: [mpMixin, mixin, props], data() { return { width: 0, parentData: { gutter: 0 }, gridNum: 12 } }, computed: { uJustify() { if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify else if (this.justify == 'around' || this.justify == 'between') return 'space-' + this.justify else return this.justify }, uAlignItem() { if (this.align == 'top') return 'flex-start' if (this.align == 'bottom') return 'flex-end' else return this.align }, colStyle() { const style = { // 这里写成"padding: 0 10px"的形式是因为nvue的需要 paddingLeft: this.$uv.addUnit(this.$uv.getPx(this.parentData.gutter)/2), paddingRight: this.$uv.addUnit(this.$uv.getPx(this.parentData.gutter)/2), alignItems: this.uAlignItem, justifyContent: this.uJustify, textAlign: this.textAlign, // #ifndef APP-NVUE // 在非nvue上,使用百分比形式 flex: `0 0 ${100 / this.gridNum * this.span}%`, marginLeft: 100 / 12 * this.offset + '%', // #endif // #ifdef APP-NVUE // 在nvue上,由于无法使用百分比单位,这里需要获取父组件的宽度,再计算得出该有对应的百分比尺寸 width: this.$uv.addUnit(Math.floor(this.width / this.gridNum * Number(this.span))), marginLeft: this.$uv.addUnit(Math.floor(this.width / this.gridNum * Number(this.offset))), // #endif } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } }, mounted() { this.init() }, methods: { async init() { // 支付宝小程序不支持provide/inject,所以使用这个方法获取整个父组件,在created定义,避免循环引用 this.updateParentData() this.width = await this.parent.getComponentWidth() }, updateParentData() { this.getParentData('uv-row') }, clickHandler(e) { this.$emit('click'); } }, } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-col { padding: 0; /* #ifndef APP-NVUE */ box-sizing:border-box; /* #endif */ /* #ifdef MP */ display: block; /* #endif */ } // nvue下百分比无效 /* #ifndef APP-NVUE */ .uv-col-0 { width: 0; } .uv-col-1 { width: calc(100%/12); } .uv-col-2 { width: calc(100%/12 * 2); } .uv-col-3 { width: calc(100%/12 * 3); } .uv-col-4 { width: calc(100%/12 * 4); } .uv-col-5 { width: calc(100%/12 * 5); } .uv-col-6 { width: calc(100%/12 * 6); } .uv-col-7 { width: calc(100%/12 * 7); } .uv-col-8 { width: calc(100%/12 * 8); } .uv-col-9 { width: calc(100%/12 * 9); } .uv-col-10 { width: calc(100%/12 * 10); } .uv-col-11 { width: calc(100%/12 * 11); } .uv-col-12 { width: calc(100%/12 * 12); } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-row/components/uv-col/uv-col.vue
Vue
unknown
4,313
export default { props: { // 给col添加间距,左右边距各占一半 gutter: { type: [String, Number], default: 0 }, // 水平排列方式,可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`) justify: { type: String, default: 'start' }, // 垂直对齐方式,可选值为top、center、bottom align: { type: String, default: 'center' }, ...uni.$uv?.props?.row } }
2301_77169380/AppruanjianApk
uni_modules/uv-row/components/uv-row/props.js
JavaScript
unknown
493
<template> <view class="uv-row" ref="uv-row" :style="[rowStyle]" @tap="clickHandler" > <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' // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') // #endif import props from './props.js'; /** * Row 栅格系统中的行 * @description 通过基础的 12 分栏,迅速简便地创建布局 * @tutorial https://www.uvui.cn/components/layout.html * @property {String | Number} gutter 栅格间隔,左右各为此值的一半,单位px (默认 0 ) * @property {String} justify 水平排列方式(微信小程序暂不支持) 可选值为`start`(或`flex-start`)、`end`(或`flex-end`)、`center`、`around`(或`space-around`)、`between`(或`space-between`) (默认 'start' ) * @property {String} align 垂直排列方式 (默认 'center' ) * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function} click row被点击 * @example <uv-row justify="space-between" customStyle="margin-bottom: 10px"></uv-row> */ export default { name: "uv-row", emits: ['click'], mixins: [mpMixin, mixin, props], data() { return { } }, computed: { uJustify() { if (this.justify == 'end' || this.justify == 'start') return 'flex-' + this.justify else if (this.justify == 'around' || this.justify == 'between') return 'space-' + this.justify else return this.justify }, uAlignItem() { if (this.align == 'top') return 'flex-start' if (this.align == 'bottom') return 'flex-end' else return this.align }, rowStyle() { const style = { alignItems: this.uAlignItem, justifyContent: this.uJustify } // 通过给uv-row左右两边的负外边距,消除uv-col在有gutter时,第一个和最后一个元素的左内边距和右内边距造成的影响 if(this.gutter) { style.marginLeft = this.$uv.addUnit(-Number(this.gutter)/2) style.marginRight = this.$uv.addUnit(-Number(this.gutter)/2) } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } }, methods: { clickHandler(e) { this.$emit('click') }, async getComponentWidth() { // 延时一定时间,以确保节点渲染完成 await this.$uv.sleep() return new Promise(resolve => { // uvui封装的获取节点的方法,详见文档 // #ifndef APP-NVUE this.$uvGetRect('.uv-row').then(res => { resolve(res.width) }) // #endif // #ifdef APP-NVUE // nvue的dom模块用于获取节点 dom.getComponentRect(this.$refs['uv-row'], (res) => { resolve(res.size.width) }) // #endif }) }, } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-row { @include flex; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-row/components/uv-row/uv-row.vue
Vue
unknown
2,956
<template> <view class="uv-safe-bottom" :style="[style]" :class="[!isNvue && 'uv-safe-area-inset-bottom']" > </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' /** * SafeBottom 底部安全区 * @description 这个适配,主要是针对IPhone X等一些底部带指示条的机型,指示条的操作区域与页面底部存在重合,容易导致用户误操作,因此我们需要针对这些机型进行底部安全区适配。 * @tutorial https://www.uvui.cn/components/safeAreaInset.html * @property {type} prop_name * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function()} * @example <uv-status-bar></uv-status-bar> */ export default { name: "uv-safe-bottom", mixins: [mpMixin, mixin], data() { return { safeAreaBottomHeight: 0, isNvue: false, }; }, computed: { style() { const style = {}; // #ifdef APP-NVUE || MP-TOUTIAO || MP-LARK // nvue下,高度使用js计算填充 style.height = this.$uv.addUnit(this.$uv.sys()?.safeAreaInsets?.bottom, 'px'); // #endif return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)); }, }, mounted() { // #ifdef APP-NVUE // 标识为是否nvue this.isNvue = true; // #endif }, }; </script> <style lang="scss" scoped> .uv-safe-bottom { /* #ifndef APP-NVUE */ width: 100%; /* #endif */ } /* #ifndef APP-NVUE */ // 历遍生成4个方向的底部安全区 @each $d in top, right, bottom, left { .uv-safe-area-inset-#{$d} { padding-#{$d}: 0; padding-#{$d}: constant(safe-area-inset-#{$d}); padding-#{$d}: env(safe-area-inset-#{$d}); } } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-safe-bottom/components/uv-safe-bottom/uv-safe-bottom.vue
Vue
unknown
1,801
// 引入bindingx,此库类似于微信小程序wxs,目的是让js运行在视图层,减少视图层和逻辑层的通信折损 const BindingX = uni.requireNativePlugin('bindingx') export default { methods: { // 此处不写注释,请自行体会 nvueScrollHandler(e) { if (this.indicator) { const anchor = this.$refs['uv-scroll-list__scroll-view'].ref const element = this.$refs['uv-scroll-list__indicator__line__bar'].ref const scrollLeft = e.contentOffset.x const contentSize = e.contentSize.width const { scrollWidth } = this const barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth // 在安卓和iOS上,需要除的倍数不一样,iOS需要除以2 const actionNum = this.$uv.os() === 'ios' ? 2 : 1 const expression = `(x / ${actionNum}) / ${contentSize - scrollWidth} * ${this.$uv.getPx(this.$uv.addUnit(barAllMoveWidth))}` BindingX.bind({ anchor, eventType: 'scroll', props: [{ element, property: 'transform.translateX', expression }] }) } } } }
2301_77169380/AppruanjianApk
uni_modules/uv-scroll-list/components/uv-scroll-list/nvue.js
JavaScript
unknown
1,072
export default { props: { // 指示器的整体宽度 indicatorWidth: { type: [String, Number], default: 50 }, // 滑块的宽度 indicatorBarWidth: { type: [String, Number], default: 20 }, // 是否显示面板指示器 indicator: { type: Boolean, default: true }, // 指示器非激活颜色 indicatorColor: { type: String, default: '#f2f2f2' }, // 指示器的激活颜色 indicatorActiveColor: { type: String, default: '#3c9cff' }, // 指示器样式,可通过bottom,left,right进行定位 indicatorStyle: { type: [String, Object], default: '' }, ...uni.$uv?.props?.scrollList } }
2301_77169380/AppruanjianApk
uni_modules/uv-scroll-list/components/uv-scroll-list/props.js
JavaScript
unknown
666
<template> <view class="uv-scroll-list" ref="uv-scroll-list" > <!-- #ifdef APP-NVUE --> <!-- nvue使用bindingX实现,以得到更好的性能 --> <scroller class="uv-scroll-list__scroll-view" ref="uv-scroll-list__scroll-view" scroll-direction="horizontal" :show-scrollbar="false" :offset-accuracy="1" @scroll="nvueScrollHandler" > <view class="uv-scroll-list__scroll-view__content"> <slot /> </view> </scroller> <!-- #endif --> <!-- #ifndef APP-NVUE --> <!-- #ifdef MP-WEIXIN || APP-VUE || H5 || MP-QQ --> <!-- 以上平台,支持wxs --> <scroll-view class="uv-scroll-list__scroll-view" scroll-x @scroll="wxs.scroll" @scrolltoupper="wxs.scrolltoupper" @scrolltolower="wxs.scrolltolower" :data-scrollWidth="scrollWidth" :data-barWidth="$uv.getPx(indicatorBarWidth)" :data-indicatorWidth="$uv.getPx(indicatorWidth)" :show-scrollbar="false" :upper-threshold="0" :lower-threshold="0" :data-unit="$uv.unit" > <!-- #endif --> <!-- #ifndef APP-NVUE || MP-WEIXIN || H5 || APP-VUE || MP-QQ --> <!-- 非以上平台,只能使用普通js实现 --> <scroll-view class="uv-scroll-list__scroll-view" scroll-x @scroll="scrollHandler" @scrolltoupper="scrolltoupperHandler" @scrolltolower="scrolltolowerHandler" :show-scrollbar="false" :upper-threshold="0" :lower-threshold="0" > <!-- #endif --> <view class="uv-scroll-list__scroll-view__content"> <slot /> </view> </scroll-view> <!-- #endif --> <view class="uv-scroll-list__indicator" v-if="indicator" :style="[$uv.addStyle(indicatorStyle)]" > <view class="uv-scroll-list__indicator__line" :style="[lineStyle]" > <view class="uv-scroll-list__indicator__line__bar" :style="[barStyle]" ref="uv-scroll-list__indicator__line__bar" ></view> </view> </view> <!-- 避免报错 --> <!-- #ifdef H5 --> <view v-else class="uv-scroll-list__indicator__line__bar"></view> <!-- #endif --> </view> </template> <script src="./scrollWxs.wxs" module="wxs" lang="wxs"></script> <script> /** * scrollList 横向滚动列表 * @description 该组件一般用于同时展示多个商品、分类的场景,也可以完成左右滑动的列表。 * @tutorial https://www.uviewui.com/components/scrollList.html * @property {String | Number} indicatorWidth 指示器的整体宽度 (默认 50 ) * @property {String | Number} indicatorBarWidth 滑块的宽度 (默认 20 ) * @property {Boolean} indicator 是否显示面板指示器 (默认 true ) * @property {String} indicatorColor 指示器非激活颜色 (默认 '#f2f2f2' ) * @property {String} indicatorActiveColor 指示器的激活颜色 (默认 '#3c9cff' ) * @property {String | Object} indicatorStyle 指示器样式,可通过bottom,left,right进行定位 * @event {Function} left 滑动到左边时触发 * @event {Function} right 滑动到右边时触发 * @example */ // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') import nvueMixin from "./nvue.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' import props from './props.js'; export default { name: 'uv-scroll-list', // #ifndef APP-NVUE mixins: [mpMixin, mixin, props], // #endif // #ifdef APP-NVUE mixins: [mpMixin, mixin, nvueMixin, props], // #endif data() { return { scrollInfo: { scrollLeft: 0, scrollWidth: 0 }, scrollWidth: 0 } }, computed: { // 指示器为线型的样式 barStyle() { const style = {} // #ifndef APP-NVUE || MP-WEIXIN || H5 || APP-VUE || MP-QQ // 此为普通js方案,只有在非nvue和不支持wxs方案的端才使用、 // 此处的计算理由为:scroll-view的滚动距离与目标滚动距离(scroll-view的实际宽度减去包裹元素的宽度)之比,等于滑块当前移动距离与总需 // 滑动距离(指示器的总宽度减去滑块宽度)的比值 const scrollLeft = this.scrollInfo.scrollLeft, scrollWidth = this.scrollInfo.scrollWidth, barAllMoveWidth = this.indicatorWidth - this.indicatorBarWidth const x = scrollLeft / (scrollWidth - this.scrollWidth) * this.$uv.getPx(this.$uv.addUnit(barAllMoveWidth)) style.transform = `translateX(${ x }px)` // #endif // 设置滑块的宽度和背景色,是每个平台都需要的 style.width = this.$uv.addUnit(this.indicatorBarWidth) style.backgroundColor = this.indicatorActiveColor return style }, lineStyle() { const style = {} // 指示器整体的样式,需要设置其宽度和背景色 style.width = this.$uv.addUnit(this.indicatorWidth) style.backgroundColor = this.indicatorColor return style } }, mounted() { this.init() }, methods: { init() { this.getComponentWidth() }, // #ifndef APP-NVUE || MP-WEIXIN || H5 || APP-VUE || MP-QQ // scroll-view触发滚动事件 scrollHandler(e) { this.scrollInfo = e.detail }, scrolltoupperHandler() { this.scrollEvent('left') this.scrollInfo.scrollLeft = 0 }, scrolltolowerHandler() { this.scrollEvent('right') // 在普通js方案中,滚动到右边时,通过设置this.scrollInfo,模拟出滚动到右边的情况 // 因为上方是用过computed计算的,设置后,会自动调整滑块的位置 this.scrollInfo.scrollLeft = this.$uv.getPx(this.indicatorWidth) - this.$uv.getPx(this.indicatorBarWidth) }, // #endif scrollEvent(status) { this.$emit(status) }, // 获取组件的宽度 async getComponentWidth() { // 延时一定时间,以获取dom尺寸 await this.$uv.sleep(30) // #ifndef APP-NVUE this.$uvGetRect('.uv-scroll-list').then(size => { this.scrollWidth = size.width }) // #endif // #ifdef APP-NVUE const ref = this.$refs['uv-scroll-list'] ref && dom.getComponentRect(ref, (res) => { this.scrollWidth = res.size.width }) // #endif }, } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-scroll-list { padding-bottom: 10px; &__scroll-view { @include flex; &__content { @include flex; } } &__indicator { @include flex; justify-content: center; margin-top: 15px; &__line { width: 60px; height: 4px; border-radius: 100px; overflow: hidden; &__bar { width: 20px; height: 4px; border-radius: 100px; } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-scroll-list/components/uv-scroll-list/uv-scroll-list.vue
Vue
unknown
6,662
export default { props: { value: { type: [String, Number], default: '' }, modelValue: { type: [String, Number], default: '' }, // 搜索框形状,round-圆形,square-方形 shape: { type: String, default: 'round' }, // 搜索框背景色,默认值#f2f2f2 bgColor: { type: String, default: '#f2f2f2' }, // 占位提示文字 placeholder: { type: String, default: '请输入关键字' }, // 是否启用清除控件 clearabled: { type: Boolean, default: true }, // 是否自动聚焦 focus: { type: Boolean, default: false }, // 是否在搜索框右侧显示取消按钮 showAction: { type: Boolean, default: true }, // 右边控件的样式 actionStyle: { type: Object, default: () => ({}) }, // 取消按钮文字 actionText: { type: String, default: '搜索' }, // 输入框内容对齐方式,可选值为 left|center|right inputAlign: { type: String, default: 'left' }, // input输入框的样式,可以定义文字颜色,大小等,对象形式 inputStyle: { type: Object, default: () => ({}) }, // 是否禁用输入框 disabled: { type: Boolean, default: false }, // 边框颜色 borderColor: { type: String, default: 'transparent' }, // 搜索图标的颜色,默认同输入框字体颜色 searchIconColor: { type: String, default: '#909399' }, // 输入框字体颜色 color: { type: String, default: '#606266' }, // placeholder的颜色 placeholderColor: { type: String, default: '#909399' }, // 左边输入框的图标,可以为uvui图标名称或图片路径 searchIcon: { type: String, default: 'search' }, searchIconSize: { type: [Number, String], default: 22 }, // 组件与其他上下左右元素之间的距离,带单位的字符串形式,如"30px"、"30px 20px"等写法 margin: { type: String, default: '0' }, // 开启showAction时,是否在input获取焦点时才显示 animation: { type: Boolean, default: false }, // 输入框最大能输入的长度,-1为不限制长度(来自uniapp文档) maxlength: { type: [String, Number], default: -1 }, // 搜索框高度,单位px height: { type: [String, Number], default: 32 }, // 搜索框左侧文本 label: { type: [String, Number, null], default: null }, // 搜索框扩展样式 boxStyle: { type: [String, Object], default: () => ({}) }, ...uni.$uv?.props?.search } }
2301_77169380/AppruanjianApk
uni_modules/uv-search/components/uv-search/props.js
JavaScript
unknown
2,564
<template> <view class="uv-search" @tap="clickHandler" :style="[{ margin: margin, }, $uv.addStyle(customStyle)]" > <view class="uv-search__content" :style="[{ backgroundColor: bgColor, borderRadius: shape == 'round' ? '100px' : '4px', borderColor: borderColor, },$uv.addStyle(boxStyle)]" > <view class="uv-search__content__disabled" v-if="disabled"></view> <slot name="prefix"> <view class="uv-search__content__icon"> <uv-icon @tap="clickIcon" :size="searchIconSize" :name="searchIcon" :color="searchIconColor ? searchIconColor : color" ></uv-icon> </view> </slot> <input confirm-type="search" @blur="blur" :value="keyword" @confirm="search" @input="inputChange" :disabled="disabled" @focus="getFocus" :focus="focus" :maxlength="maxlength" placeholder-class="uv-search__content__input--placeholder" :placeholder="placeholder" :placeholder-style="`color: ${placeholderColor}`" class="uv-search__content__input" type="text" :style="[{ textAlign: inputAlign, color: color, backgroundColor: bgColor, height: $uv.addUnit(height) }, inputStyle]" /> <view class="uv-search__content__icon uv-search__content__close" v-if="keyword && clearabled && focused" @tap="clear" > <uv-icon name="close" size="11" color="#ffffff" customStyle="line-height: 12px" ></uv-icon> </view> <slot name="suffix"></slot> </view> <text :style="[actionStyle]" class="uv-search__action" :class="[(showActionBtn || show) && 'uv-search__action--active']" @tap.stop.prevent="custom" >{{ actionText }}</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' import props from './props.js'; /** * search 搜索框 * @description 搜索组件,集成了常见搜索框所需功能,用户可以一键引入,开箱即用。 * @tutorial https://www.uvui.cn/components/search.html * @property {String} value/v-model 输入框初始值 * @property {String} shape 搜索框形状,round-圆形,square-方形(默认 'round' ) * @property {String} bgColor 搜索框背景颜色(默认 '#f2f2f2' ) * @property {String} placeholder 占位文字内容(默认 '请输入关键字' ) * @property {Boolean} clearabled 是否启用清除控件(默认 true ) * @property {Boolean} focus 是否自动获得焦点(默认 false ) * @property {Boolean} showAction 是否显示右侧控件(默认 true ) * @property {Object} actionStyle 右侧控件的样式,对象形式 * @property {String} actionText 右侧控件文字(默认 '搜索' ) * @property {String} inputAlign 输入框内容水平对齐方式 (默认 'left' ) * @property {Object} inputStyle 自定义输入框样式,对象形式 * @property {Boolean} disabled 是否启用输入框(默认 false ) * @property {String} borderColor 边框颜色,配置了颜色,才会有边框 (默认 'transparent' ) * @property {String} searchIconColor 搜索图标的颜色,默认同输入框字体颜色 (默认 '#909399' ) * @property {Number | String} searchIconSize 搜索图标的字体,默认22 * @property {String} color 输入框字体颜色(默认 '#606266' ) * @property {String} placeholderColor placeholder的颜色(默认 '#909399' ) * @property {String} searchIcon 输入框左边的图标,可以为uvui图标名称或图片路径 (默认 'search' ) * @property {String} margin 组件与其他上下左右元素之间的距离,带单位的字符串形式,如"30px" (默认 '0' ) * @property {Boolean} animation 是否开启动画,见上方说明(默认 false ) * @property {String | Number} maxlength 输入框最大能输入的长度,-1为不限制长度 (默认 '-1' ) * @property {String | Number} height 输入框高度,单位px(默认 64 ) * @property {String | Number} label 搜索框左边显示内容 * @property {Object} boxStyle 自定义内容框样式,设置padding * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function} change 输入框内容发生变化时触发 * @event {Function} search 用户确定搜索时触发,用户按回车键,或者手机键盘右下角的"搜索"键时触发 * @event {Function} custom 用户点击右侧控件时触发 * @event {Function} clear 用户点击清除按钮时触发 * @example <uv-search placeholder="日照香炉生紫烟" v-model="keyword"></uv-search> */ export default { name: "uv-search", emits: ['click', 'input', 'change', 'clear', 'search', 'custom', 'focus', 'blur', 'clickIcon', 'update:modelValue'], mixins: [mpMixin, mixin, props], data() { return { keyword: '', showClear: false, // 是否显示右边的清除图标 show: false, // 标记input当前状态是否处于聚焦中,如果是,才会显示右侧的清除控件 focused: this.focus }; }, created() { // #ifndef VUE3 this.keyword = this.value; // #endif // #ifdef VUE3 this.keyword = this.modelValue; // #endif }, watch: { value(nVal){ this.keyword = nVal; }, modelValue(nVal){ this.keyword = nVal; } }, computed: { showActionBtn() { return !this.animation && this.showAction } }, methods: { keywordChange(){ this.$emit('input', this.keyword) this.$emit('update:modelValue', this.keyword) this.$emit('change', this.keyword); }, // 目前HX2.6.9 v-model双向绑定无效,故监听input事件获取输入框内容的变化 inputChange(e) { this.keyword = e.detail.value; this.keywordChange(); }, // 清空输入 // 也可以作为用户通过this.$refs形式调用清空输入框内容 clear() { this.keyword = ''; this.$nextTick(() => { this.$emit('clear'); }) this.keywordChange(); }, // 确定搜索 search(e) { this.$emit('search', e.detail.value); try { // 收起键盘 uni.hideKeyboard(); } catch (e) {} }, // 点击右边自定义按钮的事件 custom() { this.$emit('custom', this.keyword); try { // 收起键盘 uni.hideKeyboard(); } catch (e) {} }, // 获取焦点 getFocus() { this.focused = true; // 开启右侧搜索按钮展开的动画效果 if (this.animation && this.showAction) this.show = true; this.$emit('focus', this.keyword); }, // 失去焦点 blur() { // 最开始使用的是监听图标@touchstart事件,自从hx2.8.4后,此方法在微信小程序出错 // 这里改为监听点击事件,手点击清除图标时,同时也发生了@blur事件,导致图标消失而无法点击,这里做一个延时 setTimeout(() => { this.focused = false; }, 100) this.show = false; this.$emit('blur', this.keyword); }, // 点击搜索框,只有disabled=true时才发出事件,因为禁止了输入,意味着是想跳转真正的搜索页 clickHandler() { if (this.disabled) this.$emit('click'); }, // 点击左边图标 clickIcon() { this.$emit('clickIcon'); } } } </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-search-content-padding: 0 10px !default; $uv-search-label-color: $uv-main-color !default; $uv-search-label-font-size: 14px !default; $uv-search-label-margin: 0 4px !default; $uv-search-close-size: 20px !default; $uv-search-close-radius: 100px !default; $uv-search-close-bgColor: #C6C7CB !default; $uv-search-close-transform: scale(0.82) !default; $uv-search-input-font-size: 14px !default; $uv-search-input-margin: 0 15px 0 5px !default; $uv-search-input-color: $uv-main-color !default; $uv-search-input-placeholder-color: $uv-tips-color !default; $uv-search-action-font-size: 14px !default; $uv-search-action-color: $uv-main-color !default; $uv-search-action-width: 0 !default; $uv-search-action-active-width: 40px !default; $uv-search-action-margin-left: 5px !default; /* #ifdef H5 */ // iOS15在H5下,hx的某些版本,input type=search时,会多了一个搜索图标,进行移除 [type="search"]::-webkit-search-decoration { display: none; } /* #endif */ .uv-search { @include flex(row); align-items: center; flex: 1; &__content { position: relative; @include flex; align-items: center; padding: $uv-search-content-padding; flex: 1; justify-content: space-between; border-width: 1px; border-color: transparent; border-style: solid; overflow: hidden; &__icon { @include flex; align-items: center; } &__label { color: $uv-search-label-color; font-size: $uv-search-label-font-size; margin: $uv-search-label-margin; } &__close { width: $uv-search-close-size; height: $uv-search-close-size; border-top-left-radius: $uv-search-close-radius; border-top-right-radius: $uv-search-close-radius; border-bottom-left-radius: $uv-search-close-radius; border-bottom-right-radius: $uv-search-close-radius; background-color: $uv-search-close-bgColor; @include flex(row); align-items: center; justify-content: center; transform: $uv-search-close-transform; } &__input { flex: 1; font-size: $uv-search-input-font-size; line-height: 1; margin: $uv-search-input-margin; color: $uv-search-input-color; &--placeholder { color: $uv-search-input-placeholder-color; } } &__disabled { position: absolute; left: 0; top: 0; bottom: 0; right: 0; z-index: 2; } } &__action { font-size: $uv-search-action-font-size; color: $uv-search-action-color; width: $uv-search-action-width; overflow: hidden; transition-property: width; transition-duration: 0.3s; /* #ifndef APP-NVUE */ white-space: nowrap; /* #endif */ text-align: center; &--active { width: $uv-search-action-active-width; margin-left: $uv-search-action-margin-left; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-search/components/uv-search/uv-search.vue
Vue
unknown
10,399
export default { props: { // 是否展示骨架组件 loading: { type: Boolean, default: true }, // 是否开启动画效果 animate: { type: Boolean, default: true }, // 段落占位图行数 rows: { type: [String, Number], default: 0 }, // 段落占位图的宽度 rowsWidth: { type: [String, Number, Array], default: '100%' }, // 段落占位图的高度 rowsHeight: { type: [String, Number, Array], default: 18 }, // 段落占位图的左边距 rowsLeft: { type: [String, Number, Array], default: 0 }, // 是否展示标题占位图 title: { type: Boolean, default: true }, // 段落标题的宽度 titleWidth: { type: [String, Number], default: '50%' }, // 段落标题的高度 titleHeight: { type: [String, Number], default: 18 }, // 是否展示头像占位图 avatar: { type: Boolean, default: false }, // 头像占位图大小 avatarSize: { type: [String, Number], default: 32 }, // 头像占位图的形状,circle-圆形,square-方形 avatarShape: { type: String, default: 'circle' }, ...uni.$uv?.props?.skeleton } }
2301_77169380/AppruanjianApk
uni_modules/uv-skeleton/components/uv-skeleton/props.js
JavaScript
unknown
1,179
<template> <view class="uv-skeleton"> <view class="uv-skeleton__wrapper" ref="uv-skeleton__wrapper" v-if="loading" style="display: flex; flex-direction: row;" > <view class="uv-skeleton__wrapper__avatar" v-if="avatar" :class="[`uv-skeleton__wrapper__avatar--${avatarShape}`, animate && 'animate']" :style="{ height: $uv.addUnit(avatarSize), width: $uv.addUnit(avatarSize) }" ></view> <view class="uv-skeleton__wrapper__content" ref="uv-skeleton__wrapper__content" style="flex: 1;" > <view class="uv-skeleton__wrapper__content__title" v-if="title" :style="{ width: uTitleWidth, height: $uv.addUnit(titleHeight), }" :class="[animate && 'animate']" ></view> <view class="uv-skeleton__wrapper__content__rows" :class="[animate && 'animate']" v-for="(item, index) in rowsArray" :key="index" :style="{ width: item.width, height: item.height, marginTop: item.marginTop, marginLeft: item.marginLeft }" > </view> </view> </view> <slot v-else /> </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 // 由于weex为阿里的KPI业绩考核的产物,所以不支持百分比单位,这里需要通过dom查询组件的宽度 const dom = uni.requireNativePlugin('dom') const animation = uni.requireNativePlugin('animation') // #endif /** * Skeleton 骨架屏 * @description 骨架屏一般用于页面在请求远程数据尚未完成时,页面用灰色块预显示本来的页面结构,给用户更好的体验。 * @tutorial https://www.uvui.cn/components/skeleton.html * @property {Boolean} loading 是否显示骨架占位图,设置为false将会展示子组件内容 (默认 true ) * @property {Boolean} animate 是否开启动画效果 (默认 true ) * @property {String | Number} rows 段落占位图行数 (默认 0 ) * @property {String | Number | Array} rowsWidth 段落占位图的宽度,可以为百分比,数值,带单位字符串等,可通过数组传入指定每个段落行的宽度 (默认 '100%' ) * @property {String | Number | Array} rowsHeight 段落的高度 (默认 18 ) * @property {String | Number | Array} rowsLeft 段落的左边距 (默认 0 ) * @property {Boolean} title 是否展示标题占位图 (默认 true ) * @property {String | Number} titleWidth 标题的宽度 (默认 '50%' ) * @property {String | Number} titleHeight 标题的高度 (默认 18 ) * @property {Boolean} avatar 是否展示头像占位图 (默认 false ) * @property {String | Number} avatarSize 头像占位图大小 (默认 32 ) * @property {String} avatarShape 头像占位图的形状,circle-圆形,square-方形 (默认 'circle' ) * @example <uv-skeleton :loading="true" :animate="true"></uv-skeleton> */ export default { name: 'uv-skeleton', mixins: [mpMixin, mixin, props], data() { return { width: 0, } }, watch: { loading() { this.getComponentWidth() } }, computed: { rowsArray() { if (/%$/.test(this.rowsHeight)) { this.$uv.error('rowsHeight参数不支持百分比单位') } const rows = [] for (let i = 0; i < this.rows; i++) { let item = {}, // 需要预防超出数组边界的情况 rowWidth = this.$uv.test.array(this.rowsWidth) ? (this.rowsWidth[i] || (i === this.row - 1 ? '70%' : '100%')) : i === this.rows - 1 ? '70%' : this.rowsWidth, rowHeight = this.$uv.test.array(this.rowsHeight) ? (this.rowsHeight[i] || '18px') : this.rowsHeight, rowLeft = this.$uv.test.array(this.rowsLeft) ? (this.rowsLeft[i] || 0) : this.rowsLeft; // 如果有title占位图,第一个段落占位图的外边距需要大一些,如果没有title占位图,第一个段落占位图则无需外边距 // 之所以需要这么做,是因为weex的无能,以提升性能为借口不支持css的一些伪类 item.marginTop = !this.title && i === 0 ? 0 : this.title && i === 0 ? '20px' : '12px' // 如果设置的为百分比的宽度,转换为px值,因为nvue不支持百分比单位 if (/%$/.test(rowWidth)) { // 通过parseInt提取出百分比单位中的数值部分,除以100得到百分比的小数值 item.width = this.$uv.addUnit(this.width * parseInt(rowWidth) / 100) } else { item.width = this.$uv.addUnit(rowWidth) } item.height = this.$uv.addUnit(rowHeight) item.marginLeft = this.$uv.addUnit(rowLeft) rows.push(item) } // console.log(rows); return rows }, uTitleWidth() { let tWidth = 0 if (/%$/.test(this.titleWidth)) { // 通过parseInt提取出百分比单位中的数值部分,除以100得到百分比的小数值 tWidth = this.$uv.addUnit(this.width * parseInt(this.titleWidth) / 100) } else { tWidth = this.$uv.addUnit(this.titleWidth) } return this.$uv.addUnit(tWidth) }, }, mounted() { this.init() }, methods: { init() { this.getComponentWidth() // #ifdef APP-NVUE this.loading && this.animate && this.setNvueAnimation() // #endif }, async setNvueAnimation() { // #ifdef APP-NVUE // 为了让opacity:1的状态保持一定时间,这里做一个延时 await this.$uv.sleep(500) const skeleton = this.$refs['uv-skeleton__wrapper']; skeleton && this.loading && this.animate && animation.transition(skeleton, { styles: { opacity: 0.5 }, duration: 600, }, () => { // 这里无需判断是否loading和开启动画状态,因为最终的状态必须达到opacity: 1,否则可能 // 会停留在opacity: 0.5的状态中 animation.transition(skeleton, { styles: { opacity: 1 }, duration: 600, }, () => { // 只有在loading中时,才执行动画 this.loading && this.animate && this.setNvueAnimation() }) }) // #endif }, // 获取组件的宽度 async getComponentWidth() { // 延时一定时间,以获取dom尺寸 await this.$uv.sleep(20) // #ifndef APP-NVUE this.$uvGetRect('.uv-skeleton__wrapper__content').then(size => { this.width = size.width }) // #endif // #ifdef APP-NVUE const ref = this.$refs['uv-skeleton__wrapper__content'] ref && dom.getComponentRect(ref, (res) => { this.width = res.size.width }) // #endif } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @mixin background { /* #ifdef APP-NVUE */ background-color: #F1F2F4; /* #endif */ /* #ifndef APP-NVUE */ background: linear-gradient(90deg, #F1F2F4 25%, #e6e6e6 37%, #F1F2F4 50%); background-size: 400% 100%; /* #endif */ } .uv-skeleton { flex: 1; &__wrapper { @include flex(row); &__avatar { @include background; margin-right: 15px; &--circle { border-radius: 100px; } &--square { border-radius: 4px; } } &__content { flex: 1; &__rows, &__title { @include background; border-radius: 3px; } } } } /* #ifndef APP-NVUE */ .animate { animation: skeleton 1.8s ease infinite } @keyframes skeleton { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-skeleton/components/uv-skeleton/uv-skeleton.vue
Vue
unknown
7,656
<template> <view class="uv-skeleton"> <view v-if="loading"> <view v-for="(item, index) in elements" :key="index"> <!-- 横向并列布局 --> <view class="uv-skeleton__group" :style="[style(item)]" v-if="item.type=='flex'"> <view v-for="(item2,index2) in item.children" :class="[item2.clas]" :style="[style(item2)]" :key="index2"> <view v-for="(item3,index3) in item2.elements" :key="index3"> <!-- 垂直高度站位 --> <view :style="{height: $uv.addUnit(item3.height,'rpx')}" v-if="item3.type=='gap'"></view> <view :class="[item3.clas, roundClass, animateClass]" :style="[style(item3)]" v-else ref="skeleton"></view> </view> </view> </view> <!-- 自定义骨架屏内容 --> <!-- ps 自定义扩展说明: --> <!-- 如果你需要自定义模板,可以参照这个custom的写法,增加一个skeleton配置类型,编写布局和样式就可以了 --> <!-- 注意事项:为了保证骨架效果和动态效果的一致,扩展时,在你希望实际展示在页面中的元素上加上 :class="[style, animateClass]" 和 :style="[style(item)]" 和 ref="skeleton" --> <view :class="[item.clas, animateClass]" :style="[style(item)]" ref="skeleton" v-else-if="item.type == 'custom'"></view> <!-- 垂直高度站位 --> <view :style="{height: $uv.addUnit(item.height,'rpx')}" v-else-if="item.type=='gap'"></view> <!-- 其他基本单位 line avatar 等 --> <view :class="[item.clas, roundClass, animateClass]" :style="[style(item)]" v-else ref="skeleton"></view> </view> </view> <view v-else> <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' // #ifdef APP-NVUE const animation = weex.requireModule('animation'); // #endif export default { name: 'uv-skeletons', mixins: [mpMixin, mixin], props: { // 是否显示骨架 loading: { type: Boolean, default: true }, // 骨架内容 具体说明参考文档: skeleton: { type: Array, default: () => [] }, // 是否开启动画效果 animate: { type: Boolean, default: true }, // 是否圆角骨架风格 round: { type: Boolean, default: false }, ...uni.$uv?.props?.skeleton }, data() { return { elements: [], opacity: 0.5, duration: 600 } }, computed: { animateClass() { return this.animate ? 'uv-skeleton--animation' : 'uv-skeleton--static'; }, roundClass() { return this.round ? 'uv-skeleton--round' : 'uv-skeleton--radius'; }, style(item) { return item => { const style = {}; return this.$uv.deepMerge(style, this.$uv.addStyle(item.style)); } } }, created() { this.init(); // #ifdef APP-NVUE if (this.loading && this.animate) { this.$uv.sleep(50).then(res => { this.createAnimation(this.opacity); }) } // #endif }, methods: { /** * 初始化数据 */ init() { let elements = []; if (!this.$uv.test.array(this.skeleton)) return this.$uv.error('skeleton参数必须为数组形式,参考文档示例:'); this.skeleton.forEach(el => { const elClass = this.getElCounts(el); elements = elements.concat(elClass); }) this.elements = [...elements]; }, /** * 处理骨架屏参数内容 * @param {Object} el 每项数据 */ getElCounts(el) { let elements = []; let children = []; if (this.$uv.test.number(el)) { elements.push({ type: 'gap', height: el }); return elements; } else { const type = el.type ? el.type : 'line'; const num = el.num ? el.num : 1; const style = el.style ? el.style : {}; const styleIsArray = this.$uv.test.array(style); const gap = el.gap ? el.gap : '20rpx'; const child = el.children ? el.children : []; for (let i = 0; i < child.length; i++) { children[i] = { clas: child[i].type.indexOf('avatar') > -1 || child[i].type.indexOf('custom') > -1 ? '' : 'uv-skeleton__group__sub', elements: this.getElCounts(child[i]) }; } for (let i = 0; i < num; i++) { if (gap && i < num && i > 0) { elements.push({ type: 'gap', height: gap }); } elements.push({ clas: `uv-skeleton__${type}`, type, style: styleIsArray ? style[i] : style, gap, children }); } return elements; } }, /** * 创建动画 */ createAnimation(opacity = 1) { // loading结束之后或未开启动画不执行 if (!this.loading || !this.animate) return; let count = 0; const skeletons = this.$refs.skeleton; skeletons.forEach(item => { animation.transition(item, { styles: { opacity: opacity, }, duration: this.duration }, () => { count++; if (count >= skeletons.length) { setTimeout(() => { this.createAnimation(opacity < 1 ? 1 : this.opacity); }, 200) } }); }) } } } </script> <style scoped lang="scss"> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; @mixin background { /* #ifdef APP-NVUE */ background-color: #e6e6e6; /* #endif */ /* #ifndef APP-NVUE */ background: linear-gradient(90deg, #F1F2F4 25%, #e6e6e6 37%, #F1F2F4 50%); background-size: 400% 100%; /* #endif */ } .uv-skeleton__line { height: 32rpx; // margin-bottom: 30rpx; } .uv-skeleton__line--sm { height: 24rpx; margin-bottom: 30rpx; } .uv-skeleton__line--lg { height: 48rpx; margin-bottom: 30rpx; } .uv-skeleton--static { @include background; } .uv-skeleton--radius { border-radius: 8rpx; } .uv-skeleton--round { border-radius: 30rpx; } .uv-skeleton__avatar { width: 100rpx; height: 100rpx; border-radius: 50rpx; } .uv-skeleton__avatar--sm { width: 50rpx; height: 50rpx; border-radius: 25rpx; } .uv-skeleton__avatar--lg { width: 200rpx; height: 200rpx; border-radius: 100rpx; } .uv-skeleton__group { @include flex; &__sub { flex: 1; } } .uv-skeleton--animation { @include background; /* #ifndef APP-NVUE */ animation: skeleton 1.8s ease infinite /* #endif */ } /* #ifndef APP-NVUE */ @keyframes skeleton { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-skeletons/components/uv-skeletons/uv-skeletons.vue
Vue
unknown
6,473
export default { props: { value: { type: [Number, String], default: 0 }, modelValue: { type: [Number, String], default: 0 }, // 最小可选值 min: { type: [Number, String], default: 0 }, // 最大可选值 max: { type: [Number, String], default: 100 }, // 步长,取值必须大于 0,并且可被(max - min)整除 step: { type: [Number, String], default: 1 }, // 滑块右侧已选择部分的背景色 activeColor: { type: String, default: '#2979ff' }, // 滑块左侧未选择部分的背景色 backgroundColor: { type: String, default: '#c0c4cc' }, // 滑块的大小,取值范围为 12 - 28 blockSize: { type: [Number, String], default: 18 }, // 滑块的颜色 blockColor: { type: String, default: '#ffffff' }, // 禁用状态 disabled: { type: Boolean, default: false }, // 是否显示当前的选择值 showValue: { type: Boolean, default: false }, ...uni.$uv?.props?.slider } }
2301_77169380/AppruanjianApk
uni_modules/uv-slider/components/uv-slider/props.js
JavaScript
unknown
1,026
<template> <view class="uv-slider" :style="[$uv.addStyle(customStyle)]" > <slider :min="min" :max="max" :step="step" :value="sliderValue" :activeColor="activeColor" :backgroundColor="backgroundColor" :blockSize="$uv.getPx(blockSize)" :blockColor="blockColor" :showValue="showValue" :disabled="disabled" @changing="changingHandler" @change="changeHandler" ></slider> </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' export default { name: 'uv-slider', mixins: [mpMixin, mixin, props], computed: { sliderValue(){ return this.value || this.modelValue; } }, methods: { // 拖动过程中触发 changingHandler(e) { const { value } = e.detail // 更新v-model的值 this.$emit('input', value) this.$emit('update:modelValue',value) // 触发事件 this.$emit('changing', value) }, // 滑动结束时触发 changeHandler(e) { const { value } = e.detail // 更新v-model的值 this.$emit('input', value) this.$emit('update:modelValue',value) // 触发事件 this.$emit('change', value) } } } </script>
2301_77169380/AppruanjianApk
uni_modules/uv-slider/components/uv-slider/uv-slider.vue
Vue
unknown
1,291
export default { props: { bgColor: { type: String, default: 'transparent' } } }
2301_77169380/AppruanjianApk
uni_modules/uv-status-bar/components/uv-status-bar/props.js
JavaScript
unknown
128
<template> <view :style="[style]" class="uv-status-bar" > <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'; /** * StatbusBar 状态栏占位 * @description 本组件主要用于状态填充,比如在自定导航栏的时候,它会自动适配一个恰当的状态栏高度。 * @tutorial https://www.uvui.cn/components/statusBar.html * @property {String} bgColor 背景色 (默认 'transparent' ) * @property {String | Object} customStyle 自定义样式 * @example <uv-status-bar></uv-status-bar> */ export default { name: 'uv-status-bar', mixins: [mpMixin, mixin, props], data() { return { } }, computed: { style() { const style = {} // 状态栏高度,由于某些安卓和微信开发工具无法识别css的顶部状态栏变量,所以使用js获取的方式 style.height = this.$uv.addUnit(this.$uv.sys().statusBarHeight, 'px') if(this.bgColor){ if (this.bgColor.indexOf("gradient") > -1) {// 渐变色 style.backgroundImage = this.bgColor; }else{ style.background = this.bgColor; } } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) } }, } </script> <style lang="scss" scoped> .uv-status-bar { // nvue会默认100%,如果nvue下,显式写100%的话,会导致宽度不为100%而异常 /* #ifndef APP-NVUE */ width: 100%; /* #endif */ } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-status-bar/components/uv-status-bar/uv-status-bar.vue
Vue
unknown
1,570
export default { props: { // 排列方向 direction: { type: String, default: 'row' }, // 设置第几个步骤 current: { type: [String, Number], default: 0 }, // 激活状态颜色 activeColor: { type: String, default: '#3c9cff' }, // 未激活状态颜色 inactiveColor: { type: String, default: '#969799' }, // 激活状态的图标 activeIcon: { type: String, default: '' }, // 未激活状态图标 inactiveIcon: { type: String, default: '' }, // 是否显示点类型 dot: { type: Boolean, default: false }, ...uni.$uv?.props?.steps } }
2301_77169380/AppruanjianApk
uni_modules/uv-steps/components/uv-steps/props.js
JavaScript
unknown
631
<template> <view :class="['uv-steps',`uv-steps--${direction}`]" :style="[$uv.addStyle(customStyle)]" > <slot></slot> </view> </template> <script> import { func } from '@/uni_modules/uv-ui-tools/libs/function/test.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'; /** * Steps 步骤条 * @description 该组件一般用于完成一个任务要分几个步骤,标识目前处于第几步的场景。 * @tutorial https://www.uvui.cn/components/steps.html * @property {String} direction row-横向,column-竖向 (默认 'row' ) * @property {String | Number} current 设置当前处于第几步 (默认 0 ) * @property {String} activeColor 激活状态颜色 (默认 '#3c9cff' ) * @property {String} inactiveColor 未激活状态颜色 (默认 '#969799' ) * @property {String} activeIcon 激活状态的图标 * @property {String} inactiveIcon 未激活状态图标 * @property {Boolean} dot 是否显示点类型 (默认 false ) * @example <uv-steps current="0"><uv-steps-item title="已出库" desc="10:35" ></uv-steps-item></uv-steps> */ export default { name: 'uv-steps', mixins: [mpMixin, mixin, props], data() { return { } }, watch: { children() { this.updateChildData() }, parentData() { this.updateChildData() } }, computed: { // 监听参数的变化,通过watch中,手动去更新子组件的数据,否则子组件不会自动变化 parentData() { return [this.current, this.direction, this.activeColor, this.inactiveColor, this.activeIcon, this.inactiveIcon, this.dot] } }, methods: { // 更新子组件的数据 updateChildData() { this.children.map(child => { // 先判断子组件是否存在对应的方法 func((child || {}).updateFromParent()) && child.updateFromParent() }) }, // 接受子组件的通知,去修改其他子组件的数据 updateFromChild() { this.updateChildData() } }, created() { this.children = [] } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-steps { @include flex; &--column { flex-direction: column } &--row { flex-direction: row; flex: 1; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-steps/components/uv-steps/uv-steps.vue
Vue
unknown
2,379
export default { props: { // 标题 title: { type: [String, Number], default: '' }, // 描述文本 desc: { type: [String, Number], default: '' }, // 图标大小 iconSize: { type: [String, Number], default: 17 }, // 当前步骤是否处于失败状态 error: { type: Boolean, default: false }, ...uni.$uv?.props?.stepsItem } }
2301_77169380/AppruanjianApk
uni_modules/uv-steps/components/uv-steps-item/props.js
JavaScript
unknown
380
<template> <view class="uv-steps-item" ref="uv-steps-item" :class="[`uv-steps-item--${parentData.direction}`]" :style="[$uv.addStyle(customStyle)]" > <view class="uv-steps-item__line" v-if="index + 1 < childLength" :class="[`uv-steps-item__line--${parentData.direction}`]" :style="[lineStyle]"> </view> <view :class="[ 'uv-steps-item__wrapper', `uv-steps-item__wrapper--${parentData.direction}`, parentData.dot && `uv-steps-item__wrapper--${parentData.direction}--dot` ]"> <slot name="icon"> <view class="uv-steps-item__wrapper__dot" v-if="parentData.dot" :style="{ backgroundColor: statusColor }"> </view> <view class="uv-steps-item__wrapper__icon" v-else-if="parentData.activeIcon || parentData.inactiveIcon"> <uv-icon :name="index <= parentData.current ? parentData.activeIcon : parentData.inactiveIcon" :size="iconSize" :color="index <= parentData.current ? parentData.activeColor : parentData.inactiveColor"> </uv-icon> </view> <view v-else :style="{ backgroundColor: statusClass === 'process' ? parentData.activeColor : 'transparent', borderColor: statusColor }" class="uv-steps-item__wrapper__circle"> <text v-if="statusClass === 'process' || statusClass === 'wait'" class="uv-steps-item__wrapper__circle__text" :style="{ color: index == parentData.current ? '#ffffff' : parentData.inactiveColor }">{{ index + 1}}</text> <uv-icon v-else :color="statusClass === 'error' ? 'error' : parentData.activeColor" size="12" :name="statusClass === 'error' ? 'close' : 'checkmark'"> </uv-icon> </view> </slot> </view> <view :class="[ 'uv-steps-item__content', `uv-steps-item__content--${parentData.direction}` ]" :style="[contentStyle]" > <slot name="title"> <uv-text :text="title" :type="parentData.current == index ? 'main' : 'content'" lineHeight="20px" :size="parentData.current == index ? 14 : 13" ></uv-text> </slot> <slot name="desc"> <uv-text :text="desc" type="tips" size="12" ></uv-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 /** * StepsItem 步骤条的子组件 * @description 本组件需要和uv-steps配合使用 * @tutorial https://www.uvui.cn/components/steps.html * @property {String} title 标题文字 * @property {String} current 描述文本 * @property {String | Number} iconSize 图标大小 (默认 17 ) * @property {Boolean} error 当前步骤是否处于失败状态 (默认 false ) * @example <uv-steps current="0"><uv-steps-item title="已出库" desc="10:35" ></uv-steps-item></uv-steps> */ export default { name: 'uv-steps-item', mixins: [mpMixin, mixin, props], data() { return { index: 0, childLength: 0, showLine: false, size: { height: 0, width: 0 }, parentData: { direction: 'row', current: 0, activeColor: '', inactiveColor: '', activeIcon: '', inactiveIcon: '', dot: false } } }, watch: { 'parentData'(newValue, oldValue) {} }, created() { this.init() }, computed: { lineStyle() { const style = {} if (this.parentData.direction === 'row') { style.width = this.size.width + 'px' style.left = this.size.width / 2 + 'px' } else { style.height = this.size.height + 'px' } style.backgroundColor = this.parent.children?.[this.index + 1]?.error ? '#f56c6c' : this.index < this.parentData.current ? this.parentData.activeColor : this.parentData.inactiveColor return style }, statusClass() { const { index, error } = this const { current } = this.parentData if (current == index) { return error === true ? 'error' : 'process' } else if (error) { return 'error' } else if (current > index) { return 'finish' } else { return 'wait' } }, statusColor() { let color = '' switch (this.statusClass) { case 'finish': color = this.parentData.activeColor break case 'error': color = '#f56c6c' break case 'process': color = this.parentData.dot ? this.parentData.activeColor : 'transparent' break default: color = this.parentData.inactiveColor break } return color }, contentStyle() { const style = {} if (this.parentData.direction === 'column') { style.marginLeft = this.parentData.dot ? '2px' : '6px' style.marginTop = this.parentData.dot ? '0px' : '6px' } else { style.marginTop = this.parentData.dot ? '2px' : '6px' style.marginLeft = this.parentData.dot ? '2px' : '6px' } return style } }, mounted() { this.parent && this.parent.updateFromChild() this.$uv.sleep().then(() => { this.getStepsItemRect() }) }, methods: { init() { // 初始化数据 this.updateParentData() if (!this.parent) { return this.$uv.error('uv-steps-item必须要搭配uv-steps组件使用') } this.index = this.parent.children.indexOf(this) this.childLength = this.parent.children.length }, updateParentData() { // 此方法在mixin中 this.getParentData('uv-steps') }, // 父组件数据发生变化 updateFromParent() { this.init() }, // 获取组件的尺寸,用于设置横线的位置 getStepsItemRect() { // #ifndef APP-NVUE this.$uvGetRect('.uv-steps-item').then(size => { this.size = size }) // #endif // #ifdef APP-NVUE dom.getComponentRect(this.$refs['uv-steps-item'], res => { const { size } = res this.size = 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-steps-item { flex: 1; @include flex; &--row { flex-direction: column; align-items: center; position: relative; } &--column { position: relative; flex-direction: row; justify-content: flex-start; padding-bottom: 5px; } &__wrapper { @include flex; justify-content: center; align-items: center; position: relative; background-color: #fff; &--column { width: 20px; height: 32px; &--dot { height: 20px; width: 20px; } } &--row { width: 32px; height: 20px; &--dot { width: 20px; height: 20px; } } &__circle { width: 20px; height: 20px; /* #ifndef APP-NVUE */ box-sizing: border-box; flex-shrink: 0; /* #endif */ border-radius: 100px; border-width: 1px; border-color: $uv-tips-color; border-style: solid; @include flex(row); align-items: center; justify-content: center; transition: background-color 0.3s; &__text { color: $uv-tips-color; font-size: 11px; @include flex(row); align-items: center; justify-content: center; text-align: center; line-height: 11px; } } &__dot { width: 10px; height: 10px; border-radius: 100px; background-color: $uv-content-color; } } &__content { @include flex; flex: 1; &--row { flex-direction: column; align-items: center; } &--column { flex-direction: column; margin-left: 6px; } } &__line { position: absolute; background: $uv-tips-color; &--row { top: 10px; height: 1px; } &--column { width: 1px; left: 10px; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-steps/components/uv-steps-item/uv-steps-item.vue
Vue
unknown
7,953
export default { props: { // 吸顶容器到顶部某个距离的时候,进行吸顶,在H5平台,NavigationBar为44px offsetTop: { type: [String, Number], default: 0 }, // 自定义导航栏的高度 customNavHeight: { type: [String, Number], // #ifdef H5 // H5端的导航栏属于“自定义”导航栏的范畴,因为它是非原生的,与普通元素一致 default: 44, // #endif // #ifndef H5 default: 0 // #endif }, // 是否禁用吸顶功能 disabled: { type: Boolean, default: false }, // 吸顶区域的背景颜色 bgColor: { type: String, default: 'transparent' }, // z-index值 zIndex: { type: [String, Number], default: '' }, // 列表中的索引值 index: { type: [String, Number], default: '' }, ...uni.$uv?.props?.sticky } }
2301_77169380/AppruanjianApk
uni_modules/uv-sticky/components/uv-sticky/props.js
JavaScript
unknown
848
<template> <view class="uv-sticky" :id="elId" :style="[style]" > <view :style="[stickyContent]" class="uv-sticky__content" > <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';; /** * sticky 吸顶 * @description 该组件与CSS中position: sticky属性实现的效果一致,当组件达到预设的到顶部距离时, 就会固定在指定位置,组件位置大于预设的顶部距离时,会重新按照正常的布局排列。 * @tutorial https://www.uvui.cn/components/sticky.html * @property {String | Number} offsetTop 吸顶时与顶部的距离,单位px(默认 0 ) * @property {String | Number} customNavHeight 自定义导航栏的高度 (h5 默认44 其他默认 0 ) * @property {Boolean} disabled 是否开启吸顶功能 (默认 false ) * @property {String} bgColor 组件背景颜色(默认 '#ffffff' ) * @property {String | Number} zIndex 吸顶时的z-index值 * @property {String | Number} index 自定义标识,用于区分是哪一个组件 * @property {Object} customStyle 组件的样式,对象形式 * @example <uv-sticky offsetTop="200"><view>塞下秋来风景异,衡阳雁去无留意</view></uv-sticky> */ export default { name: 'uv-sticky', mixins: [mpMixin, mixin, props], data() { return { cssSticky: false, // 是否使用css的sticky实现 stickyTop: 0, // 吸顶的top值,因为可能受自定义导航栏影响,最终的吸顶值非offsetTop值 elId: '', left: 0, // js模式时,吸顶的内容因为处于postition: fixed模式,为了和原来保持一致的样式,需要记录并重新设置它的left,height,width属性 width: 'auto', height: 'auto', fixed: false, // js模式时,是否处于吸顶模式 } }, computed: { style() { const style = {} if(!this.disabled) { if (this.cssSticky) { style.position = 'sticky' style.zIndex = this.uZindex style.top = this.$uv.addUnit(this.stickyTop) } else { style.height = this.fixed ? this.height + 'px' : 'auto' } } else { // 无需吸顶时,设置会默认的relative(nvue)和非nvue的static静态模式即可 // #ifdef APP-NVUE style.position = 'relative' // #endif // #ifndef APP-NVUE style.position = 'static' // #endif } style.backgroundColor = this.bgColor return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) }, // 吸顶内容的样式 stickyContent() { const style = {} if (!this.cssSticky) { style.position = this.fixed ? 'fixed' : 'static' style.top = this.stickyTop + 'px' style.left = this.left + 'px' style.width = this.width == 'auto' ? 'auto' : this.width + 'px' style.zIndex = this.uZindex } return style }, uZindex() { return this.zIndex ? this.zIndex : 970 } }, created() { this.elId = this.$uv.guid(); }, mounted() { this.init() }, methods: { init() { this.getStickyTop() // 判断使用的模式 this.checkSupportCssSticky() // 如果不支持css sticky,则使用js方案,此方案性能比不上css方案 if (!this.cssSticky) { !this.disabled && this.initObserveContent() } }, initObserveContent() { // 获取吸顶内容的高度,用于在js吸顶模式时,给父元素一个填充高度,防止"塌陷" this.$uvGetRect('#' + this.elId).then((res) => { this.height = res.height this.left = res.left this.width = res.width this.$nextTick(() => { this.observeContent() }) }) }, observeContent() { // 先断掉之前的观察 this.disconnectObserver('contentObserver') const contentObserver = uni.createIntersectionObserver({ // 检测的区间范围 thresholds: [0.95, 0.98, 1] }) // 到屏幕顶部的高度时触发 contentObserver.relativeToViewport({ top: -this.stickyTop }) // 绑定观察的元素 contentObserver.observe(`#${this.elId}`, res => { this.setFixed(res.boundingClientRect.top) }) this.contentObserver = contentObserver }, setFixed(top) { // 判断是否出于吸顶条件范围 const fixed = top <= this.stickyTop this.fixed = fixed }, disconnectObserver(observerName) { // 断掉观察,释放资源 const observer = this[observerName] observer && observer.disconnect() }, getStickyTop() { this.stickyTop = this.$uv.getPx(this.offsetTop) + this.$uv.getPx(this.customNavHeight) }, async checkSupportCssSticky() { // #ifdef H5 // H5,一般都是现代浏览器,是支持css sticky的,这里使用创建元素嗅探的形式判断 if (this.checkCssStickyForH5()) { this.cssSticky = true } // #endif // 如果安卓版本高于8.0,依然认为是支持css sticky的(因为安卓7在某些机型,可能不支持sticky) if (this.$uv.os() === 'android' && Number(this.$uv.sys().system) > 8) { this.cssSticky = true } // APP-Vue和微信平台,通过computedStyle判断是否支持css sticky // #ifdef APP-VUE || MP-WEIXIN this.cssSticky = await this.checkComputedStyle() // #endif // ios上,从ios6开始,都是支持css sticky的 if (this.$uv.os() === 'ios') { this.cssSticky = true } // nvue,是支持css sticky的 // #ifdef APP-NVUE this.cssSticky = true // #endif }, // 在APP和微信小程序上,通过uni.createSelectorQuery可以判断是否支持css sticky checkComputedStyle() { // 方法内进行判断,避免在其他平台生成无用代码 // #ifdef APP-VUE || MP-WEIXIN return new Promise(resolve => { uni.createSelectorQuery().in(this).select('.uv-sticky').fields({ computedStyle: ["position"] }).exec(e => { resolve('sticky' === e[0].position) }) }) // #endif }, // H5通过创建元素的形式嗅探是否支持css sticky // 判断浏览器是否支持sticky属性 checkCssStickyForH5() { // 方法内进行判断,避免在其他平台生成无用代码 // #ifdef H5 const vendorList = ['', '-webkit-', '-ms-', '-moz-', '-o-'], vendorListLength = vendorList.length, stickyElement = document.createElement('div') for (let i = 0; i < vendorListLength; i++) { stickyElement.style.position = vendorList[i] + 'sticky' if (stickyElement.style.position !== '') { return true } } return false; // #endif } }, // #ifdef VUE2 beforeDestroy() { this.disconnectObserver('contentObserver') }, // #endif // #ifdef VUE3 unmounted() { this.disconnectObserver('contentObserver') } // #endif } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-sticky { /* #ifdef APP-VUE || MP-WEIXIN */ // 此处默认写sticky属性,是为了给微信和APP通过uni.createSelectorQuery查询是否支持css sticky使用 position: sticky; /* #endif */ } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-sticky/components/uv-sticky/uv-sticky.vue
Vue
unknown
7,250
export default { props: { // tab的数据 list: { type: Array, default: () => [] }, // 当前活动的tab的index current: { type: [String, Number], default: 0 }, // 激活的颜色 activeColor: { type: String, default: '#3c9cff' }, // 未激活的颜色 inactiveColor: { type: String, default: '#303133' }, // 模式选择,mode=button为按钮形式,mode=subsection时为分段模式 mode: { type: String, default: 'button' }, // 字体大小 fontSize: { type: [String, Number], default: 12 }, // 激活tab的字体是否加粗 bold: { type: Boolean, default: true }, // mode = button时,组件背景颜色 bgColor: { type: String, default: '#eeeeef' }, // 从list元素对象中读取的键名 keyName: { type: String, default: 'name' }, customItemStyle: { type: [String, Object], default: '' }, ...uni.$uv?.props?.subsection } }
2301_77169380/AppruanjianApk
uni_modules/uv-subsection/components/uv-subsection/props.js
JavaScript
unknown
959
<template> <view class="uv-subsection" ref="uv-subsection" :class="[`uv-subsection--${mode}`]" :style="[$uv.addStyle(customStyle), wrapperStyle]"> <view class="uv-subsection__bar" ref="uv-subsection__bar" :style="[barStyle]" :class="[ mode === 'button' && 'uv-subsection--button__bar', current === 0 && mode === 'subsection' && 'uv-subsection__bar--first', current > 0 && current < list.length - 1 && mode === 'subsection' && 'uv-subsection__bar--center', current === list.length - 1 && mode === 'subsection' && 'uv-subsection__bar--last' ]" ></view> <view class="uv-subsection__item" :class="[ `uv-subsection__item--${index}`, index < list.length - 1 && 'uv-subsection__item--no-border-right', index === 0 && 'uv-subsection__item--first', index === list.length - 1 && 'uv-subsection__item--last' ]" :ref="`uv-subsection__item--${index}`" :style="[itemStyle(index)]" @tap="clickHandler(index)" v-for="(item, index) in list" :key="index" > <text class="uv-subsection__item__text" :style="[textStyle(index)]">{{ getText(item) }} </text> </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' // #ifdef APP-NVUE const dom = uni.requireNativePlugin("dom"); const animation = uni.requireNativePlugin("animation"); // #endif import props from "./props.js"; /** * Subsection 分段器 * @description 该分段器一般用于用户从几个选项中选择某一个的场景 * @tutorial https://www.uvui.cn/components/subsection.html * @property {Array} list tab的数据 * @property {String | Number} current 当前活动的tab的index(默认 0 ) * @property {String} activeColor 激活时的颜色(默认 '#3c9cff' ) * @property {String} inactiveColor 未激活时的颜色(默认 '#303133' ) * @property {String} mode 模式选择,mode=button为按钮形式,mode=subsection时为分段模式(默认 'button' ) * @property {String | Number} fontSize 字体大小,单位px(默认 12 ) * @property {Boolean} bold 激活选项的字体是否加粗(默认 true ) * @property {String} bgColor 组件背景颜色,mode为button时有效(默认 '#eeeeef' ) * @property {Object} customStyle 定义需要用到的外部样式 * @property {String} keyName 从`list`元素对象中读取的键名(默认 'name' ) * * @event {Function} change 分段器选项发生改变时触发 回调 index:选项的index索引值,从0开始 * @example <uv-subsection :list="list" :current="curNow" @change="sectionChange"></uv-subsection> */ export default { name: "uv-subsection", mixins: [mpMixin, mixin, props], data() { return { // 组件尺寸 itemRect: { width: 0, height: 0, } } }, watch: { list: { deep: true, handler(){ this.init(); } }, current: { immediate: true, handler(n) { // #ifdef APP-NVUE // 在安卓nvue上,如果通过translateX进行位移,到最后一个时,会导致右侧无法绘制圆角 // 故用animation模块进行位移 const ref = this.$refs?.["uv-subsection__bar"]?.ref; // 不存在ref的时候(理解为第一次初始化时,需要渲染dom,进行一定延时再获取ref),这里的100ms是经过测试得出的结果(某些安卓需要延时久一点),勿随意修改 this.$uv.sleep(ref ? 0 : 150).then(() => { animation.transition(this.$refs["uv-subsection__bar"].ref, { styles: { transform: `translateX(${ n * this.itemRect.width }px)`, transformOrigin: "center center" }, duration: 300, }); }); // #endif } } }, computed: { wrapperStyle() { const style = {}; // button模式时,设置背景色 if (this.mode === "button") { style.backgroundColor = this.bgColor; } return style; }, // 滑块的样式 barStyle() { const style = {}; style.width = `${this.itemRect.width}px`; style.height = `${this.itemRect.height}px`; // 通过translateX移动滑块,其移动的距离为索引*item的宽度 // #ifndef APP-NVUE style.transform = `translateX(${ this.current * this.itemRect.width }px)`; // #endif if (this.mode === "subsection") { // 在subsection模式下,需要动态设置滑块的圆角,因为移动滑块使用的是translateX,无法通过父元素设置overflow: hidden隐藏滑块的直角 style.backgroundColor = this.activeColor; } return this.$uv.deepMerge(style, this.$uv.addStyle(this.customItemStyle)); }, // 分段器item的样式 itemStyle(index) { return (index) => { const style = {}; if (this.mode === "subsection") { // 设置border的样式 style.borderColor = this.activeColor; style.borderWidth = "1px"; style.borderStyle = "solid"; } return style; }; }, // 分段器文字颜色 textStyle(index) { return (index) => { const style = {}; style.fontWeight = this.bold && this.current === index ? "bold" : "normal"; style.fontSize = this.$uv.addUnit(this.fontSize); // subsection模式下,激活时默认为白色的文字 if (this.mode === "subsection") { style.color = this.current === index ? "#fff" : this.inactiveColor; } else { // button模式下,激活时文字颜色默认为activeColor style.color = this.current === index ? this.activeColor : this.inactiveColor; } return style; }; }, }, mounted() { this.init(); }, methods: { init() { this.$uv.sleep().then(() => this.getRect()); }, // 判断展示文本 getText(item) { return typeof item === 'object' ? item[this.keyName] : item }, // 获取组件的尺寸 getRect() { // #ifndef APP-NVUE this.$uvGetRect(".uv-subsection__item--0").then((size) => { this.itemRect = size; }); // #endif // #ifdef APP-NVUE const ref = this.$refs["uv-subsection__item--0"][0]; ref && dom.getComponentRect(ref, (res) => { this.itemRect = res.size; }); // #endif }, clickHandler(index) { this.$emit("change", index); } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-subsection { @include flex; position: relative; overflow: hidden; /* #ifndef APP-NVUE */ width: 100%; box-sizing: border-box; /* #endif */ &--button { height: 32px; background-color: rgb(238, 238, 239); padding: 3px; border-radius: 3px; align-items: stretch; &__bar { background-color: #ffffff; } } &--subsection { height: 30px; } &__bar { position: absolute; /* #ifndef APP-NVUE */ transition-property: transform, color; transition-duration: 0.3s; transition-timing-function: ease-in-out; /* #endif */ &--first { border-top-left-radius: 3px; border-bottom-left-radius: 3px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; } &--center { border-top-left-radius: 0px; border-bottom-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; } &--last { border-top-left-radius: 0px; border-bottom-left-radius: 0px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; } } &__item { @include flex; flex: 1; justify-content: center; align-items: center; // vue环境下,需要设置相对定位,因为滑块为绝对定位,item需要在滑块的上面 position: relative; &--no-border-right { border-right-width: 0 !important; } &--first { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } &--last { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } &__text { font-size: 12px; line-height: 12px; @include flex; align-items: center; transition-property: color; transition-duration: 0.3s; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-subsection/components/uv-subsection/uv-subsection.vue
Vue
unknown
8,228
export default { props: { // 是否自动关闭其他swipe按钮组 autoClose: { type: Boolean, default: true }, ...uni.$uv?.props?.swipeAction } }
2301_77169380/AppruanjianApk
uni_modules/uv-swipe-action/components/uv-swipe-action/props.js
JavaScript
unknown
163
<template> <view class="uv-swipe-action"> <slot></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'; /** * SwipeAction 滑动单元格 * @description 该组件一般用于左滑唤出操作菜单的场景,用的最多的是左滑删除操作 * @tutorial https://www.uvui.cn/components/swipeAction.html * @property {Boolean} autoClose 是否自动关闭其他swipe按钮组 * @event {Function(index)} click 点击组件时触发 * @example <uv-swipe-action><uv-swipe-action-item :rightOptions="options1" ></uv-swipe-action-item></uv-swipe-action> */ export default { name: 'uv-swipe-action', mixins: [mpMixin, mixin, props], data() { return {} }, provide() { return { swipeAction: this } }, computed: { // 这里computed的变量,都是子组件uv-swipe-action-item需要用到的,由于头条小程序的兼容性差异,子组件无法实时监听父组件参数的变化 // 所以需要手动通知子组件,这里返回一个parentData变量,供watch监听,在其中去通知每一个子组件重新从父组件(uv-swipe-action-item) // 拉取父组件新的变化后的参数 parentData() { return [this.autoClose] } }, watch: { // 当父组件需要子组件需要共享的参数发生了变化,手动通知子组件 parentData() { if (this.children.length) { this.children.map(child => { // 判断子组件(uv-swipe-action-item)如果有updateParentData方法的话,就就执行(执行的结果是子组件重新从父组件拉取了最新的值) typeof(child.updateParentData) === 'function' && child.updateParentData() }) } }, }, created() { this.children = [] }, methods: { closeOther(child) { if (this.autoClose) { // 历遍所有的单元格,找出非当前操作中的单元格,进行关闭 this.children.map((item, index) => { if (child !== item) { item.closeHandler() } }) } } } } </script>
2301_77169380/AppruanjianApk
uni_modules/uv-swipe-action/components/uv-swipe-action/uv-swipe-action.vue
Vue
unknown
2,154
// nvue操作dom的库,用于获取dom的尺寸信息 const dom = uni.requireNativePlugin('dom') // nvue中用于操作元素动画的库,类似于uni.animation,只不过uni.animation不能用于nvue const animation = uni.requireNativePlugin('animation') import { sleep } from '@/uni_modules/uv-ui-tools/libs/function/index.js' export default { data() { return { // 是否滑动中 moving: false, // 状态,open-打开状态,close-关闭状态 status: 'close', // 开始触摸点的X和Y轴坐标 startX: 0, startY: 0, // 所有隐藏按钮的尺寸信息数组 buttons: [], // 所有按钮的总宽度 buttonsWidth: 0, // 记录上一次移动的位置值 moveX: 0, // 记录上一次滑动的位置,用于前后两次做对比,如果移动的距离小于某一阈值,则认为前后之间没有移动,为了解决可能存在的通信阻塞问题 lastX: 0 } }, computed: { // 获取过渡时间 getDuratin() { let duration = String(this.duration) // 如果ms为单位,返回ms的数值部分 if (duration.indexOf('ms') >= 0) return parseInt(duration) // 如果s为单位,为了得到ms的数值,需要乘以1000 if (duration.indexOf('s') >= 0) return parseInt(duration) * 1000 // 如果值传了数值,且小于30,认为是s单位 duration = Number(duration) return duration < 30 ? duration * 1000 : duration } }, watch: { show: { immediate: true, handler(n) { } } }, mounted() { sleep(20).then(() => { this.queryRect() }) }, methods: { close() { this.closeSwipeAction() }, // 触摸单元格 touchstart(event) { if (this.disabled) return this.closeOther() const { touches } = event // 记录触摸开始点的坐标值 this.startX = touches[0].pageX this.startY = touches[0].pageY }, // // 触摸滑动 touchmove(event) { if (this.disabled) return const { touches } = event const { pageX } = touches[0] const { pageY } = touches[0] let moveX = pageX - this.startX const moveY = pageY - this.startY const { buttonsWidth } = this const len = this.buttons.length // 判断前后两次的移动距离,如果小于一定值,则不进行移动处理 if (Math.abs(pageX - this.lastX) < 0.3) return this.lastX = pageX // 移动的X轴距离大于Y轴距离,也即终点与起点位置连线,与X轴夹角小于45度时,禁止页面滚动 if (Math.abs(moveX) > Math.abs(moveY) || Math.abs(moveX) > this.threshold) { event.stopPropagation() } // 如果移动的X轴距离小于Y轴距离,也即终点位置与起点位置连线,与Y轴夹角小于45度时,认为是页面上下滑动,而不是左右滑动单元格 if (Math.abs(moveX) < Math.abs(moveY)) return // 限制右滑的距离,不允许内容部分往右偏移,右滑会导致X轴偏移值大于0,以此做判断 // 此处不能直接return,因为滑动过程中会缺失某些关键点坐标,会导致错乱,最好的办法就是 // 在超出后,设置为0 if (this.status === 'open') { // 在开启状态下,向左滑动,需忽略 if (moveX < 0) moveX = 0 // 想要收起菜单,最大能移动的距离为按钮的总宽度 if (moveX > buttonsWidth) moveX = buttonsWidth // 如果是已经打开了的状态,向左滑动时,移动收起菜单 this.moveSwipeAction(-buttonsWidth + moveX) } else { // 关闭状态下,右滑动需忽略 if (moveX > 0) moveX = 0 // 滑动的距离不允许超过所有按钮的总宽度,此时只能是左滑,最终设置按钮的总宽度,同时为负数 if (Math.abs(moveX) > buttonsWidth) moveX = -buttonsWidth // 只要是在滑过程中,就不断移动菜单的内容部分,从而使隐藏的菜单显示出来 this.moveSwipeAction(moveX) } }, // 单元格结束触摸 touchend(event) { if (this.disabled) return const touches = event.changedTouches ? event.changedTouches[0] : {} const { pageX } = touches const { pageY } = touches const { buttonsWidth } = this this.moveX = pageX - this.startX if (this.status === 'open') { // 在展开的状态下,继续左滑,无需操作 if (this.moveX < 0) this.moveX = 0 if (this.moveX > buttonsWidth) this.moveX = buttonsWidth // 在开启状态下,点击一下内容区域,moveX为0,也即没有进行移动,这时执行收起菜单逻辑 if (this.moveX === 0) { return this.closeSwipeAction() } // 在开启状态下,滑动距离小于阈值,则默认为不关闭,同时恢复原来的打开状态 if (Math.abs(this.moveX) < this.threshold) { this.openSwipeAction() } else { // 如果滑动距离大于阈值,则执行收起逻辑 this.closeSwipeAction() } } else { // 在关闭的状态下,右滑,无需操作 if (this.moveX >= 0) this.moveX = 0 if (this.moveX <= -buttonsWidth) this.moveX = -buttonsWidth // 理由同上 if (Math.abs(this.moveX) < this.threshold) { this.closeSwipeAction() } else { this.openSwipeAction() } } }, // 移动滑动选择器内容区域,同时显示出其隐藏的菜单 moveSwipeAction(moveX) { if (this.moving) return this.moving = true let previewButtonsMoveX = 0 const len = this.buttons.length animation.transition(this.$refs['uv-swipe-action-item__content'].ref, { styles: { transform: `translateX(${moveX}px)` }, timingFunction: 'linear' }, () => { this.moving = false }) // 按钮的组的长度 for (let i = len - 1; i >= 0; i--) { const buttonRef = this.$refs[`uv-swipe-action-item__right__button-${i}`][0].ref // 通过比例,得出元素自身该移动的距离 const translateX = this.buttons[i].width / this.buttonsWidth * moveX // 最终移动的距离,是通过自身比例算出的距离,再加上在它之前所有按钮移动的距离之和 const realTranslateX = translateX + previewButtonsMoveX animation.transition(buttonRef, { styles: { transform: `translateX(${realTranslateX}px)` }, duration: 0, delay: 0, timingFunction: 'linear' }, () => {}) // 记录本按钮之前的所有按钮的移动距离之和 previewButtonsMoveX += translateX } }, // 关闭菜单 closeSwipeAction() { if (this.status === 'close') return this.moving = true const { buttonsWidth } = this animation.transition(this.$refs['uv-swipe-action-item__content'].ref, { styles: { transform: 'translateX(0px)' }, duration: this.getDuratin, timingFunction: 'ease-in-out' }, () => { this.status = 'close' this.moving = false this.closeHandler() }) // 按钮的组的长度 const len = this.buttons.length for (let i = len - 1; i >= 0; i--) { const buttonRef = this.$refs[`uv-swipe-action-item__right__button-${i}`][0].ref // 如果不满足边界条件,返回 if (this.buttons.length === 0 || !this.buttons[i] || !this.buttons[i].width) return animation.transition(buttonRef, { styles: { transform: 'translateX(0px)' }, duration: this.getDuratin, timingFunction: 'ease-in-out' }, () => {}) } }, // 打开菜单 openSwipeAction() { if (this.status === 'open') return this.moving = true const buttonsWidth = -this.buttonsWidth let previewButtonsMoveX = 0 animation.transition(this.$refs['uv-swipe-action-item__content'].ref, { styles: { transform: `translateX(${buttonsWidth}px)` }, duration: this.getDuratin, timingFunction: 'ease-in-out' }, () => { this.status = 'open' this.moving = false this.openHandler() }) // 按钮的组的长度 const len = this.buttons.length for (let i = len - 1; i >= 0; i--) { const buttonRef = this.$refs[`uv-swipe-action-item__right__button-${i}`][0].ref // 如果不满足边界条件,返回 if (this.buttons.length === 0 || !this.buttons[i] || !this.buttons[i].width) return // 通过比例,得出元素自身该移动的距离 const translateX = this.buttons[i].width / this.buttonsWidth * buttonsWidth // 最终移动的距离,是通过自身比例算出的距离,再加上在它之前所有按钮移动的距离之和 const realTranslateX = translateX + previewButtonsMoveX animation.transition(buttonRef, { styles: { transform: `translateX(${realTranslateX}px)` }, duration: this.getDuratin, timingFunction: 'ease-in-out' }, () => {}) previewButtonsMoveX += translateX } }, // 查询按钮节点信息 queryRect() { // 历遍所有按钮数组,通过getRectByDom返回一个promise const promiseAll = this.rightOptions.map((item, index) => this.getRectByDom(this.$refs[`uv-swipe-action-item__right__button-${index}`][0])) // 通过promise.all方法,让所有按钮的查询结果返回一个数组的形式 Promise.all(promiseAll).then((sizes) => { this.buttons = sizes // 计算所有按钮总宽度 this.buttonsWidth = sizes.reduce((sum, cur) => sum + cur.width, 0) }) }, // 通过nvue的dom模块,查询节点信息 getRectByDom(ref) { return new Promise((resolve) => { dom.getComponentRect(ref, (res) => { resolve(res.size) }) }) } } }
2301_77169380/AppruanjianApk
uni_modules/uv-swipe-action/components/uv-swipe-action-item/nvue - backup.js
JavaScript
unknown
11,903
// nvue操作dom的库,用于获取dom的尺寸信息 const dom = uni.requireNativePlugin('dom'); const bindingX = uni.requireNativePlugin('bindingx'); const animation = uni.requireNativePlugin('animation'); import { getDuration, getPx } from '@/uni_modules/uv-ui-tools/libs/function/index.js' export default { data() { return { // 所有按钮的总宽度 buttonsWidth: 0, // 是否正在移动中 moving: false } }, computed: { // 获取过渡时间 getDuratin() { let duration = String(this.duration) // 如果ms为单位,返回ms的数值部分 if (duration.indexOf('ms') >= 0) return parseInt(duration) // 如果s为单位,为了得到ms的数值,需要乘以1000 if (duration.indexOf('s') >= 0) return parseInt(duration) * 1000 // 如果值传了数值,且小于30,认为是s单位 duration = Number(duration) return duration < 30 ? duration * 1000 : duration } }, watch: { show(n) { if(n) { this.moveCellByAnimation('open') } else { this.moveCellByAnimation('close') } } }, mounted() { setTimeout(()=>{ this.initialize() },20) }, methods: { initialize() { this.queryRect() }, // 关闭单元格,用于打开一个,自动关闭其他单元格的场景 closeHandler() { if(this.status === 'open') { // 如果在打开状态下,进行点击的话,直接关闭单元格 return this.moveCellByAnimation('close') && this.unbindBindingX() } }, // 点击单元格 clickHandler() { // 如果在移动中被点击,进行忽略 if(this.moving) return // 尝试关闭其他打开的单元格 this.parent && this.parent.closeOther(this) if(this.status === 'open') { // 如果在打开状态下,进行点击的话,直接关闭单元格 return this.moveCellByAnimation('close') && this.unbindBindingX() } }, // 滑动单元格 onTouchstart(e) { // 如果当前正在移动中,或者disabled状态,则返回 if(this.moving || this.disabled) { return this.unbindBindingX() } if(this.status === 'open') { // 如果在打开状态下,进行点击的话,直接关闭单元格 return this.moveCellByAnimation('close') && this.unbindBindingX() } // 特殊情况下,e可能不为一个对象 e?.stopPropagation && e.stopPropagation() e?.preventDefault && e.preventDefault() this.moving = true // 获取元素ref const content = this.getContentRef() let expression = `min(max(${-this.buttonsWidth}, x), 0)` // 尝试关闭其他打开的单元格 this.parent && this.parent.closeOther(this) // 阿里为了KPI而开源的BindingX this.panEvent = bindingX.bind({ anchor: content, eventType: 'pan', props: [{ element: content, // 绑定width属性,设置其宽度值 property: 'transform.translateX', expression }] }, (res) => { this.moving = false if (res.state === 'end' || res.state === 'exit') { const deltaX = res.deltaX if(deltaX <= -this.buttonsWidth || deltaX >= 0) { // 如果触摸滑动的过程中,大于单元格的总宽度,或者大于0,意味着已经动过滑动达到了打开或者关闭的状态 // 这里直接进行状态的标记 this.$nextTick(() => { this.status = deltaX <= -this.buttonsWidth ? 'open' : 'close' }) } else if(Math.abs(deltaX) > getPx(this.threshold)) { // 在移动大于阈值、并且小于总按钮宽度时,进行自动打开或者关闭 // 移动距离大于0时,意味着需要关闭状态 if(Math.abs(deltaX) < this.buttonsWidth) { this.moveCellByAnimation(deltaX > 0 ? 'close' : 'open') } } else { // 在小于阈值时,进行关闭操作(如果在打开状态下,将不会执行bindingX) this.moveCellByAnimation('close') } } }) }, // 释放bindingX unbindBindingX() { // 释放上一次的资源 if (this?.panEvent?.token != 0) { bindingX.unbind({ token: this.panEvent?.token, // pan为手势事件 eventType: 'pan' }) } }, // 查询按钮节点信息 queryRect() { // 历遍所有按钮数组,通过getRectByDom返回一个promise const promiseAll = this.options.map(async(item, index) => { return await this.getRectByDom(this.$refs[`uv-swipe-action-item__right__button-${index}`][0]) }) // 通过promise.all方法,让所有按钮的查询结果返回一个数组的形式 Promise.all(promiseAll).then(sizes => { this.buttons = sizes // 计算所有按钮总宽度 this.buttonsWidth = sizes.reduce((sum, cur) => sum + cur.width, 0) }) }, // 通过nvue的dom模块,查询节点信息 getRectByDom(ref) { return new Promise(resolve => { dom.getComponentRect(ref, res => { resolve(res.size) }) }) }, // 移动单元格到左边或者右边尽头 moveCellByAnimation(status = 'open') { if(this.moving) return // 标识当前状态 this.moveing = true const content = this.getContentRef() const x = status === 'open' ? -this.buttonsWidth : 0 animation.transition(content, { styles: { transform: `translateX(${x}px)`, }, duration: getDuration(this.duration, false), timingFunction: 'ease-in-out' }, () => { this.moving = false this.status = status this.unbindBindingX() }) }, // 获取元素ref getContentRef() { return this.$refs['uv-swipe-action-item__content'].ref } }, // #ifdef VUE2 beforeDestroy() { this.unbindBindingX() }, // #endif // #ifdef VUE3 unmounted() { this.unbindBindingX() } // #endif }
2301_77169380/AppruanjianApk
uni_modules/uv-swipe-action/components/uv-swipe-action-item/nvue.js
JavaScript
unknown
5,651
export default { props: { // 控制打开或者关闭 show: { type: Boolean, default: false }, // 标识符,如果是v-for,可用index索引值 name: { type: [String, Number], default: '' }, // 是否禁用 disabled: { type: Boolean, default: false }, // 是否自动关闭其他swipe按钮组 autoClose: { type: Boolean, default: true }, // 滑动距离阈值,只有大于此值,才被认为是要打开菜单 threshold: { type: Number, default: 20 }, // 右侧按钮内容 options: { type: Array, default: () => [] }, // 动画过渡时间,单位ms duration: { type: [String, Number], default: 300 }, ...uni.$uv?.props?.swipeActionItem } }
2301_77169380/AppruanjianApk
uni_modules/uv-swipe-action/components/uv-swipe-action-item/props.js
JavaScript
unknown
739
<template> <view class="uv-swipe-action-item" ref="uv-swipe-action-item"> <view class="uv-swipe-action-item__right"> <slot name="button"> <view v-for="(item,index) in options" :key="index" class="uv-swipe-action-item__right__button" :ref="`uv-swipe-action-item__right__button-${index}`" :style="[{ alignItems: item.style && item.style.borderRadius ? 'center' : 'stretch' }]" @tap="buttonClickHandler(item, index)"> <view class="uv-swipe-action-item__right__button__wrapper" :style="[{ backgroundColor: item.style && item.style.backgroundColor ? item.style.backgroundColor : '#C7C6CD', borderRadius: item.style && item.style.borderRadius ? item.style.borderRadius : '0', padding: item.style && item.style.borderRadius ? '0' : '0 15px', }, item.style]"> <uv-icon v-if="item.icon" :name="item.icon" :color="item.style && item.style.color ? item.style.color : '#ffffff'" :size="item.iconSize ? $uv.addUnit(item.iconSize) : item.style && item.style.fontSize ? $uv.getPx(item.style.fontSize) * 1.2 : 17" :customStyle="{ marginRight: item.text ? '2px' : 0 }"></uv-icon> <text v-if="item.text" class="uv-swipe-action-item__right__button__wrapper__text uv-line-1" :style="[{ color: item.style && item.style.color ? item.style.color : '#ffffff', fontSize: item.style && item.style.fontSize ? item.style.fontSize : '16px', lineHeight: item.style && item.style.fontSize ? item.style.fontSize : '16px', }]">{{ item.text }}</text> </view> </view> </slot> </view> <!-- #ifndef APP-NVUE --> <view class="uv-swipe-action-item__content" @touchstart="wxs.touchstart" @touchmove="wxs.touchmove" @touchend="wxs.touchend" :status="status" :change:status="wxs.statusChange" :size="size" :change:size="wxs.sizeChange"> <!-- #endif --> <!-- #ifdef APP-NVUE --> <view class="uv-swipe-action-item__content" ref="uv-swipe-action-item__content" @panstart="onTouchstart" @tap="clickHandler"> <!-- #endif --> <slot /> </view> </view> </template> <!-- #ifdef APP-VUE || MP-WEIXIN || H5 || MP-QQ --> <script src="./index.wxs" module="wxs" lang="wxs"></script> <!-- #endif --> <script> import touch from '@/uni_modules/uv-ui-tools/libs/mixin/touch.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 import nvue from './nvue.js'; // #endif // #ifdef APP-VUE || MP-WEIXIN || H5 || MP-QQ import wxs from './wxs.js'; // #endif /** * SwipeActionItem 滑动单元格子组件 * @description 该组件一般用于左滑唤出操作菜单的场景,用的最多的是左滑删除操作 * @tutorial https://www.uvui.cn/components/swipeAction.html * @property {Boolean} show 控制打开或者关闭(默认 false ) * @property {String | Number} index 标识符,如果是v-for,可用index索引 * @property {Boolean} disabled 是否禁用(默认 false ) * @property {Boolean} autoClose 是否自动关闭其他swipe按钮组(默认 true ) * @property {Number} threshold 滑动距离阈值,只有大于此值,才被认为是要打开菜单(默认 30 ) * @property {Array} options 右侧按钮内容 * @property {String | Number} duration 动画过渡时间,单位ms(默认 350 ) * @event {Function(index)} open 组件打开时触发 * @event {Function(index)} close 组件关闭时触发 * @example <uv-swipe-action><uv-swipe-action-item :options="options1" ></uv-swipe-action-item></uv-swipe-action> */ export default { name: 'uv-swipe-action-item', emits: ['click'], // #ifndef APP-NVUE mixins: [mpMixin, mixin, props, touch], // #endif // #ifdef APP-NVUE mixins: [mpMixin, mixin, props, nvue , touch], // #endif // #ifdef APP-VUE || MP-WEIXIN || H5 || MP-QQ mixins: [mpMixin, mixin, props, touch, wxs], // #endif data() { return { // 按钮的尺寸信息 size: {}, // 父组件uv-swipe-action的参数 parentData: { autoClose: true, }, // 当前状态,open-打开,close-关闭 status: 'close', } }, watch: { // 由于wxs无法直接读取外部的值,需要在外部值变化时,重新执行赋值逻辑 wxsInit(newValue, oldValue) { this.queryRect() } }, computed: { wxsInit() { return [this.disabled, this.autoClose, this.threshold, this.options, this.duration] } }, mounted() { // #ifdef MP-TOUTIAO this.$uv.error('抖音小程序暂不支持wxs,故该组件暂不支持抖音小程序'); // #endif this.init() }, methods: { init() { // 初始化父组件数据 this.updateParentData() // #ifndef APP-NVUE this.$uv.sleep().then(() => { this.queryRect() }) // #endif }, updateParentData() { // 此方法在mixin中 this.getParentData('uv-swipe-action') }, // #ifndef APP-NVUE // 查询节点 queryRect() { this.$uvGetRect('.uv-swipe-action-item__right__button', true).then(buttons => { this.size = { buttons, show: this.show, disabled: this.disabled, threshold: this.threshold, duration: this.duration } }) }, // #endif // 按钮被点击 buttonClickHandler(item, index) { this.$emit('click', { index, name: this.name }) } }, } </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-swipe-action-item { position: relative; overflow: hidden; /* #ifndef APP-NVUE || MP-WEIXIN */ touch-action: pan-y; /* #endif */ &__content { background-color: #FFFFFF; z-index: 10; } &__right { position: absolute; top: 0; bottom: 0; right: 0; @include flex; &__button { @include flex; justify-content: center; overflow: hidden; align-items: center; &__wrapper { @include flex; align-items: center; justify-content: center; padding: 0 15px; &__text { @include flex; align-items: center; color: #FFFFFF; font-size: 15px; text-align: center; justify-content: center; } } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-swipe-action/components/uv-swipe-action-item/uv-swipe-action-item.vue
Vue
unknown
6,388
export default { methods: { // 关闭时执行 closeHandler() { this.status = 'close' }, setState(status) { this.status = status }, closeOther() { // 尝试关闭其他打开的单元格 this.parent && this.parent.closeOther(this) } } }
2301_77169380/AppruanjianApk
uni_modules/uv-swipe-action/components/uv-swipe-action-item/wxs.js
JavaScript
unknown
349
export default { props: { // 列表数组,元素可为字符串,如为对象可通过keyName指定目标属性名 list: { type: Array, default: () => [] }, // 是否显示面板指示器 indicator: { type: Boolean, default: false }, // 指示器非激活颜色 indicatorActiveColor: { type: String, default: '#fff' }, // 指示器的激活颜色 indicatorInactiveColor: { type: String, default: 'rgba(255, 255, 255, 0.35)' }, // 指示器样式,可通过bottom,left,right进行定位 indicatorStyle: { type: [String, Object], default: '' }, // 指示器模式,line-线型,dot-点型 indicatorMode: { type: String, default: 'line' }, // 是否自动切换 autoplay: { type: Boolean, default: true }, // 当前所在滑块的 index current: { type: [String, Number], default: 0 }, // 当前所在滑块的 item-id ,不能与 current 被同时指定 currentItemId: { type: String, default: '' }, // 滑块自动切换时间间隔 interval: { type: [String, Number], default: 3000 }, // 滑块切换过程所需时间 duration: { type: [String, Number], default: 300 }, // 播放到末尾后是否重新回到开头 circular: { type: Boolean, default: false }, // 滑动方向是否为纵向 vertical: { type: Boolean, default: false }, // 前边距,可用于露出前一项的一小部分,nvue和支付宝不支持 previousMargin: { type: [String, Number], default: 0 }, // 后边距,可用于露出后一项的一小部分,nvue和支付宝不支持 nextMargin: { type: [String, Number], default: 0 }, // 当开启时,会根据滑动速度,连续滑动多屏,支付宝不支持 acceleration: { type: Boolean, default: false }, // 同时显示的滑块数量,nvue、支付宝小程序不支持 displayMultipleItems: { type: Number, default: 1 }, // 指定swiper切换缓动动画类型,有效值:default、linear、easeInCubic、easeOutCubic、easeInOutCubic // 只对微信小程序有效 easingFunction: { type: String, default: 'default' }, // list数组中指定对象的目标属性名 keyName: { type: String, default: 'url' }, // 图片的裁剪模式 imgMode: { type: String, default: 'aspectFill' }, // 组件高度 height: { type: [String, Number], default: 130 }, // 背景颜色 bgColor: { type: String, default: '#f3f4f6' }, // 组件圆角,数值或带单位的字符串 radius: { type: [String, Number], default: 4 }, // 是否加载中 loading: { type: Boolean, default: false }, // 是否显示标题,要求数组对象中有title属性 showTitle: { type: Boolean, default: false }, // 显示的标题样式 titleStyle: { type: [Object, String], default: '' }, ...uni.$uv?.props?.swiper } }
2301_77169380/AppruanjianApk
uni_modules/uv-swiper/components/uv-swiper/props.js
JavaScript
unknown
2,961
<template> <view class="uv-swiper" :style="{ backgroundColor: bgColor, height: $uv.addUnit(height), borderRadius: $uv.addUnit(radius) }" > <view class="uv-swiper__loading" v-if="loading" > <uv-loading-icon mode="circle"></uv-loading-icon> </view> <swiper v-else class="uv-swiper__wrapper" :style="{ height: $uv.addUnit(height), flex: 1 }" @change="change" :circular="circular" :vertical="vertical" :interval="interval" :duration="duration" :autoplay="autoplay" :current="current" :currentItemId="currentItemId" :previousMargin="$uv.addUnit(previousMargin)" :nextMargin="$uv.addUnit(nextMargin)" :acceleration="acceleration" :displayMultipleItems="displayMultipleItems" :easingFunction="easingFunction" > <swiper-item class="uv-swiper__wrapper__item" v-for="(item, index) in list" :key="index" > <view class="uv-swiper__wrapper__item__wrapper" :style="[itemStyle(index)]" > <!-- 在nvue中,image图片的宽度默认为屏幕宽度,需要通过flex:1撑开,另外必须设置高度才能显示图片 --> <image class="uv-swiper__wrapper__item__wrapper__image" v-if="getItemType(item) === 'image'" :src="getSource(item)" :mode="imgMode" @tap="clickHandler(index)" :style="{ height: $uv.addUnit(height), borderRadius: $uv.addUnit(radius) }" ></image> <video class="uv-swiper__wrapper__item__wrapper__video" v-if="getItemType(item) === 'video'" :id="`video-${index}`" :enable-progress-gesture="false" :src="getSource(item)" :poster="getPoster(item)" :title="showTitle && $uv.test.object(item) && item.title ? item.title : ''" :style="{ height: $uv.addUnit(height) }" controls @tap="clickHandler(index)" ></video> <text v-if="showTitle && $uv.test.object(item) && item.title" class="uv-swiper__wrapper__item__wrapper__title uv-line-1" :style="[$uv.addStyle(titleStyle)]" >{{ item.title }}</text> </view> </swiper-item> </swiper> <view class="uv-swiper__indicator" :style="[$uv.addStyle(indicatorStyle)]"> <slot name="indicator"> <uv-swiper-indicator v-if="!loading && indicator && !showTitle" :indicatorActiveColor="indicatorActiveColor" :indicatorInactiveColor="indicatorInactiveColor" :length="list.length" :current="currentIndex" :indicatorMode="indicatorMode" ></uv-swiper-indicator> </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'; /** * Swiper 轮播图 * @description 该组件一般用于导航轮播,广告展示等场景,可开箱即用, * @tutorial https://www.uvui.cn/components/swiper.html * @property {Array} list 轮播图数据 * @property {Boolean} indicator 是否显示面板指示器(默认 false ) * @property {String} indicatorActiveColor 指示器非激活颜色(默认 '#FFFFFF' ) * @property {String} indicatorInactiveColor 指示器的激活颜色(默认 'rgba(255, 255, 255, 0.35)' ) * @property {String | Object} indicatorStyle 指示器样式,可通过bottom,left,right进行定位 * @property {String} indicatorMode 指示器模式(默认 'line' ) * @property {Boolean} autoplay 是否自动切换(默认 true ) * @property {String | Number} current 当前所在滑块的 index(默认 0 ) * @property {String} currentItemId 当前所在滑块的 item-id ,不能与 current 被同时指定 * @property {String | Number} interval 滑块自动切换时间间隔(ms)(默认 3000 ) * @property {String | Number} duration 滑块切换过程所需时间(ms)(默认 300 ) * @property {Boolean} circular 播放到末尾后是否重新回到开头(默认 false ) * @property {String | Number} previousMargin 前边距,可用于露出前一项的一小部分,nvue和支付宝不支持(默认 0 ) * @property {String | Number} nextMargin 后边距,可用于露出后一项的一小部分,nvue和支付宝不支持(默认 0 ) * @property {Boolean} acceleration 当开启时,会根据滑动速度,连续滑动多屏,支付宝不支持(默认 false ) * @property {Number} displayMultipleItems 同时显示的滑块数量,nvue、支付宝小程序不支持(默认 1 ) * @property {String} easingFunction 指定swiper切换缓动动画类型, 只对微信小程序有效(默认 'default' ) * @property {String} keyName list数组中指定对象的目标属性名(默认 'url' ) * @property {String} imgMode 图片的裁剪模式(默认 'aspectFill' ) * @property {String | Number} height 组件高度(默认 130 ) * @property {String} bgColor 背景颜色(默认 '#f3f4f6' ) * @property {String | Number} radius 组件圆角,数值或带单位的字符串(默认 4 ) * @property {Boolean} loading 是否加载中(默认 false ) * @property {Boolean} showTitle 是否显示标题,要求数组对象中有title属性(默认 false ) * @event {Function(index)} click 点击轮播图时触发 index:点击了第几张图片,从0开始 * @event {Function(index)} change 轮播图切换时触发(自动或者手动切换) index:切换到了第几张图片,从0开始 * @example <uv-swiper :list="list4" keyName="url" :autoplay="false"></uv-swiper> */ export default { name: 'uv-swiper', mixins: [mpMixin, mixin, props], emits: ['click','change'], data() { return { currentIndex: 0 } }, watch: { current(val, preVal) { if(val === preVal) return; this.currentIndex = val; // 和上游数据关联上 } }, computed: { itemStyle() { return index => { const style = {} // #ifndef APP-NVUE || MP-TOUTIAO // 左右流出空间的写法不支持nvue和头条 // 只有配置了此二值,才加上对应的圆角,以及缩放 if (this.nextMargin && this.previousMargin) { style.borderRadius = this.$uv.addUnit(this.radius) if (index !== this.currentIndex) style.transform = 'scale(0.92)' } // #endif return style } } }, methods: { getItemType(item) { if (typeof item === 'string') return this.$uv.test.video(this.getSource(item)) ? 'video' : 'image' if (typeof item === 'object' && this.keyName) { if (!item.type) return this.$uv.test.video(this.getSource(item)) ? 'video' : 'image' if (item.type === 'image') return 'image' if (item.type === 'video') return 'video' return 'image' } }, // 获取目标路径,可能数组中为字符串,对象的形式,额外可指定对象的目标属性名keyName getSource(item) { if (typeof item === 'string') return item if (typeof item === 'object' && this.keyName) return item[this.keyName] else this.$uv.error('请按格式传递列表参数') return '' }, // 轮播切换事件 change(e) { // 当前的激活索引 const { current } = e.detail this.pauseVideo(this.currentIndex) this.currentIndex = current this.$emit('change', e.detail) }, // 切换轮播时,暂停视频播放 pauseVideo(index) { const lastItem = this.getSource(this.list[index]) if (this.$uv.test.video(lastItem)) { // 当视频隐藏时,暂停播放 const video = uni.createVideoContext(`video-${index}`, this) video.pause() } }, // 当一个轮播item为视频时,获取它的视频海报 getPoster(item) { return typeof item === 'object' && item.poster ? item.poster : '' }, // 点击某个item clickHandler(index) { this.$emit('click', 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'; .uv-swiper { @include flex; justify-content: center; align-items: center; position: relative; overflow: hidden; &__wrapper { flex: 1; &__item { flex: 1; &__wrapper { @include flex; position: relative; overflow: hidden; transition: transform 0.3s; flex: 1; &__image { flex: 1; } &__video { flex: 1; } &__title { position: absolute; background-color: rgba(0, 0, 0, 0.3); bottom: 0; left: 0; right: 0; font-size: 28rpx; height: 60rpx; line-height: 60rpx; color: #FFFFFF; flex: 1; } } } } &__indicator { position: absolute; bottom: 10px; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-swiper/components/uv-swiper/uv-swiper.vue
Vue
unknown
8,937
export default { props: { // 轮播的长度 length: { type: [String, Number], default: 0 }, // 当前处于活动状态的轮播的索引 current: { type: [String, Number], default: 0 }, // 指示器非激活颜色 indicatorActiveColor: { type: String, default: '' }, // 指示器的激活颜色 indicatorInactiveColor: { type: String, default: '' }, // 指示器模式,line-线型,dot-点型 indicatorMode: { type: String, default: '' }, ...uni.$uv?.props?.swiperIndicator } }
2301_77169380/AppruanjianApk
uni_modules/uv-swiper/components/uv-swiper-indicator/props.js
JavaScript
unknown
546
<template> <view class="uv-swiper-indicator"> <view class="uv-swiper-indicator__wrapper" v-if="indicatorMode === 'line'" :class="[`uv-swiper-indicator__wrapper--${indicatorMode}`]" :style="{ width: $uv.addUnit(lineWidth * length), backgroundColor: indicatorInactiveColor }" > <view class="uv-swiper-indicator__wrapper--line__bar" :style="[lineStyle]" ></view> </view> <view class="uv-swiper-indicator__wrapper" v-if="indicatorMode === 'dot'" > <view class="uv-swiper-indicator__wrapper__dot" v-for="(item, index) in length" :key="index" :class="[index === current && 'uv-swiper-indicator__wrapper__dot--active']" :style="[dotStyle(index)]" > </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'; /** * SwiperIndicator 轮播图指示器 * @description 该组件一般用于导航轮播,广告展示等场景,可开箱即用, * @tutorial https://www.uvui.cn/components/swiper.html * @property {String | Number} length 轮播的长度(默认 0 ) * @property {String | Number} current 当前处于活动状态的轮播的索引(默认 0 ) * @property {String} indicatorActiveColor 指示器非激活颜色 * @property {String} indicatorInactiveColor 指示器的激活颜色 * @property {String} indicatorMode 指示器模式(默认 'line' ) * @example <uv-swiper :list="list4" indicator keyName="url" :autoplay="false"></uv-swiper> */ export default { name: 'uv-swiper-indicator', mixins: [mpMixin, mixin, props], data() { return { lineWidth: 22 } }, computed: { // 指示器为线型的样式 lineStyle() { let style = {} style.width = this.$uv.addUnit(this.lineWidth) style.transform = `translateX(${ this.$uv.addUnit(this.current * this.lineWidth) })` style.backgroundColor = this.indicatorActiveColor return style }, // 指示器为点型的样式 dotStyle() { return index => { let style = {} style.backgroundColor = index === this.current ? this.indicatorActiveColor : this.indicatorInactiveColor return style } } }, } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-swiper-indicator { &__wrapper { @include flex; &--line { border-radius: 100px; height: 4px; &__bar { width: 22px; height: 4px; border-radius: 100px; background-color: #FFFFFF; transition: transform 0.3s; } } &__dot { width: 5px; height: 5px; border-radius: 100px; margin: 0 4px; &--active { width: 12px; } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-swiper/components/uv-swiper-indicator/uv-swiper-indicator.vue
Vue
unknown
2,835
export default { props: { value: { type: [Boolean, String, Number], default: false }, modelValue: { type: [Boolean, String, Number], default: false }, // 是否为加载中状态 loading: { type: Boolean, default: false }, // 是否为禁用装填 disabled: { type: Boolean, default: false }, // 开关尺寸,单位px size: { type: [String, Number], default: 25 }, // 打开时的背景颜色 activeColor: { type: String, default: '#2979ff' }, // 关闭时的背景颜色 inactiveColor: { type: String, default: '#fff' }, // switch打开时的值 activeValue: { type: [String, Number, Boolean], default: true }, // switch关闭时的值 inactiveValue: { type: [String, Number, Boolean], default: false }, // 是否开启异步变更,开启后需要手动控制输入值 asyncChange: { type: Boolean, default: false }, // 圆点与外边框的距离 space: { type: [String, Number], default: 0 }, ...uni.$uv?.props?.switch } }
2301_77169380/AppruanjianApk
uni_modules/uv-switch/components/uv-switch/props.js
JavaScript
unknown
1,061
<template> <view class="uv-switch" :class="[disabled && 'uv-switch--disabled']" :style="[switchStyle, $uv.addStyle(customStyle)]" @tap="clickHandler" > <view class="uv-switch__bg" :style="[bgStyle]" > </view> <view class="uv-switch__node" :class="[innerValue && 'uv-switch__node--on']" :style="[nodeStyle]" ref="uv-switch__node" > <uv-loading-icon :show="loading" mode="circle" timingFunction='linear' :color="innerValue ? activeColor : '#AAABAD'" :size="size * 0.6" /> </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'; /** * switch 开关选择器 * @description 选择开关一般用于只有两个选择,且只能选其一的场景。 * @tutorial https://www.uvui.cn/components/switch.html * @property {Boolean} loading 是否处于加载中(默认 false ) * @property {Boolean} disabled 是否禁用(默认 false ) * @property {String | Number} size 开关尺寸,单位px (默认 25 ) * @property {String} activeColor 打开时的背景色 (默认 '#2979ff' ) * @property {String} inactiveColor 关闭时的背景色 (默认 '#ffffff' ) * @property {Boolean | String | Number} value 通过v-model双向绑定的值 (默认 false ) * @property {Boolean | String | Number} activeValue 打开选择器时通过change事件发出的值 (默认 true ) * @property {Boolean | String | Number} inactiveValue 关闭选择器时通过change事件发出的值 (默认 false ) * @property {Boolean} asyncChange 是否开启异步变更,开启后需要手动控制输入值 (默认 false ) * @property {String | Number} space 圆点与外边框的距离 (默认 0 ) * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function} change 在switch打开或关闭时触发 * @example <uv-switch v-model="checked" active-color="red" inactive-color="#eee"></uv-switch> */ export default { name: "uv-switch", mixins: [mpMixin, mixin, props], data() { return { bgColor: '#ffffff', innerValue: false } }, watch: { // #ifdef VUE2 value: { immediate: true, handler(newVal) { if (newVal !== this.inactiveValue && newVal !== this.activeValue) { return this.$uv.error('v-model绑定的值必须为inactiveValue、activeValue二者之一') } this.innerValue = newVal; } }, // #endif // #ifndef VUE2 modelValue: { immediate: true, handler(newVal) { if (newVal !== this.inactiveValue && newVal !== this.activeValue) { return this.$uv.error('v-model绑定的值必须为inactiveValue、activeValue二者之一') } this.innerValue = newVal; } } // #endif }, created() { this.innerValue = this.value || this.modelValue; }, computed: { isActive() { return this.innerValue === this.activeValue; }, switchStyle() { let style = {} // 这里需要加2,是为了腾出边框的距离,否则圆点node会和外边框紧贴在一起 style.width = this.$uv.addUnit(this.$uv.getPx(this.size) * 2 + 2) style.height = this.$uv.addUnit(this.$uv.getPx(this.size) + 2) // 如果自定义了“非激活”演示,name边框颜色设置为透明(跟非激活颜色一致) // 这里不能简单的设置为非激活的颜色,否则打开状态时,会有边框,所以需要透明 if (this.customInactiveColor) { style.borderColor = 'rgba(0, 0, 0, 0)' } style.backgroundColor = this.isActive ? this.activeColor : this.inactiveColor return style; }, nodeStyle() { let style = {} // 如果自定义非激活颜色,将node圆点的尺寸减少两个像素,让其与外边框距离更大一点 style.width = this.$uv.addUnit(this.$uv.getPx(this.size) - this.space) style.height = this.$uv.addUnit(this.$uv.getPx(this.size) - this.space) const translateX = this.isActive ? this.$uv.addUnit(this.space) : this.$uv.addUnit(this.$uv.getPx(this.size)); style.transform = `translateX(-${translateX})` return style }, bgStyle() { let style = {} // 这里配置一个多余的元素在HTML中,是为了让switch切换时,有更良好的背景色扩充体验(见实际效果) style.width = this.$uv.addUnit(this.$uv.getPx(this.size) * 2 - this.$uv.getPx(this.size) / 2) style.height = this.$uv.addUnit(this.$uv.getPx(this.size)) style.backgroundColor = this.inactiveColor // 打开时,让此元素收缩,否则反之 style.transform = `scale(${this.isActive ? 0 : 1})` return style }, customInactiveColor() { // 之所以需要判断是否自定义了“非激活”颜色,是为了让node圆点离外边框更宽一点的距离 return this.inactiveColor !== '#fff' && this.inactiveColor !== '#ffffff' } }, methods: { clickHandler() { if (!this.disabled && !this.loading) { const oldValue = this.isActive ? this.inactiveValue : this.activeValue if (!this.asyncChange) { this.$emit('input', oldValue) this.$emit('update:modelValue', oldValue) } // 放到下一个生命周期,因为双向绑定的value修改父组件状态需要时间,且是异步的 this.$nextTick(() => { this.$emit('change', oldValue) }) } } } }; </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-switch { @include flex(row); /* #ifndef APP-NVUE */ box-sizing: border-box; /* #endif */ position: relative; background-color: #fff; border-width: 1px; border-radius: 100px; transition: background-color 0.4s; border-color: rgba(0, 0, 0, 0.12); border-style: solid; justify-content: flex-end; align-items: center; // 由于weex为阿里逗着玩的KPI项目,导致bug奇多,这必须要写这一行, // 否则在iOS上,点击页面任意地方,都会触发switch的点击事件 overflow: hidden; &__node { @include flex(row); align-items: center; justify-content: center; border-radius: 100px; background-color: #fff; border-radius: 100px; box-shadow: 1px 1px 1px 0 rgba(0, 0, 0, 0.25); transition-property: transform; transition-duration: 0.4s; transition-timing-function: cubic-bezier(0.3, 1.05, 0.4, 1.05); } &__bg { position: absolute; border-radius: 100px; background-color: #FFFFFF; transition-property: transform; transition-duration: 0.4s; border-top-left-radius: 0; border-bottom-left-radius: 0; transition-timing-function: ease; } &--disabled { opacity: 0.6; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-switch/components/uv-switch/uv-switch.vue
Vue
unknown
6,826
export default { props: { // 当前匹配项的name value: { type: [String, Number, null], default: null }, // 是否为iPhoneX留出底部安全距离 safeAreaInsetBottom: { type: Boolean, default: true }, // 是否显示上方边框 border: { type: Boolean, default: true }, // 元素层级z-index zIndex: { type: [String, Number], default: 9 }, // 选中标签的颜色 activeColor: { type: String, default: '#1989fa' }, // 未选中标签的颜色 inactiveColor: { type: String, default: '#7d7e80' }, // 是否固定在底部 fixed: { type: Boolean, default: true }, // fixed定位固定在底部时,是否生成一个等高元素防止塌陷 placeholder: { type: Boolean, default: true }, // 图标大小 iconSize: { type: [String, Number], default: 20 }, ...uni.$uv?.props?.tabbar } }
2301_77169380/AppruanjianApk
uni_modules/uv-tabbar/components/uv-tabbar/props.js
JavaScript
unknown
904
<template> <view class="uv-tabbar"> <view class="uv-tabbar__content" ref="uv-tabbar__content" @touchmove.stop.prevent="noop" :class="[border && 'uv-border-top', fixed && 'uv-tabbar--fixed']" :style="[tabbarStyle]" > <view class="uv-tabbar__content__item-wrapper"> <slot /> </view> <uv-safe-bottom v-if="safeAreaInsetBottom"></uv-safe-bottom> </view> <view class="uv-tabbar__placeholder" v-if="placeholder" :style="{ height: placeholderHeight + 'px', }" ></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 /** * Tabbar 底部导航栏 * @description 此组件提供了自定义tabbar的能力。 * @tutorial https://www.uvui.cn/components/tabbar.html * @property {String | Number} value 当前匹配项的name * @property {Boolean} safeAreaInsetBottom 是否为iPhoneX留出底部安全距离(默认 true ) * @property {Boolean} border 是否显示上方边框(默认 true ) * @property {String | Number} zIndex 元素层级z-index(默认 1 ) * @property {String} activeColor 选中标签的颜色(默认 '#1989fa' ) * @property {String} inactiveColor 未选中标签的颜色(默认 '#7d7e80' ) * @property {Boolean} fixed 是否固定在底部(默认 true ) * @property {Boolean} placeholder fixed定位固定在底部时,是否生成一个等高元素防止塌陷(默认 true ) * @property {Object} customStyle 定义需要用到的外部样式 * * @example <uv-tabbar :value="value2" :placeholder="false" @change="name => value2 = name" :fixed="false" :safeAreaInsetBottom="false"><uv-tabbar-item text="首页" icon="home" dot ></uv-tabbar-item></uv-tabbar> */ export default { name: 'uv-tabbar', mixins: [mpMixin, mixin, props], data() { return { placeholderHeight: 0 } }, computed: { tabbarStyle() { const style = { zIndex: this.zIndex } // 合并来自父组件的customStyle样式 return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)) }, // 监听多个参数的变化,通过在computed执行对应的操作 updateChild() { return [this.value, this.activeColor, this.inactiveColor] }, updatePlaceholder() { return [this.fixed, this.placeholder] } }, watch: { updateChild() { // 如果updateChildren中的元素发生了变化,则执行子元素初始化操作 this.updateChildren() }, updatePlaceholder() { // 如果fixed,placeholder等参数发生变化,重新计算占位元素的高度 this.setPlaceholderHeight() } }, created() { this.children = [] }, mounted() { this.setPlaceholderHeight() }, methods: { updateChildren() { // 如果存在子元素,则执行子元素的updateFromParent进行更新数据 this.children.length && this.children.map(child => child.updateFromParent()) }, // 设置用于防止塌陷元素的高度 async setPlaceholderHeight() { if (!this.fixed || !this.placeholder) return // 延时一定时间 await this.$uv.sleep(20) // #ifndef APP-NVUE this.$uvGetRect('.uv-tabbar__content').then(({height = 50}) => { // 修复IOS safearea bottom 未填充高度 this.placeholderHeight = height }) // #endif // #ifdef APP-NVUE dom.getComponentRect(this.$refs['uv-tabbar__content'], (res) => { const { size } = res this.placeholderHeight = size.height }) // #endif } } } </script> <style lang="scss" scoped> $show-border: 1; $show-border-top: 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-tabbar { @include flex(column); flex: 1; justify-content: center; &__content { @include flex(column); background-color: #fff; &__item-wrapper { height: 50px; @include flex(row); } } &--fixed { position: fixed; bottom: 0; left: 0; right: 0; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-tabbar/components/uv-tabbar/uv-tabbar.vue
Vue
unknown
4,327
export default { props: { // item标签的名称,作为与uv-tabbar的value参数匹配的标识符 name: { type: [String, Number, null], default: null }, // uv-ui内置图标或者绝对路径的图片 icon: { icon: String, default: '' }, // 图标大小,默认uv-tabbar的iconSize=20 iconSize: { type: [String, Number], default: '' }, // 右上角的角标提示信息 badge: { type: [String, Number, null], default: null }, // 是否显示圆点,将会覆盖badge参数 dot: { type: Boolean, default: false }, // 描述文本 text: { type: String, default: '' }, // 控制徽标的位置,对象或者字符串形式,可以设置top和right属性 badgeStyle: { type: [Object, String], default: 'top: 6px;right:2px;' }, ...uni.$uv?.props?.tabbarItem } }
2301_77169380/AppruanjianApk
uni_modules/uv-tabbar/components/uv-tabbar-item/props.js
JavaScript
unknown
852
<template> <view class="uv-tabbar-item" :style="[$uv.addStyle(customStyle)]" @tap="clickHandler" > <view class="uv-tabbar-item__icon"> <uv-icon v-if="icon" :name="icon" :color="isActive? parentData.activeColor : parentData.inactiveColor" :size="iconSize? iconSize: parentData.iconSize" ></uv-icon> <template v-else> <slot v-if="isActive" name="active-icon" /> <slot v-else name="inactive-icon" /> </template> <uv-badge absolute :offset="[0, dot ? '34rpx' : badge > 9 ? '14rpx' : '20rpx']" :customStyle="badgeStyle" :isDot="dot" :value="badge || (dot ? 1 : null)" :show="dot || badge > 0" ></uv-badge> </view> <slot name="text"> <text class="uv-tabbar-item__text" :style="{ color: isActive? parentData.activeColor : parentData.inactiveColor }" >{{ text }}</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'; /** * TabbarItem 底部导航栏子组件 * @description 此组件提供了自定义tabbar的能力。 * @tutorial https://www.uvui.cn/components/tabbar.html * @property {String | Number} name item标签的名称,作为与uv-tabbar的value参数匹配的标识符 * @property {String} icon uvui内置图标或者绝对路径的图片 * @property {String | Number} badge 右上角的角标提示信息 * @property {Boolean} dot 是否显示圆点,将会覆盖badge参数(默认 false ) * @property {String} text 描述文本 * @property {Object | String} badgeStyle 控制徽标的位置,对象或者字符串形式,可以设置top和right属性(默认 'top: 6px;right:2px;' ) * @property {Object} customStyle 定义需要用到的外部样式 * * @example <uv-tabbar :value="value2" :placeholder="false" @change="name => value2 = name" :fixed="false" :safeAreaInsetBottom="false"><uv-tabbar-item text="首页" icon="home" dot ></uv-tabbar-item></uv-tabbar> */ export default { name: 'uv-tabbar-item', mixins: [mpMixin, mixin, props], emits: ['click','change'], data() { return { isActive: false, // 是否处于激活状态 parentData: { value: null, activeColor: '', inactiveColor: '', iconSize: 20 } } }, created() { this.init() }, methods: { init() { // 支付宝小程序不支持provide/inject,所以使用这个方法获取整个父组件,在created定义,避免循环引用 this.updateParentData() if (!this.parent) { this.$uv.error('uv-tabbar-item必须搭配uv-tabbar组件使用') } // 本子组件在uv-tabbar的children数组中的索引 const index = this.parent.children.indexOf(this) // 判断本组件的name(如果没有定义name,就用index索引)是否等于父组件的value参数 this.isActive = (this.name || index) === this.parentData.value }, updateParentData() { // 此方法在mixin中 this.getParentData('uv-tabbar') }, // 此方法将会被父组件uv-tabbar调用 updateFromParent() { // 重新初始化 this.init() }, clickHandler() { this.$nextTick(() => { const index = this.parent.children.indexOf(this) const name = this.name || index // 点击的item为非激活的item才发出change事件 if (name !== this.parent.value) { this.parent.$emit('change', name) } this.$emit('click', name) }) } }, } </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-tabbar-item { @include flex(column); align-items: center; justify-content: center; flex: 1; &__icon { @include flex; position: relative; width: 150rpx; justify-content: center; } &__text { margin-top: 2px; font-size: 12px; color: $uv-content-color; } } /* #ifdef MP */ // 由于小程序都使用shadow DOM形式实现,需要给影子宿主设置flex: 1才能让其撑开 :host { flex: 1 } /* #endif */ </style>
2301_77169380/AppruanjianApk
uni_modules/uv-tabbar/components/uv-tabbar-item/uv-tabbar-item.vue
Vue
unknown
4,271
export default { props: { // 滑块的移动过渡时间,单位ms duration: { type: Number, default: 300 }, // tabs标签数组 list: { type: Array, default: () => [] }, // 滑块颜色 lineColor: { type: String, default: '#3c9cff' }, // 菜单选择中时的样式 activeStyle: { type: [String, Object], default: () => ({ color: '#303133' }) }, // 菜单非选中时的样式 inactiveStyle: { type: [String, Object], default: () => ({ color: '#606266' }) }, // 滑块长度 lineWidth: { type: [String, Number], default: 20 }, // 滑块高度 lineHeight: { type: [String, Number], default: 3 }, // 滑块背景显示大小,当滑块背景设置为图片时使用 lineBgSize: { type: String, default: 'cover' }, // 菜单item的样式 itemStyle: { type: [String, Object], default: () => ({ height: '44px' }) }, // 菜单是否可滚动 scrollable: { type: Boolean, default: true }, // 当前选中标签的索引 current: { type: [Number, String], default: 0 }, // 默认读取的键名 keyName: { type: String, default: 'name' }, ...uni.$uv?.props?.tabs } }
2301_77169380/AppruanjianApk
uni_modules/uv-tabs/components/uv-tabs/props.js
JavaScript
unknown
1,230
<template> <view class="uv-tabs" :style="[$uv.addStyle(customStyle)]"> <view class="uv-tabs__wrapper"> <slot name="left" /> <view class="uv-tabs__wrapper__scroll-view-wrapper"> <scroll-view :scroll-x="scrollable" :scroll-left="scrollLeft" scroll-with-animation class="uv-tabs__wrapper__scroll-view" :show-scrollbar="false" ref="uv-tabs__wrapper__scroll-view" > <view class="uv-tabs__wrapper__nav" ref="uv-tabs__wrapper__nav" :style="{ flex: scrollable ? '' : 1 }" > <view class="uv-tabs__wrapper__nav__item" v-for="(item, index) in list" :key="index" @tap="clickHandler(item, index)" :ref="`uv-tabs__wrapper__nav__item-${index}`" :style="[{flex: scrollable ? '' : 1},$uv.addStyle(itemStyle)]" :class="[`uv-tabs__wrapper__nav__item-${index}`, item.disabled && 'uv-tabs__wrapper__nav__item--disabled']" > <text :class="[item.disabled && 'uv-tabs__wrapper__nav__item__text--disabled']" class="uv-tabs__wrapper__nav__item__text" :style="[textStyle(index)]" >{{ item[keyName] }}</text> <uv-badge :show="!!(item.badge && (item.badge.show || item.badge.isDot || item.badge.value))" :isDot="item.badge && item.badge.isDot || propsBadge.isDot" :value="item.badge && item.badge.value || propsBadge.value" :max="item.badge && item.badge.max || propsBadge.max" :type="item.badge && item.badge.type || propsBadge.type" :showZero="item.badge && item.badge.showZero || propsBadge.showZero" :bgColor="item.badge && item.badge.bgColor || propsBadge.bgColor" :color="item.badge && item.badge.color || propsBadge.color" :shape="item.badge && item.badge.shape || propsBadge.shape" :numberType="item.badge && item.badge.numberType || propsBadge.numberType" :inverted="item.badge && item.badge.inverted || propsBadge.inverted" customStyle="margin-left: 4px;" ></uv-badge> </view> <!-- #ifdef APP-NVUE --> <view class="uv-tabs__wrapper__nav__line" ref="uv-tabs__wrapper__nav__line" :style="[{ width: $uv.addUnit(lineWidth), height: firstTime?0:$uv.addUnit(lineHeight), background: lineColor, backgroundSize: lineBgSize }]" > <!-- #endif --> <!-- #ifndef APP-NVUE --> <view class="uv-tabs__wrapper__nav__line" ref="uv-tabs__wrapper__nav__line" :style="[{ width: $uv.addUnit(lineWidth), transform: `translate(${lineOffsetLeft}px)`, transitionDuration: `${firstTime ? 0 : duration}ms`, height: firstTime?0:$uv.addUnit(lineHeight), background: lineColor, backgroundSize: lineBgSize, }]" > <!-- #endif --> </view> </view> </scroll-view> </view> <slot name="right" /> </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 uvBadgeProps from '@/uni_modules/uv-badge/components/uv-badge/props.js' // #ifdef APP-NVUE const animation = uni.requireNativePlugin('animation') const dom = uni.requireNativePlugin('dom') // #endif import props from './props.js'; /** * Tabs 标签 * @description tabs标签组件,在标签多的时候,可以配置为左右滑动,标签少的时候,可以禁止滑动。 该组件的一个特点是配置为滚动模式时,激活的tab会自动移动到组件的中间位置。 * @tutorial https://www.uvui.cn/components/tabs.html * @property {Array} list 标签数组,元素为对象,如[{name: '推荐'}] * @property {String | Number} duration 滑块移动一次所需的时间,单位秒(默认 200 ) * @property {String | Object} activeStyle 菜单选择中时的样式(默认{ color: '#303133' }) * @property {String | Object} inactiveStyle 菜单非选择中时的样式(默认{ color: '#606266' }) * @property {String | Number} lineWidth 滑块长度(默认 20) * @property {String | Number} lineHeight 滑块高度(默认 3) * @property {String} lineColor 滑块颜色(默认:'#3c9cff') * @property {String} lineBgSize 滑块背景显示大小,当滑块背景设置为图片时使用(默认 cover) * @property {String | Number} itemStyle 菜单item的样式(默认 { height: '44px' }) * @property {String} scrollable 菜单是否可滚动,选项很少的时候设置为false整个tabs自动居中显示(默认:true) * @property {String | Number} current 当前选中标签的索引(默认 0 ) * @property {String} keyName 从list元素对象中读取的键名(默认 'name' ) * @property {String | Number} swierWidth swiper的宽度(默认 '750rpx' ) * @property {String | Object} customStyle 自定义外部样式 * * @event {Function(index)} change 标签改变时触发 index: 点击了第几个tab,索引从0开始 * @event {Function(index)} click 点击标签时触发 index: 点击了第几个tab,索引从0开始 * @example <uv-tabs :list="list" :is-scroll="false" :current="current" @change="change"></uv-tabs> */ export default { name: 'uv-tabs', emits: ['click','change'], mixins: [mpMixin, mixin, props], data() { return { firstTime: true, scrollLeft: 0, scrollViewWidth: 0, lineOffsetLeft: 0, tabsRect: { left: 0 }, innerCurrent: 0, moving: false, } }, watch: { current: { immediate: true, handler (newValue, oldValue) { // 内外部值不相等时,才尝试移动滑块 if (newValue !== this.innerCurrent) { this.innerCurrent = newValue this.$nextTick(() => { this.resize() }) } } }, // list变化时,重新渲染list各项信息 list() { this.$nextTick(() => { this.resize() }) } }, computed: { textStyle() { return index => { const style = {} // 取当期是否激活的样式 const customeStyle = index == this.innerCurrent ? this.$uv.addStyle(this.activeStyle) : this.$uv .addStyle( this.inactiveStyle) // 如果当前菜单被禁用,则加上对应颜色,需要在此做处理,是因为nvue下,无法在style样式中通过!import覆盖标签的内联样式 if (this.list[index].disabled) { style.color = '#c8c9cc' } return this.$uv.deepMerge(customeStyle, style) } }, propsBadge() { return uvBadgeProps } }, async mounted() { this.init() }, methods: { setLineLeft() { const tabItem = this.list[this.innerCurrent]; if (!tabItem) { return; } // 获取滑块该移动的位置 let lineOffsetLeft = this.list .slice(0, this.innerCurrent) .reduce((total, curr) => total + curr.rect.width, 0); // 获取下划线的数值px表示法 let lineWidth = this.$uv.getPx(this.lineWidth); // 如果传的值未带单位+设置了全局单位,则带上单位计算,这样才没有误差 if (this.$uv.test.number(this.lineWidth) && this.$uv.unit) { lineWidth = this.$uv.getPx(`${this.lineWidth}${this.$uv.unit}`); } this.lineOffsetLeft = lineOffsetLeft + (tabItem.rect.width - lineWidth) / 2 // #ifdef APP-NVUE // 第一次移动滑块,无需过渡时间 this.animation(this.lineOffsetLeft, this.firstTime ? 0 : parseInt(this.duration)) // #endif // 如果是第一次执行此方法,让滑块在初始化时,瞬间滑动到第一个tab item的中间 // 这里需要一个定时器,因为在非nvue下,是直接通过style绑定过渡时间,需要等其过渡完成后,再设置为false(非第一次移动滑块) if (this.firstTime) { setTimeout(() => { this.firstTime = false }, 20); } }, // nvue下设置滑块的位置 animation(x, duration = 0) { // #ifdef APP-NVUE const ref = this.$refs['uv-tabs__wrapper__nav__line'] animation.transition(ref, { styles: { transform: `translateX(${x}px)` }, duration }) // #endif }, // 点击某一个标签 clickHandler(item, index) { // 因为标签可能为disabled状态,所以click是一定会发出的,但是change事件是需要可用的状态才发出 this.$emit('click', { ...item, index }) // 如果disabled状态,返回 if (item.disabled) return if(this.innerCurrent != index) { this.$emit('change', { ...item, index }) } this.innerCurrent = index // #ifndef APP-NVUE this.$nextTick(()=>{ this.resize() }) // #endif // #ifdef APP-NVUE this.$nextTick(()=>{ // nvue模式下再给点延时,确保万无一失 this.$uv.sleep(30).then(res=>{ this.resize() }); }) // #endif }, init() { this.$uv.sleep().then(() => { this.resize() }) }, setScrollLeft() { // 当前活动tab的布局信息,有tab菜单的width和left(为元素左边界到父元素左边界的距离)等信息 const tabRect = this.list[this.innerCurrent] // 累加得到当前item到左边的距离 const offsetLeft = this.list .slice(0, this.innerCurrent) .reduce((total, curr) => { return total + curr.rect.width }, 0) // 此处为屏幕宽度 const windowWidth = this.$uv.sys().windowWidth // 将活动的tabs-item移动到屏幕正中间,实际上是对scroll-view的移动 let scrollLeft = offsetLeft - (this.tabsRect.width - tabRect.rect.width) / 2 - (windowWidth - this.tabsRect .right) / 2 + this.tabsRect.left / 2 // 这里做一个限制,限制scrollLeft的最大值为整个scroll-view宽度减去tabs组件的宽度 scrollLeft = Math.min(scrollLeft, this.scrollViewWidth - this.tabsRect.width) this.scrollLeft = Math.max(0, scrollLeft) }, // 获取所有标签的尺寸 resize() { // 如果不存在list,则不处理 if(this.list.length === 0) { return } Promise.all([this.getTabsRect(), this.getAllItemRect()]).then(([tabsRect, itemRect = []]) => { this.tabsRect = tabsRect this.scrollViewWidth = 0 itemRect.map((item, index) => { // 计算scroll-view的宽度,这里 this.scrollViewWidth += item.width // 另外计算每一个item的中心点X轴坐标 this.list[index].rect = item }) // 获取了tabs的尺寸之后,设置滑块的位置 this.setLineLeft() this.setScrollLeft() }) }, // 获取导航菜单的尺寸 getTabsRect() { return new Promise(resolve => { this.queryRect('uv-tabs__wrapper__scroll-view').then(size => resolve(size)) }) }, // 获取所有标签的尺寸 getAllItemRect() { return new Promise(resolve => { const promiseAllArr = this.list.map((item, index) => this.queryRect( `uv-tabs__wrapper__nav__item-${index}`, true)) Promise.all(promiseAllArr).then(sizes => resolve(sizes)) }) }, // 获取各个标签的尺寸 queryRect(el, item) { // #ifndef APP-NVUE // $uvGetRect为uni-ui自带的节点查询简化方法,详见文档介绍:https://www.uvui.cn/js/getRect.html // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同 return new Promise(resolve => { this.$uvGetRect(`.${el}`).then(size => { resolve(size) }) }) // #endif // #ifdef APP-NVUE // nvue下,使用dom模块查询元素高度 // 返回一个promise,让调用此方法的主体能使用then回调 return new Promise(resolve => { dom.getComponentRect(item ? this.$refs[el][0] : this.$refs[el], 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-tabs { &__wrapper { @include flex; align-items: center; &__scroll-view-wrapper { flex: 1; /* #ifndef APP-NVUE */ overflow: auto hidden; /* #endif */ } &__scroll-view { @include flex; flex: 1; } &__nav { @include flex; position: relative; &__item { padding: 0 11px; @include flex; align-items: center; justify-content: center; &--disabled { /* #ifndef APP-NVUE */ cursor: not-allowed; /* #endif */ } &__text { font-size: 15px; color: $uv-content-color; &--disabled { color: $uv-disabled-color !important; } } } &__line { height: 3px; background: $uv-primary; width: 30px; position: absolute; bottom: 2px; border-radius: 100px; transition-property: transform; transition-duration: 300ms; } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-tabs/components/uv-tabs/uv-tabs.vue
Vue
unknown
12,989
export default { props: { // 标签类型info、primary、success、warning、error type: { type: String, default: 'primary' }, // 不可用 disabled: { type: [Boolean, String], default: false }, // 标签的大小,large,medium,mini size: { type: String, default: 'medium' }, // tag的形状,circle(两边半圆形), square(方形,带圆角) shape: { type: String, default: 'square' }, // 标签文字 text: { type: [String, Number], default: '' }, // 背景颜色,默认为空字符串,即不处理 bgColor: { type: String, default: '' }, // 标签字体颜色,默认为空字符串,即不处理 color: { type: String, default: '' }, // 标签的边框颜色 borderColor: { type: String, default: '' }, // 点击时返回的索引值,用于区分例遍的数组哪个元素被点击了 name: { type: [String, Number], default: '' }, // 镂空时是否填充背景色 plainFill: { type: Boolean, default: false }, // 是否镂空 plain: { type: Boolean, default: false }, // 是否可关闭 closable: { type: Boolean, default: false }, // 关闭按钮图标的颜色 closeColor: { type: String, default: '#C6C7CB' }, // 关闭按钮图标的位置 right(右边)right-top(右上) 默认right-top closePlace: { type: String, default: 'right-top' }, // 是否显示 show: { type: Boolean, default: true }, // 内置图标,或绝对路径的图片 icon: { type: String, default: '' }, // 图标颜色 iconColor: { type: String, default: '' }, // nvue模式下 是否直接显示,在uv-list等cell下面使用就需要设置 cellChild: { type: Boolean, default: false }, ...uni.$uv?.props?.tags } }
2301_77169380/AppruanjianApk
uni_modules/uv-tags/components/uv-tags/props.js
JavaScript
unknown
1,853
<template> <uv-transition mode="fade" :show="show" :cell-child="cellChild" > <view class="uv-tags-wrapper"> <view class="uv-tags" :class="[`uv-tags--${shape}`, !plain && `uv-tags--${type}`, plain && `uv-tags--${type}--plain`, `uv-tags--${size}`,`uv-tags--${size}--${closePlace}`, plain && plainFill && `uv-tags--${type}--plain--fill`]" @tap.stop="clickHandler" :style="[{ marginRight: closable&& closePlace=='right-top' ? '10px' : 0, marginTop: closable && closePlace=='right-top' ? '10px' : 0, }, style, $uv.addStyle(customStyle)]" > <slot name="icon"> <view class="uv-tags__icon" v-if="icon" > <image v-if="$uv.test.image(icon)" :src="icon" :style="[imgStyle]" ></image> <uv-icon v-else :color="elIconColor" :name="icon" :size="iconSize" ></uv-icon> </view> </slot> <text class="uv-tags__text" :style="[textColor]" :class="[`uv-tags__text--${type}`, plain && `uv-tags__text--${type}--plain`, `uv-tags__text--${size}`]" >{{ text }}</text> <view class="uv-tags__close" :class="[`uv-tags__close--${size}`,`uv-tags__close--${closePlace}`]" v-if="closable && closePlace=='right'" @tap.stop="closeHandler" :style="{backgroundColor: closeColor}" > <uv-icon name="close" :size="closeSize" color="#ffffff" ></uv-icon> </view> </view> <view class="uv-tags__close" :class="[`uv-tags__close--${size}`,`uv-tags__close--${closePlace}`]" v-if="closable && closePlace=='right-top'" @tap.stop="closeHandler" :style="{backgroundColor: closeColor}" > <uv-icon name="close" :size="closeSize" color="#ffffff" ></uv-icon> </view> </view> </uv-transition> </template> <script> import { image } from '@/uni_modules/uv-ui-tools/libs/function/test.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'; /** * Tag 标签 * @description tag组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景 * @tutorial https://www.uvui.cn/components/tag.html * @property {String} type 标签类型info、primary、success、warning、error (默认 'primary' ) * @property {Boolean | String} disabled 不可用(默认 false ) * @property {String} size 标签的大小,large,medium,mini (默认 'medium' ) * @property {String} shape tag的形状,circle(两边半圆形), square(方形,带圆角)(默认 'square' ) * @property {String | Number} text 标签的文字内容 * @property {String} bgColor 背景颜色,默认为空字符串,即不处理 * @property {String} color 标签字体颜色,默认为空字符串,即不处理 * @property {String} borderColor 镂空形式标签的边框颜色 * @property {String} closeColor 关闭按钮图标的颜色(默认 #C6C7CB) * @property {String | Number} name 点击时返回的索引值,用于区分例遍的数组哪个元素被点击了 * @property {Boolean} plainFill 镂空时是否填充背景色(默认 false ) * @property {Boolean} plain 是否镂空(默认 false ) * @property {Boolean} closable 是否可关闭,设置为true,文字右边会出现一个关闭图标(默认 false ) * @property {Boolean} show 标签显示与否(默认 true ) * @property {String} icon 内置图标,或绝对路径的图片 * @event {Function(index)} click 点击标签时触发 index: 传递的index参数值 * @event {Function(index)} close closable为true时,点击标签关闭按钮触发 index: 传递的index参数值 * @example <uv-tags text="标签" type="error" plain plainFill></uv-tags> */ export default { name: 'uv-tags', emits: ['click','close'], mixins: [mpMixin, mixin, props], computed: { style() { const style = {} if (this.bgColor) { style.backgroundColor = this.bgColor } if (this.color) { style.color = this.color } if(this.borderColor) { style.borderColor = this.borderColor } return style }, // nvue下,文本颜色无法继承父元素 textColor() { const style = {} if (this.color) { style.color = this.color } return style }, imgStyle() { const width = this.size === 'large' ? '17px' : this.size === 'medium' ? '15px' : '13px' return { width, height: width } }, // 文本的样式 closeSize() { const size = this.size === 'large' ? 15 : this.size === 'medium' ? 13 : 12 return size }, // 图标大小 iconSize() { const size = this.size === 'large' ? 21 : this.size === 'medium' ? 19 : 16 return size }, // 图标颜色 elIconColor() { return this.iconColor ? this.iconColor : this.plain ? this.type : '#ffffff' } }, methods: { // 点击关闭按钮 closeHandler() { this.$emit('close', this.name) }, // 点击标签 clickHandler() { this.$emit('click', this.name) } } } </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-tags-wrapper { position: relative; } .uv-tags { @include flex; align-items: center; border-style: solid; &--circle { border-radius: 100px; } &--square { border-radius: 3px; } &__icon { margin-right: 4px; } &__text { &--mini { font-size: 12px; line-height: 12px; } &--medium { font-size: 13px; line-height: 13px; } &--large { font-size: 15px; line-height: 15px; } } &--mini { height: 22px; line-height: 22px; padding: 0 5px; &--right { padding-right: 2px; } } &--medium { height: 26px; line-height: 22px; padding: 0 10px; &--right { padding: 0 4px 0 8px; } } &--large { height: 32px; line-height: 32px; padding: 0 15px; &--right { padding: 0 4px 0 8px; } } &--primary { background-color: $uv-primary; border-width: 1px; border-color: $uv-primary; } &--primary--plain { border-width: 1px; border-color: $uv-primary; } &--primary--plain--fill { background-color: #ecf5ff; } &__text--primary { color: #FFFFFF; } &__text--primary--plain { color: $uv-primary; } &--error { background-color: $uv-error; border-width: 1px; border-color: $uv-error; } &--error--plain { border-width: 1px; border-color: $uv-error; } &--error--plain--fill { background-color: #fef0f0; } &__text--error { color: #FFFFFF; } &__text--error--plain { color: $uv-error; } &--warning { background-color: $uv-warning; border-width: 1px; border-color: $uv-warning; } &--warning--plain { border-width: 1px; border-color: $uv-warning; } &--warning--plain--fill { background-color: #fdf6ec; } &__text--warning { color: #FFFFFF; } &__text--warning--plain { color: $uv-warning; } &--success { background-color: $uv-success; border-width: 1px; border-color: $uv-success; } &--success--plain { border-width: 1px; border-color: $uv-success; } &--success--plain--fill { background-color: #f5fff0; } &__text--success { color: #FFFFFF; } &__text--success--plain { color: $uv-success; } &--info { background-color: $uv-info; border-width: 1px; border-color: $uv-info; } &--info--plain { border-width: 1px; border-color: $uv-info; } &--info--plain--fill { background-color: #f4f4f5; } &__text--info { color: #FFFFFF; } &__text--info--plain { color: $uv-info; } &__close { border-radius: 100px; background-color: #C6C7CB; @include flex(row); align-items: center; justify-content: center; transform: scale(0.6); &--right-top { position: absolute; z-index: 999; top: 10px; right: 10px; /* #ifndef APP-NVUE */ transform: scale(0.6) translate(80%,-80%); /* #endif */ /* #ifdef APP-NVUE */ transform: scale(0.6) translate(50%, -50%); /* #endif */ } &--mini { width: 18px; height: 18px; } &--medium { width: 22px; height: 22px; } &--large { width: 25px; height: 25px; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-tags/components/uv-tags/uv-tags.vue
Vue
unknown
8,547
export default { props: { // 主题颜色 type: { type: String, default: '' }, // 是否显示 show: { type: Boolean, default: true }, // 显示的值 text: { type: [String, Number], default: '' }, // 前置图标 prefixIcon: { type: String, default: '' }, // 后置图标 suffixIcon: { type: String, default: '' }, // 文本处理的匹配模式 // text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接 mode: { type: String, default: '' }, // mode=link下,配置的链接 href: { type: String, default: '' }, // 格式化规则 format: { type: [String, Function], default: '' }, // mode=phone时,点击文本是否拨打电话 call: { type: Boolean, default: true }, // 小程序的打开方式 openType: { type: String, default: '' }, // 是否粗体,默认normal bold: { type: Boolean, default: false }, // 是否块状 block: { type: Boolean, default: false }, // 文本显示的行数,如果设置,超出此行数,将会显示省略号 lines: { type: [String, Number], default: '' }, // 文本颜色 color: { type: String, default: '#303133' }, // 字体大小 size: { type: [String, Number], default: 15 }, // 图标的样式 iconStyle: { type: [Object, String], default: () => ({ fontSize: '15px' }) }, // 文字装饰,下划线,中划线等,可选值 none|underline|line-through decoration: { type: String, default: 'none' }, // 外边距,对象、字符串,数值形式均可 margin: { type: [Object, String, Number], default: 0 }, // 文本行高 lineHeight: { type: [String, Number], default: '' }, // 文本对齐方式,可选值left|center|right align: { type: String, default: 'left' }, // 文字换行,可选值break-word|normal|anywhere wordWrap: { type: String, default: 'normal' }, ...uni.$uv?.props?.text } }
2301_77169380/AppruanjianApk
uni_modules/uv-text/components/uv-text/props.js
JavaScript
unknown
2,060
<template> <view class="uv-text" :class="[]" v-if="show" :style="{ margin: margin, justifyContent: align === 'left' ? 'flex-start' : align === 'center' ? 'center' : 'flex-end' }" @tap="clickHandler" > <text :class="['uv-text__price', type && `uv-text__value--${type}`]" v-if="mode === 'price'" :style="[valueStyle]" >¥</text > <view class="uv-text__prefix-icon" v-if="prefixIcon"> <uv-icon :name="prefixIcon" :customStyle="$uv.addStyle(iconStyle)" ></uv-icon> </view> <uv-link v-if="mode === 'link'" :text="value" :href="href" underLine ></uv-link> <template v-else-if="openType && isMp"> <button class="uv-reset-button uv-text__value" :style="[valueStyle]" :openType="openType" @getuserinfo="onGetUserInfo" @contact="onContact" @getphonenumber="onGetPhoneNumber" @error="onError" @launchapp="onLaunchApp" @opensetting="onOpenSetting" :lang="lang" :session-from="sessionFrom" :send-message-title="sendMessageTitle" :send-message-path="sendMessagePath" :send-message-img="sendMessageImg" :show-message-card="showMessageCard" :app-parameter="appParameter" > {{ value }} </button> </template> <text v-else class="uv-text__value" :style="[valueStyle]" :class="[ type && `uv-text__value--${type}`, lines && `uv-line-${lines}` ]" >{{ value }}</text > <view class="uv-text__suffix-icon" v-if="suffixIcon"> <uv-icon :name="suffixIcon" :customStyle="$uv.addStyle(iconStyle)" ></uv-icon> </view> </view> </template> <script> import value from './value.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 button from '@/uni_modules/uv-ui-tools/libs/mixin/button.js' import openType from '@/uni_modules/uv-ui-tools/libs/mixin/openType.js' import props from './props.js' /** * Text 文本 * @description 此组件集成了文本类在项目中的常用功能,包括状态,拨打电话,格式化日期,*替换,超链接...等功能。 您大可不必在使用特殊文本时自己定义,text组件几乎涵盖您能使用的大部分场景。 * @tutorial https://www.uvui.cn/components/loading.html * @property {String} type 主题颜色 * @property {Boolean} show 是否显示(默认 true ) * @property {String | Number} text 显示的值 * @property {String} prefixIcon 前置图标 * @property {String} suffixIcon 后置图标 * @property {String} mode 文本处理的匹配模式 text-普通文本,price-价格,phone-手机号,name-姓名,date-日期,link-超链接 * @property {String} href mode=link下,配置的链接 * @property {String | Function} format 格式化规则 * @property {Boolean} call mode=phone时,点击文本是否拨打电话(默认 false ) * @property {String} openType 小程序的打开方式 * @property {Boolean} bold 是否粗体,默认normal(默认 false ) * @property {Boolean} block 是否块状(默认 false ) * @property {String | Number} lines 文本显示的行数,如果设置,超出此行数,将会显示省略号 * @property {String} color 文本颜色(默认 '#303133' ) * @property {String | Number} size 字体大小(默认 15 ) * @property {Object | String} iconStyle 图标的样式 (默认 {fontSize: '15px'} ) * @property {String} decoration 文字装饰,下划线,中划线等,可选值 none|underline|line-through(默认 'none' ) * @property {Object | String | Number} margin 外边距,对象、字符串,数值形式均可(默认 0 ) * @property {String | Number} lineHeight 文本行高 * @property {String} align 文本对齐方式,可选值left|center|right(默认 'left' ) * @property {String} wordWrap 文字换行,可选值break-word|normal|anywhere(默认 'normal' ) * @event {Function} click 点击触发事件 * @example <uv-text text="我用十年青春,赴你最后之约"></uv-text> */ export default { name: 'uv-text', emits: ['click'], // #ifdef MP mixins: [mpMixin, mixin, value, button, openType, props], // #endif // #ifndef MP mixins: [mpMixin, mixin, value, props], // #endif computed: { valueStyle() { const style = { textDecoration: this.decoration, fontWeight: this.bold ? 'bold' : 'normal', wordWrap: this.wordWrap, fontSize: this.$uv.addUnit(this.size) }; !this.type && (style.color = this.color); this.isNvue && this.lines && (style.lines = this.lines); if(this.isNvue && this.mode != 'price' && !this.prefixIcon && !this.suffixIcon) { style.flex = 1; style.textAlign = this.align === 'left' ? 'flex-start' : this.align === 'center' ? 'center' : 'right'; } this.lineHeight && (style.lineHeight = this.$uv.addUnit(this.lineHeight)); !this.isNvue && this.block && (style.display = 'block'); return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)); }, isNvue() { let nvue = false // #ifdef APP-NVUE nvue = true // #endif return nvue }, isMp() { let mp = false // #ifdef MP mp = true // #endif return mp } }, data() { return {} }, methods: { clickHandler() { // 如果为手机号模式,拨打电话 if (this.call && this.mode === 'phone') { uni.makePhoneCall({ phoneNumber: this.text }) } this.$emit('click') } } } </script> <style lang="scss" scoped> $show-lines: 1; $show-reset-button: 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-text { @include flex(row); align-items: center; flex-wrap: nowrap; flex: 1; /* #ifndef APP-NVUE */ width: 100%; /* #endif */ &__price { font-size: 14px; color: $uv-content-color; } &__value { font-size: 14px; @include flex; color: $uv-content-color; flex-wrap: wrap; // flex: 1; text-overflow: ellipsis; align-items: center; &--primary { color: $uv-primary; } &--warning { color: $uv-warning; } &--success { color: $uv-success; } &--info { color: $uv-info; } &--error { color: $uv-error; } &--main { color: $uv-main-color; } &--content { color: $uv-content-color; } &--tips { color: $uv-tips-color; } &--light { color: $uv-light-color; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-text/components/uv-text/uv-text.vue
Vue
unknown
7,023
import { func, date, url } from '@/uni_modules/uv-ui-tools/libs/function/test.js' import { error, timeFormat, priceFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js' export default { computed: { // 经处理后需要显示的值 value() { const { text, mode, format, href } = this // 价格类型 if (mode === 'price') { // 如果text不为金额进行提示 if (!/^\d+(\.\d+)?$/.test(text)) { error('金额模式下,text参数需要为金额格式'); } // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的金额格式化处理 if (func(format)) { // 如果用户传入的是函数,使用函数格式化 return format(text) } // 如果format非正则,非函数,则使用默认的金额格式化方法进行操作 return priceFormat(text, 2) } if (mode === 'date') { // 判断是否合法的日期或者时间戳 !date(text) && error('日期模式下,text参数需要为日期或时间戳格式') // 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理 if (func(format)) { // 如果用户传入的是函数,使用函数格式化 return format(text) } if (format) { // 如果format非正则,非函数,则使用默认的时间格式化方法进行操作 return timeFormat(text, format) } // 如果没有设置format,则设置为默认的时间格式化形式 return timeFormat(text, 'yyyy-mm-dd') } if (mode === 'phone') { // 判断是否合法的手机号 // !mobile(text) && error('手机号模式下,text参数需要为手机号码格式') if (func(format)) { // 如果用户传入的是函数,使用函数格式化 return format(text) } if (format === 'encrypt') { // 如果format为encrypt,则将手机号进行星号加密处理 return `${text.substr(0, 3)}****${text.substr(7)}` } return text } if (mode === 'name') { // 判断是否合法的字符粗 !(typeof (text) === 'string') && error('姓名模式下,text参数需要为字符串格式') if (func(format)) { // 如果用户传入的是函数,使用函数格式化 return format(text) } if (format === 'encrypt') { // 如果format为encrypt,则将姓名进行星号加密处理 return this.formatName(text) } return text } if (mode === 'link') { // 判断是否合法的字符粗 !url(href) && error('超链接模式下,href参数需要为URL格式') return text } return text } }, methods: { // 默认的姓名脱敏规则 formatName(name) { let value = '' if (name.length === 2) { value = name.substr(0, 1) + '*' } else if (name.length > 2) { let char = '' for (let i = 0, len = name.length - 2; i < len; i++) { char += '*' } value = name.substr(0, 1) + char + name.substr(-1, 1) } else { value = name } return value } } }
2301_77169380/AppruanjianApk
uni_modules/uv-text/components/uv-text/value.js
JavaScript
unknown
4,023
export default { props: { value: { type: [String, Number], default: '' }, modelValue: { type: [String, Number], default: '' }, // 输入框为空时占位符 placeholder: { type: [String, Number], default: '' }, // 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ placeholderClass: { type: String, default: 'textarea-placeholder' }, // 指定placeholder的样式 placeholderStyle: { type: [String, Object], default: 'color: #c0c4cc' }, // 输入框高度 height: { type: [String, Number], default: 70 }, // 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效 confirmType: { type: String, default: 'return' }, // 是否禁用 disabled: { type: Boolean, default: false }, // 是否显示统计字数 count: { type: Boolean, default: false }, // 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现 focus: { type: Boolean, default: false }, // 是否自动增加高度 autoHeight: { type: Boolean, default: false }, // 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true fixed: { type: Boolean, default: false }, // 指定光标与键盘的距离 cursorSpacing: { type: Number, default: 0 }, // 指定focus时的光标位置 cursor: { type: [String, Number], default: '' }, // 是否显示键盘上方带有”完成“按钮那一栏, showConfirmBar: { type: Boolean, default: true }, // 光标起始位置,自动聚焦时有效,需与selection-end搭配使用 selectionStart: { type: Number, default: -1 }, // 光标结束位置,自动聚焦时有效,需与selection-start搭配使用 selectionEnd: { type: Number, default: -1 }, // 键盘弹起时,是否自动上推页面 adjustPosition: { type: Boolean, default: true }, // 是否去掉 iOS 下的默认内边距,只微信小程序有效 disableDefaultPadding: { type: Boolean, default: false }, // focus时,点击页面的时候不收起键盘,只微信小程序有效 holdKeyboard: { type: Boolean, default: false }, // 最大输入长度,设置为 -1 的时候不限制最大长度 maxlength: { type: [String, Number], default: 140 }, // 边框类型,surround-四周边框,bottom-底部边框 border: { type: String, default: 'surround' }, // 用于处理或者过滤输入框内容的方法 formatter: { type: [Function, null], default: null }, // 是否忽略组件内对文本合成系统事件的处理 ignoreCompositionEvent: { type: Boolean, default: true }, // 是否忽略组件内对文本合成系统事件的处理 confirmHold: { type: Boolean, default: false }, // 文本样式 textStyle: { type: [Object, String], default: () => {} }, // 统计数字的样式 countStyle: { type: [Object, String], default: () => {} }, ...uni.$uv?.props?.textarea } }
2301_77169380/AppruanjianApk
uni_modules/uv-textarea/components/uv-textarea/props.js
JavaScript
unknown
3,111
<template> <view class="uv-textarea" :class="textareaClass" :style="[textareaStyle]"> <textarea class="uv-textarea__field" :value="innerValue" :style="[ {height: autoHeight ? 'auto' :$uv.addUnit(height)}, $uv.addStyle(textStyle) ]" :placeholder="placeholder" :placeholder-style="$uv.addStyle(placeholderStyle, 'string')" :placeholder-class="placeholderClass" :disabled="disabled" :focus="focus" :autoHeight="autoHeight" :fixed="fixed" :cursorSpacing="cursorSpacing" :cursor="cursor" :showConfirmBar="showConfirmBar" :selectionStart="selectionStart" :selectionEnd="selectionEnd" :adjustPosition="adjustPosition" :disableDefaultPadding="disableDefaultPadding" :holdKeyboard="holdKeyboard" :maxlength="maxlen" :confirmType="confirmType" :ignoreCompositionEvent="ignoreCompositionEvent" :confirm-hold="confirmHold" @focus="onFocus" @blur="onBlur" @linechange="onLinechange" @input="onInput" @confirm="onConfirm" @keyboardheightchange="onKeyboardheightchange"></textarea> <text class="uv-textarea__count" :style="[{ 'background-color': disabled ? 'transparent' : '#fff', },$uv.addStyle(countStyle)]" v-if="count && maxlen!=-1">{{ getCount }}/{{ maxlen }}</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' import props from "./props.js"; /** * Textarea 文本域 * @description 文本域此组件满足了可能出现的表单信息补充,编辑等实际逻辑的功能,内置了字数校验等 * @tutorial https://www.uvui.cn/components/textarea.html * * @property {String | Number} value / v-model 输入框的内容 * @property {String | Number} placeholder 输入框为空时占位符 * @property {String} placeholderClass 指定placeholder的样式类,注意页面或组件的style中写了scoped时,需要在类名前写/deep/ ( 默认 'input-placeholder' ) * @property {String | Object} placeholderStyle 指定placeholder的样式,字符串/对象形式,如"color: red;" * @property {String | Number} height 输入框高度(默认 70 ) * @property {String} confirmType 设置键盘右下角按钮的文字,仅微信小程序,App-vue和H5有效(默认 'done' ) * @property {Boolean} disabled 是否禁用(默认 false ) * @property {Boolean} count 是否显示统计字数(默认 false ) * @property {Boolean} focus 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现(默认 false ) * @property {Boolean | Function} autoHeight 是否自动增加高度(默认 false ) * @property {Boolean} fixed 如果textarea是在一个position:fixed的区域,需要显示指定属性fixed为true(默认 false ) * @property {Number} cursorSpacing 指定光标与键盘的距离(默认 0 ) * @property {String | Number} cursor 指定focus时的光标位置 * @property {Function} formatter 内容式化函数 * @property {Boolean} showConfirmBar 是否显示键盘上方带有”完成“按钮那一栏,(默认 true ) * @property {Number} selectionStart 光标起始位置,自动聚焦时有效,需与selection-end搭配使用,(默认 -1 ) * @property {Number | Number} selectionEnd 光标结束位置,自动聚焦时有效,需与selection-start搭配使用(默认 -1 ) * @property {Boolean} adjustPosition 键盘弹起时,是否自动上推页面(默认 true ) * @property {Boolean | Number} disableDefaultPadding 是否去掉 iOS 下的默认内边距,只微信小程序有效(默认 false ) * @property {Boolean} holdKeyboard focus时,点击页面的时候不收起键盘,只微信小程序有效(默认 false ) * @property {String | Number} maxlength 最大输入长度,设置为 -1 的时候不限制最大长度(默认 140 ) * @property {String} border 边框类型,surround-四周边框,none-无边框,bottom-底部边框(默认 'surround' ) * @property {Boolean} ignoreCompositionEvent 是否忽略组件内对文本合成系统事件的处理 * @property {Boolean} confirmHold 点击键盘右下角按钮时是否保持键盘不收起 * @property {Object} textStyle 文本样式 * @property {Object} countStyle 统计数字的样式 * * @event {Function(e)} focus 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度 * @event {Function(e)} blur 输入框失去焦点时触发,event.detail = {value, cursor} * @event {Function(e)} linechange 输入框行数变化时调用,event.detail = {height: 0, heightRpx: 0, lineCount: 0} * @event {Function(e)} input 当键盘输入时,触发 input 事件 * @event {Function(e)} confirm 点击完成时, 触发 confirm 事件 * @event {Function(e)} keyboardheightchange 键盘高度发生变化的时候触发此事件 * @example <uv--textarea v-model="value1" placeholder="请输入内容" ></uv--textarea> */ export default { name: "uv-textarea", mixins: [mpMixin, mixin, props], data() { return { // 输入框的值 innerValue: "", // 是否处于获得焦点状态 focused: false, // 过滤处理方法 innerFormatter: value => value } }, created() { // #ifndef VUE3 this.innerValue = this.value; // #endif // #ifdef VUE3 this.innerValue = this.modelValue; // #endif }, watch: { value(newVal) { this.innerValue = newVal; }, modelValue(newVal) { this.innerValue = newVal; } }, computed: { // 组件的类名 textareaClass() { let classes = [], { border, disabled } = this; border === "surround" && (classes = classes.concat(["uv-border", "uv-textarea--radius"])); border === "bottom" && (classes = classes.concat(["uv-border-bottom", "uv-textarea--no-radius", ])); disabled && classes.push("uv-textarea--disabled"); return classes.join(" "); }, // 组件的样式 textareaStyle() { const style = {}; // #ifdef APP-NVUE // 由于textarea在安卓nvue上的差异性,需要额外再调整其内边距 if (this.$uv.os() === "android") { style.paddingTop = "6px"; style.paddingLeft = "9px"; style.paddingBottom = "3px"; style.paddingRight = "6px"; } // #endif return this.$uv.deepMerge(style, this.$uv.addStyle(this.customStyle)); }, maxlen() { return this.maxlength < 0 ? this.maxlength < 0 ? -1 : 140 : this.maxlength; }, getCount() { try{ return this.innerValue.length > this.maxlen ? this.maxlen: this.innerValue.length; }catch(e){ return 0; } } }, methods: { // 在微信小程序中,不支持将函数当做props参数,故只能通过ref形式调用 setFormatter(e) { this.innerFormatter = e }, onFocus(e) { this.$emit("focus", e); }, onBlur(e) { this.$emit("blur", e); // 尝试调用uv-form的验证方法 this.$uv.formValidate(this, "blur"); }, onLinechange(e) { this.$emit("linechange", e); }, 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(); }) }, // 内容发生变化,进行处理 valueChange() { 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"); }); }, onConfirm(e) { this.$emit("confirm", e); }, onKeyboardheightchange(e) { this.$emit("keyboardheightchange", e); }, }, }; </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-textarea { border-radius: 4px; background-color: #fff; position: relative; @include flex; flex: 1; padding: 9px; &--radius { border-radius: 4px; } &--no-radius { border-radius: 0; } &--disabled { background-color: #f5f7fa; } &__field { flex: 1; font-size: 15px; color: $uv-content-color; width: 100%; } &__count { position: absolute; right: 5px; bottom: 2px; font-size: 12px; color: $uv-tips-color; background-color: #ffffff; padding: 1px 4px; } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-textarea/components/uv-textarea/uv-textarea.vue
Vue
unknown
9,026
<template> <view class="uv-toast"> <uv-overlay :show="isShow && tmpConfig.overlay" :custom-style="overlayStyle"></uv-overlay> <uv-transition :show="isShow" mode="fade" :custom-style="aniStyle"> <view class="uv-toast__content" ref="uvToastContent" :style="[contentStyle]" :class="['uv-type-' + tmpConfig.type, (tmpConfig.type === 'loading' || tmpConfig.loading) ? 'uv-toast__content--loading' : '']" > <uv-loading-icon v-if="tmpConfig.type === 'loading'" mode="circle" color="rgb(255, 255, 255)" inactiveColor="rgb(120, 120, 120)" size="25" ></uv-loading-icon> <uv-icon v-else-if="tmpConfig.type !== 'defalut' && iconName" :name="iconName" size="17" :color="tmpConfig.type" :customStyle="iconStyle" ></uv-icon> <uv-gap v-if="tmpConfig.type === 'loading' || tmpConfig.loading" height="12" bgColor="transparent" ></uv-gap> <text class="uv-toast__content__text" :class="['uv-toast__content__text--' + tmpConfig.type]" style="max-width: 400rpx;" >{{ tmpConfig.message }}</text> </view> </uv-transition> </view> </template> <script> import { hexToRgb } 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' // #ifdef APP-NVUE const dom = uni.requireNativePlugin('dom') // #endif /** * toast 消息提示 * @description 此组件表现形式类似uni的uni.showToastAPI,但也有不同的地方。 * @tutorial https://www.uvui.cn/components/toast.html * @property {Boolean} loading 是否加载中 (默认 false ) * @property {String | Number} zIndex toast展示时的zIndex值 (默认 10090 ) * @property {String | Number} message 显示的文字内容 * @property {String} icon 图标,或者绝对路径的图片 * @property {String} type 主题类型 (默认 default) * @property {Boolean} overlay 是否显示透明遮罩,防止点击穿透 (默认 false ) * @property {String} position 位置 (默认 'center' ) * @property {Object} params 跳转的参数 * @property {String | Number} duration 展示时间,单位ms (默认 2000 ) * @property {Function} complete 执行完后的回调函数 * * @event {Function} show 显示toast,如需一进入页面就显示toast,请在onReady生命周期调用 * @example <uv-toast ref="uvToastRef" /> */ export default { name: 'uv-toast', mixins: [mpMixin, mixin], data() { return { isShow: false, timer: null, // 定时器 config: { message: '', // 显示文本 type: '', // 主题类型,primary,success,error,warning,black duration: 2000, // 显示的时间,毫秒 icon: true, // 显示的图标 position: 'center', // toast出现的位置 complete: null, // 执行完后的回调函数 overlay: true, // 是否防止触摸穿透 loading: false ,// 是否加载中状态 zIndex: 10090 //弹出的层级 }, tmpConfig: {}, // 将用户配置和内置配置合并后的临时配置变量 rect: {}, opacity: 0 } }, computed: { iconName() { // 只有不为none,并且type为error|warning|succes|info时候,才显示图标 if (!this.tmpConfig.icon || this.tmpConfig.icon == 'none') { return ''; } if (['error', 'warning', 'success', 'primary'].includes(this.tmpConfig.type)) { return this.$uv.type2icon(this.tmpConfig.type) } else { return '' } }, overlayStyle() { const style = { justifyContent: 'center', alignItems: 'center', display: 'flex', zIndex: this.tmpConfig.zIndex } // 将遮罩设置为100%透明度,避免出现灰色背景 style.backgroundColor = 'rgba(0, 0, 0, 0)' return style }, iconStyle() { const style = {} // 图标需要一个右边距,以跟右边的文字有隔开的距离 style.marginRight = '4px' // #ifdef APP-NVUE // iOSAPP下,图标有1px的向下偏移,这里进行修正 if (this.$uv.os() === 'ios') { style.marginTop = '-1px' } // #endif return style }, aniStyle() { const style = { position: 'fixed', zIndex: this.tmpConfig.zIndex } return style }, // 内容盒子的样式 contentStyle() { const { windowWidth, windowHeight } = this.$uv.sys(); const style = { position: 'fixed', top: '50%', left: '50%', // #ifdef APP-NVUE opacity: this.opacity // #endif }; let value = 0 // #ifndef APP-NVUE // 根据top和bottom,对Y轴进行窗体高度的百分比偏移 if (this.tmpConfig.position === 'top') { style.top = '25%' } else if (this.tmpConfig.position === 'bottom') { style.top = '75%' } else { value = '-50%' } style.transform = `translate(-50%,${value})` // #endif // #ifdef APP-NVUE const { width = 0, height = 0 } = this.rect ? this.rect : {}; if (width && height) { style.left = `${windowWidth*0.5 - width/2}px` if (this.tmpConfig.position === 'top') { style.top = `${windowHeight*0.5- height/2 - windowHeight*0.25}px` } else if (this.tmpConfig.position === 'bottom') { style.top = `${windowHeight*0.5- height/2 + windowHeight*0.25}px` } else { style.top = `${windowHeight*0.5- height/2}px` } } // #endif return style } }, created() { // 通过主题的形式调用toast,批量生成方法函数 ['primary', 'success', 'error', 'warning', 'default', 'loading'].map(item => { this[item] = message => this.show({ type: item, message }) }) }, methods: { // 显示toast组件,由父组件通过this.$refs.xxx.show(options)形式调用 show(options) { // 不将结果合并到this.config变量,避免多次调用uv-toast,前后的配置造成混乱 this.tmpConfig = this.$uv.deepMerge(this.config, options) // 清除定时器 this.clearTimer() this.isShow = true //#ifdef APP-NVUE this.$nextTick(() => { this.$uv.sleep(100).then(async res => { this.rect = await this.queryRect(); this.$nextTick(() => { this.opacity = 1; }) }) }) // #endif this.timer = setTimeout(() => { // 倒计时结束,清除定时器,隐藏toast组件 this.clearTimer() // 判断是否存在callback方法,如果存在就执行 typeof(this.tmpConfig.complete) === 'function' && this.tmpConfig.complete() }, this.tmpConfig.duration) }, // 查询内容高度 queryRect() { return new Promise(resolve => { const ref = this.$refs['uvToastContent']; dom.getComponentRect(ref, res => { resolve(res.size) }) }) }, // 隐藏toast组件,由父组件通过this.$refs.xxx.hide()形式调用 hide() { this.clearTimer() }, clearTimer() { // #ifdef APP-NVUE this.opacity = 0; // #endif this.isShow = 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-toast-color: #fff !default; $uv-toast-border-radius: 4px !default; $uv-toast-border-background-color: #585858 !default; $uv-toast-border-font-size: 14px !default; $uv-toast-border-padding: 12px 20px !default; $uv-toast-loading-border-padding: 20px 20px !default; $uv-toast-content-text-color: #fff !default; $uv-toast-content-text-font-size: 15px !default; $uv-toast-uv-icon: 10rpx !default; $uv-toast-uv-type-primary-color: $uv-primary !default; $uv-toast-uv-type-primary-background-color: #ecf5ff !default; $uv-toast-uv-type-primary-border-color: rgb(215, 234, 254) !default; $uv-toast-uv-type-primary-border-width: 1px !default; $uv-toast-uv-type-success-color: $uv-success !default; $uv-toast-uv-type-success-background-color: #dbf1e1 !default; $uv-toast-uv-type-success-border-color: #BEF5C8 !default; $uv-toast-uv-type-success-border-width: 1px !default; $uv-toast-uv-type-error-color: $uv-error !default; $uv-toast-uv-type-error-background-color: #fef0f0 !default; $uv-toast-uv-type-error-border-color: #fde2e2 !default; $uv-toast-uv-type-error-border-width: 1px !default; $uv-toast-uv-type-warning-color: $uv-warning !default; $uv-toast-uv-type-warning-background-color: #fdf6ec !default; $uv-toast-uv-type-warning-border-color: #faecd8 !default; $uv-toast-uv-type-warning-border-width: 1px !default; $uv-toast-uv-type-default-color: #fff !default; $uv-toast-uv-type-default-background-color: #585858 !default; .uv-toast { &__content { @include flex; padding: $uv-toast-border-padding; border-radius: $uv-toast-border-radius; background-color: $uv-toast-border-background-color; color: $uv-toast-color; align-items: center; /* #ifndef APP-NVUE */ max-width: 600rpx; /* #endif */ position: relative; &--loading { flex-direction: column; padding: $uv-toast-loading-border-padding; } &__text { color: $uv-toast-content-text-color; font-size: $uv-toast-content-text-font-size; line-height: $uv-toast-content-text-font-size; &--default { color: $uv-toast-content-text-color; } &--error { color: $uv-error; } &--primary { color: $uv-primary; } &--success { color: $uv-success; } &--warning { color: $uv-warning; } } } } .uv-type-primary { color: $uv-toast-uv-type-primary-color; background-color: $uv-toast-uv-type-primary-background-color; border-color: $uv-toast-uv-type-primary-border-color; border-width: $uv-toast-uv-type-primary-border-width; } .uv-type-success { color: $uv-toast-uv-type-success-color; background-color: $uv-toast-uv-type-success-background-color; border-color: $uv-toast-uv-type-success-border-color; border-width: 1px; } .uv-type-error { color: $uv-toast-uv-type-error-color; background-color: $uv-toast-uv-type-error-background-color; border-color: $uv-toast-uv-type-error-border-color; border-width: $uv-toast-uv-type-error-border-width; } .uv-type-warning { color: $uv-toast-uv-type-warning-color; background-color: $uv-toast-uv-type-warning-background-color; border-color: $uv-toast-uv-type-warning-border-color; border-width: 1px; } .uv-type-default { color: $uv-toast-uv-type-default-color; background-color: $uv-toast-uv-type-default-background-color; } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-toast/components/uv-toast/uv-toast.vue
Vue
unknown
10,782
export default { props: { // 是否展示工具条 show: { type: Boolean, default: true }, // 是否显示下边框 showBorder: { type: Boolean, default: false }, // 取消按钮的文字 cancelText: { type: String, default: '取消' }, // 确认按钮的文字 confirmText: { type: String, default: '确认' }, // 取消按钮的颜色 cancelColor: { type: String, default: '#909193' }, // 确认按钮的颜色 confirmColor: { type: String, default: '#3c9cff' }, // 标题文字 title: { type: String, default: '' }, ...uni.$uv?.props?.toolbar } }
2301_77169380/AppruanjianApk
uni_modules/uv-toolbar/components/uv-toolbar/props.js
JavaScript
unknown
637
<template> <view :class="['uv-toolbar',{'uv-border-bottom':showBorder}]" @touchmove.stop.prevent="noop" v-if="show" > <view class="uv-toolbar__cancel__wrapper" hover-class="uv-hover-class" > <text class="uv-toolbar__wrapper__cancel" @tap="cancel" :style="{ color: cancelColor }" >{{ cancelText }}</text> </view> <text class="uv-toolbar__title uv-line-1" v-if="title" >{{ title }}</text> <view class="uv-toolbar__confirm__wrapper" hover-class="uv-hover-class" > <text class="uv-toolbar__wrapper__confirm" @tap="confirm" :style="{ color: confirmColor }" >{{ confirmText }}</text> </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'; /** * Toolbar 工具条 * @description * @tutorial https://www.uvui.cn/components/toolbar.html * @property {Boolean} show 是否展示工具条(默认 true ) * @property {Boolean} showBorder 是否展示工具条下方边框(默认 false ) * @property {String} cancelText 取消按钮的文字(默认 '取消' ) * @property {String} confirmText 确认按钮的文字(默认 '确认' ) * @property {String} cancelColor 取消按钮的颜色(默认 '#909193' ) * @property {String} confirmColor 确认按钮的颜色(默认 '#3c9cff' ) * @property {String} title 标题文字 * @event {Function} * @example */ export default { name: 'uv-toolbar', emits: ['confirm', 'cancel'], mixins: [mpMixin, mixin, props], methods: { // 点击取消按钮 cancel() { this.$emit('cancel') }, // 点击确定按钮 confirm() { this.$emit('confirm') } } } </script> <style lang="scss" scoped> $show-lines: 1; $show-hover: 1; $show-border: 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'; $uv-tips-color: #909193 !default; $uv-main-color: #303133 !default; $uv-primary: #3c9cff !default; .uv-toolbar { height: 42px; @include flex; justify-content: space-between; align-items: center; &__wrapper { &__cancel { color: $uv-tips-color; font-size: 15px; padding: 0 15px; } } &__title { color: $uv-main-color; padding: 0 60rpx; font-size: 16px; flex: 1; text-align: center; } &__wrapper { &__confirm { color: $uv-primary; font-size: 15px; padding: 0 15px; } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-toolbar/components/uv-toolbar/uv-toolbar.vue
Vue
unknown
2,608
export default { props: { // 需要显示的提示文字 text: { type: [String, Number], default: '' }, // 点击复制按钮时,复制的文本,为空则使用text值 copyText: { type: [String, Number], default: '' }, // 文本大小 size: { type: [String, Number], default: 14 }, // 字体颜色 color: { type: String, default: '#606266' }, // 弹出提示框时,文本的背景色 bgColor: { type: String, default: 'transparent' }, // 弹出提示的方向,top-上方,bottom-下方 direction: { type: String, default: 'top' }, // 弹出提示的z-index,nvue无效 zIndex: { type: [String, Number], default: 10071 }, // 是否显示复制按钮 showCopy: { type: Boolean, default: true }, // 扩展的按钮组 buttons: { type: Array, default: () => [] }, // 是否显示透明遮罩以防止触摸穿透 overlay: { type: Boolean, default: true }, // 是否显示复制成功或者失败的toast showToast: { type: Boolean, default: true }, ...uni.$uv?.props?.tooltip } }
2301_77169380/AppruanjianApk
uni_modules/uv-tooltip/components/uv-tooltip/props.js
JavaScript
unknown
1,121
<template> <view class="uv-tooltip" :style="[$uv.addStyle(customStyle)]" > <uv-overlay :show="showTooltip && tooltipTop !== -10000 && overlay && timeout>0" customStyle="backgroundColor: rgba(0, 0, 0, 0)" @click="overlayClickHandler" ></uv-overlay> <view class="uv-tooltip__wrapper"> <template v-if="isShow"> <text class="uv-tooltip__wrapper__text" :id="textId" :ref="textId" :userSelect="false" :selectable="false" @click.stop="longpressHandler" :style="{ color: color, backgroundColor: bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent' }" >{{ text }}</text> </template> <template v-else> <text class="uv-tooltip__wrapper__text" :id="textId" :ref="textId" :userSelect="false" :selectable="false" @longpress.stop="longpressHandler" :style="{ color: color, backgroundColor: bgColor && showTooltip && tooltipTop !== -10000 ? bgColor : 'transparent' }" >{{ text }}</text> </template> <uv-transition mode="fade" :show="showTooltip" :duration="300" :customStyle="{ position: 'absolute', top: $uv.addUnit(tooltipTop), zIndex: zIndex, ...tooltipStyle }" > <view class="uv-tooltip__wrapper__popup" :id="tooltipId" :ref="tooltipId" > <view class="uv-tooltip__wrapper__popup__indicator" hover-class="uv-tooltip__wrapper__popup__indicator--hover" v-if="showCopy || buttons.length" :style="[indicatorStyle, { width: $uv.addUnit(indicatorWidth), height: $uv.addUnit(indicatorWidth), }]" > <!-- 由于nvue不支持三角形绘制,这里就做一个四方形,再旋转45deg,得到露出的一个三角 --> </view> <view class="uv-tooltip__wrapper__popup__list"> <view v-if="showCopy" class="uv-tooltip__wrapper__popup__list__btn" hover-class="uv-tooltip__wrapper__popup__list__btn--hover" @tap="setClipboardData" > <text class="uv-tooltip__wrapper__popup__list__btn__text" >复制</text> </view> <uv-line direction="column" color="#8d8e90" v-if="showCopy && buttons.length > 0" length="18" ></uv-line> <block v-for="(item , index) in buttons" :key="index"> <view class="uv-tooltip__wrapper__popup__list__btn" hover-class="uv-tooltip__wrapper__popup__list__btn--hover" > <text class="uv-tooltip__wrapper__popup__list__btn__text" @tap="btnClickHandler(index)" >{{ item }}</text> </view> <uv-line direction="column" color="#8d8e90" v-if="index < buttons.length - 1" length="18" ></uv-line> </block> </view> </view> </uv-transition> </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 /** * Tooltip * @description * @tutorial https://www.uvui.cn/components/tooltip.html * @property {String | Number} text 需要显示的提示文字 * @property {String | Number} copyText 点击复制按钮时,复制的文本,为空则使用text值 * @property {String | Number} size 文本大小(默认 14 ) * @property {String} color 字体颜色(默认 '#606266' ) * @property {String} bgColor 弹出提示框时,文本的背景色(默认 'transparent' ) * @property {String} direction 弹出提示的方向,top-上方,bottom-下方(默认 'top' ) * @property {String | Number} zIndex 弹出提示的z-index,nvue无效(默认 10071 ) * @property {Boolean} showCopy 是否显示复制按钮(默认 true ) * @property {Array} buttons 扩展的按钮组 * @property {Boolean} overlay 是否显示透明遮罩以防止触摸穿透(默认 true ) * @property {Object} customStyle 定义需要用到的外部样式 * * @event {Function} * @example */ export default { name: 'uv-tooltip', emits: ['click'], mixins: [mpMixin, mixin, props], data() { return { // 是否展示气泡 showTooltip: true, // 生成唯一id,防止一个页面多个组件,造成干扰 textId: '', tooltipId: '', // 初始时甚至为很大的值,让其移到屏幕外面,为了计算元素的尺寸 tooltipTop: -10000, // 气泡的位置信息 tooltipInfo: { width: 0, left: 0 }, // 文本的位置信息 textInfo: { width: 0, left: 0 }, // 三角形指示器的样式 indicatorStyle: {}, // 气泡在可能超出屏幕边沿范围时,重新定位后,距离屏幕边沿的距离 screenGap: 12, // 三角形指示器的宽高,由于对元素进行了角度旋转,精确计算指示器位置时,需要用到其尺寸信息 indicatorWidth: 14, timeout: 0 } }, watch: { propsChange() { this.getElRect() }, showTooltip(newVal){ if(!newVal) this.timeout = 0; } }, computed: { isShow(){ const isPC = this.$uv.sys()?.model == 'PC'; if(isPC) { return true; } // #ifdef MP-WEIXIN || H5 return false; // #endif return true; }, // 特别处理H5的复制,因为H5浏览器是自带系统复制功能的,在H5环境 // 当一些依赖参数变化时,需要重新计算气泡和指示器的位置信息 propsChange() { return [this.text, this.buttons] }, // 计算气泡和指示器的位置信息 tooltipStyle() { const style = {}; if (this.tooltipInfo.width / 2 > this.textInfo.left + this.textInfo.width / 2 - this.screenGap) { this.indicatorStyle = {} style.left = `-${this.$uv.addUnit(this.textInfo.left - this.screenGap)}` this.indicatorStyle.left = this.$uv.addUnit(this.textInfo.width / 2 - this.$uv.getPx(style.left) - this.indicatorWidth / 2) } else if (this.tooltipInfo.width / 2 > this.$uv.sys().windowWidth - this.textInfo.right + this.textInfo.width / 2 - this.screenGap) { this.indicatorStyle = {} style.right = `-${this.$uv.addUnit(this.$uv.sys().windowWidth - this.textInfo.right - this.screenGap)}` this.indicatorStyle.right = this.$uv.addUnit(this.textInfo.width / 2 - this.$uv.getPx(style.right) - this .indicatorWidth / 2) } else { const left = Math.abs(this.textInfo.width / 2 - this.tooltipInfo.width / 2) style.left = this.textInfo.width > this.tooltipInfo.width ? this.$uv.addUnit(left) : -this.$uv.addUnit(left) this.indicatorStyle = {} } if (this.direction === 'top') { style.marginTop = `-${10 + this.tooltipInfo.height}px` this.indicatorStyle.bottom = '-4px' } else { style.marginTop = `${this.tooltipInfo.height-10}px` this.indicatorStyle.top = '-4px' } return style } }, created() { this.textId = this.$uv.guid(); this.tooltipId = this.$uv.guid(); }, mounted() { this.init() }, methods: { init() { this.getElRect() }, // 长按触发事件 async longpressHandler(e) { this.tooltipTop = 0 this.showTooltip = true setTimeout(()=>{ this.timeout = 1; },300) }, // 点击透明遮罩 overlayClickHandler() { this.showTooltip = false }, // 点击弹出按钮 btnClickHandler(index) { this.showTooltip = false // 如果需要展示复制按钮,此处index需要加1,因为复制按钮在第一个位置 this.$emit('click', this.showCopy ? index + 1 : index) }, // 查询内容高度 queryRect(ref) { // #ifndef APP-NVUE // 组件内部一般用this.$uvGetRect,对外的为getRect,二者功能一致,名称不同 return new Promise(resolve => { this.$uvGetRect(`#${ref}`).then(size => { resolve(size) }) }) // #endif // #ifdef APP-NVUE // nvue下,使用dom模块查询元素高度 // 返回一个promise,让调用此方法的主体能使用then回调 return new Promise(resolve => { dom.getComponentRect(this.$refs[ref], res => { resolve(res.size) }) }) // #endif }, // 元素尺寸 getElRect() { // 调用之前,先将指示器调整到屏幕外,方便获取尺寸 this.showTooltip = true this.tooltipTop = -10000 this.$uv.sleep(500).then(() => { this.queryRect(this.tooltipId).then(size => { this.tooltipInfo = size // 获取气泡尺寸之后,将其隐藏,为了让下次切换气泡显示与隐藏时,有淡入淡出的效果 this.showTooltip = false }) this.queryRect(this.textId).then(size => { this.textInfo = size }) }) }, // 复制文本到粘贴板 setClipboardData() { // 关闭组件 this.showTooltip = false this.$emit('click', 0) uni.setClipboardData({ // 优先使用copyText字段,如果没有,则默认使用text字段当做复制的内容 data: this.copyText || this.text, success: () => { this.showToast && this.$uv.toast('复制成功') }, fail: () => { this.showToast && this.$uv.toast('复制失败') }, complete: () => { this.showTooltip = false } }) } } } </script> <style lang="scss" scoped> @import '@/uni_modules/uv-ui-tools/libs/css/components.scss'; .uv-tooltip { position: relative; @include flex; &__wrapper { @include flex; justify-content: center; /* #ifndef APP-NVUE */ white-space: nowrap; /* #endif */ &__text { font-size: 14px; } &__popup { @include flex; justify-content: center; &__list { background-color: #060607; position: relative; flex: 1; border-radius: 5px; padding: 0px 0; @include flex(row); align-items: center; overflow: hidden; &__btn { padding: 11px 13px; &--hover { background-color: #58595B; } &__text { line-height: 12px; font-size: 13px; color: #FFFFFF; } } } &__indicator { position: absolute; background-color: #060607; width: 14px; height: 14px; bottom: -4px; transform: rotate(45deg); border-radius: 2px; z-index: -1; &--hover { background-color: #58595B; } } } } } </style>
2301_77169380/AppruanjianApk
uni_modules/uv-tooltip/components/uv-tooltip/uv-tooltip.vue
Vue
unknown
10,552
// const defaultOption = { // duration: 300, // timingFunction: 'linear', // delay: 0, // transformOrigin: '50% 50% 0' // } // #ifdef APP-NVUE const nvueAnimation = uni.requireNativePlugin('animation') // #endif class MPAnimation { constructor(options, _this) { this.options = options // 在iOS10+QQ小程序平台下,传给原生的对象一定是个普通对象而不是Proxy对象,否则会报parameter should be Object instead of ProxyObject的错误 this.animation = uni.createAnimation({ ...options }) this.currentStepAnimates = {} this.next = 0 this.$ = _this } _nvuePushAnimates(type, args) { let aniObj = this.currentStepAnimates[this.next] let styles = {} if (!aniObj) { styles = { styles: {}, config: {} } } else { styles = aniObj } if (animateTypes1.includes(type)) { if (!styles.styles.transform) { styles.styles.transform = '' } let unit = '' if(type === 'rotate'){ unit = 'deg' } styles.styles.transform += `${type}(${args+unit}) ` } else { styles.styles[type] = `${args}` } this.currentStepAnimates[this.next] = styles } _animateRun(styles = {}, config = {}) { let ref = this.$.$refs['ani'].ref if (!ref) return return new Promise((resolve, reject) => { nvueAnimation.transition(ref, { styles, ...config }, res => { resolve() }) }) } _nvueNextAnimate(animates, step = 0, fn) { let obj = animates[step] if (obj) { let { styles, config } = obj this._animateRun(styles, config).then(() => { step += 1 this._nvueNextAnimate(animates, step, fn) }) } else { this.currentStepAnimates = {} typeof fn === 'function' && fn() this.isEnd = true } } step(config = {}) { // #ifndef APP-NVUE this.animation.step(config) // #endif // #ifdef APP-NVUE this.currentStepAnimates[this.next].config = Object.assign({}, this.options, config) this.currentStepAnimates[this.next].styles.transformOrigin = this.currentStepAnimates[this.next].config.transformOrigin this.next++ // #endif return this } run(fn) { // #ifndef APP-NVUE this.$.animationData = this.animation.export() this.$.timer = setTimeout(() => { typeof fn === 'function' && fn() }, this.$.durationTime) // #endif // #ifdef APP-NVUE this.isEnd = false let ref = this.$.$refs['ani'] && this.$.$refs['ani'].ref if(!ref) return this._nvueNextAnimate(this.currentStepAnimates, 0, fn) this.next = 0 // #endif } } const animateTypes1 = ['matrix', 'matrix3d', 'rotate', 'rotate3d', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scale3d', 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'translate', 'translate3d', 'translateX', 'translateY', 'translateZ' ] const animateTypes2 = ['opacity', 'backgroundColor'] const animateTypes3 = ['width', 'height', 'left', 'right', 'top', 'bottom'] animateTypes1.concat(animateTypes2, animateTypes3).forEach(type => { MPAnimation.prototype[type] = function(...args) { // #ifndef APP-NVUE this.animation[type](...args) // #endif // #ifdef APP-NVUE this._nvuePushAnimates(type, args) // #endif return this } }) export function createAnimation(option, _this) { if(!_this) return clearTimeout(_this.timer) return new MPAnimation(option, _this) }
2301_77169380/AppruanjianApk
uni_modules/uv-transition/components/uv-transition/createAnimation.js
JavaScript
unknown
3,281
export default { props: { // 是否展示组件 show: { type: Boolean, default: false }, // 使用的动画模式 mode: { type: [Array, String, null], default() { return 'fade' } }, // 动画的执行时间,单位ms duration: { type: [String, Number], default: 300 }, // 使用的动画过渡函数 timingFunction: { type: String, default: 'ease-out' }, customClass: { type: String, default: '' }, ...uni.$uv?.props?.transition } }
2301_77169380/AppruanjianApk
uni_modules/uv-transition/components/uv-transition/props.js
JavaScript
unknown
502
<template> <!-- #ifndef APP-NVUE --> <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"> <slot></slot> </view> <!-- #endif --> <!-- #ifdef APP-NVUE --> <view v-if="isShow" ref="ani" :animation="animationData" :class="customClass" :style="transformStyles" @click="onClick"> <slot></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 { createAnimation } from './createAnimation' /** * transition 动画组件 * @description * @tutorial * @property {Boolean} show 控制组件显示或关闭 (默认 false ) * @property {Array | String } mode 内置过渡动画类型 (默认 'fade' ) * @value fade 渐隐渐出过渡 * @value slide-top 由上至下过渡 * @value slide-bottom 由下至上过渡 * @value slide-left 由左至右过渡 * @value slide-right 由右至左过渡 * @value zoom-in 由小到大过渡 * @value zoom-out 由大到小过渡 * @property {String | Number} duration 动画的执行时间,单位ms (默认 300 ) * @property {String} timingFunction 使用的动画过渡函数 (默认 'ease-out' ) * @property {Object} customStyle 自定义样式 * @property {String} customClass 自定义类名 * @event {Function} click 点击组件触发 * @event {Function} change 过渡动画结束时触发 * @example */ export default { name: 'uv-transition', mixins: [mpMixin,mixin], emits:['click','change'], props: { // 是否展示组件 show: { type: Boolean, default: false }, // 使用的动画模式 mode: { type: [Array, String, null], default() { return 'fade' } }, // 动画的执行时间,单位ms duration: { type: [String, Number], default: 300 }, // 使用的动画过渡函数 timingFunction: { type: String, default: 'ease-out' }, customClass: { type: String, default: '' }, // nvue模式下 是否直接显示,在uv-list等cell下面使用就需要设置 cellChild: { type: Boolean, default: false } }, data(){ return { isShow: false, transform: '', opacity: 1, animationData: {}, durationTime: 300, config: {} } }, watch: { show: { handler(newVal) { if (newVal) { this.open(); } else { // 避免上来就执行 close,导致动画错乱 if (this.isShow) { this.close(); } } }, immediate: true } }, computed: { // 初始化动画条件 transformStyles() { const style = { transform: this.transform, opacity: this.opacity, ...this.$uv.addStyle(this.customStyle), 'transition-duration': `${this.duration / 1000}s` }; return this.$uv.addStyle(style,'string'); } }, created() { // 动画默认配置 this.config = { duration: this.duration, timingFunction: this.timingFunction, transformOrigin: '50% 50%', delay: 0 }; this.durationTime = this.duration; }, methods: { /** * ref 触发 初始化动画 */ init(obj = {}) { if (obj.duration) { this.durationTime = obj.duration; } this.animation = createAnimation(Object.assign(this.config, obj),this); }, /** * 点击组件触发回调 */ onClick() { this.$emit('click', { detail: this.isShow }) }, /** * ref 触发 动画分组 * @param {Object} obj */ step(obj, config = {}) { if (!this.animation) return; for (let i in obj) { try { if(typeof obj[i] === 'object'){ this.animation[i](...obj[i]); }else{ this.animation[i](obj[i]); } } catch (e) { console.error(`方法 ${i} 不存在`); } } this.animation.step(config); return this; }, /** * ref 触发 执行动画 */ run(fn) { if (!this.animation) return; this.animation.run(fn); }, // 开始过度动画 open() { clearTimeout(this.timer); this.transform = ''; this.isShow = true; let { opacity, transform } = this.styleInit(false); if (typeof opacity !== 'undefined') { this.opacity = opacity; } this.transform = transform; // 确保动态样式已经生效后,执行动画,如果不加 nextTick ,会导致 wx 动画执行异常 this.$nextTick(() => { // TODO 定时器保证动画完全执行,目前有些问题,后面会取消定时器 this.timer = setTimeout(() => { this.animation = createAnimation(this.config, this); this.tranfromInit(false).step(); // #ifdef APP-NVUE if(this.cellChild) { this.opacity = 1; } else{ this.animation.run(); } // #endif // #ifndef APP-NVUE this.animation.run(); // #endif // #ifdef VUE3 // #ifdef H5 this.opacity = 1; // #endif // #endif this.$emit('change', { detail: this.isShow }) // #ifdef H5 // #ifdef VUE3 this.transform = ''; // #endif // #endif }, 20); }) }, // 关闭过渡动画 close(type) { if (!this.animation) return; this.tranfromInit(true) .step() .run(() => { this.isShow = false; this.animationData = null; this.animation = null; let { opacity, transform } = this.styleInit(false); this.opacity = opacity || 1; this.transform = transform; this.$emit('change', { detail: this.isShow }); }) }, // 处理动画开始前的默认样式 styleInit(type) { let styles = { transform: '' }; let buildStyle = (type, mode) => { if (mode === 'fade') { styles.opacity = this.animationType(type)[mode]; } else { styles.transform += this.animationType(type)[mode] + ' '; } } if (typeof this.mode === 'string') { buildStyle(type, this.mode); } else { this.mode.forEach(mode => { buildStyle(type, mode) }) } return styles }, // 处理内置组合动画 tranfromInit(type) { let buildTranfrom = (type, mode) => { let aniNum = null; if (mode === 'fade') { aniNum = type ? 0 : 1; } else { aniNum = type ? '-100%' : '0'; if (mode === 'zoom-in') { aniNum = type ? 0.8 : 1 } if (mode === 'zoom-out') { aniNum = type ? 1.2 : 1 } if (mode === 'slide-right') { aniNum = type ? '100%' : '0' } if (mode === 'slide-bottom') { aniNum = type ? '100%' : '0' } } this.animation[this.animationMode()[mode]](aniNum) } if (typeof this.mode === 'string') { buildTranfrom(type, this.mode) } else { this.mode.forEach(mode => { buildTranfrom(type, mode) }) } return this.animation; }, animationType(type) { return { fade: type ? 1 : 0, 'slide-top': `translateY(${type ? '0' : '-100%'})`, 'slide-right': `translateX(${type ? '0' : '100%'})`, 'slide-bottom': `translateY(${type ? '0' : '100%'})`, 'slide-left': `translateX(${type ? '0' : '-100%'})`, 'zoom-in': `scaleX(${type ? 1 : 0.8}) scaleY(${type ? 1 : 0.8})`, 'zoom-out': `scaleX(${type ? 1 : 1.2}) scaleY(${type ? 1 : 1.2})` } }, // 内置动画类型与实际动画对应字典 animationMode() { return { fade: 'opacity', 'slide-top': 'translateY', 'slide-right': 'translateX', 'slide-bottom': 'translateY', 'slide-left': 'translateX', 'zoom-in': 'scale', 'zoom-out': 'scale' } }, // 驼峰转中横线 toLine(name) { return name.replace(/([A-Z])/g, '-$1').toLowerCase() } } } </script>
2301_77169380/AppruanjianApk
uni_modules/uv-transition/components/uv-transition/uv-transition.vue
Vue
unknown
7,874
<template> <view>占位组件,请勿使用;如需下载示例项目,请使用【下载插件并导入HBuilderX】或【使用 HBuilderX 导入示例项目】或【下载示例项目ZIP】</view> </template> <script> </script> <style> </style>
2301_77169380/AppruanjianApk
uni_modules/uv-ui/components/uv-ui/uv-ui.vue
Vue
unknown
250
<template> </template> <script> </script> <style> </style>
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/components/uv-ui-tools/uv-ui-tools.vue
Vue
unknown
59
// 全局挂载引入http相关请求拦截插件 import Request from './libs/luch-request' // 引入全局mixin import mixin from './libs/mixin/mixin.js' // 小程序特有的mixin import mpMixin from './libs/mixin/mpMixin.js' // #ifdef MP import mpShare from './libs/mixin/mpShare.js' // #endif // 路由封装 import route from './libs/util/route.js' // 公共工具函数 import * as index from './libs/function/index.js' // 防抖方法 import debounce from './libs/function/debounce.js' // 节流方法 import throttle from './libs/function/throttle.js' // 规则检验 import * as test from './libs/function/test.js' // 颜色渐变相关,colorGradient-颜色渐变,hexToRgb-十六进制颜色转rgb颜色,rgbToHex-rgb转十六进制 import * as colorGradient from './libs/function/colorGradient.js' // 配置信息 import config from './libs/config/config.js' // 平台 import platform from './libs/function/platform' const $uv = { route, config, test, date: index.timeFormat, // 另名date ...index, colorGradient: colorGradient.colorGradient, hexToRgb: colorGradient.hexToRgb, rgbToHex: colorGradient.rgbToHex, colorToRgba: colorGradient.colorToRgba, http: new Request(), debounce, throttle, platform, mixin, mpMixin } uni.$uv = $uv; const install = (Vue,options={}) => { // #ifndef APP-NVUE const cloneMixin = index.deepClone(mixin); delete cloneMixin?.props?.customClass; delete cloneMixin?.props?.customStyle; Vue.mixin(cloneMixin); // #ifdef MP if(options.mpShare){ Vue.mixin(mpShare); } // #endif // #endif // #ifdef VUE2 // 时间格式化,同时两个名称,date和timeFormat Vue.filter('timeFormat', (timestamp, format) => uni.$uv.timeFormat(timestamp, format)); Vue.filter('date', (timestamp, format) => uni.$uv.timeFormat(timestamp, format)); // 将多久以前的方法,注入到全局过滤器 Vue.filter('timeFrom', (timestamp, format) => uni.$uv.timeFrom(timestamp, format)); // 同时挂载到uni和Vue.prototype中 // #ifndef APP-NVUE // 只有vue,挂载到Vue.prototype才有意义,因为nvue中全局Vue.prototype和Vue.mixin是无效的 Vue.prototype.$uv = $uv; // #endif // #endif // #ifdef VUE3 Vue.config.globalProperties.$uv = $uv; // #endif } export default { install }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/index.js
JavaScript
unknown
2,287
// 引入公共基础类 @import "./libs/css/common.scss"; // 非nvue的样式 /* #ifndef APP-NVUE */ @import "./libs/css/vue.scss"; /* #endif */
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/index.scss
SCSS
unknown
146
// 此版本发布于2024-01-20 const version = '1.1.20' // 开发环境才提示,生产环境不会提示 if (process.env.NODE_ENV === 'development') { console.log(`\n %c uvui V${version} https://www.uvui.cn/ \n\n`, 'color: #ffffff; background: #3c9cff; padding:5px 0; border-radius: 5px;'); } export default { v: version, version, // 主题名称 type: [ 'primary', 'success', 'info', 'error', 'warning' ], // 颜色部分,本来可以通过scss的:export导出供js使用,但是奈何nvue不支持 color: { 'uv-primary': '#2979ff', 'uv-warning': '#ff9900', 'uv-success': '#19be6b', 'uv-error': '#fa3534', 'uv-info': '#909399', 'uv-main-color': '#303133', 'uv-content-color': '#606266', 'uv-tips-color': '#909399', 'uv-light-color': '#c0c4cc' }, // 默认单位,可以通过配置为rpx,那么在用于传入组件大小参数为数值时,就默认为rpx unit: 'px' }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/config/config.js
JavaScript
unknown
1,031
$uv-main-color: #303133 !default; $uv-content-color: #606266 !default; $uv-tips-color: #909193 !default; $uv-light-color: #c0c4cc !default; $uv-border-color: #dadbde !default; $uv-bg-color: #f3f4f6 !default; $uv-disabled-color: #c8c9cc !default; $uv-primary: #3c9cff !default; $uv-primary-dark: #398ade !default; $uv-primary-disabled: #9acafc !default; $uv-primary-light: #ecf5ff !default; $uv-warning: #f9ae3d !default; $uv-warning-dark: #f1a532 !default; $uv-warning-disabled: #f9d39b !default; $uv-warning-light: #fdf6ec !default; $uv-success: #5ac725 !default; $uv-success-dark: #53c21d !default; $uv-success-disabled: #a9e08f !default; $uv-success-light: #f5fff0; $uv-error: #f56c6c !default; $uv-error-dark: #e45656 !default; $uv-error-disabled: #f7b2b2 !default; $uv-error-light: #fef0f0 !default; $uv-info: #909399 !default; $uv-info-dark: #767a82 !default; $uv-info-disabled: #c4c6c9 !default; $uv-info-light: #f4f4f5 !default;
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/css/color.scss
SCSS
unknown
942
// 超出行数,自动显示行尾省略号,最多5行 // 来自uvui的温馨提示:当您在控制台看到此报错,说明需要在App.vue的style标签加上【lang="scss"】 @for $i from 1 through 5 { .uv-line-#{$i} { /* #ifdef APP-NVUE */ // nvue下,可以直接使用lines属性,这是weex特有样式 lines: $i; text-overflow: ellipsis; overflow: hidden; flex: 1; /* #endif */ /* #ifndef APP-NVUE */ // vue下,单行和多行显示省略号需要单独处理 @if $i == '1' { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } @else { display: -webkit-box!important; overflow: hidden; text-overflow: ellipsis; word-break: break-all; -webkit-line-clamp: $i; -webkit-box-orient: vertical!important; } /* #endif */ } } $uv-bordercolor: #dadbde; @if variable-exists(uv-border-color) { $uv-bordercolor: $uv-border-color; } // 此处加上!important并非随意乱用,而是因为目前*.nvue页面编译到H5时, // App.vue的样式会被uni-app的view元素的自带border属性覆盖,导致无效 // 综上,这是uni-app的缺陷导致我们为了多端兼容,而必须要加上!important // 移动端兼容性较好,直接使用0.5px去实现细边框,不使用伪元素形式实现 .uv-border { border-width: 0.5px!important; border-color: $uv-bordercolor!important; border-style: solid; } .uv-border-top { border-top-width: 0.5px!important; border-color: $uv-bordercolor!important; border-top-style: solid; } .uv-border-left { border-left-width: 0.5px!important; border-color: $uv-bordercolor!important; border-left-style: solid; } .uv-border-right { border-right-width: 0.5px!important; border-color: $uv-bordercolor!important; border-right-style: solid; } .uv-border-bottom { border-bottom-width: 0.5px!important; border-color: $uv-bordercolor!important; border-bottom-style: solid; } .uv-border-top-bottom { border-top-width: 0.5px!important; border-bottom-width: 0.5px!important; border-color: $uv-bordercolor!important; border-top-style: solid; border-bottom-style: solid; } // 去除button的所有默认样式,让其表现跟普通的view、text元素一样 .uv-reset-button { padding: 0; background-color: transparent; /* #ifndef APP-PLUS */ font-size: inherit; line-height: inherit; color: inherit; /* #endif */ /* #ifdef APP-NVUE */ border-width: 0; /* #endif */ } /* #ifndef APP-NVUE */ .uv-reset-button::after { border: none; } /* #endif */ .uv-hover-class { opacity: 0.7; }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/css/common.scss
SCSS
unknown
2,560
@mixin flex($direction: row) { /* #ifndef APP-NVUE */ display: flex; /* #endif */ flex-direction: $direction; } /* #ifndef APP-NVUE */ // 由于uvui是基于nvue环境进行开发的,此环境中普通元素默认为flex-direction: column; // 所以在非nvue中,需要对元素进行重置为flex-direction: column; 否则可能会表现异常 $uvui-nvue-style: true !default; @if $uvui-nvue-style == true { view, scroll-view, swiper-item { display: flex; flex-direction: column; flex-shrink: 0; flex-grow: 0; flex-basis: auto; align-items: stretch; align-content: flex-start; } } /* #endif */
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/css/components.scss
SCSS
unknown
620
// 超出行数,自动显示行尾省略号,最多5行 // 来自uvui的温馨提示:当您在控制台看到此报错,说明需要在App.vue的style标签加上【lang="scss"】 @if variable-exists(show-lines) { @for $i from 1 through 5 { .uv-line-#{$i} { /* #ifdef APP-NVUE */ // nvue下,可以直接使用lines属性,这是weex特有样式 lines: $i; text-overflow: ellipsis; overflow: hidden; flex: 1; /* #endif */ /* #ifndef APP-NVUE */ // vue下,单行和多行显示省略号需要单独处理 @if $i == '1' { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; } @else { display: -webkit-box!important; overflow: hidden; text-overflow: ellipsis; word-break: break-all; -webkit-line-clamp: $i; -webkit-box-orient: vertical!important; } /* #endif */ } } } @if variable-exists(show-border) { $uv-bordercolor: #dadbde; @if variable-exists(uv-border-color) { $uv-bordercolor: $uv-border-color; } // 此处加上!important并非随意乱用,而是因为目前*.nvue页面编译到H5时, // App.vue的样式会被uni-app的view元素的自带border属性覆盖,导致无效 // 综上,这是uni-app的缺陷导致我们为了多端兼容,而必须要加上!important // 移动端兼容性较好,直接使用0.5px去实现细边框,不使用伪元素形式实现 @if variable-exists(show-border-surround) { .uv-border { border-width: 0.5px!important; border-color: $uv-bordercolor!important; border-style: solid; } } @if variable-exists(show-border-top) { .uv-border-top { border-top-width: 0.5px!important; border-color: $uv-bordercolor!important; border-top-style: solid; } } @if variable-exists(show-border-left) { .uv-border-left { border-left-width: 0.5px!important; border-color: $uv-bordercolor!important; border-left-style: solid; } } @if variable-exists(show-border-right) { .uv-border-right { border-right-width: 0.5px!important; border-color: $uv-bordercolor!important; border-right-style: solid; } } @if variable-exists(show-border-bottom) { .uv-border-bottom { border-bottom-width: 0.5px!important; border-color: $uv-bordercolor!important; border-bottom-style: solid; } } @if variable-exists(show-border-top-bottom) { .uv-border-top-bottom { border-top-width: 0.5px!important; border-bottom-width: 0.5px!important; border-color: $uv-bordercolor!important; border-top-style: solid; border-bottom-style: solid; } } } @if variable-exists(show-reset-button) { // 去除button的所有默认样式,让其表现跟普通的view、text元素一样 .uv-reset-button { padding: 0; background-color: transparent; /* #ifndef APP-PLUS */ font-size: inherit; line-height: inherit; color: inherit; /* #endif */ /* #ifdef APP-NVUE */ border-width: 0; /* #endif */ } /* #ifndef APP-NVUE */ .uv-reset-button::after { border: none; } /* #endif */ } @if variable-exists(show-hover) { .uv-hover-class { opacity: 0.7; } }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/css/variable.scss
SCSS
unknown
3,077
// 历遍生成4个方向的底部安全区 @each $d in top, right, bottom, left { .uv-safe-area-inset-#{$d} { padding-#{$d}: 0; padding-#{$d}: constant(safe-area-inset-#{$d}); padding-#{$d}: env(safe-area-inset-#{$d}); } } //提升H5端uni.toast()的层级,避免被uvui的modal等遮盖 /* #ifdef H5 */ uni-toast { z-index: 10090; } uni-toast .uni-toast { z-index: 10090; } /* #endif */ // 隐藏scroll-view的滚动条 ::-webkit-scrollbar { display: none; width: 0 !important; height: 0 !important; -webkit-appearance: none; background: transparent; } $uvui-nvue-style: true !default; @if $uvui-nvue-style == false { view, scroll-view, swiper-item { display: flex; flex-direction: column; flex-shrink: 0; flex-grow: 0; flex-basis: auto; align-items: stretch; align-content: flex-start; } }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/css/vue.scss
SCSS
unknown
863
/** * 求两个颜色之间的渐变值 * @param {string} startColor 开始的颜色 * @param {string} endColor 结束的颜色 * @param {number} step 颜色等分的份额 * */ function colorGradient(startColor = 'rgb(0, 0, 0)', endColor = 'rgb(255, 255, 255)', step = 10) { const startRGB = hexToRgb(startColor, false) // 转换为rgb数组模式 const startR = startRGB[0] const startG = startRGB[1] const startB = startRGB[2] const endRGB = hexToRgb(endColor, false) const endR = endRGB[0] const endG = endRGB[1] const endB = endRGB[2] const sR = (endR - startR) / step // 总差值 const sG = (endG - startG) / step const sB = (endB - startB) / step const colorArr = [] for (let i = 0; i < step; i++) { // 计算每一步的hex值 let hex = rgbToHex(`rgb(${Math.round((sR * i + startR))},${Math.round((sG * i + startG))},${Math.round((sB * i + startB))})`) // 确保第一个颜色值为startColor的值 if (i === 0) hex = rgbToHex(startColor) // 确保最后一个颜色值为endColor的值 if (i === step - 1) hex = rgbToHex(endColor) colorArr.push(hex) } return colorArr } // 将hex表示方式转换为rgb表示方式(这里返回rgb数组模式) function hexToRgb(sColor, str = true) { const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/ sColor = String(sColor).toLowerCase() if (sColor && reg.test(sColor)) { if (sColor.length === 4) { let sColorNew = '#' for (let i = 1; i < 4; i += 1) { sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1)) } sColor = sColorNew } // 处理六位的颜色值 const sColorChange = [] for (let i = 1; i < 7; i += 2) { sColorChange.push(parseInt(`0x${sColor.slice(i, i + 2)}`)) } if (!str) { return sColorChange } return `rgb(${sColorChange[0]},${sColorChange[1]},${sColorChange[2]})` } if (/^(rgb|RGB)/.test(sColor)) { const arr = sColor.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',') return arr.map((val) => Number(val)) } return sColor } // 将rgb表示方式转换为hex表示方式 function rgbToHex(rgb) { const _this = rgb const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/ if (/^(rgb|RGB)/.test(_this)) { const aColor = _this.replace(/(?:\(|\)|rgb|RGB)*/g, '').split(',') let strHex = '#' for (let i = 0; i < aColor.length; i++) { let hex = Number(aColor[i]).toString(16) hex = String(hex).length == 1 ? `${0}${hex}` : hex // 保证每个rgb的值为2位 if (hex === '0') { hex += hex } strHex += hex } if (strHex.length !== 7) { strHex = _this } return strHex } if (reg.test(_this)) { const aNum = _this.replace(/#/, '').split('') if (aNum.length === 6) { return _this } if (aNum.length === 3) { let numHex = '#' for (let i = 0; i < aNum.length; i += 1) { numHex += (aNum[i] + aNum[i]) } return numHex } } else { return _this } } /** * JS颜色十六进制转换为rgb或rgba,返回的格式为 rgba(255,255,255,0.5)字符串 * sHex为传入的十六进制的色值 * alpha为rgba的透明度 */ function colorToRgba(color, alpha) { color = rgbToHex(color) // 十六进制颜色值的正则表达式 const reg = /^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/ /* 16进制颜色转为RGB格式 */ let sColor = String(color).toLowerCase() if (sColor && reg.test(sColor)) { if (sColor.length === 4) { let sColorNew = '#' for (let i = 1; i < 4; i += 1) { sColorNew += sColor.slice(i, i + 1).concat(sColor.slice(i, i + 1)) } sColor = sColorNew } // 处理六位的颜色值 const sColorChange = [] for (let i = 1; i < 7; i += 2) { sColorChange.push(parseInt(`0x${sColor.slice(i, i + 2)}`)) } // return sColorChange.join(',') return `rgba(${sColorChange.join(',')},${alpha})` } return sColor } export { colorGradient, hexToRgb, rgbToHex, colorToRgba }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/function/colorGradient.js
JavaScript
unknown
4,407
let timeout = null /** * 防抖原理:一定时间内,只有最后一次操作,再过wait毫秒后才执行函数 * * @param {Function} func 要执行的回调函数 * @param {Number} wait 延时的时间 * @param {Boolean} immediate 是否立即执行 * @return null */ function debounce(func, wait = 500, immediate = false) { // 清除定时器 if (timeout !== null) clearTimeout(timeout) // 立即执行,此类情况一般用不到 if (immediate) { const callNow = !timeout timeout = setTimeout(() => { timeout = null }, wait) if (callNow) typeof func === 'function' && func() } else { // 设置定时器,当最后一次操作后,timeout不会再被清除,所以在延时wait毫秒后执行func回调方法 timeout = setTimeout(() => { typeof func === 'function' && func() }, wait) } } export default debounce
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/function/debounce.js
JavaScript
unknown
940
let _boundaryCheckingState = true; // 是否进行越界检查的全局开关 /** * 把错误的数据转正 * @private * @example strip(0.09999999999999998)=0.1 */ function strip(num, precision = 15) { return +parseFloat(Number(num).toPrecision(precision)); } /** * Return digits length of a number * @private * @param {*number} num Input number */ function digitLength(num) { // Get digit length of e const eSplit = num.toString().split(/[eE]/); const len = (eSplit[0].split('.')[1] || '').length - +(eSplit[1] || 0); return len > 0 ? len : 0; } /** * 把小数转成整数,如果是小数则放大成整数 * @private * @param {*number} num 输入数 */ function float2Fixed(num) { if (num.toString().indexOf('e') === -1) { return Number(num.toString().replace('.', '')); } const dLen = digitLength(num); return dLen > 0 ? strip(Number(num) * Math.pow(10, dLen)) : Number(num); } /** * 检测数字是否越界,如果越界给出提示 * @private * @param {*number} num 输入数 */ function checkBoundary(num) { if (_boundaryCheckingState) { if (num > Number.MAX_SAFE_INTEGER || num < Number.MIN_SAFE_INTEGER) { console.warn(`${num} 超出了精度限制,结果可能不正确`); } } } /** * 把递归操作扁平迭代化 * @param {number[]} arr 要操作的数字数组 * @param {function} operation 迭代操作 * @private */ function iteratorOperation(arr, operation) { const [num1, num2, ...others] = arr; let res = operation(num1, num2); others.forEach((num) => { res = operation(res, num); }); return res; } /** * 高精度乘法 * @export */ export function times(...nums) { if (nums.length > 2) { return iteratorOperation(nums, times); } const [num1, num2] = nums; const num1Changed = float2Fixed(num1); const num2Changed = float2Fixed(num2); const baseNum = digitLength(num1) + digitLength(num2); const leftValue = num1Changed * num2Changed; checkBoundary(leftValue); return leftValue / Math.pow(10, baseNum); } /** * 高精度加法 * @export */ export function plus(...nums) { if (nums.length > 2) { return iteratorOperation(nums, plus); } const [num1, num2] = nums; // 取最大的小数位 const baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2))); // 把小数都转为整数然后再计算 return (times(num1, baseNum) + times(num2, baseNum)) / baseNum; } /** * 高精度减法 * @export */ export function minus(...nums) { if (nums.length > 2) { return iteratorOperation(nums, minus); } const [num1, num2] = nums; const baseNum = Math.pow(10, Math.max(digitLength(num1), digitLength(num2))); return (times(num1, baseNum) - times(num2, baseNum)) / baseNum; } /** * 高精度除法 * @export */ export function divide(...nums) { if (nums.length > 2) { return iteratorOperation(nums, divide); } const [num1, num2] = nums; const num1Changed = float2Fixed(num1); const num2Changed = float2Fixed(num2); checkBoundary(num1Changed); checkBoundary(num2Changed); // 重要,这里必须用strip进行修正 return times(num1Changed / num2Changed, strip(Math.pow(10, digitLength(num2) - digitLength(num1)))); } /** * 四舍五入 * @export */ export function round(num, ratio) { const base = Math.pow(10, ratio); let result = divide(Math.round(Math.abs(times(num, base))), base); if (num < 0 && result !== 0) { result = times(result, -1); } // 位数不足则补0 return result; } /** * 是否进行边界检查,默认开启 * @param flag 标记开关,true 为开启,false 为关闭,默认为 true * @export */ export function enableBoundaryChecking(flag = true) { _boundaryCheckingState = flag; } export default { times, plus, minus, divide, round, enableBoundaryChecking, };
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/function/digit.js
JavaScript
unknown
3,841
import { number, empty } from './test.js' import { round } from './digit.js' /** * @description 如果value小于min,取min;如果value大于max,取max * @param {number} min * @param {number} max * @param {number} value */ function range(min = 0, max = 0, value = 0) { return Math.max(min, Math.min(max, Number(value))) } /** * @description 用于获取用户传递值的px值 如果用户传递了"xxpx"或者"xxrpx",取出其数值部分,如果是"xxxrpx"还需要用过uni.upx2px进行转换 * @param {number|string} value 用户传递值的px值 * @param {boolean} unit * @returns {number|string} */ function getPx(value, unit = false) { if (number(value)) { return unit ? `${value}px` : Number(value) } // 如果带有rpx,先取出其数值部分,再转为px值 if (/(rpx|upx)$/.test(value)) { return unit ? `${uni.upx2px(parseInt(value))}px` : Number(uni.upx2px(parseInt(value))) } return unit ? `${parseInt(value)}px` : parseInt(value) } /** * @description 进行延时,以达到可以简写代码的目的 比如: await uni.$uv.sleep(20)将会阻塞20ms * @param {number} value 堵塞时间 单位ms 毫秒 * @returns {Promise} 返回promise */ function sleep(value = 30) { return new Promise((resolve) => { setTimeout(() => { resolve() }, value) }) } /** * @description 运行期判断平台 * @returns {string} 返回所在平台(小写) * @link 运行期判断平台 https://uniapp.dcloud.io/frame?id=判断平台 */ function os() { return uni.getSystemInfoSync().platform.toLowerCase() } /** * @description 获取系统信息同步接口 * @link 获取系统信息同步接口 https://uniapp.dcloud.io/api/system/info?id=getsysteminfosync */ function sys() { return uni.getSystemInfoSync() } /** * @description 取一个区间数 * @param {Number} min 最小值 * @param {Number} max 最大值 */ function random(min, max) { if (min >= 0 && max > 0 && max >= min) { const gab = max - min + 1 return Math.floor(Math.random() * gab + min) } return 0 } /** * @param {Number} len uuid的长度 * @param {Boolean} firstU 将返回的首字母置为"u" * @param {Nubmer} radix 生成uuid的基数(意味着返回的字符串都是这个基数),2-二进制,8-八进制,10-十进制,16-十六进制 */ function guid(len = 32, firstU = true, radix = null) { const chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('') const uuid = [] radix = radix || chars.length if (len) { // 如果指定uuid长度,只是取随机的字符,0|x为位运算,能去掉x的小数位,返回整数位 for (let i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix] } else { let r // rfc4122标准要求返回的uuid中,某些位为固定的字符 uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-' uuid[14] = '4' for (let i = 0; i < 36; i++) { if (!uuid[i]) { r = 0 | Math.random() * 16 uuid[i] = chars[(i == 19) ? (r & 0x3) | 0x8 : r] } } } // 移除第一个字符,并用u替代,因为第一个字符为数值时,该guuid不能用作id或者class if (firstU) { uuid.shift() return `u${uuid.join('')}` } return uuid.join('') } /** * @description 获取父组件的参数,因为支付宝小程序不支持provide/inject的写法 this.$parent在非H5中,可以准确获取到父组件,但是在H5中,需要多次this.$parent.$parent.xxx 这里默认值等于undefined有它的含义,因为最顶层元素(组件)的$parent就是undefined,意味着不传name 值(默认为undefined),就是查找最顶层的$parent * @param {string|undefined} name 父组件的参数名 */ function $parent(name = undefined) { let parent = this.$parent // 通过while历遍,这里主要是为了H5需要多层解析的问题 while (parent) { // 父组件 if (parent.$options && parent.$options.name !== name) { // 如果组件的name不相等,继续上一级寻找 parent = parent.$parent } else { return parent } } return false } /** * @description 样式转换 * 对象转字符串,或者字符串转对象 * @param {object | string} customStyle 需要转换的目标 * @param {String} target 转换的目的,object-转为对象,string-转为字符串 * @returns {object|string} */ function addStyle(customStyle, target = 'object') { // 字符串转字符串,对象转对象情形,直接返回 if (empty(customStyle) || typeof(customStyle) === 'object' && target === 'object' || target === 'string' && typeof(customStyle) === 'string') { return customStyle } // 字符串转对象 if (target === 'object') { // 去除字符串样式中的两端空格(中间的空格不能去掉,比如padding: 20px 0如果去掉了就错了),空格是无用的 customStyle = trim(customStyle) // 根据";"将字符串转为数组形式 const styleArray = customStyle.split(';') const style = {} // 历遍数组,拼接成对象 for (let i = 0; i < styleArray.length; i++) { // 'font-size:20px;color:red;',如此最后字符串有";"的话,会导致styleArray最后一个元素为空字符串,这里需要过滤 if (styleArray[i]) { const item = styleArray[i].split(':') style[trim(item[0])] = trim(item[1]) } } return style } // 这里为对象转字符串形式 let string = '' for (const i in customStyle) { // 驼峰转为中划线的形式,否则css内联样式,无法识别驼峰样式属性名 const key = i.replace(/([A-Z])/g, '-$1').toLowerCase() string += `${key}:${customStyle[i]};` } // 去除两端空格 return trim(string) } /** * @description 添加单位,如果有rpx,upx,%,px等单位结尾或者值为auto,直接返回,否则加上px单位结尾 * @param {string|number} value 需要添加单位的值 * @param {string} unit 添加的单位名 比如px */ function addUnit(value = 'auto', unit = uni?.$uv?.config?.unit ? uni?.$uv?.config?.unit : 'px') { value = String(value) // 用uvui内置验证规则中的number判断是否为数值 return number(value) ? `${value}${unit}` : value } /** * @description 深度克隆 * @param {object} obj 需要深度克隆的对象 * @param cache 缓存 * @returns {*} 克隆后的对象或者原值(不是对象) */ function deepClone(obj, cache = new WeakMap()) { if (obj === null || typeof obj !== 'object') return obj; if (cache.has(obj)) return cache.get(obj); let clone; if (obj instanceof Date) { clone = new Date(obj.getTime()); } else if (obj instanceof RegExp) { clone = new RegExp(obj); } else if (obj instanceof Map) { clone = new Map(Array.from(obj, ([key, value]) => [key, deepClone(value, cache)])); } else if (obj instanceof Set) { clone = new Set(Array.from(obj, value => deepClone(value, cache))); } else if (Array.isArray(obj)) { clone = obj.map(value => deepClone(value, cache)); } else if (Object.prototype.toString.call(obj) === '[object Object]') { clone = Object.create(Object.getPrototypeOf(obj)); cache.set(obj, clone); for (const [key, value] of Object.entries(obj)) { clone[key] = deepClone(value, cache); } } else { clone = Object.assign({}, obj); } cache.set(obj, clone); return clone; } /** * @description JS对象深度合并 * @param {object} target 需要拷贝的对象 * @param {object} source 拷贝的来源对象 * @returns {object|boolean} 深度合并后的对象或者false(入参有不是对象) */ function deepMerge(target = {}, source = {}) { target = deepClone(target) if (typeof target !== 'object' || target === null || typeof source !== 'object' || source === null) return target; const merged = Array.isArray(target) ? target.slice() : Object.assign({}, target); for (const prop in source) { if (!source.hasOwnProperty(prop)) continue; const sourceValue = source[prop]; const targetValue = merged[prop]; if (sourceValue instanceof Date) { merged[prop] = new Date(sourceValue); } else if (sourceValue instanceof RegExp) { merged[prop] = new RegExp(sourceValue); } else if (sourceValue instanceof Map) { merged[prop] = new Map(sourceValue); } else if (sourceValue instanceof Set) { merged[prop] = new Set(sourceValue); } else if (typeof sourceValue === 'object' && sourceValue !== null) { merged[prop] = deepMerge(targetValue, sourceValue); } else { merged[prop] = sourceValue; } } return merged; } /** * @description error提示 * @param {*} err 错误内容 */ function error(err) { // 开发环境才提示,生产环境不会提示 if (process.env.NODE_ENV === 'development') { console.error(`uvui提示:${err}`) } } /** * @description 打乱数组 * @param {array} array 需要打乱的数组 * @returns {array} 打乱后的数组 */ function randomArray(array = []) { // 原理是sort排序,Math.random()产生0<= x < 1之间的数,会导致x-0.05大于或者小于0 return array.sort(() => Math.random() - 0.5) } // padStart 的 polyfill,因为某些机型或情况,还无法支持es7的padStart,比如电脑版的微信小程序 // 所以这里做一个兼容polyfill的兼容处理 if (!String.prototype.padStart) { // 为了方便表示这里 fillString 用了ES6 的默认参数,不影响理解 String.prototype.padStart = function(maxLength, fillString = ' ') { if (Object.prototype.toString.call(fillString) !== '[object String]') { throw new TypeError( 'fillString must be String' ) } const str = this // 返回 String(str) 这里是为了使返回的值是字符串字面量,在控制台中更符合直觉 if (str.length >= maxLength) return String(str) const fillLength = maxLength - str.length let times = Math.ceil(fillLength / fillString.length) while (times >>= 1) { fillString += fillString if (times === 1) { fillString += fillString } } return fillString.slice(0, fillLength) + str } } /** * @description 格式化时间 * @param {String|Number} dateTime 需要格式化的时间戳 * @param {String} fmt 格式化规则 yyyy:mm:dd|yyyy:mm|yyyy年mm月dd日|yyyy年mm月dd日 hh时MM分等,可自定义组合 默认yyyy-mm-dd * @returns {string} 返回格式化后的字符串 */ function timeFormat(dateTime = null, formatStr = 'yyyy-mm-dd') { let date // 若传入时间为假值,则取当前时间 if (!dateTime) { date = new Date() } // 若为unix秒时间戳,则转为毫秒时间戳(逻辑有点奇怪,但不敢改,以保证历史兼容) else if (/^\d{10}$/.test(dateTime?.toString().trim())) { date = new Date(dateTime * 1000) } // 若用户传入字符串格式时间戳,new Date无法解析,需做兼容 else if (typeof dateTime === 'string' && /^\d+$/.test(dateTime.trim())) { date = new Date(Number(dateTime)) } // 处理平台性差异,在Safari/Webkit中,new Date仅支持/作为分割符的字符串时间 // 处理 '2022-07-10 01:02:03',跳过 '2022-07-10T01:02:03' else if (typeof dateTime === 'string' && dateTime.includes('-') && !dateTime.includes('T')) { date = new Date(dateTime.replace(/-/g, '/')) } // 其他都认为符合 RFC 2822 规范 else { date = new Date(dateTime) } const timeSource = { 'y': date.getFullYear().toString(), // 年 'm': (date.getMonth() + 1).toString().padStart(2, '0'), // 月 'd': date.getDate().toString().padStart(2, '0'), // 日 'h': date.getHours().toString().padStart(2, '0'), // 时 'M': date.getMinutes().toString().padStart(2, '0'), // 分 's': date.getSeconds().toString().padStart(2, '0') // 秒 // 有其他格式化字符需求可以继续添加,必须转化成字符串 } for (const key in timeSource) { const [ret] = new RegExp(`${key}+`).exec(formatStr) || [] if (ret) { // 年可能只需展示两位 const beginIndex = key === 'y' && ret.length === 2 ? 2 : 0 formatStr = formatStr.replace(ret, timeSource[key].slice(beginIndex)) } } return formatStr } /** * @description 时间戳转为多久之前 * @param {String|Number} timestamp 时间戳 * @param {String|Boolean} format * 格式化规则如果为时间格式字符串,超出一定时间范围,返回固定的时间格式; * 如果为布尔值false,无论什么时间,都返回多久以前的格式 * @returns {string} 转化后的内容 */ function timeFrom(timestamp = null, format = 'yyyy-mm-dd') { if (timestamp == null) timestamp = Number(new Date()) timestamp = parseInt(timestamp) // 判断用户输入的时间戳是秒还是毫秒,一般前端js获取的时间戳是毫秒(13位),后端传过来的为秒(10位) if (timestamp.toString().length == 10) timestamp *= 1000 let timer = (new Date()).getTime() - timestamp timer = parseInt(timer / 1000) // 如果小于5分钟,则返回"刚刚",其他以此类推 let tips = '' switch (true) { case timer < 300: tips = '刚刚' break case timer >= 300 && timer < 3600: tips = `${parseInt(timer / 60)}分钟前` break case timer >= 3600 && timer < 86400: tips = `${parseInt(timer / 3600)}小时前` break case timer >= 86400 && timer < 2592000: tips = `${parseInt(timer / 86400)}天前` break default: // 如果format为false,则无论什么时间戳,都显示xx之前 if (format === false) { if (timer >= 2592000 && timer < 365 * 86400) { tips = `${parseInt(timer / (86400 * 30))}个月前` } else { tips = `${parseInt(timer / (86400 * 365))}年前` } } else { tips = timeFormat(timestamp, format) } } return tips } /** * @description 去除空格 * @param String str 需要去除空格的字符串 * @param String pos both(左右)|left|right|all 默认both */ function trim(str, pos = 'both') { str = String(str) if (pos == 'both') { return str.replace(/^\s+|\s+$/g, '') } if (pos == 'left') { return str.replace(/^\s*/, '') } if (pos == 'right') { return str.replace(/(\s*$)/g, '') } if (pos == 'all') { return str.replace(/\s+/g, '') } return str } /** * @description 对象转url参数 * @param {object} data,对象 * @param {Boolean} isPrefix,是否自动加上"?" * @param {string} arrayFormat 规则 indices|brackets|repeat|comma */ function queryParams(data = {}, isPrefix = true, arrayFormat = 'brackets') { const prefix = isPrefix ? '?' : '' const _result = [] if (['indices', 'brackets', 'repeat', 'comma'].indexOf(arrayFormat) == -1) arrayFormat = 'brackets' for (const key in data) { const value = data[key] // 去掉为空的参数 if (['', undefined, null].indexOf(value) >= 0) { continue } // 如果值为数组,另行处理 if (value.constructor === Array) { // e.g. {ids: [1, 2, 3]} switch (arrayFormat) { case 'indices': // 结果: ids[0]=1&ids[1]=2&ids[2]=3 for (let i = 0; i < value.length; i++) { _result.push(`${key}[${i}]=${value[i]}`) } break case 'brackets': // 结果: ids[]=1&ids[]=2&ids[]=3 value.forEach((_value) => { _result.push(`${key}[]=${_value}`) }) break case 'repeat': // 结果: ids=1&ids=2&ids=3 value.forEach((_value) => { _result.push(`${key}=${_value}`) }) break case 'comma': // 结果: ids=1,2,3 let commaStr = '' value.forEach((_value) => { commaStr += (commaStr ? ',' : '') + _value }) _result.push(`${key}=${commaStr}`) break default: value.forEach((_value) => { _result.push(`${key}[]=${_value}`) }) } } else { _result.push(`${key}=${value}`) } } return _result.length ? prefix + _result.join('&') : '' } /** * 显示消息提示框 * @param {String} title 提示的内容,长度与 icon 取值有关。 * @param {Number} duration 提示的延迟时间,单位毫秒,默认:2000 */ function toast(title, duration = 2000) { uni.showToast({ title: String(title), icon: 'none', duration }) } /** * @description 根据主题type值,获取对应的图标 * @param {String} type 主题名称,primary|info|error|warning|success * @param {boolean} fill 是否使用fill填充实体的图标 */ function type2icon(type = 'success', fill = false) { // 如果非预置值,默认为success if (['primary', 'info', 'error', 'warning', 'success'].indexOf(type) == -1) type = 'success' let iconName = '' // 目前(2019-12-12),info和primary使用同一个图标 switch (type) { case 'primary': iconName = 'info-circle' break case 'info': iconName = 'info-circle' break case 'error': iconName = 'close-circle' break case 'warning': iconName = 'error-circle' break case 'success': iconName = 'checkmark-circle' break default: iconName = 'checkmark-circle' } // 是否是实体类型,加上-fill,在icon组件库中,实体的类名是后面加-fill的 if (fill) iconName += '-fill' return iconName } /** * @description 数字格式化 * @param {number|string} number 要格式化的数字 * @param {number} decimals 保留几位小数 * @param {string} decimalPoint 小数点符号 * @param {string} thousandsSeparator 千分位符号 * @returns {string} 格式化后的数字 */ function priceFormat(number, decimals = 0, decimalPoint = '.', thousandsSeparator = ',') { number = (`${number}`).replace(/[^0-9+-Ee.]/g, '') const n = !isFinite(+number) ? 0 : +number const prec = !isFinite(+decimals) ? 0 : Math.abs(decimals) const sep = (typeof thousandsSeparator === 'undefined') ? ',' : thousandsSeparator const dec = (typeof decimalPoint === 'undefined') ? '.' : decimalPoint let s = '' s = (prec ? round(n, prec) + '' : `${Math.round(n)}`).split('.') const re = /(-?\d+)(\d{3})/ while (re.test(s[0])) { s[0] = s[0].replace(re, `$1${sep}$2`) } if ((s[1] || '').length < prec) { s[1] = s[1] || '' s[1] += new Array(prec - s[1].length + 1).join('0') } return s.join(dec) } /** * @description 获取duration值 * 如果带有ms或者s直接返回,如果大于一定值,认为是ms单位,小于一定值,认为是s单位 * 比如以30位阈值,那么300大于30,可以理解为用户想要的是300ms,而不是想花300s去执行一个动画 * @param {String|number} value 比如: "1s"|"100ms"|1|100 * @param {boolean} unit 提示: 如果是false 默认返回number * @return {string|number} */ function getDuration(value, unit = true) { const valueNum = parseInt(value) if (unit) { if (/s$/.test(value)) return value return value > 30 ? `${value}ms` : `${value}s` } if (/ms$/.test(value)) return valueNum if (/s$/.test(value)) return valueNum > 30 ? valueNum : valueNum * 1000 return valueNum } /** * @description 日期的月或日补零操作 * @param {String} value 需要补零的值 */ function padZero(value) { return `00${value}`.slice(-2) } /** * @description 在uv-form的子组件内容发生变化,或者失去焦点时,尝试通知uv-form执行校验方法 * @param {*} instance * @param {*} event */ function formValidate(instance, event) { const formItem = $parent.call(instance, 'uv-form-item') const form = $parent.call(instance, 'uv-form') // 如果发生变化的input或者textarea等,其父组件中有uv-form-item或者uv-form等,就执行form的validate方法 // 同时将form-item的pros传递给form,让其进行精确对象验证 if (formItem && form) { form.validateField(formItem.prop, () => {}, event) } } /** * @description 获取某个对象下的属性,用于通过类似'a.b.c'的形式去获取一个对象的的属性的形式 * @param {object} obj 对象 * @param {string} key 需要获取的属性字段 * @returns {*} */ function getProperty(obj, key) { if (!obj) { return } if (typeof key !== 'string' || key === '') { return '' } if (key.indexOf('.') !== -1) { const keys = key.split('.') let firstObj = obj[keys[0]] || {} for (let i = 1; i < keys.length; i++) { if (firstObj) { firstObj = firstObj[keys[i]] } } return firstObj } return obj[key] } /** * @description 设置对象的属性值,如果'a.b.c'的形式进行设置 * @param {object} obj 对象 * @param {string} key 需要设置的属性 * @param {string} value 设置的值 */ function setProperty(obj, key, value) { if (!obj) { return } // 递归赋值 const inFn = function(_obj, keys, v) { // 最后一个属性key if (keys.length === 1) { _obj[keys[0]] = v return } // 0~length-1个key while (keys.length > 1) { const k = keys[0] if (!_obj[k] || (typeof _obj[k] !== 'object')) { _obj[k] = {} } const key = keys.shift() // 自调用判断是否存在属性,不存在则自动创建对象 inFn(_obj[k], keys, v) } } if (typeof key !== 'string' || key === '') { } else if (key.indexOf('.') !== -1) { // 支持多层级赋值操作 const keys = key.split('.') inFn(obj, keys, value) } else { obj[key] = value } } /** * @description 获取当前页面路径 */ function page() { const pages = getCurrentPages(); const route = pages[pages.length - 1]?.route; // 某些特殊情况下(比如页面进行redirectTo时的一些时机),pages可能为空数组 return `/${route ? route : ''}` } /** * @description 获取当前路由栈实例数组 */ function pages() { const pages = getCurrentPages() return pages } /** * 获取页面历史栈指定层实例 * @param back {number} [0] - 0或者负数,表示获取历史栈的哪一层,0表示获取当前页面实例,-1 表示获取上一个页面实例。默认0。 */ function getHistoryPage(back = 0) { const pages = getCurrentPages() const len = pages.length return pages[len - 1 + back] } /** * @description 修改uvui内置属性值 * @param {object} props 修改内置props属性 * @param {object} config 修改内置config属性 * @param {object} color 修改内置color属性 * @param {object} zIndex 修改内置zIndex属性 */ function setConfig({ props = {}, config = {}, color = {}, zIndex = {} }) { const { deepMerge, } = uni.$uv uni.$uv.config = deepMerge(uni.$uv.config, config) uni.$uv.props = deepMerge(uni.$uv.props, props) uni.$uv.color = deepMerge(uni.$uv.color, color) uni.$uv.zIndex = deepMerge(uni.$uv.zIndex, zIndex) } export { range, getPx, sleep, os, sys, random, guid, $parent, addStyle, addUnit, deepClone, deepMerge, error, randomArray, timeFormat, timeFrom, trim, queryParams, toast, type2icon, priceFormat, getDuration, padZero, formValidate, getProperty, setProperty, page, pages, getHistoryPage, setConfig }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/function/index.js
JavaScript
unknown
22,441
/** * 注意: * 此部分内容,在vue-cli模式下,需要在vue.config.js加入如下内容才有效: * module.exports = { * transpileDependencies: ['uview-v2'] * } */ let platform = 'none' // #ifdef VUE3 platform = 'vue3' // #endif // #ifdef VUE2 platform = 'vue2' // #endif // #ifdef APP-PLUS platform = 'plus' // #endif // #ifdef APP-NVUE platform = 'nvue' // #endif // #ifdef H5 platform = 'h5' // #endif // #ifdef MP-WEIXIN platform = 'weixin' // #endif // #ifdef MP-ALIPAY platform = 'alipay' // #endif // #ifdef MP-BAIDU platform = 'baidu' // #endif // #ifdef MP-TOUTIAO platform = 'toutiao' // #endif // #ifdef MP-QQ platform = 'qq' // #endif // #ifdef MP-KUAISHOU platform = 'kuaishou' // #endif // #ifdef MP-360 platform = '360' // #endif // #ifdef MP platform = 'mp' // #endif // #ifdef QUICKAPP-WEBVIEW platform = 'quickapp-webview' // #endif // #ifdef QUICKAPP-WEBVIEW-HUAWEI platform = 'quickapp-webview-huawei' // #endif // #ifdef QUICKAPP-WEBVIEW-UNION platform = 'quckapp-webview-union' // #endif export default platform
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/function/platform.js
JavaScript
unknown
1,075
/** * 验证电子邮箱格式 */ function email(value) { return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value) } /** * 验证手机格式 */ function mobile(value) { return /^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(value) } /** * 验证URL格式 */ function url(value) { return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/ .test(value) } /** * 验证日期格式 */ function date(value) { if (!value) return false // 判断是否数值或者字符串数值(意味着为时间戳),转为数值,否则new Date无法识别字符串时间戳 if (number(value)) value = +value return !/Invalid|NaN/.test(new Date(value).toString()) } /** * 验证ISO类型的日期格式 */ function dateISO(value) { return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value) } /** * 验证十进制数字 */ function number(value) { return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(value) } /** * 验证字符串 */ function string(value) { return typeof value === 'string' } /** * 验证整数 */ function digits(value) { return /^\d+$/.test(value) } /** * 验证身份证号码 */ function idCard(value) { return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test( value ) } /** * 是否车牌号 */ function carNo(value) { // 新能源车牌 const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/ // 旧车牌 const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/ if (value.length === 7) { return creg.test(value) } if (value.length === 8) { return xreg.test(value) } return false } /** * 金额,只允许2位小数 */ function amount(value) { // 金额,只允许保留两位小数 return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value) } /** * 中文 */ function chinese(value) { const reg = /^[\u4e00-\u9fa5]+$/gi return reg.test(value) } /** * 只能输入字母 */ function letter(value) { return /^[a-zA-Z]*$/.test(value) } /** * 只能是字母或者数字 */ function enOrNum(value) { // 英文或者数字 const reg = /^[0-9a-zA-Z]*$/g return reg.test(value) } /** * 验证是否包含某个值 */ function contains(value, param) { return value.indexOf(param) >= 0 } /** * 验证一个值范围[min, max] */ function range(value, param) { return value >= param[0] && value <= param[1] } /** * 验证一个长度范围[min, max] */ function rangeLength(value, param) { return value.length >= param[0] && value.length <= param[1] } /** * 是否固定电话 */ function landline(value) { const reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/ return reg.test(value) } /** * 判断是否为空 */ function empty(value) { switch (typeof value) { case 'undefined': return true case 'string': if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true break case 'boolean': if (!value) return true break case 'number': if (value === 0 || isNaN(value)) return true break case 'object': if (value === null || value.length === 0) return true for (const i in value) { return false } return true } return false } /** * 是否json字符串 */ function jsonString(value) { if (typeof value === 'string') { try { const obj = JSON.parse(value) if (typeof obj === 'object' && obj) { return true } return false } catch (e) { return false } } return false } /** * 是否数组 */ function array(value) { if (typeof Array.isArray === 'function') { return Array.isArray(value) } return Object.prototype.toString.call(value) === '[object Array]' } /** * 是否对象 */ function object(value) { return Object.prototype.toString.call(value) === '[object Object]' } /** * 是否短信验证码 */ function code(value, len = 6) { return new RegExp(`^\\d{${len}}$`).test(value) } /** * 是否函数方法 * @param {Object} value */ function func(value) { return typeof value === 'function' } /** * 是否promise对象 * @param {Object} value */ function promise(value) { return object(value) && func(value.then) && func(value.catch) } /** 是否图片格式 * @param {Object} value */ function image(value) { const newValue = value.split('?')[0] const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i return IMAGE_REGEXP.test(newValue) } /** * 是否视频格式 * @param {Object} value */ function video(value) { const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i return VIDEO_REGEXP.test(value) } /** * 是否为正则对象 * @param {Object} * @return {Boolean} */ function regExp(o) { return o && Object.prototype.toString.call(o) === '[object RegExp]' } export { email, mobile, url, date, dateISO, number, digits, idCard, carNo, amount, chinese, letter, enOrNum, contains, range, rangeLength, empty, jsonString, landline, object, array, code, func, promise, video, image, regExp, string }
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/function/test.js
JavaScript
unknown
5,882
let timer; let flag /** * 节流原理:在一定时间内,只能触发一次 * * @param {Function} func 要执行的回调函数 * @param {Number} wait 延时的时间 * @param {Boolean} immediate 是否立即执行 * @return null */ function throttle(func, wait = 500, immediate = true) { if (immediate) { if (!flag) { flag = true // 如果是立即执行,则在wait毫秒内开始时执行 typeof func === 'function' && func() timer = setTimeout(() => { flag = false }, wait) } } else if (!flag) { flag = true // 如果是非立即执行,则在wait毫秒内的结束处执行 timer = setTimeout(() => { flag = false typeof func === 'function' && func() }, wait) } } export default throttle
2301_77169380/AppruanjianApk
uni_modules/uv-ui-tools/libs/function/throttle.js
JavaScript
unknown
871