这一版本优化了很多
This commit is contained in:
173
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.js
vendored
Normal file
173
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.js
vendored
Normal file
@@ -0,0 +1,173 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
if (!Math) {
|
||||
wdIcon();
|
||||
}
|
||||
const wdIcon = () => "../wd-icon/wd-icon.js";
|
||||
const __default__ = {
|
||||
name: "wd-button",
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
virtualHost: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
};
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: common_vendor.buttonProps,
|
||||
emits: [
|
||||
"click",
|
||||
"getuserinfo",
|
||||
"contact",
|
||||
"getphonenumber",
|
||||
"getrealtimephonenumber",
|
||||
"error",
|
||||
"launchapp",
|
||||
"opensetting",
|
||||
"chooseavatar",
|
||||
"agreeprivacyauthorization"
|
||||
],
|
||||
setup(__props, { emit: __emit }) {
|
||||
const loadingIcon = (color = "#4D80F0", reverse = true) => {
|
||||
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 42 42"><defs><linearGradient x1="100%" y1="0%" x2="0%" y2="0%" id="a"><stop stop-color="${reverse ? color : "#fff"}" offset="0%" stop-opacity="0"/><stop stop-color="${reverse ? color : "#fff"}" offset="100%"/></linearGradient></defs><g fill="none" fill-rule="evenodd"><path d="M21 1c11.046 0 20 8.954 20 20s-8.954 20-20 20S1 32.046 1 21 9.954 1 21 1zm0 7C13.82 8 8 13.82 8 21s5.82 13 13 13 13-5.82 13-13S28.18 8 21 8z" fill="${reverse ? "#fff" : color}"/><path d="M4.599 21c0 9.044 7.332 16.376 16.376 16.376 9.045 0 16.376-7.332 16.376-16.376" stroke="url(#a)" stroke-width="3.5" stroke-linecap="round"/></g></svg>`;
|
||||
};
|
||||
const props = __props;
|
||||
const emit = __emit;
|
||||
const hoverStartTime = common_vendor.ref(20);
|
||||
const hoverStayTime = common_vendor.ref(70);
|
||||
const loadingIconSvg = common_vendor.ref("");
|
||||
const loadingStyle = common_vendor.computed(() => {
|
||||
return `background-image: url(${loadingIconSvg.value});`;
|
||||
});
|
||||
const openTypeValue = common_vendor.computed(() => {
|
||||
return props.disabled || props.loading ? void 0 : props.openType;
|
||||
});
|
||||
common_vendor.watch(
|
||||
() => props.loading,
|
||||
() => {
|
||||
buildLoadingSvg();
|
||||
},
|
||||
{ deep: true, immediate: true }
|
||||
);
|
||||
function handleClick(event) {
|
||||
if (!props.disabled && !props.loading) {
|
||||
emit("click", event);
|
||||
}
|
||||
}
|
||||
function handleGetAuthorize(event) {
|
||||
if (props.scope === "phoneNumber") {
|
||||
handleGetphonenumber(event);
|
||||
} else if (props.scope === "userInfo") {
|
||||
handleGetuserinfo(event);
|
||||
}
|
||||
}
|
||||
function handleGetuserinfo(event) {
|
||||
emit("getuserinfo", event.detail);
|
||||
}
|
||||
function handleConcat(event) {
|
||||
emit("contact", event.detail);
|
||||
}
|
||||
function handleGetphonenumber(event) {
|
||||
emit("getphonenumber", event.detail);
|
||||
}
|
||||
function handleGetrealtimephonenumber(event) {
|
||||
emit("getrealtimephonenumber", event.detail);
|
||||
}
|
||||
function handleError(event) {
|
||||
emit("error", event.detail);
|
||||
}
|
||||
function handleLaunchapp(event) {
|
||||
emit("launchapp", event.detail);
|
||||
}
|
||||
function handleOpensetting(event) {
|
||||
emit("opensetting", event.detail);
|
||||
}
|
||||
function handleChooseavatar(event) {
|
||||
emit("chooseavatar", event.detail);
|
||||
}
|
||||
function handleAgreePrivacyAuthorization(event) {
|
||||
emit("agreeprivacyauthorization", event.detail);
|
||||
}
|
||||
function buildLoadingSvg() {
|
||||
const { loadingColor, type, plain } = props;
|
||||
let color = loadingColor;
|
||||
if (!color) {
|
||||
switch (type) {
|
||||
case "primary":
|
||||
color = "#4D80F0";
|
||||
break;
|
||||
case "success":
|
||||
color = "#34d19d";
|
||||
break;
|
||||
case "info":
|
||||
color = "#333";
|
||||
break;
|
||||
case "warning":
|
||||
color = "#f0883a";
|
||||
break;
|
||||
case "error":
|
||||
color = "#fa4350";
|
||||
break;
|
||||
case "default":
|
||||
color = "#333";
|
||||
break;
|
||||
}
|
||||
}
|
||||
const svg = loadingIcon(color, !plain);
|
||||
loadingIconSvg.value = `"data:image/svg+xml;base64,${common_vendor.encode(svg)}"`;
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: _ctx.loading
|
||||
}, _ctx.loading ? {
|
||||
b: common_vendor.s(loadingStyle.value)
|
||||
} : _ctx.icon ? {
|
||||
d: common_vendor.p({
|
||||
["custom-class"]: "wd-button__icon",
|
||||
name: _ctx.icon,
|
||||
classPrefix: _ctx.classPrefix
|
||||
})
|
||||
} : {}, {
|
||||
c: _ctx.icon,
|
||||
e: common_vendor.gei(_ctx, _ctx.buttonId),
|
||||
f: `${_ctx.disabled || _ctx.loading ? "" : "wd-button--active"}`,
|
||||
g: common_vendor.s(_ctx.customStyle),
|
||||
h: common_vendor.n("is-" + _ctx.type),
|
||||
i: common_vendor.n("is-" + _ctx.size),
|
||||
j: common_vendor.n(_ctx.round ? "is-round" : ""),
|
||||
k: common_vendor.n(_ctx.hairline ? "is-hairline" : ""),
|
||||
l: common_vendor.n(_ctx.plain ? "is-plain" : ""),
|
||||
m: common_vendor.n(_ctx.disabled ? "is-disabled" : ""),
|
||||
n: common_vendor.n(_ctx.block ? "is-block" : ""),
|
||||
o: common_vendor.n(_ctx.loading ? "is-loading" : ""),
|
||||
p: common_vendor.n(_ctx.customClass),
|
||||
q: hoverStartTime.value,
|
||||
r: hoverStayTime.value,
|
||||
s: openTypeValue.value,
|
||||
t: _ctx.sendMessageTitle,
|
||||
v: _ctx.sendMessagePath,
|
||||
w: _ctx.sendMessageImg,
|
||||
x: _ctx.appParameter,
|
||||
y: _ctx.showMessageCard,
|
||||
z: _ctx.sessionFrom,
|
||||
A: _ctx.lang,
|
||||
B: _ctx.hoverStopPropagation,
|
||||
C: _ctx.scope,
|
||||
D: common_vendor.o(handleClick),
|
||||
E: common_vendor.o(handleGetAuthorize),
|
||||
F: common_vendor.o(handleGetuserinfo),
|
||||
G: common_vendor.o(handleConcat),
|
||||
H: common_vendor.o(handleGetphonenumber),
|
||||
I: common_vendor.o(handleGetrealtimephonenumber),
|
||||
J: common_vendor.o(handleError),
|
||||
K: common_vendor.o(handleLaunchapp),
|
||||
L: common_vendor.o(handleOpensetting),
|
||||
M: common_vendor.o(handleChooseavatar),
|
||||
N: common_vendor.o(handleAgreePrivacyAuthorization)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-aa3a6253"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.js.map
|
||||
6
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.json
vendored
Normal file
6
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wd-icon": "../wd-icon/wd-icon"
|
||||
}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<button id="{{e}}" hover-class="{{f}}" style="{{g + ';' + virtualHostStyle}}" class="{{['data-v-aa3a6253', 'wd-button', h, i, j, k, l, m, n, o, p, virtualHostClass]}}" hover-start-time="{{q}}" hover-stay-time="{{r}}" open-type="{{s}}" send-message-title="{{t}}" send-message-path="{{v}}" send-message-img="{{w}}" app-parameter="{{x}}" show-message-card="{{y}}" session-from="{{z}}" lang="{{A}}" hover-stop-propagation="{{B}}" scope="{{C}}" bindtap="{{D}}" bindgetAuthorize="{{E}}" bindgetuserinfo="{{F}}" bindcontact="{{G}}" bindgetphonenumber="{{H}}" bindgetrealtimephonenumber="{{I}}" binderror="{{J}}" bindlaunchapp="{{K}}" bindopensetting="{{L}}" bindchooseavatar="{{M}}" bindagreeprivacyauthorization="{{N}}" hidden="{{virtualHostHidden || false}}"><view class="wd-button__content data-v-aa3a6253"><view wx:if="{{a}}" class="wd-button__loading data-v-aa3a6253"><view class="wd-button__loading-svg data-v-aa3a6253" style="{{b}}"></view></view><wd-icon wx:elif="{{c}}" class="data-v-aa3a6253" virtualHostClass="data-v-aa3a6253" u-i="aa3a6253-0" bind:__l="__l" u-p="{{d}}"></wd-icon><view class="wd-button__text data-v-aa3a6253"><slot/></view></view></button>
|
||||
457
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.wxss
vendored
Normal file
457
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-button/wd-button.wxss
vendored
Normal file
@@ -0,0 +1,457 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* uni.scss */
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
/**
|
||||
* 混合宏
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/**
|
||||
* 辅助函数
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/* 转换成字符串 */
|
||||
/* 判断是否存在 Modifier */
|
||||
/* 判断是否存在伪类 */
|
||||
/**
|
||||
* 主题色切换
|
||||
* @params $theme-color 主题色
|
||||
* @params $type 变暗’dark‘ 变亮 'light'
|
||||
* @params $mix-color 自己设置的混色
|
||||
*/
|
||||
/**
|
||||
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
|
||||
* @params $open-linear 是否开启线性渐变色
|
||||
* @params $deg 渐变色角度
|
||||
* @params $theme-color 当前配色
|
||||
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
|
||||
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
|
||||
* @params [Array] $per-list 渐变色比例
|
||||
*/
|
||||
/**
|
||||
* BEM,定义块(b)
|
||||
*/
|
||||
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
|
||||
/* 此方法用于生成穿透样式 */
|
||||
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
|
||||
/* 定义状态(m) */
|
||||
/* 定义状态(m) */
|
||||
/* 对于需要需要嵌套在 m 底下的 e,调用这个混合宏,一般在切换整个组件的状态,如切换颜色的时候 */
|
||||
/* 状态,生成 is-$state 类名 */
|
||||
/**
|
||||
* 常用混合宏
|
||||
*/
|
||||
/* 单行超出隐藏 */
|
||||
/* 多行超出隐藏 */
|
||||
/* 清除浮动 */
|
||||
/* 0.5px 边框 指定方向*/
|
||||
/* 0.5px 边框 环绕 */
|
||||
/**
|
||||
* 三角形实现尖角样式,适用于背景透明情况
|
||||
* @param $size 三角形高,底边为 $size * 2
|
||||
* @param $bg 三角形背景颜色
|
||||
*/
|
||||
/**
|
||||
* 正方形实现尖角样式,适用于背景不透明情况
|
||||
* @param $size 正方形边长
|
||||
* @param $bg 正方形背景颜色
|
||||
* @param $z-index z-index属性值,不得大于外部包裹器
|
||||
* @param $box-shadow 阴影
|
||||
*/
|
||||
/**
|
||||
* 辅助函数
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/* 转换成字符串 */
|
||||
/* 判断是否存在 Modifier */
|
||||
/* 判断是否存在伪类 */
|
||||
/**
|
||||
* 主题色切换
|
||||
* @params $theme-color 主题色
|
||||
* @params $type 变暗’dark‘ 变亮 'light'
|
||||
* @params $mix-color 自己设置的混色
|
||||
*/
|
||||
/**
|
||||
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
|
||||
* @params $open-linear 是否开启线性渐变色
|
||||
* @params $deg 渐变色角度
|
||||
* @params $theme-color 当前配色
|
||||
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
|
||||
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
|
||||
* @params [Array] $per-list 渐变色比例
|
||||
*/
|
||||
/**
|
||||
* UI规范基础变量
|
||||
*/
|
||||
/*----------------------------------------- Theme color. start ----------------------------------------*/
|
||||
/* 主题颜色 */
|
||||
/* 辅助色 */
|
||||
/* 文字颜色(默认浅色背景下 */
|
||||
/* 暗黑模式 */
|
||||
/* 图形颜色 */
|
||||
/*----------------------------------------- Theme color. end -------------------------------------------*/
|
||||
/*-------------------------------- Theme color application size. start --------------------------------*/
|
||||
/* 文字字号 */
|
||||
/* 文字字重 */
|
||||
/* 尺寸 */
|
||||
/*-------------------------------- Theme color application size. end --------------------------------*/
|
||||
/* component var */
|
||||
/* action-sheet */
|
||||
/* badge */
|
||||
/* button */
|
||||
/* cell */
|
||||
/* calendar */
|
||||
/* checkbox */
|
||||
/* collapse */
|
||||
/* divider */
|
||||
/* drop-menu */
|
||||
/* input-number */
|
||||
/* input */
|
||||
/* textarea */
|
||||
/* loadmore */
|
||||
/* message-box */
|
||||
/* notice-bar */
|
||||
/* pagination */
|
||||
/* picker */
|
||||
/* col-picker */
|
||||
/* overlay */
|
||||
/* popup */
|
||||
/* progress */
|
||||
/* radio */
|
||||
/* search */
|
||||
/* slider */
|
||||
/* sort-button */
|
||||
/* steps */
|
||||
/* switch */
|
||||
/* tabs */
|
||||
/* tag */
|
||||
/* toast */
|
||||
/* loading */
|
||||
/* tooltip */
|
||||
/* popover */
|
||||
/* grid-item */
|
||||
/* statustip */
|
||||
/* card */
|
||||
/* upload */
|
||||
/* curtain */
|
||||
/* notify */
|
||||
/* skeleton */
|
||||
/* circle */
|
||||
/* swiper */
|
||||
/* swiper-nav */
|
||||
/* segmented */
|
||||
/* tabbar */
|
||||
/* tabbar-item */
|
||||
/* navbar */
|
||||
/* navbar-capsule */
|
||||
/* table */
|
||||
/* sidebar */
|
||||
/* sidebar-item */
|
||||
/* fab */
|
||||
/* count-down */
|
||||
/* keyboard */
|
||||
/* number-keyboard */
|
||||
/* passwod-input */
|
||||
/* form-item */
|
||||
/* backtop */
|
||||
/* index-bar */
|
||||
/* text */
|
||||
/* video-preview */
|
||||
/* img-cropper */
|
||||
/* floating-panel */
|
||||
/* signature */
|
||||
/* tour */
|
||||
/* avatar */
|
||||
/* avatar-group */
|
||||
/* slide-verify */
|
||||
.wot-theme-dark .wd-button.is-info.data-v-aa3a6253 {
|
||||
background: var(--wot-dark-background4, #323233);
|
||||
color: var(--wot-dark-color3, rgba(232, 230, 227, 0.8));
|
||||
}
|
||||
.wot-theme-dark .wd-button.is-plain.data-v-aa3a6253 {
|
||||
background: transparent;
|
||||
}
|
||||
.wot-theme-dark .wd-button.is-plain.is-info.data-v-aa3a6253 {
|
||||
color: var(--wot-dark-color, var(--wot-color-white, white));
|
||||
}
|
||||
.wot-theme-dark .wd-button.is-plain.is-info.data-v-aa3a6253::after {
|
||||
border-color: var(--wot-dark-background5, #646566);
|
||||
}
|
||||
.wot-theme-dark .wd-button.is-text.is-disabled.data-v-aa3a6253 {
|
||||
color: var(--wot-dark-color-gray, var(--wot-color-secondary, #595959));
|
||||
background: transparent;
|
||||
}
|
||||
.wot-theme-dark .wd-button.is-icon.data-v-aa3a6253 {
|
||||
color: var(--wot-dark-color, var(--wot-color-white, white));
|
||||
}
|
||||
.wot-theme-dark .wd-button.is-icon.is-disabled.data-v-aa3a6253 {
|
||||
color: var(--wot-dark-color-gray, var(--wot-color-secondary, #595959));
|
||||
background: transparent;
|
||||
}
|
||||
.wd-button.data-v-aa3a6253 {
|
||||
margin-left: initial;
|
||||
margin-right: initial;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
outline: none;
|
||||
-webkit-appearance: none;
|
||||
background: transparent;
|
||||
box-sizing: border-box;
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
color: var(--wot-button-normal-color, var(--wot-color-title, var(--wot-color-black, black)));
|
||||
transition: opacity 0.2s;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
font-weight: normal;
|
||||
}
|
||||
.wd-button.data-v-aa3a6253::before {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: var(--wot-color-black, black);
|
||||
border: inherit;
|
||||
border-color: var(--wot-color-black, black);
|
||||
border-radius: inherit;
|
||||
transform: translate(-50%, -50%);
|
||||
opacity: 0;
|
||||
content: " ";
|
||||
}
|
||||
.wd-button.data-v-aa3a6253::after {
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
}
|
||||
.wd-button__content.data-v-aa3a6253 {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
.wd-button--active.data-v-aa3a6253:active::before {
|
||||
opacity: 0.15;
|
||||
}
|
||||
.wd-button.is-disabled.data-v-aa3a6253 {
|
||||
opacity: var(--wot-button-disabled-opacity, 0.6);
|
||||
}
|
||||
.wd-button__loading.data-v-aa3a6253 {
|
||||
margin-right: 5px;
|
||||
animation: wd-rotate-aa3a6253 0.8s linear infinite;
|
||||
animation-duration: 2s;
|
||||
}
|
||||
.wd-button__loading-svg.data-v-aa3a6253 {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-size: cover;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
.wd-button.is-primary.data-v-aa3a6253 {
|
||||
background: var(--wot-button-primary-bg-color, var(--wot-color-theme, #4d80f0));
|
||||
color: var(--wot-button-primary-color, var(--wot-color-white, white));
|
||||
}
|
||||
.wd-button.is-success.data-v-aa3a6253 {
|
||||
background: var(--wot-button-success-bg-color, var(--wot-color-success, #34d19d));
|
||||
color: var(--wot-button-success-color, var(--wot-color-white, white));
|
||||
}
|
||||
.wd-button.is-info.data-v-aa3a6253 {
|
||||
background: var(--wot-button-info-bg-color, #f0f0f0);
|
||||
color: var(--wot-button-info-color, var(--wot-color-title, var(--wot-color-black, black)));
|
||||
}
|
||||
.wd-button.is-warning.data-v-aa3a6253 {
|
||||
background: var(--wot-button-warning-bg-color, var(--wot-color-warning, #f0883a));
|
||||
color: var(--wot-button-warning-color, var(--wot-color-white, white));
|
||||
}
|
||||
.wd-button.is-error.data-v-aa3a6253 {
|
||||
background: var(--wot-button-error-bg-color, var(--wot-color-danger, #fa4350));
|
||||
color: var(--wot-button-error-color, var(--wot-color-white, white));
|
||||
}
|
||||
.wd-button.is-small.data-v-aa3a6253 {
|
||||
height: var(--wot-button-small-height, 28px);
|
||||
padding: var(--wot-button-small-padding, 0 12px);
|
||||
border-radius: var(--wot-button-small-radius, 2px);
|
||||
font-size: var(--wot-button-small-fs, var(--wot-fs-secondary, 12px));
|
||||
font-weight: normal;
|
||||
}
|
||||
.wd-button.is-small .wd-button__loading.data-v-aa3a6253 {
|
||||
width: var(--wot-button-small-loading, 14px);
|
||||
height: var(--wot-button-small-loading, 14px);
|
||||
}
|
||||
.wd-button.is-medium.data-v-aa3a6253 {
|
||||
height: var(--wot-button-medium-height, 36px);
|
||||
padding: var(--wot-button-medium-padding, 0 16px);
|
||||
border-radius: var(--wot-button-medium-radius, 4px);
|
||||
font-size: var(--wot-button-medium-fs, var(--wot-fs-content, 14px));
|
||||
min-width: 120px;
|
||||
}
|
||||
.wd-button.is-medium.is-round.is-icon.data-v-aa3a6253 {
|
||||
min-width: 0;
|
||||
border-radius: 50%;
|
||||
}
|
||||
.wd-button.is-medium.is-round.is-text.data-v-aa3a6253 {
|
||||
border-radius: 0;
|
||||
min-width: 0;
|
||||
}
|
||||
.wd-button.is-medium .wd-button__loading.data-v-aa3a6253 {
|
||||
width: var(--wot-button-medium-loading, 18px);
|
||||
height: var(--wot-button-medium-loading, 18px);
|
||||
}
|
||||
.wd-button.is-large.data-v-aa3a6253 {
|
||||
height: var(--wot-button-large-height, 44px);
|
||||
padding: var(--wot-button-large-padding, 0 36px);
|
||||
border-radius: var(--wot-button-large-radius, 8px);
|
||||
font-size: var(--wot-button-large-fs, var(--wot-fs-title, 16px));
|
||||
}
|
||||
.wd-button.is-large.data-v-aa3a6253::after {
|
||||
border-radius: var(--wot-button-large-radius, 8px);
|
||||
}
|
||||
.wd-button.is-large .wd-button__loading.data-v-aa3a6253 {
|
||||
width: var(--wot-button-large-loading, 24px);
|
||||
height: var(--wot-button-large-loading, 24px);
|
||||
}
|
||||
.wd-button.is-round.data-v-aa3a6253 {
|
||||
border-radius: 999px;
|
||||
}
|
||||
.wd-button.is-text.data-v-aa3a6253 {
|
||||
color: var(--wot-button-primary-bg-color, var(--wot-color-theme, #4d80f0));
|
||||
min-width: 0;
|
||||
padding: 4px 0;
|
||||
}
|
||||
.wd-button.is-text.data-v-aa3a6253::after {
|
||||
display: none;
|
||||
}
|
||||
.wd-button.is-text.wd-button--active.data-v-aa3a6253 {
|
||||
opacity: var(--wot-button-text-hover-opacity, 0.7);
|
||||
}
|
||||
.wd-button.is-text.wd-button--active.data-v-aa3a6253:active::before {
|
||||
display: none;
|
||||
}
|
||||
.wd-button.is-text.is-disabled.data-v-aa3a6253 {
|
||||
color: var(--wot-button-normal-disabled-color, rgba(0, 0, 0, 0.25));
|
||||
background: transparent;
|
||||
}
|
||||
.wd-button.is-plain.data-v-aa3a6253 {
|
||||
background: var(--wot-button-plain-bg-color, var(--wot-color-white, white));
|
||||
border: 1px solid currentColor;
|
||||
}
|
||||
.wd-button.is-plain.is-primary.data-v-aa3a6253 {
|
||||
color: var(--wot-button-primary-bg-color, var(--wot-color-theme, #4d80f0));
|
||||
}
|
||||
.wd-button.is-plain.is-success.data-v-aa3a6253 {
|
||||
color: var(--wot-button-success-bg-color, var(--wot-color-success, #34d19d));
|
||||
}
|
||||
.wd-button.is-plain.is-info.data-v-aa3a6253 {
|
||||
color: var(--wot-button-info-plain-normal-color, rgba(0, 0, 0, 0.85));
|
||||
border-color: var(--wot-button-info-plain-border-color, rgba(0, 0, 0, 0.45));
|
||||
}
|
||||
.wd-button.is-plain.is-warning.data-v-aa3a6253 {
|
||||
color: var(--wot-button-warning-bg-color, var(--wot-color-warning, #f0883a));
|
||||
}
|
||||
.wd-button.is-plain.is-error.data-v-aa3a6253 {
|
||||
color: var(--wot-button-error-bg-color, var(--wot-color-danger, #fa4350));
|
||||
}
|
||||
.wd-button.is-hairline.data-v-aa3a6253 {
|
||||
border-width: 0;
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.data-v-aa3a6253 {
|
||||
position: relative;
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.data-v-aa3a6253::after {
|
||||
position: absolute;
|
||||
display: block;
|
||||
content: " ";
|
||||
pointer-events: none;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
left: 0;
|
||||
top: 0;
|
||||
border: 1px solid var(--wot-color-border-light, #e8e8e8);
|
||||
transform: scale(0.5);
|
||||
box-sizing: border-box;
|
||||
transform-origin: left top;
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.data-v-aa3a6253::before {
|
||||
border-radius: inherit;
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.data-v-aa3a6253::after {
|
||||
border-color: inherit;
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.is-round.data-v-aa3a6253::after {
|
||||
border-radius: inherit !important;
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.is-large.data-v-aa3a6253::after {
|
||||
border-radius: calc(2 * var(--wot-button-large-radius, 8px));
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.is-medium.data-v-aa3a6253::after {
|
||||
border-radius: calc(2 * var(--wot-button-medium-radius, 4px));
|
||||
}
|
||||
.wd-button.is-hairline.is-plain.is-small.data-v-aa3a6253::after {
|
||||
border-radius: calc(2 * var(--wot-button-small-radius, 2px));
|
||||
}
|
||||
.wd-button.is-block.data-v-aa3a6253 {
|
||||
display: block;
|
||||
}
|
||||
.wd-button.is-icon.data-v-aa3a6253 {
|
||||
width: var(--wot-button-icon-size, 40px);
|
||||
height: var(--wot-button-icon-size, 40px);
|
||||
padding: 0;
|
||||
border-radius: 50%;
|
||||
color: var(--wot-button-icon-color, rgba(0, 0, 0, 0.65));
|
||||
}
|
||||
.wd-button.is-icon.data-v-aa3a6253::after {
|
||||
display: none;
|
||||
}
|
||||
.wd-button.is-icon.data-v-aa3a6253 .wd-button__icon {
|
||||
margin-right: 0;
|
||||
}
|
||||
.wd-button.is-icon.is-disabled.data-v-aa3a6253 {
|
||||
color: var(--wot-button-icon-disabled-color, var(--wot-color-icon-disabled, #a7a7a7));
|
||||
background: transparent;
|
||||
}
|
||||
.data-v-aa3a6253 .wd-button__icon {
|
||||
display: block;
|
||||
margin-right: 6px;
|
||||
font-size: var(--wot-button-icon-fs, 18px);
|
||||
vertical-align: middle;
|
||||
}
|
||||
.wd-button__text.data-v-aa3a6253 {
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
@keyframes wd-rotate-aa3a6253 {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
54
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.js
vendored
Normal file
54
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.js
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
const __default__ = {
|
||||
name: "wd-icon",
|
||||
options: {
|
||||
virtualHost: true,
|
||||
addGlobalClass: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
};
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: common_vendor.iconProps,
|
||||
emits: ["click", "touch"],
|
||||
setup(__props, { emit: __emit }) {
|
||||
const props = __props;
|
||||
const emit = __emit;
|
||||
const isImage = common_vendor.computed(() => {
|
||||
return common_vendor.isDef(props.name) && props.name.includes("/");
|
||||
});
|
||||
const rootClass = common_vendor.computed(() => {
|
||||
const prefix = props.classPrefix;
|
||||
return `${prefix} ${props.customClass} ${isImage.value ? "wd-icon--image" : prefix + "-" + props.name}`;
|
||||
});
|
||||
const rootStyle = common_vendor.computed(() => {
|
||||
const style = {};
|
||||
if (props.color) {
|
||||
style["color"] = props.color;
|
||||
}
|
||||
if (props.size) {
|
||||
style["font-size"] = common_vendor.addUnit(props.size);
|
||||
}
|
||||
return `${common_vendor.objToStyle(style)} ${props.customStyle}`;
|
||||
});
|
||||
function handleClick(event) {
|
||||
emit("click", event);
|
||||
}
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: isImage.value
|
||||
}, isImage.value ? {
|
||||
b: _ctx.name
|
||||
} : {}, {
|
||||
c: common_vendor.o(handleClick),
|
||||
d: common_vendor.n(rootClass.value),
|
||||
e: common_vendor.s(rootStyle.value),
|
||||
f: common_vendor.gei(_ctx, "")
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-d4a8410a"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.js.map
|
||||
4
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.json
vendored
Normal file
4
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.json
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
1
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.wxml
vendored
Normal file
1
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.wxml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<view bindtap="{{c}}" class="{{['data-v-d4a8410a', d, virtualHostClass]}}" style="{{e + ';' + virtualHostStyle}}" hidden="{{virtualHostHidden || false}}" id="{{f}}"><image wx:if="{{a}}" class="wd-icon__image data-v-d4a8410a" src="{{b}}"></image></view>
|
||||
1107
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.wxss
vendored
Normal file
1107
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-icon/wd-icon.wxss
vendored
Normal file
File diff suppressed because it is too large
Load Diff
502
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-signature/wd-signature.js
vendored
Normal file
502
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-signature/wd-signature.js
vendored
Normal file
@@ -0,0 +1,502 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../../../common/vendor.js");
|
||||
if (!Array) {
|
||||
const _easycom_wd_button2 = common_vendor.resolveComponent("wd-button");
|
||||
_easycom_wd_button2();
|
||||
}
|
||||
const _easycom_wd_button = () => "../wd-button/wd-button.js";
|
||||
if (!Math) {
|
||||
_easycom_wd_button();
|
||||
}
|
||||
const __default__ = {
|
||||
name: "wd-signature",
|
||||
options: {
|
||||
addGlobalClass: true,
|
||||
virtualHost: true,
|
||||
styleIsolation: "shared"
|
||||
}
|
||||
};
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
...__default__,
|
||||
props: common_vendor.signatureProps,
|
||||
emits: ["start", "end", "signing", "confirm", "clear"],
|
||||
setup(__props, { expose: __expose, emit: __emit }) {
|
||||
const props = __props;
|
||||
const emit = __emit;
|
||||
const { translate } = common_vendor.useTranslate("signature");
|
||||
const { proxy } = common_vendor.getCurrentInstance();
|
||||
const canvasId = common_vendor.ref(`signature${common_vendor.uuid()}`);
|
||||
let canvas = null;
|
||||
const drawing = common_vendor.ref(false);
|
||||
const pixelRatio = common_vendor.ref(1);
|
||||
const canvasState = common_vendor.reactive({
|
||||
canvasWidth: 0,
|
||||
canvasHeight: 0,
|
||||
ctx: null
|
||||
// canvas上下文
|
||||
});
|
||||
function isTransparentColor(color) {
|
||||
if (!color)
|
||||
return true;
|
||||
const transparentKeywords = ["transparent", "#0000", "#00000000"];
|
||||
if (transparentKeywords.includes(color.toLowerCase())) {
|
||||
return true;
|
||||
}
|
||||
const rgbaMatch = color.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*(\d*\.?\d+))?\)$/i);
|
||||
if (rgbaMatch) {
|
||||
const alpha = rgbaMatch[4] ? parseFloat(rgbaMatch[4]) : 1;
|
||||
return alpha === 0;
|
||||
}
|
||||
const hslaMatch = color.match(/^hsla?\(\s*(\d+)(?:deg)?\s*,\s*(\d+)%\s*,\s*(\d+)%(?:\s*,\s*(\d*\.?\d+))?\)$/i);
|
||||
if (hslaMatch) {
|
||||
const alpha = hslaMatch[4] ? parseFloat(hslaMatch[4]) : 1;
|
||||
return alpha === 0;
|
||||
}
|
||||
const hexMatch = color.match(/^#([0-9a-f]{8}|[0-9a-f]{4})$/i);
|
||||
if (hexMatch) {
|
||||
const hex = hexMatch[1];
|
||||
const alphaHex = hex.length === 8 ? hex.slice(6, 8) : hex.slice(3, 4).repeat(2);
|
||||
const alpha = parseInt(alphaHex, 16);
|
||||
return alpha === 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
common_vendor.watch(
|
||||
() => props.penColor,
|
||||
() => {
|
||||
setLine();
|
||||
}
|
||||
);
|
||||
common_vendor.watch(
|
||||
() => props.lineWidth,
|
||||
() => {
|
||||
setLine();
|
||||
}
|
||||
);
|
||||
const canvasStyle = common_vendor.computed(() => {
|
||||
const style = {};
|
||||
if (common_vendor.isDef(props.width)) {
|
||||
style.width = common_vendor.addUnit(props.width);
|
||||
}
|
||||
if (common_vendor.isDef(props.height)) {
|
||||
style.height = common_vendor.addUnit(props.height);
|
||||
}
|
||||
return `${common_vendor.objToStyle(style)}`;
|
||||
});
|
||||
const disableScroll = common_vendor.computed(() => props.disableScroll);
|
||||
const enableHistory = common_vendor.computed(() => props.enableHistory);
|
||||
const lines = common_vendor.ref([]);
|
||||
const redoLines = common_vendor.ref([]);
|
||||
const currentLine = common_vendor.ref();
|
||||
const currentStep = common_vendor.ref(0);
|
||||
function calculateLineWidth(speed) {
|
||||
if (!props.pressure)
|
||||
return props.lineWidth;
|
||||
const minSpeed = props.minSpeed || 1.5;
|
||||
const limitedSpeed = Math.min(minSpeed * 10, Math.max(minSpeed, speed));
|
||||
const addWidth = (props.maxWidth - props.minWidth) * (limitedSpeed - minSpeed) / minSpeed;
|
||||
const lineWidth = Math.max(props.maxWidth - addWidth, props.minWidth);
|
||||
return Math.min(lineWidth, props.maxWidth);
|
||||
}
|
||||
const getDefaultLineWidth = () => {
|
||||
if (props.pressure) {
|
||||
return (props.maxWidth + props.minWidth) / 2;
|
||||
}
|
||||
return props.lineWidth;
|
||||
};
|
||||
const startDrawing = (e) => {
|
||||
e.preventDefault();
|
||||
drawing.value = true;
|
||||
setLine();
|
||||
emit("start", e);
|
||||
const { x, y } = e.touches[0];
|
||||
currentLine.value = {
|
||||
points: [
|
||||
{
|
||||
x,
|
||||
y,
|
||||
t: Date.now()
|
||||
// 使用 t 替换 width
|
||||
}
|
||||
],
|
||||
color: props.penColor,
|
||||
width: getDefaultLineWidth(),
|
||||
backgroundColor: props.backgroundColor,
|
||||
isPressure: props.pressure
|
||||
// 添加笔锋模式标记
|
||||
};
|
||||
redoLines.value = [];
|
||||
draw(e);
|
||||
};
|
||||
const stopDrawing = (e) => {
|
||||
e.preventDefault();
|
||||
drawing.value = false;
|
||||
if (currentLine.value) {
|
||||
lines.value.push({
|
||||
...currentLine.value,
|
||||
points: currentLine.value.points.map((point) => ({
|
||||
...point,
|
||||
t: point.t,
|
||||
speed: point.speed,
|
||||
distance: point.distance,
|
||||
lineWidth: point.lineWidth,
|
||||
lastX1: point.lastX1,
|
||||
lastY1: point.lastY1,
|
||||
lastX2: point.lastX2,
|
||||
lastY2: point.lastY2,
|
||||
isFirstPoint: point.isFirstPoint
|
||||
}))
|
||||
});
|
||||
currentStep.value = lines.value.length;
|
||||
}
|
||||
currentLine.value = void 0;
|
||||
const { ctx } = canvasState;
|
||||
if (ctx)
|
||||
ctx.beginPath();
|
||||
emit("end", e);
|
||||
};
|
||||
const initCanvas = (forceUpdate = false) => {
|
||||
if (!forceUpdate && canvasState.canvasHeight && canvasState.canvasWidth) {
|
||||
return;
|
||||
}
|
||||
getContext().then(() => {
|
||||
const { ctx } = canvasState;
|
||||
if (ctx && common_vendor.isDef(props.backgroundColor)) {
|
||||
ctx.setFillStyle(props.backgroundColor);
|
||||
ctx.fillRect(0, 0, canvasState.canvasWidth, canvasState.canvasHeight);
|
||||
ctx.draw();
|
||||
}
|
||||
});
|
||||
};
|
||||
const clear = () => {
|
||||
lines.value = [];
|
||||
redoLines.value = [];
|
||||
currentStep.value = 0;
|
||||
clearCanvas();
|
||||
emit("clear");
|
||||
};
|
||||
const confirmSignature = () => {
|
||||
canvasToImage();
|
||||
};
|
||||
const draw = (e) => {
|
||||
e.preventDefault();
|
||||
const { ctx } = canvasState;
|
||||
if (!drawing.value || props.disabled || !ctx)
|
||||
return;
|
||||
const { x, y } = e.touches[0];
|
||||
const point = {
|
||||
x,
|
||||
y,
|
||||
t: Date.now()
|
||||
};
|
||||
if (currentLine.value) {
|
||||
const points = currentLine.value.points;
|
||||
const prePoint = points[points.length - 1];
|
||||
if (prePoint.t === point.t || prePoint.x === x && prePoint.y === y) {
|
||||
return;
|
||||
}
|
||||
point.distance = Math.sqrt(Math.pow(point.x - prePoint.x, 2) + Math.pow(point.y - prePoint.y, 2));
|
||||
point.speed = point.distance / (point.t - prePoint.t || 0.1);
|
||||
if (props.pressure) {
|
||||
point.lineWidth = calculateLineWidth(point.speed);
|
||||
if (points.length >= 2) {
|
||||
const prePoint2 = points[points.length - 2];
|
||||
if (prePoint2.lineWidth && prePoint.lineWidth) {
|
||||
const rate = (point.lineWidth - prePoint.lineWidth) / prePoint.lineWidth;
|
||||
const maxRate = 0.2;
|
||||
if (Math.abs(rate) > maxRate) {
|
||||
const per = rate > 0 ? maxRate : -maxRate;
|
||||
point.lineWidth = prePoint.lineWidth * (1 + per);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
points.push(point);
|
||||
if (!props.pressure) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prePoint.x, prePoint.y);
|
||||
ctx.lineTo(point.x, point.y);
|
||||
ctx.stroke();
|
||||
ctx.draw(true);
|
||||
} else if (points.length >= 2) {
|
||||
drawSmoothLine(prePoint, point);
|
||||
}
|
||||
}
|
||||
emit("signing", e);
|
||||
};
|
||||
const redrawCanvas = () => {
|
||||
const { ctx } = canvasState;
|
||||
if (!ctx)
|
||||
return;
|
||||
if (!isTransparentColor(props.backgroundColor)) {
|
||||
ctx.setFillStyle(props.backgroundColor);
|
||||
ctx.fillRect(0, 0, canvasState.canvasWidth, canvasState.canvasHeight);
|
||||
} else {
|
||||
ctx.clearRect(0, 0, canvasState.canvasWidth, canvasState.canvasHeight);
|
||||
}
|
||||
if (lines.value.length === 0) {
|
||||
ctx.draw();
|
||||
return;
|
||||
}
|
||||
lines.value.forEach((line) => {
|
||||
if (!line.points.length)
|
||||
return;
|
||||
ctx.setStrokeStyle(line.color);
|
||||
ctx.setLineJoin("round");
|
||||
ctx.setLineCap("round");
|
||||
if (line.isPressure && props.pressure) {
|
||||
line.points.forEach((point, index) => {
|
||||
if (index === 0)
|
||||
return;
|
||||
const prePoint = line.points[index - 1];
|
||||
const dis_x = point.x - prePoint.x;
|
||||
const dis_y = point.y - prePoint.y;
|
||||
const distance = Math.sqrt(dis_x * dis_x + dis_y * dis_y);
|
||||
if (distance <= 2) {
|
||||
point.lastX1 = point.lastX2 = prePoint.x + dis_x * 0.5;
|
||||
point.lastY1 = point.lastY2 = prePoint.y + dis_y * 0.5;
|
||||
} else {
|
||||
const speed = point.speed || 0;
|
||||
const minSpeed = props.minSpeed || 1.5;
|
||||
const speedFactor = Math.max(0.1, Math.min(0.9, speed / (minSpeed * 10)));
|
||||
point.lastX1 = prePoint.x + dis_x * (0.2 + speedFactor * 0.3);
|
||||
point.lastY1 = prePoint.y + dis_y * (0.2 + speedFactor * 0.3);
|
||||
point.lastX2 = prePoint.x + dis_x * (0.8 - speedFactor * 0.3);
|
||||
point.lastY2 = prePoint.y + dis_y * (0.8 - speedFactor * 0.3);
|
||||
}
|
||||
const lineWidth = point.lineWidth || line.width;
|
||||
if (typeof prePoint.lastX1 === "number") {
|
||||
ctx.setLineWidth(lineWidth);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prePoint.lastX2, prePoint.lastY2);
|
||||
ctx.quadraticCurveTo(prePoint.x, prePoint.y, point.lastX1, point.lastY1);
|
||||
ctx.stroke();
|
||||
if (!prePoint.isFirstPoint) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prePoint.lastX1, prePoint.lastY1);
|
||||
ctx.quadraticCurveTo(prePoint.x, prePoint.y, prePoint.lastX2, prePoint.lastY2);
|
||||
ctx.stroke();
|
||||
}
|
||||
} else {
|
||||
point.isFirstPoint = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ctx.setLineWidth(line.width);
|
||||
line.points.forEach((point, index) => {
|
||||
if (index === 0)
|
||||
return;
|
||||
const prePoint = line.points[index - 1];
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prePoint.x, prePoint.y);
|
||||
ctx.lineTo(point.x, point.y);
|
||||
ctx.stroke();
|
||||
});
|
||||
}
|
||||
});
|
||||
ctx.draw();
|
||||
};
|
||||
const revoke = () => {
|
||||
if (!lines.value.length)
|
||||
return;
|
||||
const step = Math.min(props.step, lines.value.length);
|
||||
const removedLines = lines.value.splice(lines.value.length - step);
|
||||
redoLines.value.push(...removedLines);
|
||||
currentStep.value = Math.max(0, currentStep.value - step);
|
||||
redrawCanvas();
|
||||
};
|
||||
const restore = () => {
|
||||
if (!redoLines.value.length)
|
||||
return;
|
||||
const step = Math.min(props.step, redoLines.value.length);
|
||||
const restoredLines = redoLines.value.splice(redoLines.value.length - step);
|
||||
lines.value.push(...restoredLines);
|
||||
currentStep.value = Math.min(lines.value.length, currentStep.value + step);
|
||||
redrawCanvas();
|
||||
};
|
||||
function drawSmoothLine(prePoint, point) {
|
||||
const { ctx } = canvasState;
|
||||
if (!ctx)
|
||||
return;
|
||||
const dis_x = point.x - prePoint.x;
|
||||
const dis_y = point.y - prePoint.y;
|
||||
const distance = Math.sqrt(dis_x * dis_x + dis_y * dis_y);
|
||||
if (distance <= 2) {
|
||||
point.lastX1 = point.lastX2 = prePoint.x + dis_x * 0.5;
|
||||
point.lastY1 = point.lastY2 = prePoint.y + dis_y * 0.5;
|
||||
} else {
|
||||
const speed = point.speed || 0;
|
||||
const minSpeed = props.minSpeed || 1.5;
|
||||
const speedFactor = Math.max(0.1, Math.min(0.9, speed / (minSpeed * 10)));
|
||||
point.lastX1 = prePoint.x + dis_x * (0.2 + speedFactor * 0.3);
|
||||
point.lastY1 = prePoint.y + dis_y * (0.2 + speedFactor * 0.3);
|
||||
point.lastX2 = prePoint.x + dis_x * (0.8 - speedFactor * 0.3);
|
||||
point.lastY2 = prePoint.y + dis_y * (0.8 - speedFactor * 0.3);
|
||||
}
|
||||
const lineWidth = point.lineWidth || props.lineWidth;
|
||||
if (typeof prePoint.lastX1 === "number") {
|
||||
ctx.setLineWidth(lineWidth);
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prePoint.lastX2, prePoint.lastY2);
|
||||
ctx.quadraticCurveTo(prePoint.x, prePoint.y, point.lastX1, point.lastY1);
|
||||
ctx.stroke();
|
||||
if (!prePoint.isFirstPoint) {
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(prePoint.lastX1, prePoint.lastY1);
|
||||
ctx.quadraticCurveTo(prePoint.x, prePoint.y, prePoint.lastX2, prePoint.lastY2);
|
||||
ctx.stroke();
|
||||
}
|
||||
ctx.draw(true);
|
||||
} else {
|
||||
point.isFirstPoint = true;
|
||||
}
|
||||
}
|
||||
common_vendor.onMounted(() => {
|
||||
initCanvas();
|
||||
});
|
||||
common_vendor.onBeforeMount(() => {
|
||||
pixelRatio.value = common_vendor.getSystemInfo().pixelRatio;
|
||||
});
|
||||
function getContext() {
|
||||
return new Promise((resolve) => {
|
||||
const { ctx } = canvasState;
|
||||
if (ctx) {
|
||||
return resolve(ctx);
|
||||
}
|
||||
common_vendor.getRect(`#${canvasId.value}`, false, proxy, true).then((canvasRect) => {
|
||||
if (canvasRect && canvasRect.node && canvasRect.width && canvasRect.height) {
|
||||
const canvasInstance = canvasRect.node;
|
||||
canvasState.ctx = common_vendor.canvas2dAdapter(canvasInstance.getContext("2d"));
|
||||
canvasInstance.width = canvasRect.width * pixelRatio.value;
|
||||
canvasInstance.height = canvasRect.height * pixelRatio.value;
|
||||
canvasState.ctx.scale(pixelRatio.value, pixelRatio.value);
|
||||
canvas = canvasInstance;
|
||||
setcanvasState(canvasRect.width, canvasRect.height);
|
||||
resolve(canvasState.ctx);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
function setcanvasState(width, height) {
|
||||
canvasState.canvasHeight = height * pixelRatio.value;
|
||||
canvasState.canvasWidth = width * pixelRatio.value;
|
||||
}
|
||||
function setLine() {
|
||||
const { ctx } = canvasState;
|
||||
if (ctx) {
|
||||
ctx.setLineWidth(getDefaultLineWidth());
|
||||
ctx.setStrokeStyle(props.penColor);
|
||||
ctx.setLineJoin("round");
|
||||
ctx.setLineCap("round");
|
||||
}
|
||||
}
|
||||
function canvasToImage() {
|
||||
const { fileType, quality, exportScale } = props;
|
||||
const { canvasWidth, canvasHeight } = canvasState;
|
||||
common_vendor.index.canvasToTempFilePath(
|
||||
{
|
||||
width: canvasWidth,
|
||||
height: canvasHeight,
|
||||
destWidth: canvasWidth * exportScale,
|
||||
destHeight: canvasHeight * exportScale,
|
||||
fileType,
|
||||
quality,
|
||||
canvasId: canvasId.value,
|
||||
canvas,
|
||||
success: (res) => {
|
||||
const result = {
|
||||
tempFilePath: res.tempFilePath,
|
||||
width: canvasWidth * exportScale / pixelRatio.value,
|
||||
height: canvasHeight * exportScale / pixelRatio.value,
|
||||
success: true
|
||||
};
|
||||
emit("confirm", result);
|
||||
},
|
||||
fail: () => {
|
||||
const result = {
|
||||
tempFilePath: "",
|
||||
width: canvasWidth * exportScale / pixelRatio.value,
|
||||
height: canvasHeight * exportScale / pixelRatio.value,
|
||||
success: false
|
||||
};
|
||||
emit("confirm", result);
|
||||
}
|
||||
},
|
||||
proxy
|
||||
);
|
||||
}
|
||||
function clearCanvas() {
|
||||
const { canvasWidth, canvasHeight, ctx } = canvasState;
|
||||
if (ctx) {
|
||||
ctx.clearRect(0, 0, canvasWidth, canvasHeight);
|
||||
if (!isTransparentColor(props.backgroundColor)) {
|
||||
ctx.setFillStyle(props.backgroundColor);
|
||||
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
|
||||
}
|
||||
ctx.draw();
|
||||
}
|
||||
}
|
||||
__expose({
|
||||
init: initCanvas,
|
||||
clear,
|
||||
confirm: confirmSignature,
|
||||
restore,
|
||||
revoke
|
||||
});
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.s(canvasStyle.value),
|
||||
b: canvasState.canvasWidth,
|
||||
c: canvasState.canvasHeight,
|
||||
d: canvasId.value,
|
||||
e: canvasId.value,
|
||||
f: disableScroll.value,
|
||||
g: common_vendor.o(startDrawing),
|
||||
h: common_vendor.o(stopDrawing),
|
||||
i: common_vendor.o(draw),
|
||||
j: enableHistory.value
|
||||
}, enableHistory.value ? {
|
||||
k: common_vendor.t(_ctx.revokeText || common_vendor.unref(translate)("revokeText")),
|
||||
l: common_vendor.o(revoke),
|
||||
m: common_vendor.p({
|
||||
size: "small",
|
||||
plain: true,
|
||||
disabled: lines.value.length <= 0
|
||||
}),
|
||||
n: common_vendor.t(_ctx.restoreText || common_vendor.unref(translate)("restoreText")),
|
||||
o: common_vendor.o(restore),
|
||||
p: common_vendor.p({
|
||||
size: "small",
|
||||
plain: true,
|
||||
disabled: redoLines.value.length <= 0
|
||||
})
|
||||
} : {}, {
|
||||
q: common_vendor.t(_ctx.clearText || common_vendor.unref(translate)("clearText")),
|
||||
r: common_vendor.o(clear),
|
||||
s: common_vendor.p({
|
||||
size: "small",
|
||||
plain: true
|
||||
}),
|
||||
t: common_vendor.t(_ctx.confirmText || common_vendor.unref(translate)("confirmText")),
|
||||
v: common_vendor.o(confirmSignature),
|
||||
w: common_vendor.p({
|
||||
size: "small"
|
||||
}),
|
||||
x: common_vendor.r("footer", {
|
||||
clear,
|
||||
confirm: confirmSignature,
|
||||
currentStep: currentStep.value,
|
||||
revoke,
|
||||
restore,
|
||||
canUndo: lines.value.length > 0,
|
||||
canRedo: redoLines.value.length > 0,
|
||||
historyList: lines.value
|
||||
}),
|
||||
y: common_vendor.gei(_ctx, "")
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-5bbd3260"]]);
|
||||
wx.createComponent(Component);
|
||||
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/node-modules/wot-design-uni/components/wd-signature/wd-signature.js.map
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"wd-button": "../wd-button/wd-button"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
<view class="{{['wd-signature', 'data-v-5bbd3260', virtualHostClass]}}" style="{{virtualHostStyle}}" hidden="{{virtualHostHidden || false}}" id="{{y}}"><view class="wd-signature__content data-v-5bbd3260"><block wx:if="{{r0}}"><canvas class="wd-signature__content-canvas data-v-5bbd3260" style="{{a}}" width="{{b}}" height="{{c}}" canvas-id="{{d}}" id="{{e}}" disable-scroll="{{f}}" bindtouchstart="{{g}}" bindtouchend="{{h}}" bindtouchmove="{{i}}" type="2d"/></block></view><view class="wd-signature__footer data-v-5bbd3260"><block wx:if="{{$slots.footer}}"><slot name="footer"></slot></block><block wx:else><block wx:if="{{j}}"><wd-button wx:if="{{m}}" class="data-v-5bbd3260" virtualHostClass="data-v-5bbd3260" u-s="{{['d']}}" bindclick="{{l}}" u-i="5bbd3260-0" bind:__l="__l" u-p="{{m}}">{{k}}</wd-button><wd-button wx:if="{{p}}" class="data-v-5bbd3260" virtualHostClass="data-v-5bbd3260" u-s="{{['d']}}" bindclick="{{o}}" u-i="5bbd3260-1" bind:__l="__l" u-p="{{p}}">{{n}}</wd-button></block><wd-button wx:if="{{s}}" class="data-v-5bbd3260" virtualHostClass="data-v-5bbd3260" u-s="{{['d']}}" bindclick="{{r}}" u-i="5bbd3260-2" bind:__l="__l" u-p="{{s}}">{{q}}</wd-button><wd-button wx:if="{{w}}" class="data-v-5bbd3260" virtualHostClass="data-v-5bbd3260" u-s="{{['d']}}" bindclick="{{v}}" u-i="5bbd3260-3" bind:__l="__l" u-p="{{w}}">{{t}}</wd-button></block></view></view>
|
||||
214
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-signature/wd-signature.wxss
vendored
Normal file
214
unpackage/dist/dev/mp-weixin/node-modules/wot-design-uni/components/wd-signature/wd-signature.wxss
vendored
Normal file
@@ -0,0 +1,214 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* uni.scss */
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
/**
|
||||
* 辅助函数
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/* 转换成字符串 */
|
||||
/* 判断是否存在 Modifier */
|
||||
/* 判断是否存在伪类 */
|
||||
/**
|
||||
* 主题色切换
|
||||
* @params $theme-color 主题色
|
||||
* @params $type 变暗’dark‘ 变亮 'light'
|
||||
* @params $mix-color 自己设置的混色
|
||||
*/
|
||||
/**
|
||||
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
|
||||
* @params $open-linear 是否开启线性渐变色
|
||||
* @params $deg 渐变色角度
|
||||
* @params $theme-color 当前配色
|
||||
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
|
||||
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
|
||||
* @params [Array] $per-list 渐变色比例
|
||||
*/
|
||||
/**
|
||||
* UI规范基础变量
|
||||
*/
|
||||
/*----------------------------------------- Theme color. start ----------------------------------------*/
|
||||
/* 主题颜色 */
|
||||
/* 辅助色 */
|
||||
/* 文字颜色(默认浅色背景下 */
|
||||
/* 暗黑模式 */
|
||||
/* 图形颜色 */
|
||||
/*----------------------------------------- Theme color. end -------------------------------------------*/
|
||||
/*-------------------------------- Theme color application size. start --------------------------------*/
|
||||
/* 文字字号 */
|
||||
/* 文字字重 */
|
||||
/* 尺寸 */
|
||||
/*-------------------------------- Theme color application size. end --------------------------------*/
|
||||
/* component var */
|
||||
/* action-sheet */
|
||||
/* badge */
|
||||
/* button */
|
||||
/* cell */
|
||||
/* calendar */
|
||||
/* checkbox */
|
||||
/* collapse */
|
||||
/* divider */
|
||||
/* drop-menu */
|
||||
/* input-number */
|
||||
/* input */
|
||||
/* textarea */
|
||||
/* loadmore */
|
||||
/* message-box */
|
||||
/* notice-bar */
|
||||
/* pagination */
|
||||
/* picker */
|
||||
/* col-picker */
|
||||
/* overlay */
|
||||
/* popup */
|
||||
/* progress */
|
||||
/* radio */
|
||||
/* search */
|
||||
/* slider */
|
||||
/* sort-button */
|
||||
/* steps */
|
||||
/* switch */
|
||||
/* tabs */
|
||||
/* tag */
|
||||
/* toast */
|
||||
/* loading */
|
||||
/* tooltip */
|
||||
/* popover */
|
||||
/* grid-item */
|
||||
/* statustip */
|
||||
/* card */
|
||||
/* upload */
|
||||
/* curtain */
|
||||
/* notify */
|
||||
/* skeleton */
|
||||
/* circle */
|
||||
/* swiper */
|
||||
/* swiper-nav */
|
||||
/* segmented */
|
||||
/* tabbar */
|
||||
/* tabbar-item */
|
||||
/* navbar */
|
||||
/* navbar-capsule */
|
||||
/* table */
|
||||
/* sidebar */
|
||||
/* sidebar-item */
|
||||
/* fab */
|
||||
/* count-down */
|
||||
/* keyboard */
|
||||
/* number-keyboard */
|
||||
/* passwod-input */
|
||||
/* form-item */
|
||||
/* backtop */
|
||||
/* index-bar */
|
||||
/* text */
|
||||
/* video-preview */
|
||||
/* img-cropper */
|
||||
/* floating-panel */
|
||||
/* signature */
|
||||
/* tour */
|
||||
/* avatar */
|
||||
/* avatar-group */
|
||||
/* slide-verify */
|
||||
/**
|
||||
* 混合宏
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/**
|
||||
* 辅助函数
|
||||
*/
|
||||
/**
|
||||
* SCSS 配置项:命名空间以及BEM
|
||||
*/
|
||||
/* 转换成字符串 */
|
||||
/* 判断是否存在 Modifier */
|
||||
/* 判断是否存在伪类 */
|
||||
/**
|
||||
* 主题色切换
|
||||
* @params $theme-color 主题色
|
||||
* @params $type 变暗’dark‘ 变亮 'light'
|
||||
* @params $mix-color 自己设置的混色
|
||||
*/
|
||||
/**
|
||||
* 颜色结果切换, 如果开启线性渐变色 使用渐变色,如果没有开启,那么使用主题色
|
||||
* @params $open-linear 是否开启线性渐变色
|
||||
* @params $deg 渐变色角度
|
||||
* @params $theme-color 当前配色
|
||||
* @params [Array] $set 主题色明暗设置,与 $color-list 数量对应
|
||||
* @params [Array] $color-list 渐变色顺序, $color-list 和 $per-list 数量相同
|
||||
* @params [Array] $per-list 渐变色比例
|
||||
*/
|
||||
/**
|
||||
* BEM,定义块(b)
|
||||
*/
|
||||
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
|
||||
/* 此方法用于生成穿透样式 */
|
||||
/* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
|
||||
/* 定义状态(m) */
|
||||
/* 定义状态(m) */
|
||||
/* 对于需要需要嵌套在 m 底下的 e,调用这个混合宏,一般在切换整个组件的状态,如切换颜色的时候 */
|
||||
/* 状态,生成 is-$state 类名 */
|
||||
/**
|
||||
* 常用混合宏
|
||||
*/
|
||||
/* 单行超出隐藏 */
|
||||
/* 多行超出隐藏 */
|
||||
/* 清除浮动 */
|
||||
/* 0.5px 边框 指定方向*/
|
||||
/* 0.5px 边框 环绕 */
|
||||
/**
|
||||
* 三角形实现尖角样式,适用于背景透明情况
|
||||
* @param $size 三角形高,底边为 $size * 2
|
||||
* @param $bg 三角形背景颜色
|
||||
*/
|
||||
/**
|
||||
* 正方形实现尖角样式,适用于背景不透明情况
|
||||
* @param $size 正方形边长
|
||||
* @param $bg 正方形背景颜色
|
||||
* @param $z-index z-index属性值,不得大于外部包裹器
|
||||
* @param $box-shadow 阴影
|
||||
*/
|
||||
.wd-signature__content.data-v-5bbd3260 {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
background: var(--wot-signature-bg, var(--wot-color-white, white));
|
||||
border-radius: var(--wot-signature-radius, 4px);
|
||||
border: var(--wot-signature-border, 1px solid var(--wot-color-gray-5, #c8c9cc));
|
||||
}
|
||||
.wd-signature__content-canvas.data-v-5bbd3260 {
|
||||
width: 100%;
|
||||
}
|
||||
.wd-signature__footer.data-v-5bbd3260 {
|
||||
margin-top: var(--wot-signature-footer-margin-top, 8px);
|
||||
justify-content: flex-end;
|
||||
display: flex;
|
||||
}
|
||||
.wd-signature__footer.data-v-5bbd3260 .wd-button {
|
||||
margin-left: var(--wot-signature-button-margin-left, 8px);
|
||||
}
|
||||
Reference in New Issue
Block a user