first commit

This commit is contained in:
PC-202306242200\Administrator
2026-03-28 23:09:02 +08:00
commit dac42e3b0c
3512 changed files with 181637 additions and 0 deletions

View File

@@ -0,0 +1,72 @@
"use strict";
const uni_modules_uviewPlus_libs_config_props = require("../../libs/config/props.js");
const props = {
props: {
// radio的名称
name: {
type: [String, Number, Boolean],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.name
},
// 形状square为方形circle为圆型
shape: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.shape
},
// 是否禁用
disabled: {
type: [String, Boolean],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.disabled
},
// 是否禁止点击提示语选中单选框
labelDisabled: {
type: [String, Boolean],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.labelDisabled
},
// 选中状态下的颜色如设置此值将会覆盖parent的activeColor值
activeColor: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.activeColor
},
// 未选中的颜色
inactiveColor: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.inactiveColor
},
// 图标的大小单位px
iconSize: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.iconSize
},
// label的字体大小px单位
labelSize: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.labelSize
},
// label提示文字因为nvue下直接slot进来的文字由于特殊的结构无法修改样式
label: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.label
},
// 整体的大小
size: {
type: [String, Number],
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.size
},
// 图标颜色
color: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.color
},
// label的颜色
labelColor: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.labelColor
},
// 图标颜色
iconColor: {
type: String,
default: () => uni_modules_uviewPlus_libs_config_props.defProps.radio.iconColor
}
}
};
exports.props = props;

View File

@@ -0,0 +1,76 @@
.u-empty.data-v-83036558,
.u-empty__wrap.data-v-83036558,
.u-tabs.data-v-83036558,
.u-tabs__wrapper.data-v-83036558,
.u-tabs__wrapper__scroll-view-wrapper.data-v-83036558,
.u-tabs__wrapper__scroll-view.data-v-83036558,
.u-tabs__wrapper__nav.data-v-83036558,
.u-tabs__wrapper__nav__line.data-v-83036558 {
display: flex;
flex-direction: column;
flex-shrink: 0;
flex-grow: 0;
flex-basis: auto;
align-items: stretch;
align-content: flex-start;
}
.u-radio.data-v-83036558 {
display: flex;
flex-direction: row;
overflow: hidden;
flex-direction: row;
align-items: center;
margin-bottom: 5px;
margin-top: 5px;
}
.u-radio-label--left.data-v-83036558 {
flex-direction: row;
}
.u-radio-label--right.data-v-83036558 {
flex-direction: row-reverse;
justify-content: space-between;
}
.u-radio__icon-wrap.data-v-83036558 {
box-sizing: border-box;
transition-property: border-color, background-color, color;
transition-duration: 0.2s;
color: #606266;
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
color: transparent;
text-align: center;
margin-right: 6px;
font-size: 20px;
border-width: 1px;
border-color: #c8c9cc;
border-style: solid;
}
.u-radio__icon-wrap--circle.data-v-83036558 {
border-radius: 100%;
}
.u-radio__icon-wrap--square.data-v-83036558 {
border-radius: 3px;
}
.u-radio__icon-wrap--checked.data-v-83036558 {
color: #fff;
background-color: red;
border-color: #2979ff;
}
.u-radio__icon-wrap--disabled.data-v-83036558 {
background-color: #ebedf0 !important;
}
.u-radio__icon-wrap--disabled--checked.data-v-83036558 {
color: #c8c9cc !important;
}
.u-radio__label.data-v-83036558 {
word-wrap: break-word;
margin-left: 5px;
margin-right: 12px;
color: #606266;
font-size: 15px;
}
.u-radio__label--disabled.data-v-83036558 {
color: #c8c9cc;
}

View File

@@ -0,0 +1 @@
<view catchTap="{{j}}" style="{{k}}" class="{{('u-radio') + ' ' + 'cursor-pointer' + ' ' + 'data-v-83036558' + ' ' + l + ' ' + m}}"><view catchTap="{{b}}" class="{{('u-radio__icon-wrap') + ' ' + 'cursor-pointer' + ' ' + 'data-v-83036558' + ' ' + c}}" style="{{d}}"><slot name="icon"><u-icon class="u-radio__icon-wrap__icon data-v-83036558" u-i="83036558-0" onVI="__l" u-p="{{a}}"/></slot></view><slot><text class="u-radio__text data-v-83036558" catchTap="{{f}}" style="{{'color:' + g + ';' + ('font-size:' + h) + ';' + ('line-height:' + i)}}">{{e}}</text></slot></view>

View File

@@ -0,0 +1,193 @@
"use strict";
const uni_modules_uviewPlus_components_uRadio_props = require("./props.js");
const uni_modules_uviewPlus_libs_mixin_mpMixin = require("../../libs/mixin/mpMixin.js");
const uni_modules_uviewPlus_libs_mixin_mixin = require("../../libs/mixin/mixin.js");
const uni_modules_uviewPlus_libs_function_index = require("../../libs/function/index.js");
const common_vendor = require("../../../../common/vendor.js");
const _sfc_main = {
name: "u-radio",
mixins: [uni_modules_uviewPlus_libs_mixin_mpMixin.mpMixin, uni_modules_uviewPlus_libs_mixin_mixin.mixin, uni_modules_uviewPlus_components_uRadio_props.props],
data() {
return {
checked: false,
// 当你看到这段代码的时候,
// 父组件的默认值因为头条小程序不支持在computed中使用this.parent.shape的形式
// 故只能使用如此方法
parentData: {
iconSize: 12,
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: {
// 是否禁用如果父组件u-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 uni_modules_uviewPlus_libs_function_index.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) {
return this.checked ? this.elInactiveColor : "transparent";
} else {
return this.checked ? iconColor : "transparent";
}
},
iconClasses() {
let classes = [];
classes.push("u-radio__icon-wrap--" + this.elShape);
if (this.elDisabled) {
classes.push("u-radio__icon-wrap--disabled");
}
if (this.checked && this.elDisabled) {
classes.push("u-radio__icon-wrap--disabled--checked");
}
classes = classes.join(" ");
return classes;
},
iconWrapStyle() {
const style = {};
style.backgroundColor = this.checked && !this.elDisabled ? this.elActiveColor : "#ffffff";
style.borderColor = this.checked && !this.elDisabled ? this.elActiveColor : this.elInactiveColor;
style.width = uni_modules_uviewPlus_libs_function_index.addUnit(this.elSize);
style.height = uni_modules_uviewPlus_libs_function_index.addUnit(this.elSize);
if (this.parentData.iconPlacement === "right") {
style.marginRight = 0;
}
return style;
},
radioStyle() {
const style = {};
if (this.parentData.borderBottom && this.parentData.placement === "row") {
uni_modules_uviewPlus_libs_function_index.error("检测到您将borderBottom设置为true需要同时将u-radio-group的placement设置为column才有效");
}
if (this.parentData.borderBottom && this.parentData.placement === "column") {
style.paddingBottom = uni_modules_uviewPlus_libs_function_index.os() === "ios" ? "12px" : "8px";
}
return uni_modules_uviewPlus_libs_function_index.deepMerge(style, uni_modules_uviewPlus_libs_function_index.addStyle(this.customStyle));
}
},
mounted() {
this.init();
},
emits: ["change"],
methods: {
init() {
this.updateParentData();
if (!this.parent) {
uni_modules_uviewPlus_libs_function_index.error("u-radio必须搭配u-radio-group组件使用");
}
this.checked = this.name === this.parentData.modelValue;
},
updateParentData() {
this.getParentData("u-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);
if (!this.elLabelDisabled && !this.elDisabled) {
this.setRadioCheckedStatus();
}
},
emitEvent() {
if (!this.checked) {
this.$emit("change", this.name);
this.$nextTick(() => {
uni_modules_uviewPlus_libs_function_index.formValidate(this, "change");
});
}
},
// 改变组件选中状态
// 这里的改变的依据是更改本组件的checked值为true同时通过父组件遍历所有u-radio实例
// 将本组件外的其他u-radio的checked都设置为false(都被取消选中状态),因而只剩下一个为选中状态
setRadioCheckedStatus() {
this.emitEvent();
this.checked = true;
typeof this.parent.unCheckedOther === "function" && this.parent.unCheckedOther(this);
}
}
};
if (!Array) {
const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
_easycom_u_icon2();
}
const _easycom_u_icon = () => "../u-icon/u-icon.js";
if (!Math) {
_easycom_u_icon();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.p({
name: "checkbox-mark",
size: $options.elIconSize,
color: $options.elIconColor
}),
b: common_vendor.o((...args) => $options.iconClickHandler && $options.iconClickHandler(...args)),
c: common_vendor.n($options.iconClasses),
d: common_vendor.s($options.iconWrapStyle),
e: common_vendor.t(_ctx.label),
f: common_vendor.o((...args) => $options.labelClickHandler && $options.labelClickHandler(...args)),
g: $options.elDisabled ? $options.elInactiveColor : $options.elLabelColor,
h: $options.elLabelSize,
i: $options.elLabelSize,
j: common_vendor.o((...args) => $options.wrapperClickHandler && $options.wrapperClickHandler(...args)),
k: common_vendor.s($options.radioStyle),
l: common_vendor.n(`u-radio-label--${$data.parentData.iconPlacement}`),
m: common_vendor.n($data.parentData.borderBottom && $data.parentData.placement === "column" && "u-border-bottom")
};
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-83036558"]]);
my.createComponent(Component);

View File

@@ -0,0 +1,7 @@
{
"component": true,
"styleIsolation": "apply-shared",
"usingComponents": {
"u-icon": "../u-icon/u-icon"
}
}